<template>
  <ele-modal
    :visible.sync="visible"
    title="选择生产版本"
    width="75vw"
    append-to-body
  >
    <ele-pro-table
      ref="table"
      :columns="columns"
      :datasource="datasource"
      :toolbar="false"
      highlight-current-row
      :current.async="current"
    >
      <template v-slot:action="row">
        <el-radio class="radio" v-model="current.id" :label="row.id"
          ><i></i
        ></el-radio>
      </template>
    </ele-pro-table>
    <template v-slot:footer>
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="save" :loading="loading">
        确定
      </el-button>
    </template>
  </ele-modal>
</template>

<script>
  import { versionPage } from '@/api/mainData';
  export default {
    props: {
      productCode: String
    },
    data() {
      return {
        visible: false,
        loading: false,
        radio: '',
        current: {},
        columns: [
          {
            type: 'index',
            label: '序号'
          },
          {
            label: '生产版本',
            prop: 'produceVersionName'
          },
          {
            label: '未完成工单数量',
            prop: 'produceVersionName'
          },
          {
            label: '未完成重量',
            prop: 'produceVersionName'
          },
          // {
          //   label: '预计完成时间',
          //   prop: 'produceVersionName'
          // },
          {
            label: '标准产能',
            prop: 'produceVersionName'
          },
          {
            label: '原料1库存',
            prop: 'produceVersionName'
          },
          {
            label: '原料2库存',
            prop: 'produceVersionName'
          },
          {
            label: '原料3库存',
            prop: 'produceVersionName'
          },
          {
            label: '选择',
            slot: 'action',
            action: 'action'
          }
        ]
      };
    },
    computed: {},
    created() {},
    methods: {
      open() {
        this.visible = true;
      },
      /* 表格数据源 */
      datasource({ page, limit, where }) {
        return versionPage({ pageNum: page, size: limit, ...where });
      },
      cancel() {
        this.visible = false;
        this.radio = '';
        this.current = {};
      },
      /* 保存编辑 */
      save() {
        this.visible = false;
        this.$emit('confirm', this.current);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .basic-details-title {
    margin: 10px 0;
  }
  .add-product {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 30px;
    color: #1890ff;
    margin: 10px 0;
    cursor: pointer;
  }
</style>
