SignUpLevel.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. <template>
  2. <div class="signUpLevel">
  3. <!-- <m-header /> -->
  4. <m-step :number="3" />
  5. <div v-if="examSubjectList.length > 0">
  6. <div class="title">报考专业</div>
  7. <van-field readonly required @click="onGetSheetList('examSubject')" name="subjectId" label="报考专业" placeholder="请选择" v-model="formText.subjectName" is-link />
  8. <van-field readonly required @click="onGetSheetList('level')" name="levelId" label="专业级别" placeholder="请选择" v-model="formText.levelName" is-link />
  9. <div class="title">报考曲目</div>
  10. <div v-if="form.levelId" class="van-hairline--bottom">
  11. <div class="van-hairline--bottom" v-if="practiceSongIdList" key="practiceNum">
  12. <van-field required readonly v-for="(item, index) in practiceNum" :key="index" :label="`练习曲${numberToCN(index)}名称及作者`" v-model.trim="practiceSelect[index]" @click="onChangePractice('practice', index)" placeholder="请选择" is-link />
  13. </div>
  14. <div class="van-hairline--bottom" v-else key="practiceNum">
  15. <van-field required readonly v-model.trim="practiceSelect[index]" v-for="(item, index) in practiceNum" :key="index" clearable name="code" :label="`练习曲${numberToCN(index)}名称及作者`" >
  16. <template #button>
  17. <span class="codeText" @click="onUploadSong('practiceNum', index)">上传曲目</span>
  18. </template>
  19. </van-field>
  20. </div>
  21. <div v-if="performSongIdList" key="performNum">
  22. <van-field required readonly v-for="(item, index) in performNum" :key="index" :label="`演奏曲${numberToCN(index)}名称及作者`" v-model.trim="performNumSelect[index]" @click="onChangePractice('performNum', index)" placeholder="请选择" is-link />
  23. </div>
  24. <div v-else key="performNum">
  25. <van-field required readonly v-model.trim="performNumSelect[index]" v-for="(item, index) in performNum" :key="index" clearable name="code" :label="`演奏曲${numberToCN(index)}名称及作者`" >
  26. <template #button>
  27. <span class="codeText" @click="onUploadSong('performNum', index)">上传曲目</span>
  28. </template>
  29. </van-field>
  30. </div>
  31. </div>
  32. <!-- <div class="title">上传证书</div> -->
  33. <!-- <van-field readonly clickable name="nation" label="上次考级级别" placeholder="请选择级别" is-link /> -->
  34. <van-field readonly clearable name="code" label="已获最高等级专业证书" >
  35. <template #input>
  36. <van-uploader
  37. name="certificate"
  38. :before-read="beforeRead"
  39. :before-delete="beforeDelete"
  40. :after-read="afterRead"
  41. accept="image/*"
  42. v-model="uploadCertificate"
  43. :max-count="1" />
  44. </template>
  45. </van-field>
  46. </div>
  47. <div class="title">乐理知识</div>
  48. <van-field required @click="onGetSheetList('examMusicTheory')" readonly clickable name="nation" label="乐理级别" v-model="formText.examMusicTheoryName" placeholder="请选择乐理级别" is-link />
  49. <!-- <van-field readonly clickable name="nation" label="上次考级级别" placeholder="请选择" is-link /> -->
  50. <!-- 乐理级别为免考 和 专业级别大于2级 -->
  51. <!-- :required="form.examMusicTheoryId == 999 && form.levelId > 2? true : false" -->
  52. <van-field readonly clearable name="code" label="已获最高等级乐理证书" >
  53. <template #input>
  54. <van-uploader
  55. name="certificate2"
  56. :before-read="beforeRead"
  57. :before-delete="beforeDelete"
  58. :after-read="afterRead"
  59. v-model="uploadCertificate2"
  60. accept="image/*"
  61. :max-count="1" />
  62. </template>
  63. </van-field>
  64. <div class="title">指导老师</div>
  65. <van-field name="adviserName" v-model="form.adviserName" label="老师姓名" placeholder="请输入老师姓名" />
  66. <van-field name="adviserPhone" maxlength="11" v-model="form.adviserPhone" type="tel" label="联系方式" placeholder="请输入联系方式" />
  67. <div class="m-btn-group">
  68. <van-button class="btn_prev" round color="#2DC7AA" @click="onBack" style="background-color: transparent" plain>上一步</van-button>
  69. <van-button round color="#2DC7AA" @click="onSubmit">确认报名</van-button>
  70. </div>
  71. <!-- 报考专业弹窗 -->
  72. <van-popup v-model="sheetForm.sheetStatus" position="bottom">
  73. <van-picker :loading="sheetForm.loading" :default-index="sheetForm.index" :columns="sheetForm.columns" show-toolbar @cancel="sheetForm.sheetStatus = false" @confirm="onSheetConfirm" />
  74. </van-popup>
  75. <!-- 曲目弹窗 -->
  76. <van-popup v-model="sheetSong.status" position="bottom">
  77. <van-picker :default-index="sheetSong.index" :columns="sheetSong.columns" show-toolbar @cancel="sheetSong.status = false" @confirm="onPracticeConfirm" />
  78. </van-popup>
  79. <van-popup class="van-popup-song" v-model="songUpload.songStatus" :close-on-click-overlay="false">
  80. <div class="song-popup">
  81. <div class="title">自定义曲目</div>
  82. <van-field name="songName" v-model="songUpload.name" label="曲名" placeholder="请输入曲名" >
  83. <template #label><i style="color: #ee0a24">*</i>曲名</template>
  84. </van-field>
  85. <van-field name="songAuthor" v-model="songUpload.author" label="作者" placeholder="请输入作者" >
  86. <template #label><i style="color: #ffffff">*</i>作者</template>
  87. </van-field>
  88. <van-field readonly clearable >
  89. <template #input>
  90. <van-uploader
  91. v-if="songUpload.indexName == 'practiceNum'"
  92. :name="songUpload.indexName + '-' + songUpload.index"
  93. :before-read="beforeRead"
  94. :before-delete="beforeDelete"
  95. :after-read="afterRead"
  96. v-model.trim="practiceUpload[songUpload.index]"
  97. multiple
  98. accept="image/*"
  99. :max-count="5" >
  100. </van-uploader>
  101. <van-uploader
  102. v-if="songUpload.indexName == 'performNum'"
  103. :name="songUpload.indexName + '-' + songUpload.index"
  104. :before-read="beforeRead"
  105. :before-delete="beforeDelete"
  106. :after-read="afterRead"
  107. v-model.trim="performNumUpload[songUpload.index]"
  108. multiple
  109. accept="image/*"
  110. :max-count="5" >
  111. </van-uploader>
  112. </template>
  113. </van-field>
  114. <p class="song-popup-tips"><i style="color: #ee0a24">*</i>支持格式:png,jpg,bmp</p>
  115. <div class="popup-group">
  116. <span @click="onSaveCancel">取消</span>
  117. <span class="popup-sure" @click="onSaveUpload">确定</span>
  118. </div>
  119. </div>
  120. </van-popup>
  121. </div>
  122. </template>
  123. <script>
  124. import MStep from '@/components/MStep'
  125. import setLoading from '@/utils/loading'
  126. import { patternPhone } from '@/utils/validateRules'
  127. import { getExamSubjects, getExamSubjectLevel, getExamSubjectSong, uploadFile, getTheoryLevelList, getExamIngOrder, closeOrder } from './SignUpApi'
  128. // import fileUtil from '@/utils/fileUtil'
  129. const levelToCN = {
  130. 1: "壹级",
  131. 2: "贰级",
  132. 3: "叁级",
  133. 4: "肆级",
  134. 5: "伍级",
  135. 6: "陆级",
  136. 7: "柒级",
  137. 8: "捌级",
  138. 9: "玖级",
  139. 10: "拾级",
  140. }
  141. export default {
  142. name: 'signUpLevel',
  143. components: { MStep },
  144. data () {
  145. const examId = localStorage.getItem('examId')
  146. const organId = localStorage.getItem('organId')
  147. const examRegistrationParams = localStorage.getItem("examRegistrationParams") ? JSON.parse(localStorage.getItem("examRegistrationParams")) : null
  148. return {
  149. examId: examId,
  150. organId: organId,
  151. examRegistrationParams: examRegistrationParams,
  152. patternPhone: patternPhone,
  153. sheetForm: { // 上拉弹窗
  154. currentType: null, // 当前选择的类型
  155. sheetStatus: false,
  156. loading: false, // 加载数据
  157. index: 0, // 选中的索引值
  158. columns: []
  159. },
  160. examSubjectList: [], // 报考专业
  161. examSubjectIndex: 0, // 报考专业选择项目索引
  162. levelList: [], // 专业级别
  163. levelIndex: 0, // 专业级别选择项目索引
  164. practiceNum: 0, // 练习曲数量
  165. practiceSongIdList: null,
  166. performNum: 0, // 演奏曲数量
  167. performSongIdList: null,
  168. songList: [], //歌曲数量(包括练习曲和演奏曲)
  169. songUpload: {
  170. songStatus: false, // 曲目状态
  171. indexName: null,
  172. index: null, // 索引
  173. name: null, // 曲名
  174. author: null // 作者
  175. },
  176. form: {
  177. subjectId: null,
  178. levelId: null, // 级别
  179. examSubjectSongId: null, // 级别编号
  180. adviserName: null, // 老师姓名
  181. adviserPhone: null, // 联系电话
  182. lastExamCertificateUrl: null,
  183. lastMusicTheoryCertificateUrl: null,
  184. examMusicTheoryId: null,
  185. examMusicTheoryLevel: null,
  186. levelFee: 0,// 级别费用
  187. theoryLevelFee: 0, // 乐理费用
  188. },
  189. formText: {
  190. subjectName: null,
  191. levelName: null,
  192. examMusicTheoryName: null
  193. },
  194. sheetSong: { // 上拉弹窗
  195. status: false,
  196. index: 0, // 选中的索引值
  197. columns: []
  198. },
  199. practiceSelect: [], // 练习曲循环列表
  200. practiceSelectUploadList: [],
  201. practiceSelectList: [], // 弹窗练习曲列表
  202. practiceSelectIds: [], // 选中练习曲编号
  203. performNumSelect: [], // 演奏曲循环列表
  204. performNumSelectUploadList: [],
  205. performNumSelectList: [], // 弹窗演奏曲列表
  206. performNumSelectIds: [], // 选中演奏曲编号
  207. songSelectIndex: null, // 选中的哪个
  208. uploadCertificate: [], // 上传证书
  209. uploadCertificate2: [], // 上传乐理证书
  210. practiceUpload: [],
  211. practiceUploadTemp: [],
  212. performNumUpload: [],
  213. performNumUploadTemp: [],
  214. examMusicTheoryList: [], // 乐理列表
  215. examMusicTheoryIndex: 0, // 乐理索引
  216. }
  217. },
  218. mounted() {
  219. // 插入token
  220. // let params = this.$route.query
  221. // if(params.Authorization) {
  222. // localStorage.setItem('Authorization', decodeURI(params.Authorization))
  223. // localStorage.setItem('userInfo', decodeURI(params.Authorization))
  224. // }
  225. this.__init()
  226. if(this.examRegistrationParams) {
  227. this.getRegisterInfo(this.examRegistrationParams)
  228. }
  229. this.onCheckOrder() // 查询有没有待支付订单
  230. // this.form.levelId = 1
  231. // this.practiceNum = 2
  232. // this.practiceSongIdList = ""
  233. // this.performNum = 2
  234. // this.performSongIdList = ""
  235. // this.getExamSubjectSong()
  236. },
  237. methods: {
  238. async onCheckOrder() {
  239. const order = await getExamIngOrder({ examinationBasicId: this.examId })
  240. const resultOrder = order.data
  241. if(resultOrder.code == 200 && resultOrder.data) {
  242. this.$dialog.confirm({
  243. title: '提示',
  244. message: "您当前有待支付订单",
  245. confirmButtonColor: '#269a93',
  246. cancelButtonText: '取消订单',
  247. confirmButtonText: '去支付'
  248. }).then(() => {
  249. this.$router.push({
  250. path: '/signUpPayment',
  251. query: {
  252. orderNo: resultOrder.data.orderNo,
  253. examRegistrationId: resultOrder.data.examRegistrationId
  254. }
  255. })
  256. }).catch(() => {
  257. const orderNo = resultOrder.data.orderNo
  258. this.$dialog.close()
  259. if(!orderNo) {
  260. return
  261. }
  262. localStorage.removeItem("examRegistrationParams")
  263. this.onCloseOrder(orderNo)
  264. })
  265. } else {
  266. localStorage.removeItem("examRegistrationParams")
  267. }
  268. },
  269. async onCloseOrder(orderNo) {
  270. setLoading(true)
  271. await closeOrder({ orderNo: orderNo })
  272. setLoading(false)
  273. },
  274. async getRegisterInfo(data) {
  275. if(!data) { // 判断是否有数据
  276. return
  277. }
  278. let form = this.form,
  279. formText = this.formText
  280. form.subjectId = data.subjectId // 报考专业专业
  281. formText.subjectName = data.subjectName // 报考专业名称
  282. form.levelFee = data.levelFee,// 级别费用
  283. form.theoryLevelFee = data.theoryLevelFee, // 乐理费用
  284. this.getExamSubjectLevel((tempList) => {
  285. //
  286. tempList.forEach(item => {
  287. if(item.level == data.level) {
  288. form.levelId = item.value
  289. form.examSubjectSongId = item.id
  290. formText.levelName = levelToCN[data.level]
  291. this.practiceNum = item.practiceNum
  292. this.practiceSongIdList = item.practiceSongIdList
  293. this.performNum = item.performNum
  294. this.performSongIdList = item.performSongIdList
  295. }
  296. })
  297. // 报考曲目
  298. this.getExamSubjectSong()
  299. const songJsonParse = data.songJson ? JSON.parse(data.songJson) : []
  300. let tempPracticeArr = [],
  301. tempPracticeStr = [],
  302. tempPerformArr = [],
  303. tempPerformStr = []
  304. songJsonParse.forEach(item => {
  305. const str = item.songName + (item.songAuthor ? "-" + item.songAuthor : "")
  306. if(item.type == "PERFORM") {
  307. tempPerformArr.push(item)
  308. tempPerformStr.push(str)
  309. this.performNumSelectIds.push(item.id)
  310. } else if(item.type == "PRACTICE") {
  311. tempPracticeArr.push(item)
  312. tempPracticeStr.push(str)
  313. this.practiceSelectIds.push(item.id)
  314. }
  315. })
  316. // 练习课 "PRACTICE"
  317. this.practiceSelect = tempPracticeStr
  318. if(this.practiceSongIdList) {
  319. this.practiceSelectList = tempPracticeArr
  320. } else {
  321. tempPracticeArr.forEach(item => {
  322. item.name = item.songName
  323. item.author = item.songAuthor
  324. const urlList = item.uploadUrl ? item.uploadUrl.split(',') : []
  325. let tempUrl = []
  326. urlList.forEach(url => {
  327. tempUrl.push({
  328. url: url
  329. })
  330. })
  331. this.practiceUpload.push(tempUrl)
  332. this.practiceUploadTemp.push(tempUrl)
  333. })
  334. this.practiceSelectUploadList = tempPracticeArr
  335. }
  336. // 演奏课 "PERFORM"
  337. this.performNumSelect = tempPerformStr
  338. if(this.performSongIdList) {
  339. this.performNumSelectList = tempPerformArr
  340. } else {
  341. tempPerformArr.forEach(item => {
  342. item.name = item.songName
  343. item.author = item.songAuthor
  344. const urlList = item.uploadUrl ? item.uploadUrl.split(',') : []
  345. let tempUrl = []
  346. urlList.forEach(url => {
  347. tempUrl.push({
  348. url: url
  349. })
  350. })
  351. this.performNumUpload.push(tempUrl)
  352. this.performNumUploadTemp.push(tempUrl)
  353. })
  354. this.performNumSelectUploadList = tempPerformArr
  355. }
  356. }) // 获取专业级别
  357. // 上传证书(上次考级证书)
  358. if(data.lastExamCertificateUrl) {
  359. form.lastExamCertificateUrl = data.lastExamCertificateUrl
  360. this.uploadCertificate = [{ url: data.lastExamCertificateUrl }]
  361. }
  362. // 乐理知识
  363. this.getTheoryLevelList((tempList) => {
  364. tempList.forEach(item => {
  365. if(!data.examMusicTheoryId && !data.examMusicTheoryLevel) {
  366. form.examMusicTheoryId = 999
  367. form.examMusicTheoryLevel = 999
  368. formText.examMusicTheoryName = "免考"
  369. } else if(item.level == data.examMusicTheoryLevel) {
  370. form.examMusicTheoryId = item.id
  371. form.examMusicTheoryLevel = item.level
  372. formText.examMusicTheoryName = item.text
  373. }
  374. })
  375. })
  376. if(data.lastMusicTheoryCertificateUrl) {
  377. form.lastMusicTheoryCertificateUrl = data.lastMusicTheoryCertificateUrl
  378. this.uploadCertificate2 = [{ url: data.lastMusicTheoryCertificateUrl }]
  379. }
  380. form.adviserName = data.adviserName
  381. form.adviserPhone = data.adviserPhone
  382. },
  383. async __init() {
  384. setLoading(true)
  385. try {
  386. // 获取报考专业
  387. const res = await getExamSubjects({ examId: this.examId })
  388. const result = res.data
  389. if(result.code == 200 && result.data.length > 0) {
  390. let tempArr = []
  391. result.data.forEach(item => {
  392. item.value = item.id
  393. item.text = item.name
  394. tempArr.push(item)
  395. })
  396. this.examSubjectList = tempArr
  397. }
  398. this.getTheoryLevelList()
  399. } catch(err) {
  400. //
  401. }
  402. setLoading(false)
  403. },
  404. async getTheoryLevelList(callBack) {
  405. setLoading(true)
  406. try {
  407. const resTheory = await getTheoryLevelList({ examId: this.examId })
  408. const resultTheory = resTheory.data
  409. if(resultTheory.code == 200 && resultTheory.data.length > 0) {
  410. let tempArr2 = []
  411. if(this.examSubjectList.length > 0) {
  412. tempArr2 = [{
  413. id: 999,
  414. value: 999,
  415. text: "免考",
  416. level: 999,
  417. fee: 0
  418. }]
  419. }
  420. resultTheory.data.forEach(item => {
  421. item.value = item.id
  422. item.text = levelToCN[item.level]
  423. tempArr2.push(item)
  424. })
  425. this.examMusicTheoryList = tempArr2
  426. callBack && callBack(tempArr2)
  427. }
  428. } catch(err) {
  429. //
  430. }
  431. setLoading(false)
  432. },
  433. onGetSheetList(type) {
  434. let sheetForm = this.sheetForm
  435. let form = this.form
  436. sheetForm.columns = []
  437. sheetForm.currentType = type
  438. sheetForm.index = 0
  439. // 报考专业
  440. if(type === "examSubject") {
  441. if(this.examSubjectList.length > 0) {
  442. sheetForm.sheetStatus = true
  443. sheetForm.columns = this.examSubjectList
  444. sheetForm.index = this.examSubjectIndex
  445. } else {
  446. this.$toast("暂无报考专业")
  447. return
  448. }
  449. } else if(type === "level") {
  450. if(!form.subjectId) {
  451. this.$toast("请选择报考专业")
  452. return
  453. }
  454. if(this.levelList.length > 0) {
  455. sheetForm.sheetStatus = true
  456. sheetForm.columns = this.levelList
  457. sheetForm.index = this.levelIndex
  458. } else {
  459. this.$toast("暂无报专业级别")
  460. return
  461. }
  462. } else if(type == "examMusicTheory") {
  463. if(this.examMusicTheoryList.length > 0) {
  464. sheetForm.sheetStatus = true
  465. sheetForm.columns = this.examMusicTheoryList
  466. sheetForm.index = this.examMusicTheoryIndex
  467. } else {
  468. this.$toast("暂无乐理级别")
  469. return
  470. }
  471. }
  472. },
  473. onSheetConfirm(value, index) {
  474. let sheetForm = this.sheetForm,
  475. form = this.form,
  476. formText = this.formText
  477. if(!value) { // 判断是否在选中的值
  478. sheetForm.sheetStatus = false
  479. return
  480. }
  481. if(sheetForm.currentType == "examSubject") {
  482. if(form.subjectId != value.id) {
  483. form.subjectId = value.id
  484. formText.subjectName = value.name
  485. this.examSubjectIndex = index
  486. // 清除专业级别
  487. form.levelId = null
  488. formText.levelName = null
  489. form.examSubjectSongId = null
  490. form.levelFee = 0
  491. this.levelIndex = 0
  492. this.practiceNum = 0 // 练习曲数量
  493. this.practiceSongIdList = null
  494. this.performNum = 0 // 演奏曲数量
  495. this.performSongIdList = null
  496. this.onResetSong()
  497. this.getExamSubjectLevel() // 请求专业级别
  498. }
  499. sheetForm.sheetStatus = false
  500. } else if(sheetForm.currentType == 'level') {
  501. sheetForm.sheetStatus = false
  502. if(form.levelId === value.value) { // 判断两次选择是否是一样
  503. return
  504. }
  505. form.levelId = value.value
  506. form.examSubjectSongId = value.id
  507. form.levelFee = value.registrationFee // 级别费用
  508. formText.levelName = value.text
  509. this.levelIndex = index
  510. this.practiceNum = value.practiceNum
  511. this.practiceSongIdList = value.practiceSongIdList
  512. this.performNum = value.performNum
  513. this.performSongIdList = value.performSongIdList
  514. this.onResetSong()
  515. this.getExamSubjectSong()
  516. } else if(sheetForm.currentType == "examMusicTheory") {
  517. form.examMusicTheoryId = value.value
  518. form.theoryLevelFee = value.fee
  519. form.examMusicTheoryLevel = value.level
  520. formText.examMusicTheoryName = value.text
  521. this.examMusicTheoryIndex = index
  522. sheetForm.sheetStatus = false
  523. }
  524. },
  525. onResetSong() { // 重置报考曲目数据
  526. this.practiceSelect = []
  527. this.practiceUpload = []
  528. this.practiceUploadTemp = []
  529. this.practiceSelectUploadList = []
  530. this.practiceSelectIds = []
  531. this.performNumSelectUploadList = []
  532. this.performNumSelect = []
  533. this.performNumUpload = []
  534. this.performNumUploadTemp = []
  535. this.performNumSelectIds = []
  536. },
  537. async getExamSubjectLevel(callBack) {
  538. setLoading(true)
  539. try {
  540. const form = this.form
  541. const res = await getExamSubjectLevel({ examSubjectId: form.subjectId, examinationBasicId: this.examId })
  542. const result = res.data
  543. if(result.code == 200 && result.data.length > 0) {
  544. let tempArr = []
  545. result.data.forEach(item => {
  546. item.value = item.level
  547. item.text = levelToCN[item.level]
  548. tempArr.push(item)
  549. })
  550. this.levelList = tempArr
  551. callBack && callBack(tempArr)
  552. }
  553. } catch(err) {
  554. //
  555. }
  556. setLoading(false)
  557. },
  558. async getExamSubjectSong(callBack) {
  559. setLoading(true)
  560. try {
  561. const form = this.form
  562. const params = {
  563. examSubjectId: form.subjectId,
  564. examinationBasicId: this.examId,
  565. level: form.levelId
  566. }
  567. const res = await getExamSubjectSong(params)
  568. const result = res.data
  569. if(result.code == 200 && result.data.length > 0) {
  570. let tempArr = []
  571. result.data.forEach(item => {
  572. item.value = item.id
  573. item.text = item.songName + '-' + item.songAuthor
  574. tempArr.push(item)
  575. })
  576. this.songList = tempArr
  577. callBack && callBack(tempArr)
  578. }
  579. } catch(err) {
  580. //
  581. }
  582. setLoading(false)
  583. },
  584. onChangePractice(type, index) {
  585. let songList = this.songList
  586. let sheetSong = this.sheetSong
  587. sheetSong.columns = []
  588. sheetSong.index = 0
  589. let tempPracticeArr = [],
  590. tempPerformArr = []
  591. songList.forEach(item => {
  592. if(item.type == "PERFORM") {
  593. // if(this.performNumSelectIds.includes(item.id)) {
  594. // item.disabled = true
  595. // } else {
  596. // item.disabled = false
  597. // }
  598. tempPerformArr.push(item)
  599. } else if(item.type == "PRACTICE") {
  600. // if(this.practiceSelectIds.includes(item.id)) {
  601. // item.disabled = true
  602. // } else {
  603. // item.disabled = false
  604. // }
  605. tempPracticeArr.push(item)
  606. }
  607. })
  608. if(type == 'practice') {
  609. sheetSong.columns = tempPracticeArr
  610. } else if(type == 'performNum') {
  611. sheetSong.columns = tempPerformArr
  612. }
  613. this.songSelectIndex = index
  614. sheetSong.status = true
  615. },
  616. onPracticeConfirm(value) {
  617. // 没有内容
  618. if(!value) {
  619. return
  620. }
  621. let songSelectIndex = this.songSelectIndex
  622. if(value.type == "PRACTICE") { // 练习
  623. this.practiceSelect[songSelectIndex] = value.text
  624. this.practiceSelectIds[songSelectIndex] = value.value
  625. this.practiceSelectList[songSelectIndex] = value
  626. } else if(value.type == "PERFORM") { // 演奏
  627. this.performNumSelect[songSelectIndex] = value.text
  628. this.performNumSelectIds[songSelectIndex] = value.value
  629. this.performNumSelectList[songSelectIndex] = value
  630. }
  631. this.sheetSong.status = false
  632. },
  633. beforeRead(file) {
  634. const isLt2M = file.size / 1024 / 1024 < 5
  635. if (!isLt2M) {
  636. this.$toast('上传图片大小不能超过 5MB')
  637. return false
  638. }
  639. // return new Promise((resolve) => {
  640. // fileUtil.getOrientation(file).then((orient) => {
  641. // console.log(orient)
  642. // if (orient && orient != "" && orient != 1) {
  643. // let reader = new FileReader()
  644. // let img = new Image()
  645. // reader.onload = (e) => {
  646. // img.src = e.target.result
  647. // img.onload = function () {
  648. // const data = fileUtil.rotateImage(img, img.width, img.height, orient)
  649. // const newFile = fileUtil.dataURLtoFile(data, file.name)
  650. // resolve(newFile)
  651. // }
  652. // }
  653. // reader.readAsDataURL(file)
  654. // } else {
  655. // resolve(file)
  656. // }
  657. // })
  658. // })
  659. return true
  660. },
  661. beforeDelete(file, detail) {
  662. const obj = detail.name.split('-')
  663. let form = this.form
  664. if(obj[0] == "certificate2") {
  665. form.lastMusicTheoryCertificateUrl = "" // 上传图片地址为空
  666. } else if(obj[0] == "certificate") {
  667. form.lastExamCertificateUrl = ""
  668. }
  669. return true
  670. },
  671. async afterRead(file, detail) { // 上传头像
  672. const obj = detail.name.split('-')
  673. try {
  674. file.status = 'uploading'
  675. file.message = '上传中...'
  676. let formData = new FormData()
  677. formData.append('file', file.file)
  678. let res = await uploadFile(formData)
  679. let result = res.data
  680. if(result.code == 200) {
  681. file.status = 'done'
  682. let form = this.form
  683. if(obj[0] == "certificate2") {
  684. form.lastMusicTheoryCertificateUrl = result.data.url // 上传图片地址为空
  685. } else if(obj[0] == "certificate") {
  686. form.lastExamCertificateUrl = result.data.url
  687. } else if(obj[0] == 'practiceNum') {
  688. file.url = result.data.url
  689. } else if(obj[0] == 'performNum') {
  690. file.url = result.data.url
  691. }
  692. } else {
  693. file.status = 'failed'
  694. file.message = '上传失败'
  695. this.$toast(result.msg)
  696. return false
  697. }
  698. } catch (err) {
  699. return false
  700. }
  701. },
  702. onUploadSong(value, index) { // 上传曲目
  703. let songUpload = this.songUpload
  704. songUpload.songStatus = true
  705. songUpload.indexName = value
  706. songUpload.index = index
  707. let practiceSUL = this.practiceSelectUploadList[index]
  708. let performSUL = this.performNumSelectUploadList[index]
  709. if(value == "practiceNum") {
  710. songUpload.name = practiceSUL ? practiceSUL.name : null
  711. songUpload.author = practiceSUL ? practiceSUL.author : null
  712. } else if(value == "performNum") {
  713. songUpload.name = performSUL ? performSUL.name : null
  714. songUpload.author = performSUL ? performSUL.author : null
  715. }
  716. },
  717. onSaveCancel() {
  718. this.songUpload.songStatus = false
  719. this.performNumUpload = JSON.parse(JSON.stringify(this.performNumUploadTemp)) // 回填数据
  720. this.practiceUpload = JSON.parse(JSON.stringify(this.practiceUploadTemp)) // 回填数据
  721. },
  722. onSaveUpload() {
  723. let songUpload = this.songUpload
  724. if(!songUpload.name) {
  725. this.$toast("请输入曲名")
  726. return
  727. }
  728. const nameAuthor = songUpload.name + (songUpload.author ? "-" + songUpload.author : "")
  729. if(songUpload.indexName == "practiceNum") {
  730. const practiceObj = this.practiceUpload[songUpload.index]
  731. const practiceLength = practiceObj ? practiceObj.length : 0
  732. if(practiceObj && practiceLength > 0 && practiceObj[0].url) {
  733. if(practiceObj[practiceLength - 1].url) {
  734. this.practiceSelect[songUpload.index] = nameAuthor
  735. this.practiceSelectUploadList[songUpload.index] = JSON.parse(JSON.stringify(songUpload))
  736. this.practiceUploadTemp = JSON.parse(JSON.stringify(this.practiceUpload))
  737. } else {
  738. this.$toast("上传曲谱中,请稍等")
  739. return
  740. }
  741. } else {
  742. this.$toast("请上传文件")
  743. return
  744. }
  745. } else if(songUpload.indexName == "performNum") {
  746. const performObj = this.performNumUpload[songUpload.index]
  747. const performLength = performObj ? performObj.length : 0
  748. if(performObj && performLength > 0) {
  749. if(performObj[performLength - 1].url) {
  750. this.performNumSelect[songUpload.index] = nameAuthor
  751. this.performNumSelectUploadList[songUpload.index] = JSON.parse(JSON.stringify(songUpload))
  752. this.performNumUploadTemp = JSON.parse(JSON.stringify(this.performNumUpload))
  753. } else {
  754. this.$toast("上传曲谱中,请稍等")
  755. return
  756. }
  757. } else {
  758. this.$toast("请上传文件")
  759. return
  760. }
  761. }
  762. songUpload.name = null
  763. songUpload.author = null
  764. songUpload.songStatus = false
  765. },
  766. async onSubmit() {
  767. setLoading(true)
  768. try {
  769. // 验证
  770. if(!this.onCheckFields()) {
  771. return
  772. }
  773. let songJson = [] // json 数组
  774. // 练习课 "PRACTICE"
  775. if(this.practiceSongIdList) { // 下拉选择
  776. this.practiceSelectList.forEach(item => {
  777. songJson.push({
  778. id: item.id,
  779. type: item.type,
  780. songName: item.songName,
  781. songAuthor: item.songAuthor,
  782. uploadUrl: item.fileUrlList
  783. })
  784. })
  785. } else { // 自选
  786. const practiceUpload = this.practiceUpload
  787. this.practiceSelectUploadList.forEach(item => {
  788. let tempUrl = []
  789. practiceUpload[item.index].forEach(item => {
  790. tempUrl.push(item.url)
  791. })
  792. songJson.push({
  793. songName: item.name,
  794. songAuthor: item.author,
  795. index: item.index,
  796. type: "PRACTICE",
  797. uploadUrl: tempUrl.join(',')
  798. })
  799. })
  800. }
  801. // 演奏课 "PERFORM"
  802. if(this.performSongIdList) {
  803. this.performNumSelectList.forEach(item => {
  804. songJson.push({
  805. id: item.id,
  806. type: item.type,
  807. songName: item.songName,
  808. songAuthor: item.songAuthor,
  809. uploadUrl: item.fileUrlList
  810. })
  811. })
  812. } else {
  813. const performNumUpload = this.performNumUpload
  814. this.performNumSelectUploadList.forEach(item => {
  815. let tempUrl = []
  816. performNumUpload[item.index].forEach(item => {
  817. tempUrl.push(item.url)
  818. })
  819. songJson.push({
  820. songName: item.name,
  821. songAuthor: item.author,
  822. index: item.index,
  823. type: "PERFORM",
  824. uploadUrl: tempUrl.join(',')
  825. })
  826. })
  827. }
  828. let form = this.form,
  829. formText = this.formText
  830. let params = {
  831. // studentName: localStorage.getItem("studentName"),
  832. examStartTime: localStorage.getItem("examStartTime"),
  833. adviserName: form.adviserName,
  834. adviserPhone: form.adviserPhone,
  835. examMusicTheoryId: form.examMusicTheoryId == 999 ? null : form.examMusicTheoryId,
  836. examMusicTheoryLevel: form.examMusicTheoryLevel == 999 ? null : form.examMusicTheoryLevel,
  837. examinationBasicId: this.examId,
  838. lastExamCertificateUrl: form.lastExamCertificateUrl,
  839. lastMusicTheoryCertificateUrl: form.lastMusicTheoryCertificateUrl,
  840. level: form.levelId,
  841. examSubjectSongId: form.examSubjectSongId,
  842. subjectId: form.subjectId, // 考级专业
  843. subjectName: formText.subjectName,
  844. songJson: JSON.stringify(songJson),
  845. organId: this.organId,
  846. levelFee: form.levelFee,
  847. theoryLevelFee: form.theoryLevelFee
  848. }
  849. setLoading(false)
  850. localStorage.setItem("examRegistrationParams", JSON.stringify(params))
  851. this.$router.push({
  852. path: '/signUpPayment'
  853. })
  854. } catch(err) {
  855. //
  856. }
  857. },
  858. onCheckFields() {
  859. // 校验数据
  860. let form = this.form
  861. if(this.examSubjectList.length > 0) {
  862. if(!form.subjectId) {
  863. this.$toast('请选择报考专业')
  864. return false
  865. }
  866. if(!form.levelId) {
  867. this.$toast('请选择专业级别')
  868. return false
  869. }
  870. }
  871. // 有值说明是列表
  872. if(this.practiceSongIdList) {
  873. if(this.practiceSelectIds.length != this.practiceNum) {
  874. this.$toast('请选择练习曲')
  875. return false
  876. }
  877. const tempIds = new Set(this.practiceSelectIds)
  878. if(this.practiceSelectIds.length != tempIds.size) {
  879. this.$toast("不能选择重复的练习曲")
  880. return false
  881. }
  882. } else {
  883. if(this.practiceUpload.length != this.practiceNum) {
  884. this.$toast('请上传练习曲')
  885. return false
  886. }
  887. }
  888. if(this.performSongIdList) {
  889. if(this.performNumSelectIds.length != this.performNum) {
  890. this.$toast('请选择演奏曲')
  891. return false
  892. }
  893. const tempIds = new Set(this.performNumSelectIds)
  894. if(this.performNumSelectIds.length != tempIds.size) {
  895. this.$toast("不能选择重复的演奏曲")
  896. return false
  897. }
  898. } else {
  899. if(this.performNumUpload.length != this.performNum) {
  900. this.$toast('请上传演奏曲')
  901. return false
  902. }
  903. }
  904. if(!form.examMusicTheoryId) {
  905. this.$toast('请选择乐理级别')
  906. return false
  907. }
  908. // if(form.examMusicTheoryId == 999 && form.levelId > 2 && !form.lastMusicTheoryCertificateUrl) {
  909. // this.$toast('请上传乐理证书')
  910. // return false
  911. // }
  912. if(form.adviserPhone && !this.checkPhone(form.adviserPhone)) {
  913. return false
  914. }
  915. return true
  916. },
  917. checkPhone(phoneNumber) {
  918. let result = true
  919. if(!(this.patternPhone.test(phoneNumber))){
  920. this.$toast('联系方式输入有误')
  921. result = false
  922. }
  923. return result
  924. },
  925. onBack() { // 上一步
  926. window.history.go(-1)
  927. },
  928. numberToCN (value) {
  929. const tempNumber = {
  930. 0: '一',
  931. 1: '二',
  932. 2: '三',
  933. 3: '四',
  934. 4: '五',
  935. 5: '六',
  936. 6: '七',
  937. 7: '八',
  938. 8: '九',
  939. 9: '十',
  940. }
  941. return tempNumber[value]
  942. }
  943. },
  944. destroyed() {
  945. this.$toast.clear()
  946. this.$dialog.close()
  947. }
  948. }
  949. </script>
  950. <style lang="less" scoped>
  951. @import url("../../assets/commonLess/variable");
  952. .signUpLevel {
  953. // height: 100vh;
  954. min-height: calc(100vh - 1rem);
  955. padding-bottom: 1rem;
  956. overflow-y: auto;
  957. overflow-x: hidden;
  958. background-color: @--main-bg-color;
  959. position: relative;
  960. .title {
  961. font-size: .16rem;
  962. color: @--font-second-color;
  963. padding: .12rem .16rem;
  964. }
  965. /deep/.van-cell {
  966. padding: .13rem .16rem;
  967. }
  968. /deep/.van-field__label {
  969. font-size: .17rem;
  970. color: @--font-main-color;
  971. width: 1.15rem;
  972. }
  973. /deep/.van-field__body {
  974. font-size: .16rem
  975. }
  976. .codeText {
  977. font-size: .16rem;
  978. color: @--main-color;
  979. }
  980. }
  981. .van-popup-song {
  982. width: 80%;
  983. border-radius: .08rem;
  984. }
  985. .song-popup {
  986. text-align: center;
  987. .title {
  988. font-size: 18px;
  989. font-weight: 500;
  990. color: @--font-main-color;
  991. padding: .2rem 0 .15rem;
  992. }
  993. // .song-upload {
  994. // margin: 0 .5rem;
  995. // padding: .18rem 0 .1rem;
  996. // border-radius: .05rem;
  997. // border: 1px dashed transparent;
  998. // background: linear-gradient(0deg, transparent 6px, #777777 6px) repeat-y,
  999. // linear-gradient(0deg, transparent 50%, #777777 0) repeat-y,
  1000. // linear-gradient(90deg, transparent 50%, #777777 0) repeat-x,
  1001. // linear-gradient(90deg, transparent 50%, #777777 0) repeat-x;
  1002. // background-size: 1px 12px, 1px 12px, 12px 1px, 12px 1px;
  1003. // background-position: 0 0, 100% 0, 0 0, 0 100%;
  1004. // font-size: .16rem;
  1005. // color: #777;
  1006. // }
  1007. .song-upload {
  1008. border-radius: .05rem;
  1009. border: 1px solid #c5c7cb;
  1010. background-position: 0 0, 100% 0, 0 0, 0 100%;
  1011. font-size: .16rem;
  1012. color: #777;
  1013. width: 80px;
  1014. height: 80px;
  1015. display: flex;
  1016. justify-content: center;
  1017. align-items: center;
  1018. text-align: center;
  1019. .van-uploader__preview {
  1020. margin: 0;
  1021. }
  1022. p {
  1023. font-size: 13px;
  1024. }
  1025. }
  1026. /deep/.van-uploader {
  1027. margin: 0 auto;
  1028. }
  1029. /deep/.van-uploader__upload,
  1030. /deep/.van-uploader__preview-image {
  1031. width: 65px;
  1032. height: 65px;
  1033. }
  1034. .song-popup-tips {
  1035. font-size: .14rem;
  1036. color: #808080;
  1037. padding-bottom: .15rem
  1038. // padding-top: .1rem;
  1039. // padding-bottom: .25rem;
  1040. }
  1041. /deep/.van-cell {
  1042. padding: 13px 35px;
  1043. }
  1044. /deep/.van-field__label {
  1045. width: .8rem;
  1046. text-align: left;
  1047. }
  1048. .popup-group {
  1049. width: 100%;
  1050. display: flex;
  1051. color: @--main-color;
  1052. background-color: #F0F0F0;
  1053. font-size: .18rem;
  1054. span {
  1055. padding: .12rem 0;
  1056. flex: 1;
  1057. }
  1058. .popup-sure {
  1059. color: #ffffff;
  1060. background-color: @--main-color;
  1061. }
  1062. }
  1063. }
  1064. /deep/.van-uploader__upload {
  1065. margin-bottom: 0;
  1066. }
  1067. .m-btn-group {
  1068. position: fixed;
  1069. bottom: 0;
  1070. width: calc(100% - .4rem);
  1071. padding: .1rem .2rem;
  1072. display: flex;
  1073. justify-content: space-between;
  1074. background-color: #fff;
  1075. box-shadow:0px -1px 4px 0px rgba(226,226,226,1);
  1076. .van-button {
  1077. font-size: .18rem;
  1078. height: .5rem;
  1079. width: 48%;
  1080. }
  1081. .btn_prev:active {
  1082. color: @--main-color !important;
  1083. background-color: #F5FFFD !important;
  1084. }
  1085. .btn_prev:active::before {
  1086. // background-color: #F5FFFD !important;
  1087. // border-color: @--main-color !important;
  1088. opacity: 0;
  1089. }
  1090. }
  1091. </style>