<template>
  <div>
    <el-table
      :data="tableData"
      :key="tablenum"
      ref="addStore"
      @selection-change="handleSelectionChangeStoreAdd"
      :row-class-name="rowHideFn">
      <el-table-column type="selection" width="55" align="center" :selectable="selected" />
      <el-table-column
        label="接收名称"
        align="center"
        prop="receiveName"
        :show-overflow-tooltip="true" />
      <el-table-column
        label="接收编号"
        align="center"
        prop="receiveCode"
        :show-overflow-tooltip="true" />
      <el-table-column label="接收数量" align="center" prop="grantNum">
        <template slot-scope="scope">
          <el-input
            v-model="scope.row.grantNum"
            type="number"
            :min="1"
            :step="1"
            size="mini"
            style="width: 70px"></el-input>
        </template>
        <!-- @input="extendOnInput(scope.$index)" -->
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        width="80">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-delete" size="mini">
            <span @click="handleDeleteTableItem(scope.row)">删除</span>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
      tablenum: 1,
      statusOptions2: [],
    };
  },
  watch: {
    tableData(val) {
      // debugger;
    },
  },
  created() {
    this.getDicts("sign_status").then((response) => {
      this.statusOptions2 = response.data;
    });
  },
  methods: {
    selected(row, index) {
      if (row.statue == "3") {
        return false; //不可勾选
      } else {
        return true; //可勾选
      }
    },
    rowHideFn({ row, rowIndex }) {
      if (row.isHide == true) {
        return "hideRow";
      } else {
        return;
      }
    },
    handleSelectionChangeStoreAdd(selection) {
      this.$emit("selectChange", selection);
    },

    receiveNumInput(index, code, Deptname) {},
    extendOnInput(index) {
      // this.storeListAdd[index].extend = this.storeListAdd[index].extend.replace(/[^\d.]/g,'');
      this.storeListAdd[index].extend = /^[0-9]*$/.test(parseInt(this.storeListAdd[index].extend))
        ? String(parseInt(this.storeListAdd[index].extend)).replace(".", "")
        : "";
      this.$forceUpdate();
    },
    /** 删除按钮操作 */
    handleDeleteTableItem(row) {
      this.$confirm("是否确认删除数据?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$emit("deleteTableData", row.receiveCode);
        this.$forceUpdate();
      });
    },
  },
};
</script>
<style scoped lang="scss"></style>
