<template>
  <el-dialog
    title="详情"
    :visible.sync="open"
    width="80%"
    :close-on-click-modal="false"
    @close="handleClose"
  >
    <div class="formContent">
      <Com-table
        ref="table"
        :tableFormat="tableFormat"
        :tableData="tableData"
      ></Com-table>
    </div>
    <span slot="footer">
      <el-button @click="open = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { queryOrgMaterialInfo } from "@/api/home";
import { commodityStockNumDetail } from "../utils/index.json";
export default {
  data() {
    return {
      open: false,
      tableFormat: commodityStockNumDetail,
      tableData: [],
      currentRow: {},
    };
  },
  methods: {
    handleInit({ data }) {
      this.tableData = [];
      this.currentRow = data;
      this.open = true;
      this.getData()
    },
    getData() {
      let obj = {
        orgNo: this.currentRow.orgNo,
        mtrlDes: this.currentRow.mtrlDes,
        mtrlNo: this.currentRow.mtrlNo,
      };
      queryOrgMaterialInfo(obj).then((res) => {
        if (res && res.code == 200) {
          this.tableData = res.data || [];
        }
      });
    },
    handleClose() {
      this.open = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.formContent {
  height: 500px;
}
::v-deep {
  .el-dialog__footer {
    text-align: center;
  }
}
</style>
