input.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view class="topBox">
  4. <view>
  5. <u-icon name="error-circle-fill" color="#FF3B30" size="28"></u-icon>
  6. <text style="color: #FF3B30;margin-left: 10rpx;">学习前请提交完整审核资料</text>
  7. </view>
  8. <view style="color: #007AFF;">稍后再填</view>
  9. </view>
  10. <view class="bodyBox" style="margin-top: 30rpx;padding:0 20rpx;">
  11. <u-form :model="form" ref="uForm">
  12. <template v-for="(item, index) in listData">
  13. <u-form-item
  14. :key="index"
  15. v-if="item.inputType == 1"
  16. :label="item.fieldName"
  17. :required="item.required"
  18. :label-width="auto"
  19. :prop="item.required ? item.fieldKey : ''"
  20. >
  21. <u-input v-model="form[item.fieldKey]" :placeholder="`请输入${item.fieldName}`" />
  22. </u-form-item>
  23. <u-form-item
  24. :key="index"
  25. v-if="item.inputType == 2"
  26. :label="item.fieldName"
  27. :label-width="auto"
  28. :required="item.required"
  29. :prop="item.required ? item.fieldKey : ''"
  30. >
  31. <picker @change="bindPickerChange(item.fieldKey, $event)" :value="form[item.fieldKey]" :range="getarrays(item.fieldKey)">
  32. <view class="picker">{{ returnName(item.fieldKey) }}</view>
  33. </picker>
  34. </u-form-item>
  35. <u-form-item
  36. :key="index"
  37. v-if="item.inputType == 5"
  38. :label="item.fieldName"
  39. :label-width="auto"
  40. :required="item.required"
  41. :prop="item.required ? item.fieldKey : ''"
  42. >
  43. <picker mode="date" :value="form[item.fieldKey]" @change="bindDateChange(item.fieldKey, $event)">
  44. <view class="picker">{{ getTimes(item.fieldKey) }}</view>
  45. </picker>
  46. </u-form-item>
  47. <u-form-item
  48. :key="index"
  49. v-if="item.inputType == 3 && item.fieldKey !== 'commitment_electr_signature'"
  50. :label="item.fieldName"
  51. :required="item.required"
  52. :label-width="auto"
  53. label-position="top"
  54. :prop="item.required ? item.fieldKey : ''"
  55. >
  56. <text v-if="item.fieldKey === 'recent_photos'" style="color: #999999;position: absolute;top: 20rpx;left: 130rpx;">竖向证件照 文件大小≤2M</text>
  57. <text
  58. v-if="item.fieldKey === 'idcard_face_photo' || item.fieldKey === 'idcard_national_photo'"
  59. style="color: #999999;position: absolute;top: 20rpx;left: 180rpx;"
  60. >
  61. 文件大小≤2M
  62. </text>
  63. <u-upload
  64. :max-size="2097152"
  65. @on-list-change="
  66. item.fieldKey === 'recent_photos'
  67. ? changePhotoListHeader1($event)
  68. : item.fieldKey === 'idcard_face_photo'
  69. ? changePhotoListHeader2($event)
  70. : item.fieldKey === 'idcard_national_photo'
  71. ? changePhotoListHeader3($event)
  72. : ''
  73. "
  74. :auto-upload="false"
  75. custom-btn="true"
  76. :action="action"
  77. :file-list="
  78. item.fieldKey === 'recent_photos'
  79. ? fileList1
  80. : item.fieldKey === 'idcard_face_photo'
  81. ? fileList2
  82. : item.fieldKey === 'idcard_national_photo'
  83. ? fileList3
  84. : ''
  85. "
  86. width="120"
  87. height="120"
  88. size-type="['compressed']"
  89. max-count="1"
  90. >
  91. <template v-slot:addBtn>
  92. <image
  93. :src="
  94. item.fieldKey === 'recent_photos'
  95. ? '/static/info_1.png'
  96. : item.fieldKey === 'idcard_face_photo'
  97. ? '/static/info_2.png'
  98. : item.fieldKey === 'idcard_national_photo'
  99. ? '/static/info_3.png'
  100. : ''
  101. "
  102. :style="
  103. item.fieldKey === 'recent_photos'
  104. ? 'width: 120rpx; height: 169rpx;'
  105. : item.fieldKey === 'idcard_face_photo'
  106. ? 'width: 120rpx; height: 82rpx;'
  107. : item.fieldKey === 'idcard_national_photo'
  108. ? 'width: 120rpx; height: 82rpx;'
  109. : ''
  110. "
  111. ></image>
  112. </template>
  113. </u-upload>
  114. </u-form-item>
  115. <view :key="index" v-if="item.inputType == 3 && item.fieldKey === 'commitment_electr_signature'">
  116. <u-form-item
  117. v-if="item.inputType == 3 && item.fieldKey === 'commitment_electr_signature'"
  118. label="承诺书"
  119. :required="true"
  120. :label-width="auto"
  121. label-position="top"
  122. >
  123. <view style="line-height: 40rpx;text-indent:2em">
  124. <text>
  125. 本人自愿做出如下承诺:本人己仔细阅读《广东省住房和城乡建设厅关于推进住房和城乡建设领域施工现场专业人员职业培训工作的通知》
  126. 全部内容并知晓和理解,本人的学历证书、身份证、工作年限、相片等所有资料完全真实、符合报名条件、资格审查要求和相关规定,本人在报名、审查、培训、测试等有关的事项中会严格道守相关规定和要求,如有虛假或与实际规定不符等情况造成的一切后果由本人承担。
  127. </text>
  128. <view style="line-height: 40rpx;text-indent:2em"><text>特此承诺!</text></view>
  129. </view>
  130. </u-form-item>
  131. <u-form-item
  132. v-if="item.inputType == 3 && item.fieldKey === 'commitment_electr_signature'"
  133. label="签名板"
  134. :required="true"
  135. :label-width="auto"
  136. label-position="top"
  137. :prop="item.required ? item.fieldKey : ''"
  138. >
  139. <view class="dis_stys">
  140. <text style="color: #999999;">请在下方签名区进行签名</text>
  141. <text @click="retDraw" mode="">清空</text>
  142. </view>
  143. <view class="handCenter">
  144. <canvas
  145. class="handWriting"
  146. disable-scroll="true"
  147. @touchstart="uploadScaleStart"
  148. @touchmove="uploadScaleMove"
  149. @touchend="uploadScaleEnd"
  150. @tap="mouseDown"
  151. canvas-id="handWriting"
  152. ></canvas>
  153. </view>
  154. </u-form-item>
  155. </view>
  156. </template>
  157. </u-form>
  158. </view>
  159. <view @click="submits" class="submit_btn">{{ nextStatus ? '下一步' : '提交资料' }}</view>
  160. </view>
  161. </template>
  162. <script>
  163. import { mapGetters } from 'vuex';
  164. import Handwriting from '@/common/signature.js';
  165. export default {
  166. data() {
  167. return {
  168. form: {
  169. name: '',
  170. sex: '',
  171. idcard: '',
  172. telphone: '',
  173. education: '',
  174. school: '',
  175. graduation_time: '',
  176. work_unit: '',
  177. unit_contact: '',
  178. unit_tel: '',
  179. apply_post: '',
  180. major: '',
  181. working_years: '',
  182. recent_photos: '',
  183. idcard_face_photo: '',
  184. idcard_national_photo: '',
  185. commitment_electr_signature: ''
  186. },
  187. array_sex: ['男', '女'],
  188. pageInfo: {},
  189. lineColor: 'black',
  190. slideValue: 50,
  191. handwriting: '',
  192. goodsId: null,
  193. listData: {}, //页面数据
  194. fileList1: [], //个人近照
  195. fileList2: [], //人像
  196. fileList3: [], //国徽
  197. openVerify: false, // 控制是否手动验证
  198. nextStatus: false, //是否有下一步
  199. rules: {
  200. name: [
  201. {
  202. required: true,
  203. message: '请输入姓名',
  204. trigger: ['change', 'blur']
  205. }
  206. ],
  207. sex: [
  208. {
  209. required: true,
  210. message: '请选择性别',
  211. trigger: 'change'
  212. }
  213. ],
  214. idcard: [
  215. {
  216. required: true,
  217. message: '请输入身份证号',
  218. trigger: ['change', 'blur']
  219. },
  220. {
  221. validator: (rule, value, callback) => {
  222. return this.$u.test.idCard(value);
  223. },
  224. message: '身份证号不正确',
  225. trigger: ['change', 'blur']
  226. }
  227. ],
  228. telphone: [
  229. {
  230. required: true,
  231. message: '请输入手机号码',
  232. trigger: ['change', 'blur']
  233. },
  234. {
  235. validator: (rule, value, callback) => {
  236. return this.$u.test.mobile(value);
  237. },
  238. message: '手机号码不正确',
  239. trigger: ['change', 'blur']
  240. }
  241. ],
  242. education: [
  243. {
  244. required: true,
  245. message: '请选择学历',
  246. trigger: 'change'
  247. }
  248. ],
  249. school: [
  250. {
  251. required: true,
  252. message: '请输入毕业院校',
  253. trigger: ['change', 'blur']
  254. }
  255. ],
  256. graduation_time: [
  257. {
  258. required: true,
  259. message: '请选择毕业时间',
  260. trigger: 'change'
  261. }
  262. ],
  263. work_unit: [
  264. {
  265. required: true,
  266. message: '请输入工作单位',
  267. trigger: ['change', 'blur']
  268. }
  269. ],
  270. unit_contact: [
  271. {
  272. required: true,
  273. message: '请输入单位联系人',
  274. trigger: ['change', 'blur']
  275. }
  276. ],
  277. unit_tel: [
  278. {
  279. required: true,
  280. message: '请输入单位联系电话',
  281. trigger: ['change', 'blur']
  282. },
  283. {
  284. validator: (rule, value, callback) => {
  285. return this.$u.test.mobile(value);
  286. },
  287. message: '单位联系电话不正确',
  288. trigger: ['change', 'blur']
  289. }
  290. ],
  291. apply_post: [
  292. {
  293. required: true,
  294. message: '请输入报名岗位',
  295. trigger: ['change', 'blur']
  296. }
  297. ],
  298. major: [
  299. {
  300. required: true,
  301. message: '请输入所学专业',
  302. trigger: ['change', 'blur']
  303. }
  304. ],
  305. working_years: [
  306. {
  307. required: true,
  308. message: '请选择工作年限',
  309. trigger: 'change'
  310. }
  311. ],
  312. recent_photos: [
  313. {
  314. required: true,
  315. message: '请上传个人近照',
  316. trigger: ['change', 'blur']
  317. }
  318. ],
  319. idcard_face_photo: [
  320. {
  321. required: true,
  322. message: '请上传身份证正面照',
  323. trigger: ['change', 'blur']
  324. }
  325. ],
  326. idcard_national_photo: [
  327. {
  328. required: true,
  329. message: '请上传身份证国徽照',
  330. trigger: ['change', 'blur']
  331. }
  332. ],
  333. commitment_electr_signature: [
  334. {
  335. required: true,
  336. message: '请签写承诺书电子签',
  337. trigger: ['change', 'blur']
  338. }
  339. ]
  340. }
  341. };
  342. },
  343. created() {},
  344. onLoad(option) {
  345. this.goodsId = Number(option.id);
  346. this.getInfo();
  347. },
  348. onReady(res) {
  349. this.handwriting = new Handwriting({
  350. lineColor: this.lineColor,
  351. slideValue: this.slideValue, // 0, 25, 50, 75, 100
  352. canvasName: 'handWriting'
  353. });
  354. this.$refs.uForm.setRules(this.rules);
  355. },
  356. computed: { ...mapGetters(['dictObj']) },
  357. methods: {
  358. //提交表单
  359. async submitApi() {
  360. var data = JSON.parse(JSON.stringify(this.form));
  361. if (data['sex']) {
  362. data.sex = this.dictObj['sys_user_sex'][Number(data.sex)];
  363. }
  364. if (data['education']) {
  365. data.education = this.dictObj['edu_level'][Number(data.education)];
  366. }
  367. if (data['working_years']) {
  368. data.working_years = this.dictObj['working_years'][Number(data.working_years)];
  369. }
  370. if (data['recent_photos']) {
  371. data.recent_photos = await this.$method.uploadFile(data.recent_photos, 0);
  372. }
  373. if (data['idcard_face_photo']) {
  374. data.idcard_face_photo = await this.$method.uploadFile(data.idcard_face_photo, 0);
  375. }
  376. if (data['idcard_national_photo']) {
  377. data.idcard_national_photo = await this.$method.uploadFile(data.idcard_national_photo, 0);
  378. }
  379. if (data['commitment_electr_signature']) {
  380. data.commitment_electr_signature = await this.$method.uploadFile(data.commitment_electr_signature, 0);
  381. }
  382. if (this.nextStatus) {
  383. this.$store.commit('updataCopyData', data);
  384. this.$navTo.togo('/pages2/verify/input2', {
  385. id: this.goodsId
  386. });
  387. } else {
  388. console.log(data);
  389. }
  390. },
  391. //验证表单
  392. resultForm(int) {
  393. if (this.openVerify) {
  394. this.$refs.uForm.validate(valid => {
  395. if (valid) {
  396. if (int === 1) {
  397. this.submitApi();
  398. }
  399. } else {
  400. console.log('验证失败');
  401. }
  402. });
  403. }
  404. },
  405. async submits() {
  406. await this.subCanvas();
  407. this.openVerify = true;
  408. this.resultForm(1);
  409. },
  410. async changePhotoListHeader1(lists, name) {
  411. if (lists.length) {
  412. this.fileList1 = lists;
  413. this.form.recent_photos = await this.$method.imageInfos(lists[0].url);
  414. } else {
  415. this.fileList1 = [];
  416. this.$set(this.form, 'recent_photos', '');
  417. }
  418. this.$nextTick(function() {
  419. this.resultForm();
  420. });
  421. },
  422. async changePhotoListHeader2(lists, name) {
  423. if (lists.length) {
  424. this.fileList2 = lists;
  425. this.form.idcard_face_photo = await this.$method.imageInfos(lists[0].url);
  426. } else {
  427. this.fileList2 = [];
  428. this.$set(this.form, 'idcard_face_photo', '');
  429. }
  430. this.$nextTick(function() {
  431. this.resultForm();
  432. });
  433. },
  434. async changePhotoListHeader3(lists, name) {
  435. if (lists.length) {
  436. this.fileList3 = lists;
  437. this.form.idcard_national_photo = await this.$method.imageInfos(lists[0].url);
  438. } else {
  439. this.fileList3 = [];
  440. this.$set(this.form, 'idcard_national_photo', '');
  441. }
  442. this.$nextTick(function() {
  443. this.resultForm();
  444. });
  445. },
  446. getTimes(key) {
  447. if (this.form[key]) {
  448. return this.form[key];
  449. } else {
  450. return '请选择时间';
  451. }
  452. },
  453. getarrays(key) {
  454. if (key === 'sex') {
  455. return this.dictObj['sys_user_sex'];
  456. }
  457. if (key === 'education') {
  458. return this.dictObj['edu_level'];
  459. }
  460. if (key === 'working_years') {
  461. return this.dictObj['working_years'];
  462. }
  463. },
  464. returnName(key) {
  465. if (key === 'sex') {
  466. if (this.form[key]) {
  467. return this.dictObj['sys_user_sex'][Number(this.form[key])];
  468. } else {
  469. return '请选择性别';
  470. }
  471. }
  472. if (key === 'education') {
  473. if (this.form[key]) {
  474. return this.dictObj['edu_level'][Number(this.form[key])];
  475. } else {
  476. return '请选择学历';
  477. }
  478. }
  479. if (key === 'working_years') {
  480. if (this.form[key]) {
  481. return this.dictObj['working_years'][Number(this.form[key])];
  482. } else {
  483. return '请选择工作年限';
  484. }
  485. }
  486. },
  487. getInfo() {
  488. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  489. var ast = JSON.parse(res.data.data.keyValue);
  490. const key2 = JSON.parse(res.data.data.keyValue2);
  491. if (key2.length) {
  492. this.nextStatus = true;
  493. }
  494. ast.forEach(item => {
  495. if (item.fieldKey === 'school' || item.fieldKey === 'major') {
  496. item.inputType = 1;
  497. }
  498. });
  499. this.listData = ast;
  500. });
  501. },
  502. bindPickerChange(key, e) {
  503. this.$set(this.form, key, e.detail.value);
  504. this.$nextTick(function() {
  505. this.resultForm();
  506. });
  507. },
  508. bindDateChange(key, e) {
  509. this.form[key] = e.detail.value;
  510. },
  511. retDraw() {
  512. this.handwriting.retDraw();
  513. this.$set(this.form, 'commitment_electr_signature', '');
  514. this.$nextTick(function() {
  515. this.resultForm();
  516. });
  517. },
  518. uploadScaleStart(event) {
  519. this.handwriting.uploadScaleStart(event);
  520. },
  521. uploadScaleMove(event) {
  522. this.handwriting.uploadScaleMove(event);
  523. },
  524. uploadScaleEnd(event) {
  525. this.handwriting.uploadScaleEnd(event);
  526. },
  527. subCanvas() {
  528. return new Promise((resolve, reject) => {
  529. var self = this;
  530. self.handwriting
  531. .saveCanvas()
  532. .then(res => {
  533. if (this.handwriting.linePrack.length) {
  534. this.$set(this.form, 'commitment_electr_signature', res);
  535. }
  536. resolve(res);
  537. })
  538. .catch(err => {
  539. uni.showToast({
  540. title: '签名上传失败',
  541. icon: 'error'
  542. });
  543. });
  544. });
  545. }
  546. }
  547. };
  548. </script>
  549. <style>
  550. page {
  551. background: #eaeef1;
  552. }
  553. </style>
  554. <style scope>
  555. .dis_stys {
  556. display: flex;
  557. align-items: center;
  558. justify-content: space-between;
  559. }
  560. .handCenter {
  561. background: #f7f7f7;
  562. border: 2rpx solid #eeeeee;
  563. border-radius: 24rpx;
  564. }
  565. .headerSDels {
  566. height: 58rpx;
  567. padding: 0rpx 24rpx;
  568. font-weight: bold;
  569. display: flex;
  570. align-items: center;
  571. flex-direction: row-reverse;
  572. }
  573. .listBox {
  574. margin: 24rpx 32rpx 0rpx;
  575. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  576. border-radius: 32rpx;
  577. background-color: #fff;
  578. overflow: hidden;
  579. }
  580. .imgBoxs {
  581. width: 156rpx;
  582. height: 203rpx;
  583. }
  584. .imgBoxs2 {
  585. width: 171rpx;
  586. height: 108rpx;
  587. }
  588. .submit_btn {
  589. width: 526rpx;
  590. height: 80rpx;
  591. background: #007aff;
  592. border-radius: 40rpx;
  593. text-align: center;
  594. line-height: 80rpx;
  595. color: #ffffff;
  596. margin: 30rpx auto;
  597. }
  598. .picker {
  599. text-align: right;
  600. }
  601. input {
  602. text-align: right;
  603. }
  604. .bodyBox {
  605. background: #ffffff;
  606. border-radius: 24rpx;
  607. width: 100%;
  608. }
  609. .topBox {
  610. height: 80rpx;
  611. background: #ffffff;
  612. border-radius: 24rpx;
  613. width: 100%;
  614. display: flex;
  615. justify-content: space-between;
  616. line-height: 80rpx;
  617. padding: 0 20rpx;
  618. font-size: 24rpx;
  619. }
  620. </style>