Blame view

src/views/workflow/components/qlrCommonTable.vue 7.34 KB
1
<!--
xiaomiao committed
2
 * @Description:
3
 * @Autor: renchao
4
 * @LastEditTime: 2023-09-01 13:35:05
5
-->
liangyifan committed
6 7
<template>
  <div>
8
    <lb-table :column="column" :pagination="false" :key="key" :heightNumSetting="true"
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
        ],
        column: []
      }
    },
    watch: {
      tableData: {
        handler: function (val, oldVal) {
          let that = this
          this.$nextTick(() => {
            if (val.length == 0 || !val) {
127 128 129 130 131 132
              // that.tableDataList = _.cloneDeep([{
              //   sqrmc: '',
              //   dlrzjlx: '',
              //   dlrzjh: '',
              //   fr: ''
              // }])
133 134 135 136
            } else {
              that.tableDataList = _.cloneDeep(val)
            }
          })
任超 committed
137
        },
138 139 140 141 142 143 144 145
        immediate: true,
        deep: true
      },
      gyfs: {
        handler (newVal, oldValue) {
          let dataList = _.cloneDeep(this.InformationTable)
          if (newVal == 0) {
            this.column = _.cloneDeep(dataList)
146
            this.tableDataList = _.cloneDeep(this.tableData)
147 148 149 150 151 152
          } else if ((newVal == '1' || newVal == '3')) {
            this.column = dataList
          } else {
            this.column = _.cloneDeep(dataList)
            this.column.splice(
              2, 0, {
153
              prop: "qlbl",
154
              label: "份数"
任超 committed
155 156
            })
          }
任超 committed
157
        },
158 159 160 161
        immediate: true
      }
    },
    methods: {
yuanbo committed
162 163 164 165 166
      /**
       * @description: handleupdateDetail
       * @param {*} value
       * @author: renchao
       */
167
      handleupdateDetail (value) {
168
        let arr = this.tableData.map(item => item.zjh)
169
        if (this.isaddupdate) {
170
          if (!arr.includes(value.zjh)) {
171 172
            this.tableDataList[this.tableDataList.length] = _.cloneDeep(value);
            this.$emit('upDateQlrxxList', this.tableDataList)
173 174
          } else {
            this.$message.error('证件号不能重复');
任超 committed
175
          }
176
        } else {
177
          if (!arr.includes(value.zjh) || this.tableData[this.dataIndex].zjh == value.zjh) {
178 179
            this.tableDataList[this.dataIndex] = _.cloneDeep(value);
            this.$emit('upDateQlrxxList', this.tableDataList)
180 181
          } else {
            this.$message.error('证件号不能重复');
任超 committed
182
          }
183 184
        }
        this.key++
liangyifan committed
185
      },
yuanbo committed
186 187 188 189
      /**
       * @description: 新增
       * @author: renchao
       */
190 191 192
      addClick () {
        if (this.gyfs == '0' && this.tableDataList.length > 0) {
          this.$message.warning("当前共有方式为单独所有,无法添加多个权利人")
任超 committed
193
        } else {
194 195
          this.key++
          this.details = {}
196 197
          this.dialog = true
          this.isaddupdate = true
任超 committed
198 199
        }
      },
200

yuanbo committed
201 202 203 204 205 206
      /**
       * @description: 删除
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
207
      deleClick (index, row) {
208 209
        this.tableDataList.splice(index, 1)
        this.$emit('upDateQlrxxList', this.tableDataList)
210
      },
yuanbo committed
211 212 213 214 215
      /**
       * @description: 身份证读取
       * @param {*} row
       * @author: renchao
       */
216
      readClick (row) {
217
        getIdCardInfo().then(res => {
218
          if (res.data.code == 0) {
renchao@pashanhoo.com committed
219 220
            let data = res.data.IDCardInfo
            row.sqrmc = data.name
221
            row.zjzl = '1'
renchao@pashanhoo.com committed
222
            row.zjh = data.cardID
223 224 225
            row.xb = data.sexCode
            row.txdz = data.address
            row.fzjg = data.issueOrgan
226 227 228 229 230 231 232 233 234
            this.$message({
              message: '读取成功!',
              type: 'success'
            })
          } else {
            this.$message({
              message: res.data.message,
              type: 'warning'
            })
renchao@pashanhoo.com committed
235
          }
236 237
        })
      },
yuanbo committed
238 239 240 241 242 243
      /**
       * @description: 修改
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
244
      editClick (index, row) {
xiaomiao committed
245
        this.details = row
246
        this.details.gyfs = this.gyfs
247 248
        this.dataIndex = index
        this.dialog = true
xiaomiao committed
249 250


251 252
        this.isaddupdate = false
      },
yuanbo committed
253 254 255 256 257 258
      /**
       * @description: queryViewClick
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
259 260
      queryViewClick (index, row) {
        this.details = row
xiaomiao committed
261
        this.dialog = true
262
      }
任超 committed
263
    }
liangyifan committed
264
  }
liangyifan committed
265
</script>
266 267 268 269
<style scoped lang="scss">
  /deep/.el-table th {
    height: 30px !important;
  }
270
  /deep/.el-table .cell {
xiaomiao committed
271
    padding-right: 12px;
272 273
  }
</style>