change-major.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="page-container">
  3. <u-nav-bar title="专业分流志愿填报" bg="#007aff" ref="uNavBar" />
  4. <view class="u-bg" />
  5. <view class="main-content">
  6. <u-panel v-if="form.notice">
  7. <u-des-row label="注意事项" />
  8. <view class="notice-tip" v-html="form.notice" />
  9. </u-panel>
  10. <u-panel title="个人信息">
  11. <u-des-row label="学号" :value="userInfo.studentNO" border />
  12. <u-des-row label="姓名" :value="userInfo.studentName" border />
  13. <u-des-row label="班级" :value="userInfo.gradeName" border />
  14. <u-des-row label="联系电话" eye>
  15. <view slot="value" slot-scope="{isOpen}">
  16. {{isOpen ? userInfo.mobileNo : hideCode(userInfo.mobileNo, 3,4) }}
  17. </view>
  18. </u-des-row>
  19. </u-panel>
  20. <u-panel title="专业志愿">
  21. <u-picker v-model="form.majorId1st" label-key="majorName" value-key="majorId" :options="majorOptions"
  22. @change="e=>pickerMajor(e, 'majorId1st')">
  23. <u-des-row slot-scope="{data}" label="第一专业志愿" :value="data.majorName || '请选择'"
  24. :style="{opacity: data.majorName?1:0.5}" border />
  25. </u-picker>
  26. <u-picker v-model="form.majorId2nd" label-key="majorName" value-key="majorId" :options="majorOptions"
  27. @change="e=>pickerMajor(e, 'majorId2nd')">
  28. <u-des-row slot-scope="{data}" label="第二专业志愿" :value="data.majorName || '请选择'"
  29. :style="{opacity: data.majorName?1:0.5}" border />
  30. </u-picker>
  31. <u-picker v-model="form.majorId3rd" label-key="majorName" value-key="majorId" :options="majorOptions"
  32. @change="e=>pickerMajor(e, 'majorId3rd')">
  33. <u-des-row slot-scope="{data}" label="第三专业志愿" :value="data.majorName || '请选择'"
  34. :style="{opacity: data.majorName?1:0.5}" border />
  35. </u-picker>
  36. <u-picker v-model="form.majorId4th" label-key="majorName" value-key="majorId" :options="majorOptions"
  37. @change="e=>pickerMajor(e, 'majorId4th')">
  38. <u-des-row slot-scope="{data}" label="第四专业志愿" :value="data.majorName || '请选择'"
  39. :style="{opacity: data.majorName?1:0.5}" border />
  40. </u-picker>
  41. <u-picker v-model="form.majorId5th" label-key="majorName" value-key="majorId" :options="majorOptions"
  42. @change="e=>pickerMajor(e, 'majorId5th')">
  43. <u-des-row slot-scope="{data}" label="第五专业志愿" :value="data.majorName || '请选择'"
  44. :style="{opacity: data.majorName?1:0.5}" />
  45. </u-picker>
  46. </u-panel>
  47. <u-panel>
  48. <u-des-row label="学生签名" @click="visible=true">
  49. <image slot="value" style="width: 34rpx;height: 30rpx;" src="/static/sign_icon.png"
  50. mode="widthFix" />
  51. </u-des-row>
  52. <view v-if="form.studentSign" class="u-sign-preview">
  53. <image :src="form.studentSign" style="width: 100%;height: 100%;" mode="widthFix"></image>
  54. <view class="icon-clear u-flex-center" @click="form.studentSign=''">
  55. <uni-icons type="closeempty" size="15" color="white" />
  56. </view>
  57. </view>
  58. <view v-else class="sign-tip">填写完信息请点击签字笔完成签名哦~</view>
  59. </u-panel>
  60. <view class="u-flex" style="margin: 96rpx 0 32rpx;">
  61. <view class="u-button save-button" :class="{'disabled':disabledSave}" @click="!disabledSave && onSumbit(1)">
  62. 暂存
  63. </view>
  64. <view style="width:20rpx">
  65. </view>
  66. <button class="u-button sumbit-button" :class="{'disabled':disabledSumbit}" @click="!disabledSumbit && onSumbit(2)">
  67. {{form.applyStatus >= 1 ? '已提交' : '提交'}}
  68. </button>
  69. </view>
  70. </view>
  71. <u-drawer :visible.sync="visible" title="手写签名" @sumbit="signSumbit" @cancel="visible=false">
  72. <view class="drawer-tip">
  73. <text class="empty-2"></text>
  74. <text>本人已仔细阅读专业分流并理解了有关要求和规定,在此我郑重承诺:“本人自愿按以上顺序选择专业,服从调剂,且专业分流后不再变更。
  75. 对违反以上承诺所造成的后果,本人自愿承担相应责任。”</text>
  76. </view>
  77. <u-sign ref="uSign" v-if="visible" />
  78. </u-drawer>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. mapState
  84. } from 'vuex'
  85. import {
  86. hideCode
  87. } from '@/common'
  88. import formChecker from '@/common/formChecker.js'
  89. export default {
  90. data() {
  91. return {
  92. form: {
  93. notice: '',
  94. majorId1st: '',
  95. majorId2nd: '',
  96. majorId3rd: '',
  97. majorId4th: '',
  98. majorId5th: '',
  99. studentSign: '',
  100. //
  101. applyStatus: '',
  102. majorApplyId: ''
  103. },
  104. visible: false, // 签名 抽屉
  105. majorOptions: []
  106. }
  107. },
  108. computed: {
  109. ...mapState({
  110. userInfo: state => state.user.userInfo,
  111. }),
  112. disabledSave() {
  113. return this.form.applyStatus >= 1 // 已提交
  114. },
  115. disabledSumbit() {
  116. return this.form.applyStatus >= 1 || !this.form.majorApplyId // 已提交 或 未缓存
  117. },
  118. },
  119. mounted() {
  120. this.$ajax.get('/shunt/major-info').then(res => {
  121. this.majorOptions = res.data.map(item => ({
  122. majorId: item.majorId,
  123. majorName: item.majorName,
  124. disabled: false
  125. }))
  126. this.majorOptionsDisabled()
  127. })
  128. this.init()
  129. },
  130. methods: {
  131. hideCode,
  132. async init() {
  133. // 志愿填报浏览
  134. this.$ajax.post('/shunt/major-apply-view').then(res => {
  135. Object.assign(this.form, res.data)
  136. })
  137. },
  138. majorOptionsDisabled() {
  139. const selectedList = []
  140. Object.keys(this.form).forEach(key => {
  141. key.indexOf('majorId') >= 0 && this.form[key] && selectedList.push(this.form[key])
  142. })
  143. this.majorOptions.forEach(element => {
  144. element.disabled = selectedList.indexOf(element.majorId) >= 0
  145. })
  146. console.log(1111, selectedList, this.majorOptions)
  147. },
  148. pickerMajor(val, prop) {
  149. console.log(222, val, prop)
  150. Object.keys(this.form).forEach(key => {
  151. if (key != prop && key.indexOf('majorId') >= 0 && this.form[key] === val) {
  152. this.form[key] = ''
  153. }
  154. })
  155. // this.form[majorKey] = this.majorOptions[index].label
  156. // this[indexKey] = index
  157. this.majorOptionsDisabled()
  158. },
  159. signSumbit() {
  160. this.$refs.uSign.getBase64(res => {
  161. this.form.studentSign = res?.tempFilePath || ''
  162. this.visible = false
  163. })
  164. },
  165. // api
  166. onSumbit(type) { // 1:暂存 2:提交
  167. //定义表单规则
  168. var rule = [{
  169. name: "majorId1st",
  170. checkType: "notnull",
  171. errorMsg: "请输入第一专业志愿"
  172. }, {
  173. name: "majorId2nd",
  174. checkType: "notnull",
  175. errorMsg: "请输入第二专业志愿"
  176. }, {
  177. name: "majorId3rd",
  178. checkType: "notnull",
  179. errorMsg: "请输入第三专业志愿"
  180. }, {
  181. name: "majorId4th",
  182. checkType: "notnull",
  183. errorMsg: "请输入第四专业志愿"
  184. }, {
  185. name: "majorId5th",
  186. checkType: "notnull",
  187. errorMsg: "请输入第五专业志愿"
  188. }, {
  189. name: "studentSign",
  190. checkType: "notnull",
  191. errorMsg: "请填写签名"
  192. }, ];
  193. //进行表单检查
  194. var checkRes = formChecker.check(this.form, rule);
  195. if (!checkRes) {
  196. uni.showToast({
  197. title: formChecker.error,
  198. icon: "none"
  199. });
  200. return
  201. }
  202. const that = this
  203. uni.showLoading()
  204. this.$ajax.post('/shunt/major-apply', this.form).then(res => {
  205. if (type === 1) {
  206. uni.showToast({
  207. title: '暂存成功',
  208. icon: "success"
  209. });
  210. that.init()
  211. }
  212. uni.hideLoading()
  213. }).catch(error => {
  214. uni.hideLoading()
  215. uni.showModal({
  216. title: '错误',
  217. content: error.msg || error,
  218. showCancel: false
  219. })
  220. })
  221. if (type === 2) {
  222. uni.showLoading()
  223. this.$ajax.post('/shunt/major-apply-submit').then(res => {
  224. uni.showToast({
  225. title: '提交成功',
  226. icon: "success"
  227. });
  228. that.init()
  229. uni.hideLoading()
  230. }).catch(error => {
  231. uni.hideLoading()
  232. uni.showModal({
  233. title: '错误',
  234. content: error.msg || error,
  235. showCancel: false
  236. })
  237. })
  238. }
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .page-container {
  245. .u-bg {
  246. height: 317rpx;
  247. background: $uni-color-primary;
  248. }
  249. .main-content {
  250. padding: 60rpx 32rpx 32rpx 32rpx;
  251. }
  252. .notice-tip {
  253. font-size: 24rpx;
  254. font-weight: 400;
  255. color: #999999;
  256. line-height: 1.5;
  257. padding-bottom: 32rpx;
  258. }
  259. .sign-tip {
  260. height: 144rpx;
  261. font-size: 20rpx;
  262. font-weight: 400;
  263. color: #A3ABBF;
  264. }
  265. .drawer-tip {
  266. font-size: 24rpx;
  267. font-weight: 400;
  268. line-height: 1.5;
  269. color: #999999;
  270. margin-bottom: 36rpx;
  271. }
  272. .save-button,
  273. .sumbit-button {
  274. flex: 1;
  275. height: 88rpx;
  276. background: linear-gradient(90deg, #FFCF18 0%, #FFB300 100%);
  277. border-radius: 8rpx;
  278. &.disabled {
  279. cursor: not-allowed;
  280. opacity: 0.3;
  281. }
  282. }
  283. .sumbit-button {
  284. background: linear-gradient(90deg, #36ACFC 0%, #078EF7 100%);
  285. }
  286. }
  287. </style>