input.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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">提交资料</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. onLoad(option) {
  344. this.goodsId = Number(option.id);
  345. this.getInfo();
  346. },
  347. onReady(res) {
  348. this.handwriting = new Handwriting({
  349. lineColor: this.lineColor,
  350. slideValue: this.slideValue, // 0, 25, 50, 75, 100
  351. canvasName: 'handWriting'
  352. });
  353. this.$refs.uForm.setRules(this.rules);
  354. },
  355. computed: { ...mapGetters(['dictObj']) },
  356. methods: {
  357. uploadDatas(data) {
  358. var self= this
  359. var objs = {};
  360. for (let k in data) {
  361. objs[k] = {
  362. fieldKey: k,
  363. value: data[k],
  364. fieldName:function(){
  365. for(let i = 0; i < self.listData.length;i++){
  366. if(self.listData[i].fieldKey == k){
  367. return self.listData[i].fieldName
  368. }
  369. }
  370. }(),
  371. status: 0
  372. };
  373. }
  374. var datas = {
  375. goodsId:this.goodsId,
  376. keyValue:JSON.stringify(objs)
  377. }
  378. this.$api.addbaseprofiletp(datas).then(res => {
  379. if(res.data.code === 200){
  380. this.$method.showToast("提交成功")
  381. }
  382. })
  383. },
  384. //提交表单
  385. async submitApi() {
  386. var data = JSON.parse(JSON.stringify(this.form));
  387. if (data['sex']) {
  388. data.sex = this.dictObj['sys_user_sex'][Number(data.sex)];
  389. }
  390. if (data['education']) {
  391. data.education = this.dictObj['edu_level'][Number(data.education)];
  392. }
  393. if (data['working_years']) {
  394. data.working_years = this.dictObj['working_years'][Number(data.working_years)];
  395. }
  396. if (data['recent_photos']) {
  397. data.recent_photos = await this.$method.uploadFile(data.recent_photos, 0);
  398. }
  399. if (data['idcard_face_photo']) {
  400. data.idcard_face_photo = await this.$method.uploadFile(data.idcard_face_photo, 0);
  401. }
  402. if (data['idcard_national_photo']) {
  403. data.idcard_national_photo = await this.$method.uploadFile(data.idcard_national_photo, 0);
  404. }
  405. if (data['commitment_electr_signature']) {
  406. data.commitment_electr_signature = await this.$method.uploadFile(data.commitment_electr_signature, 0);
  407. }
  408. // if (this.nextStatus) {
  409. // this.$store.commit('updataCopyData', data);
  410. // this.$navTo.togo('/pages2/verify/input2', {
  411. // id: this.goodsId
  412. // });
  413. // } else {
  414. this.uploadDatas(data)
  415. console.log(data);
  416. // }
  417. },
  418. //验证表单
  419. resultForm(int) {
  420. if (this.openVerify) {
  421. this.$refs.uForm.validate(valid => {
  422. if (valid) {
  423. if (int === 1) {
  424. this.submitApi();
  425. }
  426. } else {
  427. console.log('验证失败');
  428. }
  429. });
  430. }
  431. },
  432. async submits() {
  433. await this.subCanvas();
  434. this.openVerify = true;
  435. this.resultForm(1);
  436. },
  437. async changePhotoListHeader1(lists, name) {
  438. if (lists.length) {
  439. this.fileList1 = lists;
  440. this.form.recent_photos = await this.$method.imageInfos(lists[0].url);
  441. } else {
  442. this.fileList1 = [];
  443. this.$set(this.form, 'recent_photos', '');
  444. }
  445. this.$nextTick(function() {
  446. this.resultForm();
  447. });
  448. },
  449. async changePhotoListHeader2(lists, name) {
  450. if (lists.length) {
  451. this.fileList2 = lists;
  452. this.form.idcard_face_photo = await this.$method.imageInfos(lists[0].url);
  453. } else {
  454. this.fileList2 = [];
  455. this.$set(this.form, 'idcard_face_photo', '');
  456. }
  457. this.$nextTick(function() {
  458. this.resultForm();
  459. });
  460. },
  461. async changePhotoListHeader3(lists, name) {
  462. if (lists.length) {
  463. this.fileList3 = lists;
  464. this.form.idcard_national_photo = await this.$method.imageInfos(lists[0].url);
  465. } else {
  466. this.fileList3 = [];
  467. this.$set(this.form, 'idcard_national_photo', '');
  468. }
  469. this.$nextTick(function() {
  470. this.resultForm();
  471. });
  472. },
  473. getTimes(key) {
  474. if (this.form[key]) {
  475. return this.form[key];
  476. } else {
  477. return '请选择时间';
  478. }
  479. },
  480. getarrays(key) {
  481. if (key === 'sex') {
  482. return this.dictObj['sys_user_sex'];
  483. }
  484. if (key === 'education') {
  485. return this.dictObj['edu_level'];
  486. }
  487. if (key === 'working_years') {
  488. return this.dictObj['working_years'];
  489. }
  490. },
  491. returnName(key) {
  492. if (key === 'sex') {
  493. if (this.form[key]) {
  494. return this.dictObj['sys_user_sex'][Number(this.form[key])];
  495. } else {
  496. return '请选择性别';
  497. }
  498. }
  499. if (key === 'education') {
  500. if (this.form[key]) {
  501. return this.dictObj['edu_level'][Number(this.form[key])];
  502. } else {
  503. return '请选择学历';
  504. }
  505. }
  506. if (key === 'working_years') {
  507. if (this.form[key]) {
  508. return this.dictObj['working_years'][Number(this.form[key])];
  509. } else {
  510. return '请选择工作年限';
  511. }
  512. }
  513. },
  514. getInfo() {
  515. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  516. var ast = JSON.parse(res.data.data.keyValue);
  517. // const key2 = JSON.parse(res.data.data.keyValue2);
  518. // if (key2.length) {
  519. // this.nextStatus = true;
  520. // }
  521. ast.forEach(item => {
  522. if (item.fieldKey === 'school' || item.fieldKey === 'major') {
  523. item.inputType = 1;
  524. }
  525. });
  526. this.listData = ast;
  527. });
  528. },
  529. bindPickerChange(key, e) {
  530. this.$set(this.form, key, e.detail.value);
  531. this.$nextTick(function() {
  532. this.resultForm();
  533. });
  534. },
  535. bindDateChange(key, e) {
  536. this.form[key] = e.detail.value;
  537. },
  538. retDraw() {
  539. this.handwriting.retDraw();
  540. this.$set(this.form, 'commitment_electr_signature', '');
  541. this.$nextTick(function() {
  542. this.resultForm();
  543. });
  544. },
  545. uploadScaleStart(event) {
  546. this.handwriting.uploadScaleStart(event);
  547. },
  548. uploadScaleMove(event) {
  549. this.handwriting.uploadScaleMove(event);
  550. },
  551. uploadScaleEnd(event) {
  552. this.handwriting.uploadScaleEnd(event);
  553. },
  554. subCanvas() {
  555. return new Promise((resolve, reject) => {
  556. var self = this;
  557. self.handwriting
  558. .saveCanvas()
  559. .then(res => {
  560. if (this.handwriting.linePrack.length) {
  561. this.$set(this.form, 'commitment_electr_signature', res);
  562. }
  563. resolve(res);
  564. })
  565. .catch(err => {
  566. uni.showToast({
  567. title: '签名上传失败',
  568. icon: 'error'
  569. });
  570. });
  571. });
  572. }
  573. }
  574. };
  575. </script>
  576. <style>
  577. page {
  578. background: #eaeef1;
  579. }
  580. </style>
  581. <style scope>
  582. .dis_stys {
  583. display: flex;
  584. align-items: center;
  585. justify-content: space-between;
  586. }
  587. .handCenter {
  588. background: #f7f7f7;
  589. border: 2rpx solid #eeeeee;
  590. border-radius: 24rpx;
  591. }
  592. .headerSDels {
  593. height: 58rpx;
  594. padding: 0rpx 24rpx;
  595. font-weight: bold;
  596. display: flex;
  597. align-items: center;
  598. flex-direction: row-reverse;
  599. }
  600. .listBox {
  601. margin: 24rpx 32rpx 0rpx;
  602. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  603. border-radius: 32rpx;
  604. background-color: #fff;
  605. overflow: hidden;
  606. }
  607. .imgBoxs {
  608. width: 156rpx;
  609. height: 203rpx;
  610. }
  611. .imgBoxs2 {
  612. width: 171rpx;
  613. height: 108rpx;
  614. }
  615. .submit_btn {
  616. width: 526rpx;
  617. height: 80rpx;
  618. background: #007aff;
  619. border-radius: 40rpx;
  620. text-align: center;
  621. line-height: 80rpx;
  622. color: #ffffff;
  623. margin: 30rpx auto;
  624. }
  625. .picker {
  626. text-align: right;
  627. }
  628. input {
  629. text-align: right;
  630. }
  631. .bodyBox {
  632. background: #ffffff;
  633. border-radius: 24rpx;
  634. width: 100%;
  635. }
  636. .topBox {
  637. height: 80rpx;
  638. background: #ffffff;
  639. border-radius: 24rpx;
  640. width: 100%;
  641. display: flex;
  642. justify-content: space-between;
  643. line-height: 80rpx;
  644. padding: 0 20rpx;
  645. font-size: 24rpx;
  646. }
  647. </style>