Blame view

src/views/workflow/components/dialog/zsdy.vue 30.6 KB
1
<!--
yuanbo committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2024-01-18 08:20:44
5
-->
蔡俊立 committed
6
<template>
renchao@pashanhoo.com committed
7
  <div>
8
    <div class="zsdy-content" v-Loading="loading">
renchao@pashanhoo.com committed
9 10 11 12 13
      <el-form
        :model="ruleForm"
        ref="ruleForm"
        label-width="120px">
        <el-form-item label="印刷序列号:" prop="ysxlh">
14
          <el-row>
15
            <el-col :span="18">
16 17 18 19 20 21 22 23 24
              <el-select v-model="ruleForm.ysxlh" @change="handleSelect" :disabled="disabled" placeholder="请选择">
                <el-option
                  v-for="item in ysxlh"
                  :key="item.ysxlh"
                  :label="item.ysxlh"
                  :value="item.ysxlh">
                </el-option>
              </el-select>
            </el-col>
25 26 27 28 29 30
            <el-col :span="4" v-if="this.formData.bdcqzlx==1">
              <el-tabs v-model="activeTitle">
                <el-tab-pane label="第一页" name="title1"></el-tab-pane>
                <el-tab-pane label="第二页" name="title2"></el-tab-pane>
              </el-tabs>
            </el-col>
31
            <el-col :span="2" v-if="this.formData.ysxlh" style="float:right">
renchao@pashanhoo.com committed
32
              <el-button type="primary" @click="handleZF" v-if="disabled">作废</el-button>
33 34 35
            </el-col>
          </el-row>

renchao@pashanhoo.com committed
36 37
        </el-form-item>
      </el-form>
38
      <div class="zs-content">
39 40
        <canvas ref="zs1" width="1000" v-show="this.formData.bdcqzlx==1 && activeTitle=='title1'" height="700"></canvas>
        <canvas ref="zs" width="1000" v-show="this.formData.bdcqzlx==1 && activeTitle=='title2'" height="700"></canvas>
41
        <canvas ref="zm" width="1180" v-show="this.formData.bdcqzlx==2" height="780"></canvas>
42
      </div>
renchao@pashanhoo.com committed
43
    </div>
renchao@pashanhoo.com committed
44 45 46 47
    <!-- 打印模板需要此模块 -->
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" v-show="false">
      <embed id="LODOP_EM" type="application/x-print-lodop" width="1180" height="720" pluginspage="install_lodop32.exe" />
    </object>
renchao@pashanhoo.com committed
48
    <div class="text-center pt-10">
renchao@pashanhoo.com committed
49
      <el-button @click="$popupCacel">取消</el-button>
50
      <el-button type="primary" @click="handlePrint" v-if="disabled">打印</el-button>
51
      <el-button type="primary" @click="handleSubmit" v-else>确定</el-button>
蔡俊立 committed
52
    </div>
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

    <el-dialog title="证书作废" :visible.sync="invalidDiglog" width="40%" :modal-append-to-body="false" top="30vh">
      <div class="invalid-diglog">
        <div class="invalid-title">
          <i class="el-icon-question invalid-icon"></i>
          <div class="invalid-body">您确定作废证书并再次打印?印刷序列号{{bdcqz.ysxlh}}</div>
        </div>
        <div class="invalid-reson">作废原因:</div>
        <el-input v-model="zfyy" placeholder="请输入作废原因" type="textarea" :rows="4"></el-input>
        <div class="text-center pt-10">
          <el-button @click="closeInvalidDiglog">取 消</el-button>
          <el-button type="primary" @click="confirmInvalid">确 定</el-button>
        </div>
      </div>
    </el-dialog>
renchao@pashanhoo.com committed
68
  </div>
蔡俊立 committed
69 70 71
</template>

<script>
72
  import QRCode from 'qrcode'
renchao@pashanhoo.com committed
73 74
  import store from '@/store/index.js'
  import { datas } from "../../javascript/zsyl.js";
renchao@pashanhoo.com committed
75 76
  import { getPrintTemplateByCode } from "@/api/print";
  import { getLodop } from "@/utils/LodopFuncs"
77
  import { readYsxlh, certificate, getBdcqzDetail, invalidCertificate } from "@/api/bdcqz.js";
renchao@pashanhoo.com committed
78 79
  export default {
    props: {
renchao@pashanhoo.com committed
80 81 82 83 84 85
      formData: {
        type: Object,
        default: () => {
          return {}
        }
      }
86
    },
renchao@pashanhoo.com committed
87 88
    data () {
      return {
89
        activeTitle: 'title1',
90 91
        // 详细信息
        bdcqz: {},
92
        key: 0,
93
        disabled: false,
94
        // 不动产证书图片地址
95
        imgSrc1: require('@/image/bdcqz/bdcqzs1.jpg'),
96
        imgSrc: require('@/image/bdcqz/bdcqzs2.jpg'),
97
        bdczmSrc: require('@/image/bdcqz/bdczm.jpg'),
98
        loading: false,
renchao@pashanhoo.com committed
99 100 101 102
        //印刷序列号集合
        ysxlh: [],
        //列名称对象
        columns: [],
103 104
        //tab选择绑定值
        activeName: '',
105 106
        invalidDiglog: false,
        zfyy: "",
renchao@pashanhoo.com committed
107 108 109 110 111
        ruleForm: {
          bsmBdcqz: "",
          szmc: "不动产权证书",
          bdcqzlx: "",
          szzh: "",
renchao@pashanhoo.com committed
112
          ysxlh: ""
113
        }
renchao@pashanhoo.com committed
114 115
      }
    },
116
    mounted () {
renchao@pashanhoo.com committed
117
      store.dispatch('user/refreshPage', false)
renchao@pashanhoo.com committed
118 119
      this.columns = datas.columns()
      this.ysxlhList()
120 121 122 123
      // 获取详细信息
      this.getDetail()
      if (this.formData.ysxlh) {
        this.disabled = true
124
      } else {
125
        this.disabled = false
126
      }
renchao@pashanhoo.com committed
127 128
    },
    methods: {
yuanbo committed
129
      /**
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
       * @description: 获取详细信息
       * @author: renchao
       */
      getDetail () {
        this.loading = true
        getBdcqzDetail(this.formData.bsmBdcqz).then(res => {
          this.bdcqz = res.result
          this.loading = false
          if (this.bdcqz.ysxlh) this.ruleForm.ysxlh = this.bdcqz.ysxlh
          if (this.bdcqz.bdcqzlx == 1) {
            this.drawTextOnImage()
          } else {
            this.drawTextzmImage()
          }
        })
      },
      /**
yuanbo committed
147 148 149
       * @description: 获取印刷序列号列表
       * @author: renchao
       */
renchao@pashanhoo.com committed
150
      ysxlhList () {
151
        readYsxlh({ zslx: this.formData.bdcqzlx }).then((res) => {
renchao@pashanhoo.com committed
152 153 154
          if (res.code === 200) {
            this.ysxlh = res.result;
          }
renchao@pashanhoo.com committed
155
        })
renchao@pashanhoo.com committed
156
      },
yuanbo committed
157 158 159 160 161
      /**
       * @description: handleSelect
       * @param {*} val
       * @author: renchao
       */
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
      handleSelect (val) {
        this.bdcqz.ysxlh = this.ruleForm.ysxlh
        if (this.bdcqz.bdcqzlx == 1) {
          this.drawTextOnImage()
        } else {
          this.drawTextzmImage()
        }
      },
      /**
      * @description: closeInvalidDiglog
      * @author: renchao
      */
      closeInvalidDiglog () {
        this.zfyy = "";
        this.invalidDiglog = false
      },
yuanbo committed
178 179 180 181
      /**
       * @description: handleZF
       * @author: renchao
       */
renchao@pashanhoo.com committed
182 183 184
      handleZF () {
        this.invalidDiglog = true
      },
185 186 187 188 189
      /**
       * @description: 作废缮证信息
       * @author: renchao
       */
      confirmInvalid () {
renchao@pashanhoo.com committed
190
        store.dispatch('user/reWorkFresh', false)
191 192 193 194 195 196 197 198 199 200 201 202 203
        invalidCertificate({ bsmBdcqz: this.bdcqz.bsmBdcqz, zfyy: this.zfyy }).then((res) => {
          if (res.code === 200) {
            this.$message.success("作废成功");
            this.disabled = false
            this.invalidDiglog = false;
            this.zfyy = ''
            this.ruleForm.ysxlh = ''
            this.bdcqz.ysxlh = ''
            if (this.bdcqz.bdcqzlx == 1) {
              this.drawTextOnImage()
            } else {
              this.drawTextzmImage()
            }
renchao@pashanhoo.com committed
204
            store.dispatch('user/reWorkFresh', true)
205 206 207 208 209
          } else {
            this.$message.error(res.message);
          }
        })
      },
yuanbo committed
210 211 212 213
      /**
       * @description: 不动产证书
       * @author: renchao
       */
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
      drawTextOnImage1 () {
        const canvas = this.$refs.zs1;
        const context = canvas.getContext('2d');
        const image = new Image();
        image.onload = () => {
          context.drawImage(image, 0, 0);
          context.font = '18px 楷体';
          context.fillStyle = '#000000';
          let date = this.bdcqz.djsj.split(' ')[0].split('/');
          let nian = date[0]
          let yue = date[1]
          let ri = date[2]
          this.bdcqz.nian = nian
          this.bdcqz.yue = yue
          this.bdcqz.ri = ri
          context.fillText(nian ? nian : '', 780, 499);
          context.fillText(yue ? yue : '', 840, 499);
          context.fillText(ri ? ri : '', 885, 499);
          QRCode.toDataURL(this.bdcqz.bdcqzh, { margin: 0 })
            .then(url => {
              const qrImage = new Image();
              this.bdcqz.qrImage = url; // 将二维码图片的 URL 存储到 bdcqz 对象的 qrImage 属性中
              qrImage.onload = () => {
                context.drawImage(qrImage, 670, 400, 100, 100);
              };
              qrImage.src = url;
            })
            .catch(error => {
              console.error(error);
            });
          context.fillText(this.bdcqz.bdcqzbm ? this.bdcqz.bdcqzbm : '', 745, 633);
        };
        image.src = this.imgSrc1;
      },
248
      drawTextOnImage () {
249
        this.drawTextOnImage1()
250 251
        function getByteLen (val) {
          var len = 0;
252
          if (!val) return len;
253 254 255 256 257 258 259 260 261 262
          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;
        }
263 264 265 266 267
        const canvas = this.$refs.zs;
        const context = canvas.getContext('2d');
        const image = new Image();
        image.onload = () => {
          context.drawImage(image, 0, 0);
renchao@pashanhoo.com committed
268
          context.font = '18px 楷体';
269
          context.fillStyle = '#000000';
270 271 272 273 274 275
          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);
          context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 129, 97);
          context.fillText(this.bdcqz.gyqk ? this.bdcqz.gyqk : '', 129, 136);
276

277 278
          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)
279
          context.fillText(this.bdcdyh ? this.bdcdyh : '', 129, 223);
280 281


282

283 284 285 286
          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);
          let lines6 = this.bdcqz.mj ? this.bdcqz.mj.split(' ') : [];
287
          if (getByteLen(this.bdcqz.mj) > 37) {
288 289
            lines6.forEach((line, index) => {
              const y = 378 + (index * 27); // 每行文本的垂直位置
290 291 292 293 294
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
295
                if (lineWidth <= 336) {
296 297 298 299 300 301 302 303
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
304
                context.fillText(line, 129, y + (index * 20)); // 调整行高
305 306 307
              })
            })
          } else {
308 309 310 311 312 313 314
            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;
315
                if (lineWidth <= 336) {
316 317 318 319 320 321 322 323 324 325 326
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
327
          }
328 329
          // 权利其他状态
          const maxWidth = 332; // 最大宽度限制
330
          let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n').filter(i => i && i.trim()) : [];
331
          for (let i = 0; i < lines.length; i++) {
332 333
            let num = Math.ceil(getByteLen(lines[i]) / 37)
            if (getByteLen(lines[i]) > 37) {
334 335 336 337 338 339 340 341 342 343 344
              let currentLine = '';
              let arr = [];
              for (let word of lines[i]) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= maxWidth) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
345
              }
346
              arr.push(currentLine);
347 348
              if (i > 0) {
                arr.forEach((line, index) => {
349
                  context.fillText(line, 129, 495 + (29 * (i - 1)) + 4 * num + (index * 14)); // 调整行高
350 351 352
                })
              } else {
                arr.forEach((line, index) => {
353
                  context.fillText(line, 129, 493 + (26 * (i - 1)) + (index * 14)); // 调整行高
354 355
                })
              }
356
            } else {
357
              if (i > 0) {
358
                context.fillText(lines[i] ? lines[i] : '', 129, 500 + 4 * num + (29 * (i - 1)));
359
              } else {
360
                context.fillText(lines[i] ? lines[i] : '', 129, 505 + (27 * (i - 1)));
361
              }
362
            }
363 364
          }

365
          let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split('\n').filter(i => i && i.trim()) : [];
366
          lines1.forEach((line, index) => {
367
            const y = 100 + (index * 30); // 每行文本的垂直位置
368 369 370 371 372 373 374 375 376 377 378 379 380 381
            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) => {
382
              context.fillText(line, 580, y + (index * 30)); // 调整行高
383 384
            })
          })
385
          let lines3 = this.bdcqz.syqx ? this.bdcqz.syqx.split(' ') : [];
386
          if (getByteLen(this.bdcqz.syqx) > 37) {
387 388 389 390 391 392 393 394 395 396 397 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
            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;
                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 {
            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)); // 调整行高
              })
            })
          }

428
          let lines2 = this.bdcqz.zl ? this.bdcqz.zl.split(' ') : [];
429
          if (getByteLen(this.bdcqz.zl) > 37) {
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
            lines2.forEach((line, index) => {
              const y = 170 + (index * 20); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 336) {
                  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) => {
              const y = 180 + (index * 20); // 每行文本的垂直位置
              let currentLine = '';
              let arr = [];
              for (let word of line) {
                const testLine = currentLine + word;
                const lineWidth = context.measureText(testLine).width;
                if (lineWidth <= 336) {
                  currentLine = testLine;
                } else {
                  arr.push(currentLine);
                  currentLine = word;
                }
              }
              arr.push(currentLine);
              arr.forEach((line, index) => {
                context.fillText(line, 129, y + (index * 20)); // 调整行高
              })
            })
          }
470 471
        }
        image.src = this.imgSrc
renchao@pashanhoo.com committed
472
      },
yuanbo committed
473
      /**
474 475 476 477 478 479
       * @description: 不动产证明
       * @author: renchao
       */
      drawTextzmImage () {
        function getByteLen (val) {
          var len = 0;
480
          if (!val) return len;
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
          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;
        }

        const canvas = this.$refs.zm;
        const context = canvas.getContext('2d');
        const image = new Image();
        image.onload = () => {
          context.drawImage(image, 0, 0);
renchao@pashanhoo.com committed
497
          context.font = '18px 楷体';
498 499
          context.fillStyle = '#000000';
          // ysxlh
500
          context.fillText(this.bdcqz.ysxlh ? this.bdcqz.ysxlh : '', 280, 712);
501
          // djsj
502 503
          if (this.bdcqz.djsj) {
            let djsjList = this.bdcqz.djsj.split(' ')[0].split('/')
504 505 506 507
            context.fillText(djsjList[0] ? djsjList[0] : '', 327, 580);
            context.fillText(djsjList[1] ? djsjList[1] : '', 393, 580);
            context.fillText(djsjList[2] ? djsjList[2] : '', 443, 580);
          }
508 509 510 511 512
          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);
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
          // context.fillText(this.bdcqz.qlr ? this.bdcqz.qlr : '', 775, 228);
          // 权利人
          let qlrlines = this.bdcqz.qlr ? this.bdcqz.qlr.split(' ') : [];
          if (getByteLen(this.bdcqz.qlr) > 37) {
            qlrlines.forEach((line, index) => {
              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, 218 + (index * 20)); // 调整行高
              })
            })
          } else {
            qlrlines.forEach((line, index) => {
              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, 228 + (index * 20)); // 调整行高
              })
            })
          }
          // 义务人
556
          context.fillText(this.bdcqz.ywr ? this.bdcqz.ywr : '', 775, 275);
557
          let lines2 = this.bdcqz.zl ? this.bdcqz.zl.split(' ') : [];
558
          if (getByteLen(this.bdcqz.zl) > 37) {
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
            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)); // 调整行高
              })
            })
          }
599
          // bdcdyh
600 601
          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)
602 603 604 605 606
          // 保存当前字体设置
          const originalFont = context.font;
          // 设置新的字体大小
          context.font = '16px 楷体'; // 替换为你想要的字体和大小
          // 绘制 bdcdyh
607
          context.fillText(this.bdcdyh ? this.bdcdyh : '', 775, 373);
608 609
          // 恢复原始字体设置
          context.font = originalFont;
610
          // qlqtzk
611
          const maxWidth = 290; // 最大宽度限制
612
          let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n').filter(i => i && i.trim()) : [];
613
          for (let i = 0; i < lines.length; i++) {
614
            console.log(getByteLen(lines[i]));
615 616
            let num = Math.ceil(getByteLen(lines[i]) / 37)
            if (getByteLen(lines[i]) > 37) {
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
              let currentLine = '';
              let arr = [];
              for (let word of lines[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) => {
632
                  context.fillText(line, 770, 438 + (24 * (i - 1)) + 5 * num + (index * 17)); // 调整行高
633 634 635
                })
              } else {
                arr.forEach((line, index) => {
636
                  context.fillText(line, 770, 438 + (24 * (i - 1)) + (index * 17)); // 调整行高
637 638 639 640
                })
              }
            } else {
              if (i > 0) {
641
                context.fillText(lines[i] ? lines[i] : '', 770, 447 + 6 * num + (25 * (i - 1)));
642
              } else {
643
                context.fillText(lines[i] ? lines[i] : '', 770, 447 + (25 * (i - 1)));
644 645 646 647
              }
            }
          }
          // fj
648
          let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split('\n').filter(i => i && i.trim()) : [];
649
          for (let i = 0; i < lines1.length; i++) {
650 651
            let num = Math.ceil(getByteLen(lines1[i]) / 37)
            if (getByteLen(lines1[i]) > 37) {
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
              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) => {
667
                  context.fillText(line, 770, 610 + (25 * (i - 1)) + 5 * num + (index * 22)); // 调整行高
668 669 670
                })
              } else {
                arr.forEach((line, index) => {
671
                  context.fillText(line, 770, 610 + (25 * (i - 1)) + (index * 22)); // 调整行高
672 673 674 675
                })
              }
            } else {
              if (i > 0) {
676
                context.fillText(lines1[i] ? lines1[i] : '', 770, 610 + 5 * num + (24 * (i - 1)));
677
              } else {
678
                context.fillText(lines1[i] ? lines1[i] : '', 770, 610 + (24 * (i - 1)));
679 680 681 682 683 684
              }
            }
          }
        }
        image.src = this.bdczmSrc;
      },
yuanbo committed
685 686 687 688
      /**
       * @description: 打印
       * @author: renchao
       */
689
      handlePrint () {
690
        let that = this
691 692 693 694
        if (this.ruleForm.ysxlh == '') {
          this.$message.error('请选择印刷序列号');
          return;
        }
renchao@pashanhoo.com committed
695
        store.dispatch('user/reWorkFresh', false)
696
        if (this.bdcqz.bdcqzlx == 1) {
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
          if (this.activeTitle == 'title1') {
            getPrintTemplateByCode({ tmpno: 'zsdy1' }).then(resInfo => {
              if (resInfo.code == 200) {
                //打开模板设计
                let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
                LODOP.ADD_PRINT_DATA("ProgramData", resInfo.result.tmpcontent); //装载模板
                console.log(that.bdcqz);
                for (let key in that.bdcqz) {
                  LODOP.SET_PRINT_STYLEA(key, "CONTENT", that.bdcqz[key]);
                }
                LODOP.PREVIEW();
              } else {
                that.$message.error(resInfo.message)
              }
              that.$popupCacel()
              //刷新列表
              store.dispatch('user/reWorkFresh', true)
            })
          } else {
            getPrintTemplateByCode({ tmpno: 'zsdy' }).then(resInfo => {
              if (resInfo.code == 200) {
                //打开模板设计
                let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
                LODOP.ADD_PRINT_DATA("ProgramData", resInfo.result.tmpcontent); //装载模板
721

722 723 724 725 726 727 728 729 730
                that.bdcqz.bdcdyh1 = that.bdcqz.bdcdyh.slice(0, 6) + ' ' + that.bdcqz.bdcdyh.slice(6, 12) + ' ' +
                  that.bdcqz.bdcdyh.slice(12, 19) + ' ' + that.bdcqz.bdcdyh.slice(19, that.bdcqz.bdcdyh.length)
                //todo 调取后端接口获取数据 循环set
                for (let key in that.bdcqz) {
                  LODOP.SET_PRINT_STYLEA(key, "CONTENT", that.bdcqz[key]);
                }
                LODOP.PREVIEW();
              } else {
                that.$message.error(resInfo.message)
731
              }
732 733 734 735 736
              that.$popupCacel()
              //刷新列表
              store.dispatch('user/reWorkFresh', true)
            })
          }
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
        } else {
          getPrintTemplateByCode({ tmpno: 'zmdy' }).then(resInfo => {
            if (resInfo.code == 200) {
              //打开模板设计
              let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
              LODOP.ADD_PRINT_DATA("ProgramData", resInfo.result.tmpcontent); //装载模板

              // 年月日
              this.bdcqz.nian = this.bdcqz.djsj.split(' ')[0].split('/')[0]
              this.bdcqz.yue = this.bdcqz.djsj.split(' ')[0].split('/')[1]
              this.bdcqz.ri = this.bdcqz.djsj.split(' ')[0].split('/')[1]
              this.bdcqz.bdcdyh1 = 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)
              //todo 调取后端接口获取数据 循环set
              for (let key in this.bdcqz) {
                LODOP.SET_PRINT_STYLEA(key, "CONTENT", this.bdcqz[key]);
              }
              LODOP.PREVIEW();
            } else {
              this.$message.error(resInfo.message)
            }
758 759 760
            that.$popupCacel()
            //刷新列表
            store.dispatch('user/reWorkFresh', true)
761 762
          })
        }
renchao@pashanhoo.com committed
763
      },
yuanbo committed
764 765 766 767
      /**
       * @description: 保存打印记录
       * @author: renchao
       */
768
      handleSubmit () {
renchao@pashanhoo.com committed
769
        let that = this
770 771 772 773
        if (this.ruleForm.ysxlh == '') {
          this.$message.error('请选择印刷序列号');
          return;
        }
renchao@pashanhoo.com committed
774
        store.dispatch('user/reWorkFresh', false)
775 776 777 778
        this.ruleForm.bsmBdcqz = this.bdcqz.bsmBdcqz;
        this.ruleForm.bdcqzlx = this.bdcqz.bdcqzlx;
        this.ruleForm.szzh = this.bdcqz.bdcqzh;
        this.bdcqz.ysxlh = this.ruleForm.ysxlh
renchao@pashanhoo.com committed
779 780
        certificate(this.ruleForm).then((res) => {
          if (res.code === 200) {
renchao@pashanhoo.com committed
781
            that.$popupCacel()
782
            this.handlePrint()
renchao@pashanhoo.com committed
783
          } else {
renchao@pashanhoo.com committed
784
            this.$message.error(res.message)
renchao@pashanhoo.com committed
785
          }
786
          store.dispatch('user/reWorkFresh', true)
787 788 789 790
        })
      }
    }
  }
蔡俊立 committed
791 792
</script>
<style scoped lang="scss">
renchao@pashanhoo.com committed
793
  @import "~@/styles/mixin.scss";
794 795 796 797 798 799 800 801 802
  /deep/.el-tabs__nav-wrap::after {
    display: none;
  }
  /deep/.el-tabs__header {
    margin: 0;
  }
  /deep/.el-form-item--small.el-form-item {
    margin-bottom: 0;
  }
renchao@pashanhoo.com committed
803 804 805 806
  .zsdy-content {
    height: 80vh;
    overflow-y: scroll;
  }
807
  .zs-content {
renchao@pashanhoo.com committed
808
    text-align: center;
蔡俊立 committed
809
  }
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
  .invalid-diglog {
    padding-bottom: 20px;
    font-size: 16px;
    font-weight: bold;
    color: rgb(99, 99, 99);

    .invalid-title {
      display: flex;
      align-content: center;

      .invalid-icon {
        color: rgb(254, 148, 0);
        font-size: 34px;
        margin-right: 10px;
      }

      .invalid-body {
        line-height: 40px;
        margin-bottom: 10px;
      }
    }

    .invalid-reson {
      margin-bottom: 10px;
    }

    .dialog-footer {
      margin-top: 10px;
      display: flex;
      justify-content: flex-end;
    }
  }
蔡俊立 committed
842
</style>