Blame view

src/views/workflow/components/dialog/zsyl.vue 20.2 KB
1
<!--
yuanbo committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-11-15 15:34:21
5
-->
liangyifan committed
6
<template>
7
  <div class="from-clues loadingtext" v-Loading="loading" element-loading-text="拼命加载中..." style="height:720px;text-align: center;">
任超 committed
8
    <!-- 表单部分 -->
9
    <el-tabs v-model="activeName" @tab-click="handleClick" v-if="headTabBdcqz.length >1" style="margin-top:-23px">
10 11 12
      <el-tab-pane :label="item.qlr + (item.bdcqzh !== null ? '(' + item.bdcqzh + ')' : '')" :name="item.bsmBdcqz"
        v-for="(item, index) in headTabBdcqz" :key="index">
      </el-tab-pane>
任超 committed
13
    </el-tabs>
14
    <el-empty description="暂无数据" v-if="headTabBdcqz.length == 0 && noData"></el-empty>
yangwei committed
15
    <div :style="{'width':'1180px','height': `calc(100% - ${hdiffHeight}px)`,'overflow-y': 'auto'}">
16 17
      <canvas ref="zs" width="1000" v-show="this.bdcqz.bdcqzlx==1" height="700"></canvas>
      <canvas ref="zm" width="1180" v-show="this.bdcqz.bdcqzlx==2" height="780"></canvas>
18
    </div>
任超 committed
19
  </div>
liangyifan committed
20 21 22
</template>

<script>
23
  import { datas } from "../../javascript/zsyl.js";
24
  import { getSlsqBdcqzList } from "@/api/bdcqz.js"
25 26 27 28 29 30 31
  export default {
    name: "zsyl",
    props: {
      formData: {
        type: Object,
        default: {}
      }
蔡俊立 committed
32
    },
33 34
    data () {
      return {
35
        key: 0,
36
        noData: false,
37
        imgSrc: require('@/image/bdcqz/bdcqzs2.jpg'),
38
        bdczmSrc: require('@/image/bdcqz/bdczm.jpg'),
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
        loading: false,
        //印刷序列号集合
        ysxlh: [],
        //列名称对象
        columns: [],
        //选择的不动产权证文件
        bdcqz: '',
        //证书打开类型 是否需要展示打印按钮
        isToPrint: false,
        //tab切换栏数组
        headTabBdcqz: [],
        //tab选择绑定值
        activeName: '',
        //证书图片预览
        previewImage: '',
        ruleForm: {
          bsmBdcqz: '',
          szmc: '不动产权证书',
          szzh: '',
          ysxlh: '',
        },
      }
61
    },
62 63 64 65 66 67 68 69 70
    mounted () {
      this.columns = datas.columns();
      if (this.formData.bdcqz) {
        //从缮证进入
        this.bdcqz = this.formData.bdcqz
      } else {
        //从按钮进入
        this.getHeadTabBdcqz();
      }
71

72
    },
73
    methods: {
yuanbo committed
74 75 76 77 78
      /**
       * @description: 获取证书内容
       * @param {*} code
       * @author: renchao
       */
79 80 81 82
      getRowValue (code) {
        var value = this.bdcqz[code];
        return value;
      },
yuanbo committed
83 84 85 86
      /**
       * @description: 获取受理申请下全部不动产权证
       * @author: renchao
       */
87 88 89 90
      getHeadTabBdcqz () {
        this.loading = true
        getSlsqBdcqzList({ bsmSlsq: this.formData.bsmSlsq }).then(res => {
          if (res.code == 200) {
91
            this.noData = true
92 93 94
            if (res.result && res.result.length > 0) {
              this.bdcqz = res.result[0]
              this.headTabBdcqz = res.result
95 96
              if (this.formData.bsmBdcqz) {
                this.activeName = this.formData.bsmBdcqz
97 98
              } else {
                this.activeName = res.result[0].bsmBdcqz
99
              }
100
              if (this.bdcqz.bdcqzlx == 1) {
101 102 103 104
                this.drawTextOnImage()
              } else {
                this.drawTextzmImage()
              }
105 106
            }
          }
107
          this.loading = false
108 109
        })
      },
yuanbo committed
110 111 112 113 114
      /**
       * @description: tab表头切换方法
       * @param {*} e
       * @author: renchao
       */
115 116
      handleClick (tab, event) {
        this.bdcqz = this.headTabBdcqz[tab.index]
117
        if (this.bdcqz.bdcqzlx == 1) {
118 119 120 121
          this.drawTextOnImage()
        } else {
          this.drawTextzmImage()
        }
122
      },
yuanbo committed
123 124 125 126
      /**
       * @description: 不动产证书
       * @author: renchao
       */
127
      drawTextOnImage () {
128 129
        function getByteLen (val) {
          var len = 0;
130
          if (!val) return len;
131 132 133 134 135 136 137 138 139 140
          for (var i = 0; i < val.length; i++) {
            var length = val.charCodeAt(i);
            if (length >= 0 && length <= 128) {
              len += 1;
            } else {
              len += 2;
            }
          }
          return len;
        }
141
        const canvas = this.$refs.zs;
142 143 144 145
        const context = canvas.getContext('2d');
        const image = new Image();
        image.onload = () => {
          context.drawImage(image, 0, 0);
146
          context.font = '18px 楷体';
147 148 149 150 151
          context.fillStyle = '#000000';
          context.fillText(this.bdcqz.sjjc ? this.bdcqz.sjjc : '', 60, 56);
          context.fillText(this.bdcqz.djnd ? this.bdcqz.djnd : '', 113, 56);
          context.fillText(this.bdcqz.sxqc ? this.bdcqz.sxqc : '', 180, 56);
          context.fillText(this.bdcqz.sxh ? this.bdcqz.sxh : '', 370, 56);
152 153 154
          context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 129, 97);
          context.fillText(this.bdcqz.gyqk ? this.bdcqz.gyqk : '', 129, 136);

155
          this.bdcdyh = this.bdcqz.bdcdyh.slice(0, 6) + ' ' + this.bdcqz.bdcdyh.slice(6, 12) + ' ' +
156
            this.bdcqz.bdcdyh.slice(12, 19) + ' ' + this.bdcqz.bdcdyh.slice(19, this.bdcqz.bdcdyh.length)
157
          context.fillText(this.bdcdyh ? this.bdcdyh : '', 129, 223);
158 159 160 161 162 163



          context.fillText(this.bdcqz.qllx ? this.bdcqz.qllx : '', 129, 263);
          context.fillText(this.bdcqz.qlxz ? this.bdcqz.qlxz : '', 129, 303);
          context.fillText(this.bdcqz.yt ? this.bdcqz.yt : '', 129, 346);
164 165
          // context.fillText(this.bdcqz.mj ? this.bdcqz.mj : '', 129, 386);
          let lines6 = this.bdcqz.mj ? this.bdcqz.mj.split(' ') : [];
166
          if (getByteLen(this.bdcqz.mj) > 37) {
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
            lines6.forEach((line, index) => {
              const y = 378 + (index * 27); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 330) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          } else {
            lines6.forEach((line, index) => {
              const y = 386 + (index * 27); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 330) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          }
207
          // 权利其他状态
208
          let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n') : [];
209
          for (let i = 0; i < lines.length; i++) {
210
            let num = Math.ceil(getByteLen(lines[i]) / 38)
211
            if (getByteLen(lines[i]) > 37) {
212 213 214 215 216
              let currentLine = '';
              let arr = [];
              for (let word of lines[i]) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
217
                if (lineWidth <= 323) {
218 219 220 221 222
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
223
              }
224
              arr.push(currentLine);
225 226
              if (i > 0) {
                arr.forEach((line, index) => {
227
                  context.fillText(line, 129, 495 + (29 * (i - 1)) + 4 * num + (index * 14)); // 调整行高
228 229 230
                })
              } else {
                arr.forEach((line, index) => {
231
                  context.fillText(line, 129, 493 + (26 * (i - 1)) + (index * 14)); // 调整行高
232 233
                })
              }
234
            } else {
235
              if (i > 0) {
236
                context.fillText(lines[i] ? lines[i] : '', 129, 500 + 4 * num + (29 * (i - 1)));
237
              } else {
238
                context.fillText(lines[i] ? lines[i] : '', 129, 505 + (27 * (i - 1)));
239
              }
240
            }
241 242
          }

renchao@pashanhoo.com committed
243
          let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split('\n') : [];
244
          lines1.forEach((line, index) => {
renchao@pashanhoo.com committed
245
            const y = 100 + (index * 30); // 每行文本的垂直位置
246 247 248 249 250 251 252 253 254 255 256 257 258 259
            let currentLine = '';
            let arr = [];
            for (let word of line) {
              const testLine = currentLine + word;
              const lineWidth = context.measureText(testLine).width;
              if (lineWidth <= 395) {
                currentLine = testLine;
              } else {
                arr.push(currentLine);
                currentLine = word;
              }
            }
            arr.push(currentLine);
            arr.forEach((line, index) => {
260
              context.fillText(line, 580, y + (index * 30)); // 调整行高
261 262
            })
          })
263
          let lines3 = this.bdcqz.syqx ? this.bdcqz.syqx.split(' ') : [];
264
          if (getByteLen(this.bdcqz.syqx) > 37) {
265 266 267 268 269 270 271
            lines3.forEach((line, index) => {
              const y = 423 + (index * 27); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
272
                if (lineWidth <= 330) {
273 274 275 276 277
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
278
              }
279 280 281 282
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
283
            })
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
          } else {
            lines3.forEach((line, index) => {
              const y = 430 + (index * 27); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 315) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          }
305

306
          let lines2 = this.bdcqz.zl ? this.bdcqz.zl.split(' ') : [];
307
          if (getByteLen(this.bdcqz.zl) > 37) {
308
            lines2.forEach((line, index) => {
309
              const y = 170 + (index * 20); // 每行文本的垂直位置
310 311 312 313 314
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
1  
renchao@pashanhoo.com committed
315
                if (lineWidth <= 336) {
316 317 318 319 320 321 322 323 324 325 326 327 328
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          } else {
            lines2.forEach((line, index) => {
329
              const y = 180 + (index * 20); // 每行文本的垂直位置
330 331 332 333 334
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
1  
renchao@pashanhoo.com committed
335
                if (lineWidth <= 336) {
336 337 338 339 340 341 342 343 344 345 346 347
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          }
348
        }
349 350
        image.src = this.imgSrc
      },
yuanbo committed
351 352 353 354
      /**
       * @description: 不动产证明
       * @author: renchao
       */
355
      drawTextzmImage () {
356 357
        function getByteLen (val) {
          var len = 0;
358
          if (!val) return len;
359 360 361 362 363 364 365 366 367 368 369
          for (var i = 0; i < val.length; i++) {
            var length = val.charCodeAt(i);
            if (length >= 0 && length <= 128) {
              len += 1;
            } else {
              len += 2;
            }
          }
          return len;
        }

370 371 372 373 374
        const canvas = this.$refs.zm;
        const context = canvas.getContext('2d');
        const image = new Image();
        image.onload = () => {
          context.drawImage(image, 0, 0);
375
          context.font = '18px 楷体';
376
          context.fillStyle = '#000000';
377 378 379
          // ysxlh
          context.fillText(this.bdcqz.ysxlh ? this.bdcqz.ysxlh : '', 280, 712);
          // djsj
380 381 382 383 384 385
          if (this.bdcqz.djsj) {
            let djsjList = this.bdcqz.djsj.split(' ')[0].split('/')
            context.fillText(djsjList[0] ? djsjList[0] : '', 327, 580);
            context.fillText(djsjList[1] ? djsjList[1] : '', 393, 580);
            context.fillText(djsjList[2] ? djsjList[2] : '', 443, 580);
          }
386 387 388 389 390 391 392 393
          context.fillText(this.bdcqz.sjjc ? this.bdcqz.sjjc : '', 620, 125);
          context.fillText(this.bdcqz.djnd ? this.bdcqz.djnd : '', 665, 125);
          context.fillText(this.bdcqz.sxqc ? this.bdcqz.sxqc : '', 750, 125);
          context.fillText(this.bdcqz.sxh ? this.bdcqz.sxh : '', 960, 123);
          context.fillText(this.bdcqz.zmqlhsx ? this.bdcqz.zmqlhsx : '', 775, 180);
          context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 775, 228);
          // 义务人
          context.fillText(this.bdcqz.ywr ? this.bdcqz.ywr : '', 775, 275);
394 395 396
          // context.fillText(this.bdcqz.zl ? this.bdcqz.zl : '', 775, 325);

          let lines2 = this.bdcqz.zl ? this.bdcqz.zl.split(' ') : [];
397
          if (getByteLen(this.bdcqz.zl) >= 39) {
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
            lines2.forEach((line, index) => {
              const y = 315 + (index * 20); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 295) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 775, y + (index * 20)); // 调整行高
              })
            })
          } else {
            lines2.forEach((line, index) => {
              const y = 325 + (index * 20); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 295) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 775, y + (index * 20)); // 调整行高
              })
            })
          }


440
          // bdcdyh
441 442 443
          this.bdcdyh = this.bdcqz.bdcdyh.slice(0, 6) + ' ' + this.bdcqz.bdcdyh.slice(6, 12) + ' ' +
            this.bdcqz.bdcdyh.slice(12, 19) + ' ' + this.bdcqz.bdcdyh.slice(19, this.bdcqz.bdcdyh.length)
          context.fillText(this.bdcdyh ? this.bdcdyh : '', 775, 373);
444
          // qlqtzk
445
          const maxWidth = 295; // 最大宽度限制
446
          let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n') : [];
447
          for (let i = 0; i < lines.length; i++) {
448 449
            let num = Math.ceil(getByteLen(lines[i]) / 37)
            if (getByteLen(lines[i]) > 37) {
450 451
              let currentLine = '';
              let arr = [];
452
              for (let word of lines[i]) {
453 454 455 456 457 458 459 460 461 462
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= maxWidth) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
463 464
              if (i > 0) {
                arr.forEach((line, index) => {
465
                  context.fillText(line, 770, 428 + (25 * (i - 1)) + 5 * num + (index * 15)); // 调整行高
466
                })
467
              } else {
468
                arr.forEach((line, index) => {
469
                  context.fillText(line, 770, 435 + (25 * (i - 1)) + (index * 14)); // 调整行高
470 471 472
                })
              }
            } else {
473 474 475 476 477
              if (i > 0) {
                context.fillText(lines[i] ? lines[i] : '', 770, 440 + 5 * num + (24 * (i - 1)));
              } else {
                context.fillText(lines[i] ? lines[i] : '', 770, 440 + (24 * (i - 1)));
              }
478
            }
479
          }
renchao@pashanhoo.com committed
480
          // fj
renchao@pashanhoo.com committed
481
          let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split('\n') : [];
482
          for (let i = 0; i < lines1.length; i++) {
483 484
            let num = Math.ceil(getByteLen(lines1[i]) / 37)
            if (getByteLen(lines1[i]) > 37) {
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
              let currentLine = '';
              let arr = [];
              for (let word of lines1[i]) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= maxWidth) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              if (i > 0) {
                arr.forEach((line, index) => {
500
                  context.fillText(line, 770, 610 + (25 * (i - 1)) + 5 * num + (index * 22)); // 调整行高
501
                })
502
              } else {
503
                arr.forEach((line, index) => {
504
                  context.fillText(line, 770, 610 + (25 * (i - 1)) + (index * 22)); // 调整行高
505 506 507 508
                })
              }
            } else {
              if (i > 0) {
509
                context.fillText(lines1[i] ? lines1[i] : '', 770, 610 + 5 * num + (24 * (i - 1)));
510
              } else {
511
                context.fillText(lines1[i] ? lines1[i] : '', 770, 610 + (24 * (i - 1)));
512 513
              }
            }
514
          }
515
        }
renchao@pashanhoo.com committed
516

517
        image.src = this.bdczmSrc;
518
      }
yangwei committed
519
    },
520 521 522
    computed: {
      hdiffHeight () {
        return this.headTabBdcqz.length > 1 ? 54 : 0
yangwei committed
523
      }
524
    }
liangyifan committed
525 526 527
  }
</script>
<style scoped lang="scss">
528
  @import "~@/styles/mixin.scss";
任超 committed
529

530 531 532 533 534
  .imgClass {
    display: inline-block;
    height: auto;
    max-width: 100%;
  }
任超 committed
535

536 537 538
  .middle_padding {
    padding-bottom: 10px;
  }
任超 committed
539

540 541 542
  .zsyl-button {
    text-align: center;
    margin-top: 20px;
任超 committed
543

544 545 546 547
    .operation_button {
      width: 100px;
      border: 1px solid rgb(0, 121, 254);
    }
任超 committed
548

549 550 551 552
    .dy-button {
      color: white;
      background-color: rgb(0, 121, 254);
    }
蔡俊立 committed
553
  }
任超 committed
554

555 556 557
  .table-column {
    border-spacing: 1px;
    width: 100%;
任超 committed
558

559 560 561 562 563 564 565 566
    tr td {
      border: 1px solid #ccc;
      text-align: center;
      height: 40px;
      padding: 4px;
      font-size: 13px;
      background: rgb(251, 249, 229);
    }
任超 committed
567 568
  }

569 570 571 572 573 574
  .zsyl-title {
    background: #fafbe5;
    text-align: center;
    padding: 5px 0px;
    font-size: 20px;
  }
蔡俊立 committed
575

576 577 578 579 580 581
  .no-data {
    font-size: 18px;
    display: flex;
    text-align: center;
    justify-content: center;
  }
liangyifan committed
582
</style>