index.vue 6.57 KB
<!--
 * @Description:补充材料通知书
 * @Autor: renchao
 * @LastEditTime: 2024-03-27 11:24:03
-->
<template>
  <div class="clmlmx-box">
    <lb-table :column="column" :key="key" row-key="bsmSj" ref="table" :heightNumSetting="true" :calcHeight="600"
      :pagination="false" :data="tableData" @row-click="handleRowClick" @selection-change="handleSelectionChange">
    </lb-table>
    <div class="text-center">
      <el-button @click="handleCancel">取消</el-button>
      <el-button type="primary" @click="handleSubmit" :loading="loading">打印</el-button>
    </div>
  </div>
</template>
<script>
  import Vue from 'vue'
  import store from '@/store/index.js'
  import { ywPopupCacel } from "@/utils/popup.js";
  import { getLodop } from "@/utils/LodopFuncs";
  import { updateClml, InitClml } from "@/api/clxx.js";
  import { getNewDate } from '@/utils/util'
  import { getPrintTemplateByCode, getPrintSupplementalMaterials } from "@/api/print";
  export default {
    props: {
      formData: {
        type: Object,
        default: () => {
          return {}
        }
      }
    },
    data () {
      return {
        selectList: [],
        loading: false,
        sortable: null,
        newDate: getNewDate(),
        column: [
          {
            type: 'selection',
            label: '全选',
            width: '60'
          },
          {
            label: "材料名称",
            render: (h, scope) => {
              return (
                (this.formData.ableOperation && scope.row.sfxjcl == '1') ?
                  <el-input value={scope.row.sjmc} onInput={(val) => { scope.row.sjmc = val }}></el-input> : <span>{scope.row.sjmc}</span>
              )
            }
          },
          {
            label: "份数",
            render: (h, scope) => {
              if (scope.row.ys && scope.row.ys > 0) {
                return (
                  <div>
                    <span>{scope.row.ys}</span>
                  </div>
                );
              } else {
                return (
                  <div>
                    <span>0</span>
                  </div>
                );
              }
            }
          },
          {
            label: "材料类型",
            render: (h, scope) => {
              return (
                this.formData.ableOperation ?
                  <el-select value={scope.row.sjlx}
                    onChange={(val) => { scope.row.sjlx = val }}>
                    {
                      store.getters.dictData['A40'].map(option => {
                        return (
                          <el-option label={option.dname} value={option.dcode}></el-option>
                        )
                      })
                    }
                  </el-select> : <span>{this.dicStatus(scope.row.sjlx, "A40")}</span>
              )
            }
          }
        ],
        key: 0,
        tableData: []
      }
    },
    mounted () {
      var formdata = new FormData();
      formdata.append("bsmSlsq", this.formData.bsmSlsq ? this.formData.bsmSlsq : '');
      formdata.append("bsmSldy", this.formData.bsmSldy ? this.formData.bsmSldy : '');
      console.log(this.formData);
      InitClml(formdata).then((res) => {
        if (res.code == 200) {
          if (res.result && res.result.length > 0) {
            this.tableData = res.result
            this.key++
          }
        } else {
          this.$message.error(res.message);
        }
      })
    },
    beforeDestroy () {
      if (this.sortable) {
        this.sortable.destroy();
      }
    },
    methods: {
      handleSelectionChange (val) {
        this.selectList = val
      },
      handleRowClick (row) {
        let refs = 'table';
        this.$refs[refs].toggleRowSelection(row)
      },
      handleCancel () {
        ywPopupCacel()
      },
      handleSubmit () {
        this.loading = true
        if (this.selectList.length == 0) {
          this.$message.error('请先选择材料目录')
          this.loading = false
          return
        }
        getPrintTemplateByCode({ tmpno: 'bdcdjbccltts' }).then(res => {
          if (res.code === 200) {
            getPrintSupplementalMaterials(this.formData.bsmSldy, this.selectList).then(infoRes => {
              this.loading = false
              if (infoRes.code === 200) {
                if (infoRes.result.fileList && infoRes.result.fileList.length > 0) {
                  infoRes.result.fileList.forEach((it, index) => {
                    let key = index + 1
                    this.$set(infoRes.result, "file" + key, it.sjmc)
                    this.$set(infoRes.result, "file" + key + 'ys', it.ys)
                    this.$set(infoRes.result, "file" + key + 'lx', it.sjlx == 1 ? "原件" : "复印件")
                  })
                }
                infoRes.result.nownian = this.newDate.split(' ')[0].split('年')[0]
                infoRes.result.nowyue = this.newDate.slice(5, 7)
                infoRes.result.nowri = this.newDate.slice(8, 10)
                let date = infoRes.result.sqrq
                infoRes.result.sqnian = date.split(' ')[0].split('-')[0]
                infoRes.result.sqyue = date.split(' ')[0].split('-')[1]
                infoRes.result.sqri = date.split(' ')[0].split('-')[2]
                console.log(infoRes.result)
                let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));

                // 装载第一个模板并设置数据
                LODOP.ADD_PRINT_DATA("ProgramData", res.result.tmpcontent);
                for (let key in infoRes.result) {
                  LODOP.SET_PRINT_STYLEA(key, "CONTENT", infoRes.result[key]);
                }

                // 进行预览
                LODOP.PREVIEW();
              } else {
                this.$message.error(infoRes.message);
              }
            }).catch(() => {
              this.loading = false
            })
          } else {
            this.loading = false
            this.$message.error(res.message);
          }
        })
      },
      dicStatus (val, code) {
        let data = store.getters.dictData[code],
          name = '暂无'
        if (data) {
          data.map((item) => {
            if (item.dcode == val) {
              name = item.dname
            }
          })
          return name
        }
      },
    }
  }
</script>
<style scoped lang='scss'>
  @import "~@/styles/mixin.scss";
  .clmlmx-box {
    margin: 0 auto;
    .title {
      text-align: center;
      height: 60px;
      line-height: 60px;
      border: 1px solid #dfe6ec;
      font-size: 20px;
      background: #81d3f81a;
      margin-bottom: -1px;
    }
  }
</style>