<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.contactName }}</el-col
          >
          <el-col :offset="6" :span="8">车牌号：{{ orderRow.carNo }}</el-col>
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >客户联系人：{{ orderRow.linkName }}</el-col
          >
          <el-col :offset="6" :span="8"
            >发货单据编码：{{ orderRow.docNo }}</el-col
          >
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >客户电话：{{ orderRow.linkPhone }}</el-col
          >
          <el-col :offset="6" :span="8"
            >制单人：{{ orderRow.makerName }}</el-col
          >
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >客户地址：{{ orderRow.receiveAddress }}</el-col
          >
          <el-col :offset="6" :span="8"
            >订单编码：{{ orderRow.orderNo }}</el-col
          >
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >发货附件：{{ orderRow.sendFiles }}</el-col
          >
          <el-col :offset="6" :span="8"
            >是否回执：{{ orderRow.replied == 1 ? '是' : '否' }}</el-col
          >
        </el-row>
        <el-row>
          <el-col :offset="2" :span="8"
            >审核状态：{{ status[orderRow.reviewStatus] }}</el-col
          >
        </el-row>
        <header-title title="产品清单" size="16px"></header-title>
        <el-table border :data="orderRow.productList" style="width: 100%">
          <el-table-column type="index" width="80" label="序号" align="center">
          </el-table-column>
          <el-table-column
            prop="productName"
            label="名称"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="productCode"
            label="编码"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="productCategoryName"
            label="类型"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="productBrand"
            label="牌号"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="modelType"
            label="型号"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="specification"
            label="规格"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="totalCount"
            width="120"
            label="数量"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="measuringUnit"
            label="计量单位"
            width="120"
            align="center"
          >
          </el-table-column>
          <!-- <el-table-column
            prop="singlePrice"
            label="单价"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="totalPrice"
            label="销售总金额"
            width="120"
            align="center"
          >
          </el-table-column> -->
          <el-table-column
            prop="deliveryDays"
            label="交期（天）"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="guaranteePeriod"
            label="质保期"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="technicalAnswerName"
            label="技术答疑人"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="technicalParams"
            label="技术参数"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="technicalDrawings"
            label="技术图纸"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="remark"
            label="备注"
            width="120"
            align="center"
          >
          </el-table-column>
        </el-table>
      </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>
  import { getById } from '@/api/mes';
  export default {
    data() {
      return {
        dialogVisible: false,
        orderRow: {},
        status: ['未提交', '待审核', '已审核', '审核未通过']
      };
    },
    methods: {
      handleMine() {},
      async 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 ? '未领料' : '已领料'
        // };
        const data = await getById(row.id);
        console.log('===', data);
        this.orderRow = {
          ...data.data,
          sendFiles: data.data.sendFiles.join(',')
        };
        this.dialogVisible = true;
      },
      handleClose(done) {}
    }
  };
</script>

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