<template>
  <div>
    <el-dialog
      title="选择销售订单"
      :visible.sync="dialogVisible"
      width="60%"
      :before-close="handleClose"
    >
      <div class="main">
        <ele-pro-table
          ref="table"
          :initLoad="false"
          :columns="columns"
          :current.sync="current"
          highlight-current-row
          :datasource="tableData"
          tool-class="ele-toolbar-form"
          cache-key="systemOrgUserTable"
          @row-click="chooseRow"
        >
          <!-- 表头工具栏 -->
          <template v-slot:docNo="{ row }">
            <!-- @click="details(row)" -->
            <el-link
              type="primary"
              @click="pickOrderEdit(row)"
              :underline="false"
            >
              {{ row.docNo }}
            </el-link>
          </template>
          <template v-slot:replied="{ row }">
            {{ row.replied == 1 ? '是' : '否' }}
          </template>
          <template v-slot:reviewStatus="{ row }">
            <span v-if="row.reviewStatus == 0">未提交</span>
            <span v-if="row.reviewStatus == 1">审核中</span>
            <span v-if="row.reviewStatus == 2">审核通过</span>
            <span v-if="row.reviewStatus == 3">审核未通过</span>
          </template>
          <template v-slot:action="{ row }">
            <el-radio class="radio" v-model="radio" :label="row.id"
              ><i></i
            ></el-radio>
          </template>
        </ele-pro-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>

    <eomEdit ref="eomEditRef" />
  </div>
</template>

<script>
  import { saleordersendrecordPage } from '@/api/mes';
  import eomEdit from './eomEdit.vue';
  export default {
    components: { eomEdit },
    data() {
      return {
        dialogVisible: false,
        pages: {
          pageNum: 1,
          size: 10
        },
        total: 0,
        tableData: [],
        current: {},
        radio: null,
        columns: [
          {
            columnKey: 'index',
            type: 'index',
            width: 80,
            label: '序号',
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },
          {
            prop: 'docNo',
            label: '发货编码',
            showOverflowTooltip: true,
            slot: 'docNo'
          },
          {
            prop: 'orderNo',
            label: '销售订单编号',
            showOverflowTooltip: true
          },
          {
            prop: 'contactName',
            label: '客户名称',
            showOverflowTooltip: true
          },
          {
            prop: 'replied',
            label: '是否回执',
            showOverflowTooltip: true,
            slot: 'replied'
          },
          {
            prop: 'reviewStatus',
            label: '状态',
            showOverflowTooltip: true,
            slot: 'reviewStatus'
          },
          {
            prop: 'createTime',
            label: '创建时间',
            showOverflowTooltip: true
          },
          {
            columnKey: 'action',
            slot: 'action',
            align: 'center',
            fixed: 'right',
            width: 50
          }
        ]
      };
    },
    methods: {
      pickOrderEdit(row) {
        this.$refs.eomEditRef.open(row);
      },
      handleMine() {
        // const current = this.current.orderInfoList;
        // for (const key in current) {
        //   if (
        //     current[key].bomDetailDTOS.length == 0 &&
        //     current[key].instanceList.length == 0
        //   ) {
        //     this.$message.warning('当前领料单数据为空');
        //     return;
        //   }
        // }
        console.log('sacnmmmmmm=', this.current);
        this.$emit('success', this.current);
        this.dialogVisible = false;
      },
      async open() {
        this.dialogVisible = true;
        const res = await saleordersendrecordPage(this.pages);
        console.log(res);
        this.tableData = res.data.list;
        this.total = res.data.count;
      },
      chooseRow(row) {
        this.current = row;
        this.radio = row.id;
      },
      handleClose(done) {
        this.dialogVisible = false;
      }
    }
  };
</script>
