Blame view

src/views/djbworkflow/components/ywrCommonTable.vue 7.14 KB
xiaomiao committed
1 2 3 4 5 6 7
<!--
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-05-17 10:41:20
-->
<template>
  <div>
xiaomiao committed
8 9 10 11 12 13 14 15
    <lb-table
      :column="column"
      :pagination="false"
      :key="key"
      :heightNumSetting="true"
      :minHeight="150"
      :data="tableDataList"
    >
xiaomiao committed
16
    </lb-table>
xiaomiao committed
17 18 19 20 21 22
    <addYwr
      v-model="dialog"
      :details="details"
      :showButton="showButton"
      @updateDetail="handleupdateDetail"
    />
xiaomiao committed
23 24 25
  </div>
</template>
<script>
xiaomiao committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
import addYwr from "./dialog/addYwr.vue";
import { mapGetters } from "vuex";
export default {
  components: {
    addYwr,
  },
  computed: {
    ...mapGetters(["dictData"]),
  },
  props: {
    tableData: {
      type: Array,
      default: function () {
        return [];
      },
xiaomiao committed
41
    },
xiaomiao committed
42 43 44
    ableOperation: {
      type: Boolean,
      default: false,
xiaomiao committed
45
    },
xiaomiao committed
46 47 48
    gyfs: {
      type: String,
      default: "1",
xiaomiao committed
49
    },
xiaomiao committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  },
  data() {
    return {
      key: 0,
      dataIndex: 0,
      dialog: false,
      isaddupdate: false,
      showButton: this.ableOperation,
      details: {},
      tableDataList: [],
      InformationTable: [
        {
          width: "50",
          renderHeader: (h, scope) => {
            return (
              <div>
                {" "}
                {!this.ableOperation ? (
                  "序号"
                ) : (
                  <i
                    class="el-icon-plus pointer"
                    onClick={() => {
                      this.addClick();
                    }}
                  ></i>
                )}
xiaomiao committed
77
              </div>
xiaomiao committed
78
            );
xiaomiao committed
79
          },
xiaomiao committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
          render: (h, scope) => {
            return (
              <div>
                {!this.ableOperation ? (
                  <span>{scope.$index + 1}</span>
                ) : (
                  <i
                    class="el-icon-minus pointer"
                    onClick={() => {
                      this.deleClick(scope.$index, scope.row);
                    }}
                  ></i>
                )}
              </div>
            );
xiaomiao committed
95
          },
xiaomiao committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
        },
        {
          label: "身份证读卡器",
          align: "center",
          render: (h, scope) => {
            return (
              <el-button
                type="text"
                icon="el-icon-tickets"
                disabled={!this.ableOperation}
                onClick={() => {
                  this.readClick(scope);
                }}
              >
                读取
              </el-button>
            );
xiaomiao committed
113
          },
xiaomiao committed
114 115 116 117 118 119 120 121 122 123 124 125
        },
        {
          prop: "ywrmc",
          label: "姓名/名称",
        },
        {
          prop: "zjzl",
          label: "证件种类",
          render: (h, scope) => {
            return (
              this.dictData["A30"] &&
              this.dictData["A30"].map((option) => {
xiaomiao committed
126
                if (option.dcode == scope.row.zjzl) {
xiaomiao committed
127
                  return <span>{option.dname}</span>;
xiaomiao committed
128 129
                }
              })
xiaomiao committed
130
            );
xiaomiao committed
131
          },
xiaomiao committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145
        },
        {
          prop: "zjh",
          label: "证件号",
        },
        {
          prop: "dh",
          label: "联系电话",
        },
        {
          label: "操作",
          render: (h, scope) => {
            return (
              <div>
xiaomiao committed
146
                {!this.showButton? (
xiaomiao committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
                  <el-button
                    icon="el-icon-view"
                    type="text"
                    onClick={() => {
                      this.queryViewClick(scope.$index, scope.row);
                    }}
                    disabled={!this.ableOperation}
                  >
                    {" "}
                    查看
                  </el-button>
                ) : (
                  <el-button
                    icon="el-icon-edit-outline"
                    type="text"
                    onClick={() => {
                      this.editClick(scope.$index, scope.row);
                    }}
                    disabled={!this.ableOperation}
                  >
                    编辑
                  </el-button>
                )}
              </div>
            );
xiaomiao committed
172 173
          },
        },
xiaomiao committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
      ],
      column: [],
    };
  },
  watch: {
    tableData: {
      handler: function (val, oldVal) {
        let that = this;
        this.$nextTick(() => {
          if (val.length == 0 || !val) {
            that.tableDataList = _.cloneDeep([
              {
                ywrmc: "",
                dlrzjlx: "",
                dlrzjh: "",
                fr: "",
              },
            ]);
xiaomiao committed
192
          } else {
xiaomiao committed
193
            that.tableDataList = _.cloneDeep(val);
xiaomiao committed
194
          }
xiaomiao committed
195 196 197 198
        });
      },
      immediate: true,
      deep: true,
xiaomiao committed
199
    },
xiaomiao committed
200 201 202 203 204 205 206 207
    gyfs: {
      handler(newVal, oldValue) {
        let dataList = _.cloneDeep(this.InformationTable);
        if (newVal == 0) {
          // this.column = _.cloneDeep(dataList).slice(1, dataList.length)
          this.column = _.cloneDeep(dataList);
        } else if (newVal == "1" || newVal == "3") {
          this.column = dataList;
xiaomiao committed
208
        } else {
xiaomiao committed
209 210 211 212 213
          this.column = _.cloneDeep(dataList);
          this.column.splice(2, 0, {
            prop: "fs",
            label: "份数",
          });
xiaomiao committed
214 215
        }
      },
xiaomiao committed
216 217 218 219
      immediate: true,
    },
  },
  methods: {
yuanbo committed
220 221 222 223 224
    /**
     * @description: handleupdateDetail
     * @param {*} value
     * @author: renchao
     */
xiaomiao committed
225 226 227 228 229
    handleupdateDetail(value) {
      if (this.isaddupdate) {
        if (!_.isEqual(value, this.tableData)) {
          this.tableDataList[this.tableDataList.length] = _.cloneDeep(value);
          this.$emit("upDateQlrxxList", this.tableDataList);
xiaomiao committed
230
        }
xiaomiao committed
231 232 233 234 235 236 237 238 239
      } else {
        if (!_.isEqual(value, this.tableData)) {
          this.tableDataList[this.dataIndex] = _.cloneDeep(value);
          this.$emit("upDateQlrxxList", this.tableDataList);
        }
      }
      this.key++;
    },
    // 新增
yuanbo committed
240 241 242 243
    /**
     * @description: 新增
     * @author: renchao
     */
xiaomiao committed
244 245 246 247 248 249 250 251
    addClick() {
      if (this.gyfs == "0" && this.tableDataList.length > 0) {
        this.$message.warning("当前共有方式为单独所有,无法添加多个权利人");
      } else {
        this.dialog = true;
        this.isaddupdate = true;
      }
    },
xiaomiao committed
252

xiaomiao committed
253
    // 删除
yuanbo committed
254 255 256 257 258 259
    /**
     * @description: 删除
     * @param {*} index
     * @param {*} row
     * @author: renchao
     */
xiaomiao committed
260 261 262 263 264 265 266 267 268 269 270
    deleClick(index, row) {
      this.$confirm("确定要删除吗, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.tableData.splice(index, 1);
        })
        .catch(() => {});
    },
xiaomiao committed
271

xiaomiao committed
272
    // 身份证读取
yuanbo committed
273 274 275 276
    /**
     * @description: 身份证读取
     * @author: renchao
     */
xiaomiao committed
277
    readClick() {},
xiaomiao committed
278

xiaomiao committed
279
    // 修改
yuanbo committed
280 281 282 283 284 285
    /**
     * @description: 修改
     * @param {*} index
     * @param {*} row
     * @author: renchao
     */
xiaomiao committed
286 287 288 289 290 291
    editClick(index, row) {
      this.dataIndex = index;
      this.dialog = true;
      this.details = row;
      this.isaddupdate = false;
    },
yuanbo committed
292 293 294 295 296 297
    /**
     * @description: queryViewClick
     * @param {*} index
     * @param {*} row
     * @author: renchao
     */
xiaomiao committed
298 299 300 301 302 303
    queryViewClick(index, row) {
      this.dialog = true;
      this.details = row;
    },
  },
};
xiaomiao committed
304
</script>