<template>
  <div>
    <el-dialog
      title="选择领料单"
      :visible.sync="dialogVisible"
      width="40%"
      :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: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>
  </div>
</template>

<script>
  import { pickOrderPage } from '@/api/mes';
  export default {
    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: 'code',
            label: '领料单号',
            showOverflowTooltip: true
          },
          {
            prop: 'executorName',
            label: '执行人名称',
            showOverflowTooltip: true
          },
          {
            prop: 'executorTime',
            label: '执行日期',
            showOverflowTooltip: true
          },
          {
            prop: 'status',
            label: '领料状态',
            showOverflowTooltip: true
          },
          {
            columnKey: 'action',
            slot: 'action',
            align: 'center',
            fixed: 'right',
            width: 50
          }
        ]
      };
    },
    methods: {
      handleMine() {
        this.$emit('success', this.current);
        this.dialogVisible = false;
      },
      async open() {
        this.dialogVisible = true;
        const res = await pickOrderPage(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) {}
    }
  };
</script>
