<template>
  <ele-modal
    width="80vw"
    :visible.sync="visible"
    :close-on-click-modal="false"
    row-key="code"
    custom-class="ele-dialog-form"
    :title="'在途详情'"
    :maxable="true"
  >
    <div class="form-wrapper">
      <el-form ref="form" :model="form" :rules="rules">
        <ele-pro-table
          ref="table"
          :needPage="true"
          :columns="columns"
          :datasource="datasource"
          :init-load="false"
        >
          <template v-slot:action="{ $index }">
            <el-link type="primary" :underline="false" icon="el-icon-view">
              库存
            </el-link>
            <el-link type="primary" :underline="false" icon="el-icon-view">
              在途
            </el-link>
          </template>
        </ele-pro-table>
      </el-form>
    </div>
    <div slot="footer">
      <el-button plain @click="cancel">取消</el-button>
      <el-button type="primary" @click="confirm">确定</el-button>
    </div>
  </ele-modal>
</template>

<script>
  import { getCurrentList } from '@/api/beEntrusted';
  export default {
    components: {},
    data() {
      return {
        visible: false,

        formData: {},
        requestData: {
          deviceCode: '',
          deviceName: '',
          deviceId: ''
        },
        requiredFormingNum: 0,

        form: {
          currentList: []
        },

        rules: {},

        columns: [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true
          },
          {
            prop: 'orderNo',
            label: '订单号',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'productCode',
            label: '产品编码',
            align: 'center',
            minWidth: 100
          },
          {
            prop: 'productName',
            label: '产品名称',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'totalCount',
            label: '采购数量',
            align: 'center',
            minWidth: 100
          },
          // {
          //   prop: 'receiveNo',
          //   label: '发货单号',
          //   align: 'center',
          //   minWidth: 80
          // },
          {
            prop: 'ztNumber',
            label: '在途数量',
            align: 'center',
            minWidth: 80
          }
          // {
          //   prop: 'deliveryDeadline',
          //   label: '预计交期时间',
          //   align: 'center',
          //   minWidth: 80
          // }
        ]
      };
    },
    methods: {
      reload(where) {
        this.$nextTick(() => {
          this.$refs.table.reload({ page: 1, where });
        });
      },
      /* 表格数据源 */
      datasource({ page, limit, where }) {
        return getCurrentList({
          pageNum: page,
          size: limit,
          ...where
        });
      },
      open(row) {
        this.visible = true;
        this.reload({ code: row.bomCode });
      },
      cancel() {
        this.formData = {};
        this.visible = false;
      },

      confirm() {
        this.visible = false;
      }
    }
  };
</script>

<style lang="scss" scoped>
  .mt20 {
    margin-top: 20px;
  }

  .el-form-item {
    margin-bottom: 0 !important;
  }
</style>
