| @@ -51,3 +51,12 @@ export function generateContractorCode(params) { | |||||
| params: params | params: params | ||||
| }); | }); | ||||
| } | } | ||||
| // 承包方调查签字 | |||||
| export function contractorSignature(data) { | |||||
| return request({ | |||||
| url: '/service/cbf/surveySign', | |||||
| method: 'post', | |||||
| data: data | |||||
| }); | |||||
| } | |||||
| @@ -26,3 +26,12 @@ export function updateFbf(data) { | |||||
| data: data | data: data | ||||
| }) | }) | ||||
| } | } | ||||
| // 发包方调查签字 | |||||
| export function manualSignature(data) { | |||||
| return request({ | |||||
| url: '/service/fbf/surveySign', | |||||
| method: 'post', | |||||
| data: data | |||||
| }); | |||||
| } | |||||
| @@ -3,24 +3,128 @@ | |||||
| <van-nav-bar left-arrow fixed placeholder @click-left="goBack"> | <van-nav-bar left-arrow fixed placeholder @click-left="goBack"> | ||||
| <template #title> | <template #title> | ||||
| <div class="tb_main"> | <div class="tb_main"> | ||||
| {{ contractorName }}<p><span class="tb">签字完成</span><span class="tb">异常挂起</span></p> | |||||
| {{ contractorName }}<p><span class="tb" @click="handleSign">签字完成</span><span class="tb">异常挂起</span></p> | |||||
| </div> | </div> | ||||
| </template> | </template> | ||||
| </van-nav-bar> | </van-nav-bar> | ||||
| <van-popup v-model="showSignPopup" closeable position="right" :style="{ height: '100%' }" > | |||||
| <van-cell-group style="width: 100%;height:100%;overflow: hidden;padding-top: 10px;padding-bottom: 10px;"> | |||||
| <div class="signature-box" @mousedown="canvasTTdown" @touchstart="canvasTTdown"> | |||||
| <vue-esign | |||||
| ref="esign" | |||||
| class="mySign" | |||||
| :width="500" | |||||
| :height="height" | |||||
| :isCrop="signature.isCrop" | |||||
| :lineWidth="signature.lineWidth" | |||||
| :lineColor="signature.lineColor" | |||||
| :bgColor.sync="signature.bgColor" | |||||
| /> | |||||
| </div> | |||||
| <img src="../../../../assets/images/sunVillage_info/signature_icon_10.png" id="canvasTT" style="position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%)" alt=""> | |||||
| <div class="signature-footer"> | |||||
| <van-button @click="handleReset" class="clearBtn" type="info" plain size="small">清空画板</van-button> | |||||
| <van-button @click="handleGenerate" type="info" size="small">保存签字</van-button> | |||||
| </div> | |||||
| </van-cell-group> | |||||
| </van-popup> | |||||
| </div> | </div> | ||||
| </template> | </template> | ||||
| <script> | <script> | ||||
| import { getDept } from "@/api/contracted"; | import { getDept } from "@/api/contracted"; | ||||
| import { contractorSignature } from "@/api/contracted/cbf"; | |||||
| import vueEsign from "vue-esign"; | |||||
| import $ from "jquery"; | |||||
| export default { | export default { | ||||
| name: 'contractedVillageHeader', | name: 'contractedVillageHeader', | ||||
| props: ['deptId', 'contractorCode', 'contractorName', 'surveyStatus'], | props: ['deptId', 'contractorCode', 'contractorName', 'surveyStatus'], | ||||
| components: { | |||||
| vueEsign | |||||
| }, | |||||
| data() { | |||||
| return { | |||||
| // 控制签字面板的显示和隐藏 | |||||
| showSignPopup: false, | |||||
| height: null, | |||||
| //电子签名 | |||||
| signature: { | |||||
| lineWidth: 6, // 画笔的线条粗细 | |||||
| lineColor: "#000000", // 画笔的颜色 | |||||
| bgColor: "", // 画布的背景颜色 | |||||
| resultImg: "", // 最终画布生成的base64图片 | |||||
| isCrop: false, // 是否裁剪,在画布设定尺寸基础上裁掉四周空白部分 | |||||
| }, | |||||
| }; | |||||
| }, | |||||
| created() { | |||||
| this.height = window.screen.height * 1.28 - 20; | |||||
| }, | |||||
| methods: { | methods: { | ||||
| goBack() { | goBack() { | ||||
| getDept(this.deptId).then(response => { | getDept(this.deptId).then(response => { | ||||
| this.$router.push({path:'/contracted/village/contractor', query: { deptId: this.deptId, deptName: response.data.deptName }}); | this.$router.push({path:'/contracted/village/contractor', query: { deptId: this.deptId, deptName: response.data.deptName }}); | ||||
| }); | }); | ||||
| } | |||||
| }, | |||||
| handleSign() { | |||||
| this.showSignPopup = true; | |||||
| this.handleReset(); | |||||
| }, | |||||
| canvasTTdown() { | |||||
| $('#canvasTT').css('display', 'none'); | |||||
| }, | |||||
| // 清空画板 | |||||
| handleReset() { | |||||
| if (this.$refs.esign) { | |||||
| this.$refs.esign.reset(); | |||||
| } | |||||
| $('#canvasTT').css('display', 'block') | |||||
| }, | |||||
| // 生成签字图片 | |||||
| handleGenerate() { | |||||
| this.$refs.esign | |||||
| .generate() // 使用生成器调用把签字的图片转换成为base64图片格式 | |||||
| .then((res) => { | |||||
| this.signature.resultImg = res; | |||||
| let wj = this.dataURLtoBlob(res); | |||||
| let param = new FormData() // 创建form对象 | |||||
| param.append('file', wj) // 通过append向form对象添加数据 | |||||
| param.append('cbfbm', this.contractorCode); | |||||
| contractorSignature(param).then(response => { | |||||
| if (response.code === 200) { | |||||
| this.$toast({ | |||||
| icon: 'success', // 找到自己需要的图标 | |||||
| message: '签字成功', | |||||
| duration: "1000", | |||||
| onClose: () => { | |||||
| this.showSignPopup = false; | |||||
| this.goBack(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| }); | |||||
| }) | |||||
| .catch((err) => { | |||||
| // 画布没有签字时会执行这里提示一下 | |||||
| this.$toast.fail('请签名后再保存签字'); | |||||
| }); | |||||
| }, | |||||
| dataURLtoBlob(dataurl, filename = 'file') { | |||||
| let arr = dataurl.split(',') | |||||
| let mime = arr[0].match(/:(.*?);/)[1] | |||||
| let suffix = mime.split('/')[1] | |||||
| let bstr = atob(arr[1]) | |||||
| let n = bstr.length | |||||
| let u8arr = new Uint8Array(n) | |||||
| while (n--) { | |||||
| u8arr[n] = bstr.charCodeAt(n) | |||||
| } | |||||
| return new File([u8arr], `${filename}.${suffix}`, { | |||||
| type: mime | |||||
| }) | |||||
| }, | |||||
| } | } | ||||
| } | } | ||||
| </script> | </script> | ||||
| @@ -43,4 +147,25 @@ | |||||
| border-radius: 50PX; | border-radius: 50PX; | ||||
| margin-right: 5PX; | margin-right: 5PX; | ||||
| } | } | ||||
| .signature-box { | |||||
| border: 1px dashed #666; | |||||
| margin: 2px 20px; | |||||
| height: 100%; | |||||
| /*canvas{*/ | |||||
| /* height: 100%!important;*/ | |||||
| /*}*/ | |||||
| } | |||||
| .signature-footer { | |||||
| transform: rotate(90deg); | |||||
| width: auto; | |||||
| position: absolute; | |||||
| top: 50%; | |||||
| left: 0PX; | |||||
| .clearBtn { | |||||
| margin-left: 15px; | |||||
| } | |||||
| } | |||||
| </style> | </style> | ||||
| @@ -52,19 +52,45 @@ | |||||
| </van-form> | </van-form> | ||||
| <div class="btn_main"> | <div class="btn_main"> | ||||
| <p class="btn" @click="submitForm">保存</p> | <p class="btn" @click="submitForm">保存</p> | ||||
| <p class="btn1">签字</p> | |||||
| <p class="btn1" @click="handleSign">签字</p> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <van-popup v-model="showSignPopup" closeable position="right" :style="{ height: '100%' }" > | |||||
| <van-cell-group style="width: 100%;height:100%;overflow: hidden;padding-top: 10px;padding-bottom: 10px;"> | |||||
| <div class="signature-box" @mousedown="canvasTTdown" @touchstart="canvasTTdown"> | |||||
| <vue-esign | |||||
| ref="esign" | |||||
| class="mySign" | |||||
| :width="500" | |||||
| :height="height" | |||||
| :isCrop="signature.isCrop" | |||||
| :lineWidth="signature.lineWidth" | |||||
| :lineColor="signature.lineColor" | |||||
| :bgColor.sync="signature.bgColor" | |||||
| /> | |||||
| </div> | |||||
| <img src="../../../../assets/images/sunVillage_info/signature_icon_10.png" id="canvasTT" style="position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%)" alt=""> | |||||
| <div class="signature-footer"> | |||||
| <van-button @click="handleReset" class="clearBtn" type="info" plain size="small">清空画板</van-button> | |||||
| <van-button @click="handleGenerate" type="info" size="small">保存签字</van-button> | |||||
| </div> | |||||
| </van-cell-group> | |||||
| </van-popup> | |||||
| </div> | </div> | ||||
| </template> | </template> | ||||
| <script> | <script> | ||||
| import Cookies from "js-cookie"; | import Cookies from "js-cookie"; | ||||
| import { listFbf, addFbf, updateFbf } from "@/api/contracted/fbf"; | |||||
| import { listFbf, addFbf, updateFbf, manualSignature } from "@/api/contracted/fbf"; | |||||
| import vueEsign from "vue-esign"; | |||||
| import $ from "jquery"; | |||||
| export default { | export default { | ||||
| name: "contractedVillageContractor", | name: "contractedVillageContractor", | ||||
| components: { | |||||
| vueEsign | |||||
| }, | |||||
| data() { | data() { | ||||
| return { | return { | ||||
| form: {}, // 发包方信息表单 | form: {}, // 发包方信息表单 | ||||
| @@ -72,9 +98,22 @@ | |||||
| credentialTypeOptions: [], // 证件类型字典 | credentialTypeOptions: [], // 证件类型字典 | ||||
| credentialTypeText: null, // 证件类型标签名 | credentialTypeText: null, // 证件类型标签名 | ||||
| showCredentialType: false, // 控制证件类型字典弹出层的显示和隐藏 | showCredentialType: false, // 控制证件类型字典弹出层的显示和隐藏 | ||||
| // 控制签字面板的显示和隐藏 | |||||
| showSignPopup: false, | |||||
| height: null, | |||||
| //电子签名 | |||||
| signature: { | |||||
| lineWidth: 6, // 画笔的线条粗细 | |||||
| lineColor: "#000000", // 画笔的颜色 | |||||
| bgColor: "", // 画布的背景颜色 | |||||
| resultImg: "", // 最终画布生成的base64图片 | |||||
| isCrop: false, // 是否裁剪,在画布设定尺寸基础上裁掉四周空白部分 | |||||
| }, | |||||
| }; | }; | ||||
| }, | }, | ||||
| created() { | created() { | ||||
| this.height = window.screen.height * 1.28 - 20; | |||||
| this.getDicts("cert_type").then(response => { | this.getDicts("cert_type").then(response => { | ||||
| this.credentialTypeOptions = response.data; | this.credentialTypeOptions = response.data; | ||||
| }); | }); | ||||
| @@ -145,7 +184,64 @@ | |||||
| fbfdcjs: null, | fbfdcjs: null, | ||||
| fbfdcqz: null | fbfdcqz: null | ||||
| } | } | ||||
| } | |||||
| }, | |||||
| handleSign() { | |||||
| this.showSignPopup = true; | |||||
| this.handleReset(); | |||||
| }, | |||||
| canvasTTdown() { | |||||
| $('#canvasTT').css('display', 'none'); | |||||
| }, | |||||
| // 清空画板 | |||||
| handleReset() { | |||||
| if (this.$refs.esign) { | |||||
| this.$refs.esign.reset(); | |||||
| } | |||||
| $('#canvasTT').css('display', 'block') | |||||
| }, | |||||
| // 生成签字图片 | |||||
| handleGenerate() { | |||||
| this.$refs.esign | |||||
| .generate() // 使用生成器调用把签字的图片转换成为base64图片格式 | |||||
| .then((res) => { | |||||
| this.signature.resultImg = res; | |||||
| let wj = this.dataURLtoBlob(res); | |||||
| let param = new FormData(); // 创建form对象 | |||||
| param.append('file', wj); // 通过append向form对象添加数据 | |||||
| param.append('deptId', this.$route.query.deptId); | |||||
| manualSignature(param).then(response => { | |||||
| if (response.code === 200) { | |||||
| this.$toast({ | |||||
| icon: 'success', // 找到自己需要的图标 | |||||
| message: '签字成功', | |||||
| duration: "1000", | |||||
| onClose: () => { | |||||
| this.showSignPopup = false; | |||||
| this.form.fbfdcqz = response.data; | |||||
| } | |||||
| }); | |||||
| } | |||||
| }); | |||||
| }) | |||||
| .catch((err) => { | |||||
| // 画布没有签字时会执行这里提示一下 | |||||
| this.$toast.fail('请签名后再保存签字'); | |||||
| }); | |||||
| }, | |||||
| dataURLtoBlob(dataurl, filename = 'file') { | |||||
| let arr = dataurl.split(',') | |||||
| let mime = arr[0].match(/:(.*?);/)[1] | |||||
| let suffix = mime.split('/')[1] | |||||
| let bstr = atob(arr[1]) | |||||
| let n = bstr.length | |||||
| let u8arr = new Uint8Array(n) | |||||
| while (n--) { | |||||
| u8arr[n] = bstr.charCodeAt(n) | |||||
| } | |||||
| return new File([u8arr], `${filename}.${suffix}`, { | |||||
| type: mime | |||||
| }) | |||||
| }, | |||||
| }, | }, | ||||
| }; | }; | ||||
| </script> | </script> | ||||
| @@ -308,4 +404,25 @@ | |||||
| margin: 2vh auto; | margin: 2vh auto; | ||||
| } | } | ||||
| .signature-box { | |||||
| border: 1px dashed #666; | |||||
| margin: 2px 20px; | |||||
| height: 100%; | |||||
| /*canvas{*/ | |||||
| /* height: 100%!important;*/ | |||||
| /*}*/ | |||||
| } | |||||
| .signature-footer { | |||||
| transform: rotate(90deg); | |||||
| width: auto; | |||||
| position: absolute; | |||||
| top: 50%; | |||||
| left: 0PX; | |||||
| .clearBtn { | |||||
| margin-left: 15px; | |||||
| } | |||||
| } | |||||
| </style> | </style> | ||||