<template>
  <div>
    <el-dialog
      title="领料单详情"
      :visible.sync="dialogVisible"
      width="60%"
      :before-close="handleClose"
    >
      <div class="main">
        <header-title title="基本信息" size="16px"></header-title>
        <el-row>
          <el-col :offset="2" :span="8">领料单号：{{ orderRow.code }}</el-col>
          <el-col :offset="6" :span="8">状态：{{ orderRow.status }}</el-col>
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >执行人：{{ orderRow.executorName }}</el-col
          >
          <el-col :offset="6" :span="8"
            >执行日期：{{ orderRow.executorTime }}</el-col
          >
        </el-row>
        <header-title title="工单信息" size="16px"></header-title>
        <div v-for="(item, index) in orderRow.orderInfoList" :key="index">
          <el-row>
            <el-col :offset="2" :span="8">工单编号：{{ item.code }}</el-col>
          </el-row>
          <el-table border :data="item.tableData" style="width: 100%">
            <el-table-column
              type="index"
              width="80"
              label="序号"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="rootCategoryLevelName"
              width="120"
              label="物品类型"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="categoryCode"
              label="物品编码"
              width="180"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="categoryName"
              label="物品名称"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="brandNo"
              label="牌号"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="model"
              label="型号"
              width="180"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="specifications"
              label="规格"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="demandQuantity"
              label="需求数量"
              width="120"
              align="center"
            >
            </el-table-column>

            <el-table-column
              prop="unit"
              label="单位"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="warehouseCode"
              label="仓库编码"
              width="120"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="warehouseName"
              label="仓库名称"
              width="120"
              align="center"
            >
            </el-table-column>
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关 闭</el-button>
        <!-- <el-button type="primary" @click="handleMine">确 定</el-button> -->
      </span>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dialogVisible: false,
        orderRow: {}
      };
    },
    methods: {
      handleMine() {},
      open(row) {
        for (const key in row.orderInfoList) {
          row.orderInfoList[key].tableData = [];
          for (const i in row.orderInfoList[key].bomDetailDTOS) {
            row.orderInfoList[key].tableData.push({
              ...row.orderInfoList[key].bomDetailDTOS[i]
            });
          }
          for (const j in row.orderInfoList[key].instanceList) {
            row.orderInfoList[key].tableData.push({
              ...row.orderInfoList[key].instanceList[j]
            });
          }
        }
        this.orderRow = {
          ...row,
          status: row.status == 0 ? '未领料' : '已领料'
        };
        this.dialogVisible = true;
        console.log({ ...row });
      },
      handleClose(done) {
        this.dialogVisible = false;
      }
    }
  };
</script>

<style lang="scss" scoped>
  .el-row {
    margin-bottom: 15px;
    font-size: 14px;
  }
</style>
