移动端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

240 рядки
7.4 KiB

  1. <template>
  2. <div>
  3. <van-nav-bar left-arrow fixed placeholder @click-left="goBack">
  4. <template #title>
  5. <div class="tb_main">
  6. {{ contractorName }}<p v-if="showBtn"><span class="tb" @click="handleSign">签字完成</span><span class="tb" @click="handleHangUp">异常挂起</span></p>
  7. </div>
  8. </template>
  9. </van-nav-bar>
  10. <van-popup v-model="showSignPopup" closeable position="right" :style="{ height: '100%' }" >
  11. <van-cell-group style="width: 100%;height:100%;overflow: hidden;padding-top: 10px;padding-bottom: 10px;">
  12. <div class="signature-box" @mousedown="canvasTTdown" @touchstart="canvasTTdown">
  13. <vue-esign
  14. ref="esign"
  15. class="mySign"
  16. :width="500"
  17. :height="height"
  18. :isCrop="signature.isCrop"
  19. :lineWidth="signature.lineWidth"
  20. :lineColor="signature.lineColor"
  21. :bgColor.sync="signature.bgColor"
  22. />
  23. </div>
  24. <img src="../../../../assets/images/sunVillage_info/signature_icon_10.png" id="canvasTT" style="position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%)" alt="">
  25. <div class="signature-footer">
  26. <van-button @click="handleReset" class="clearBtn" type="info" plain size="small">清空画板</van-button>
  27. <van-button @click="handleGenerate" type="info" size="small">保存签字</van-button>
  28. </div>
  29. </van-cell-group>
  30. </van-popup>
  31. <van-dialog v-model="showRemark" title="异常挂起原因" show-cancel-button confirmButtonText="保存" cancelButtonText="关闭"
  32. :before-close="onBeforeClose" @confirm="handleConfirm">
  33. <van-form ref="remarkForm" class="remarkForm">
  34. <van-field v-model="remark" label="挂起原因:" type="textarea" rows="4" placeholder="请输入挂起原因" required
  35. :rules="[{ required: true }]" input-align="left" label-width="auto" />
  36. </van-form>
  37. </van-dialog>
  38. </div>
  39. </template>
  40. <script>
  41. import { getDept } from "@/api/contracted";
  42. import { contractorSignature, hangUp } from "@/api/contracted/cbf";
  43. import vueEsign from "vue-esign";
  44. import $ from "jquery";
  45. import Cookies from "js-cookie";
  46. export default {
  47. name: 'contractedVillageHeader',
  48. props: ['deptId', 'contractorCode', 'contractorName', 'surveyStatus', 'taskStatus'],
  49. components: {
  50. vueEsign
  51. },
  52. data() {
  53. return {
  54. // 控制签字面板的显示和隐藏
  55. showSignPopup: false,
  56. height: null,
  57. //电子签名
  58. signature: {
  59. lineWidth: 6, // 画笔的线条粗细
  60. lineColor: "#000000", // 画笔的颜色
  61. bgColor: "", // 画布的背景颜色
  62. resultImg: "", // 最终画布生成的base64图片
  63. isCrop: false, // 是否裁剪,在画布设定尺寸基础上裁掉四周空白部分
  64. },
  65. // 控制异常信息备注提示框的显示和隐藏
  66. showRemark: false,
  67. // 异常备注信息
  68. remark: null,
  69. // 控制签字按钮和挂起按钮的显示和隐藏
  70. showBtn: true,
  71. };
  72. },
  73. created() {
  74. this.height = window.screen.height * 1.28 - 20;
  75. if (this.taskStatus === '2' && this.surveyStatus !== '3') {
  76. this.showBtn = true;
  77. } else {
  78. this.showBtn = false;
  79. }
  80. },
  81. methods: {
  82. goBack() {
  83. getDept(this.deptId).then(response => {
  84. this.$router.push({path:'/contracted/village/contractor', query: { deptId: this.deptId, deptName: response.data.deptName }});
  85. Cookies.remove('householdStatus');
  86. Cookies.remove('householdStatusText');
  87. });
  88. },
  89. handleSign() {
  90. this.showSignPopup = true;
  91. this.handleReset();
  92. },
  93. canvasTTdown() {
  94. $('#canvasTT').css('display', 'none');
  95. },
  96. // 清空画板
  97. handleReset() {
  98. if (this.$refs.esign) {
  99. this.$refs.esign.reset();
  100. }
  101. $('#canvasTT').css('display', 'block')
  102. },
  103. // 生成签字图片
  104. handleGenerate() {
  105. this.$refs.esign
  106. .generate() // 使用生成器调用把签字的图片转换成为base64图片格式
  107. .then((res) => {
  108. this.signature.resultImg = res;
  109. let wj = this.dataURLtoBlob(res);
  110. let param = new FormData() // 创建form对象
  111. param.append('file', wj) // 通过append向form对象添加数据
  112. param.append('cbfbm', this.contractorCode);
  113. contractorSignature(param).then(response => {
  114. if (response.code === 200) {
  115. this.$toast({
  116. icon: 'success', // 找到自己需要的图标
  117. message: '签字成功',
  118. duration: "1000",
  119. onClose: () => {
  120. this.showSignPopup = false;
  121. this.goBack();
  122. }
  123. });
  124. }
  125. });
  126. })
  127. .catch((err) => {
  128. // 画布没有签字时会执行这里提示一下
  129. this.$toast.fail('请签名后再保存签字');
  130. });
  131. },
  132. dataURLtoBlob(dataurl, filename = 'file') {
  133. let arr = dataurl.split(',')
  134. let mime = arr[0].match(/:(.*?);/)[1]
  135. let suffix = mime.split('/')[1]
  136. let bstr = atob(arr[1])
  137. let n = bstr.length
  138. let u8arr = new Uint8Array(n)
  139. while (n--) {
  140. u8arr[n] = bstr.charCodeAt(n)
  141. }
  142. return new File([u8arr], `${filename}.${suffix}`, {
  143. type: mime
  144. })
  145. },
  146. // 异常挂起
  147. handleHangUp() {
  148. this.showRemark = true;
  149. this.remark = null;
  150. },
  151. // van-dialog 点击confirm事件不自动关闭
  152. onBeforeClose(action, done) {
  153. if (action === 'confirm') {
  154. return done(false);
  155. } else {
  156. return done();
  157. }
  158. },
  159. handleConfirm() {
  160. this.$refs.remarkForm.validate().then(() => {
  161. let data = new FormData() // 创建form对象
  162. data.append('cbfbm', this.contractorCode);
  163. data.append('remark', this.remark);
  164. hangUp(data).then(response => {
  165. if (response.code === 200) {
  166. this.$toast({
  167. icon: 'success',
  168. message: '当前承包方调查已被挂起',
  169. duration: '2000',
  170. onClose: () => {
  171. this.showRemark = false;
  172. this.goBack();
  173. }
  174. });
  175. }
  176. });
  177. }).catch(() => {
  178. this.$notify({ type: 'danger', message: '请填写备注信息' });
  179. });
  180. }
  181. }
  182. }
  183. </script>
  184. <style scoped lang="scss">
  185. /deep/ .remarkForm .van-cell__value {
  186. border: 1px solid #b0b3ba;
  187. border-radius: 5px;
  188. padding: 0 15px;
  189. .van-field__control {
  190. color: #646566;
  191. }
  192. }
  193. .tb_main{
  194. position: relative;
  195. p{
  196. position: absolute;
  197. display: inline-block;
  198. margin-left: 10PX;
  199. }
  200. }
  201. .tb{
  202. font-size: .35rem;
  203. color: #ff8900;
  204. background: #daf6e7;
  205. border: 1px solid #d7be6e;
  206. padding: 2PX 8PX;
  207. border-radius: 50PX;
  208. margin-right: 5PX;
  209. }
  210. .signature-box {
  211. border: 1px dashed #666;
  212. margin: 2px 20px;
  213. height: 100%;
  214. /*canvas{*/
  215. /* height: 100%!important;*/
  216. /*}*/
  217. }
  218. .signature-footer {
  219. transform: rotate(90deg);
  220. width: auto;
  221. position: absolute;
  222. top: 50%;
  223. left: 0PX;
  224. .clearBtn {
  225. margin-left: 15px;
  226. }
  227. }
  228. </style>