Blame view

src/views/workflow/components/qlrCommonTable.vue 9.53 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2024-01-18 14:55:20
5
-->
liangyifan committed
6 7
<template>
  <div>
8
    <lb-table :column="column" :pagination="false" :key="key" :heightNumSetting="true" :minHeight="0" :rowStyleHeight='25'
renchao@pashanhoo.com committed
9
      :data="tableDataList">
任超 committed
10
    </lb-table>
11
    <addQlr v-model="dialog" :details="details" :showButton="disabled" @updateDetail="handleupdateDetail" />
liangyifan committed
12 13 14
  </div>
</template>
<script>
15
  import { mapGetters } from 'vuex'
16
  import { getIdCardInfo } from '@/utils/operation.js'
17
  import addQlr from './dialog/addQlr.vue'
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  export default {
    components: {
      addQlr
    },
    computed: {
      ...mapGetters(["dictData"]),
    },
    props: {
      tableData: {
        type: Array,
        default: function () {
          return []
        }
      },
      gyfs: {
        type: String,
        default: '1'
35 36 37
      },
      disabled: {
        type: Boolean,
1  
renchao@pashanhoo.com committed
38
        default: true
任超 committed
39
      }
任超 committed
40
    },
41 42 43 44 45 46 47 48 49 50 51 52 53
    data () {
      return {
        key: 0,
        dataIndex: 0,
        dialog: false,
        isaddupdate: false,
        details: {},
        tableDataList: [],
        InformationTable: [
          {
            width: '50',
            renderHeader: (h, scope) => {
              return <div> {
54
                !this.disabled ? '序号' : <i class="el-icon-plus pointer" onClick={() => { this.addClick() }}></i>
55 56 57 58 59 60 61
              }
              </div>
            },
            render: (h, scope) => {
              return (
                <div>
                  {
62
                    !this.disabled ? <span>{scope.$index + 1}</span> :
63 64 65 66
                      <i class="el-icon-minus pointer" onClick={() => { this.deleClick(scope.$index, scope.row) }}></i>
                  }
                </div>
              )
任超 committed
67
            }
liangyifan committed
68
          },
69 70 71 72 73 74 75
          {
            label: '身份证读卡器',
            align: 'center',
            render: (h, scope) => {
              return <el-button type="text" icon="el-icon-tickets" disabled={!this.disabled} onClick={() => { this.readClick(scope.row) }}>读取</el-button>
            }
          },
76 77 78 79 80 81 82 83 84 85 86
          {
            prop: "sqrmc",
            label: "姓名/名称"
          },
          {
            prop: "zjzl",
            label: "证件种类",
            render: (h, scope) => {
              return this.dictData['A30'] && this.dictData['A30'].map(option => {
                if (option.dcode == scope.row.zjzl) {
                  return <span>{option.dname}</span>
任超 committed
87
                }
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
              })
            }
          },
          {
            prop: "zjh",
            label: "证件号"
          },
          {
            prop: "dh",
            label: "联系电话"
          },
          {
            label: '操作',
            render: (h, scope) => {
              return (
                <div>
                  {
105 106
                    this.disabled ? <el-button
                      icon="el-icon-edit-outline"
107
                      type="text"
108 109
                      onClick={() => { this.editClick(scope.$index, scope.row) }}>编辑</el-button> : <el-button
                        icon="el-icon-view"
110
                        type="text"
111
                        onClick={() => { this.queryViewClick(scope.$index, scope.row) }} > 查看</el-button>
112 113 114 115
                  }
                </div>
              )
            }
任超 committed
116
          }
117 118 119 120 121 122 123 124 125 126 127 128
        ],
        column: []
      }
    },
    watch: {
      tableData: {
        handler: function (val, oldVal) {
          let that = this
          this.$nextTick(() => {
            if (val.length == 0 || !val) {
            } else {
              that.tableDataList = _.cloneDeep(val)
129
              that.key++
130 131
            }
          })
任超 committed
132
        },
133 134 135 136 137 138 139 140
        immediate: true,
        deep: true
      },
      gyfs: {
        handler (newVal, oldValue) {
          let dataList = _.cloneDeep(this.InformationTable)
          if (newVal == 0) {
            this.column = _.cloneDeep(dataList)
141
            this.tableDataList = _.cloneDeep(this.tableData)
142
            this.key++
143 144 145 146 147 148
          } else if ((newVal == '1' || newVal == '3')) {
            this.column = dataList
          } else {
            this.column = _.cloneDeep(dataList)
            this.column.splice(
              2, 0, {
149
              prop: "qlbl",
150
              label: "份数"
任超 committed
151 152
            })
          }
任超 committed
153
        },
154 155 156 157
        immediate: true
      }
    },
    methods: {
yuanbo committed
158 159 160 161 162
      /**
       * @description: handleupdateDetail
       * @param {*} value
       * @author: renchao
       */
163
      handleupdateDetail (value) {
164
        let that = this
165
        let arr = this.tableData.map(item => item.zjh)
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
        // if (this.isaddupdate) {
        //   if (!arr.includes(value.zjh)) {
        //     this.tableDataList[this.tableDataList.length] = _.cloneDeep(value);
        //     this.$emit('upDateQlrxxList', this.tableDataList)
        //   } else {
        //     setTimeout(() => {
        //       that.$message.error('证件号不能重复')
        //     }, 1500)
        //   }
        // } else {
        //   if (!arr.includes(value.zjh) || this.tableData[this.dataIndex].zjh == value.zjh) {
        //     this.tableDataList[this.dataIndex] = _.cloneDeep(value);
        //     this.$emit('upDateQlrxxList', this.tableDataList)
        //   } else {
        //     setTimeout(() => {
        //       that.$message.error('证件号不能重复')
        //     }, 1500)
        //   }
        // }

186
        if (this.isaddupdate) {
187
          if (!_.isEqual(value, this.tableData)) {
188
            this.tableDataList[this.tableDataList.length] = _.cloneDeep(value);
189
            this.$emit("upDateQlrxxList", this.tableDataList);
任超 committed
190
          }
191
        } else {
192
          if (!_.isEqual(value, this.tableData)) {
193
            this.tableDataList[this.dataIndex] = _.cloneDeep(value);
194
            this.$emit("upDateQlrxxList", this.tableDataList);
任超 committed
195
          }
196 197
        }
        this.key++
liangyifan committed
198
      },
yuanbo committed
199 200 201 202
      /**
       * @description: 新增
       * @author: renchao
       */
203 204 205
      addClick () {
        if (this.gyfs == '0' && this.tableDataList.length > 0) {
          this.$message.warning("当前共有方式为单独所有,无法添加多个权利人")
任超 committed
206
        } else {
207
          this.key++
208 209 210 211 212 213 214 215
          this.details = {
            sqrmc: '',
            zjzl: '1',
            zjh: '',
            xb: '',
            txdz: '',
            fzjg: ''
          }
216 217
          this.dialog = true
          this.isaddupdate = true
任超 committed
218 219
        }
      },
220

yuanbo committed
221 222 223 224 225 226
      /**
       * @description: 删除
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
227
      deleClick (index, row) {
228 229
        this.tableDataList.splice(index, 1)
        this.$emit('upDateQlrxxList', this.tableDataList)
230
        this.key++
231
      },
yuanbo committed
232 233 234 235 236
      /**
       * @description: 身份证读取
       * @param {*} row
       * @author: renchao
       */
237
      readClick (row) {
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        function getObjectByValue (arrayOfObjects, value) {
          var name = ''
          arrayOfObjects.forEach(item => {
            if (item.dname.includes(value)) name = item.dcode
          })
          return name
        }
        getIdCardInfo(this.BASE_API.gaopaiyi).then(res => {
          if (this.BASE_API.gaopaiyi == 'jy') {
            const {
              Name,
              IdNo,
              Sex,
              Address,
              Agencvy,
              PhotoB64
            } = JSON.parse(res)
255 256 257 258 259 260 261 262
            if (Name != '') {
              row.sqrmc = Name;
              row.zjzl = '1';
              row.zjh = IdNo;
              row.xb = getObjectByValue(this.dictData['A43'], Sex);
              row.txdz = Address;
              row.fzjg = Agencvy;
              row.avatar = 'data:image/png;base64,' + PhotoB64
263 264 265 266 267 268
              this.$message({
                message: '读取成功!',
                type: 'success'
              })
            } else {
              this.$message({
269
                message: '请放置身份证',
270 271 272
                type: 'warning'
              })
            }
273
          } else {
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
            if (res.data.code == 0) {
              let data = res.data.IDCardInfo;
              const {
                name,
                cardID: zjh,
                sexCode: xb,
                address: txdz,
                issueOrgan: fzjg,
                photoBase64
              } = data
              row.sqrmc = name;
              row.zjzl = '1';
              row.zjh = zjh;
              row.xb = xb
              row.txdz = txdz;
              row.fzjg = fzjg;
              row.avatar = 'data:image/png;base64,' + photoBase64
              this.$message({
                message: '读取成功!',
                type: 'success'
              })
            } else {
              this.$message({
                message: res.data.message,
                type: 'warning'
              })
            }
renchao@pashanhoo.com committed
301
          }
302
          this.$emit('upDateQlrxxList', this.tableDataList)
303 304
        })
      },
yuanbo committed
305 306 307 308 309 310
      /**
       * @description: 修改
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
311
      editClick (index, row) {
xiaomiao committed
312
        this.details = row
313
        this.details.gyfs = this.gyfs
314 315
        this.dataIndex = index
        this.dialog = true
xiaomiao committed
316 317


318 319
        this.isaddupdate = false
      },
yuanbo committed
320 321 322 323 324 325
      /**
       * @description: queryViewClick
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
326 327
      queryViewClick (index, row) {
        this.details = row
xiaomiao committed
328
        this.dialog = true
329
      }
任超 committed
330
    }
liangyifan committed
331
  }
liangyifan committed
332
</script>
333
<style scoped lang="scss">
334 335 336
  /deep/.el-table--small .el-table__cell {
    padding: 0 0 !important;
  }
337 338 339
  /deep/.el-table th {
    height: 30px !important;
  }
340
  /deep/.el-table .cell {
xiaomiao committed
341
    padding-right: 12px;
342 343
  }
</style>