<template>
  <div>
    <ele-modal
      width="90vw"
      :visible.sync="visible"
      v-if="visible"
      :close-on-click-modal="false"
      row-key="code"
      custom-class="ele-dialog-form"
      :title="'齐套性检查'"
      :maxable="true"
      append-to-body
    >
      <div>
        <div>
          <ele-pro-table
            ref="table"
            :needPage="false"
            :columns="columns"
            :datasource="datasourceList"
            row-key="code"
            :cache-key="`ProductionPlanTable`"
            border
            height="40vh"
            key="id"
          >
            <template v-slot:availableCountBase="{ row }">
              <span> {{ row.availableCountBase }}{{ row.measuringUnit }} </span>
            </template>

            <template v-slot:baseCount="{ row }">
              <span> {{ row.baseCount }}{{ row.measuringUnit }} </span>
            </template>

            <template v-slot:count="{ row }">
              <span> {{ row.count }}{{ row.measuringUnit }} </span>
            </template>

            <template v-slot:demandQuantity="{ row }">
              <span> {{ row.demandQuantity }}{{ row.measuringUnit }} </span>
            </template>
          </ele-pro-table>
        </div>
      </div>
      <div slot="footer">
        <el-button plain @click="cancel">取消</el-button>
      </div>
    </ele-modal>

    <!-- <stockDetailDialog ref="stockDetailDialog" />
    <currentDetailDialog ref="currentDetailDialog" />
    <purchaseDialog ref="purchaseDialogRef" :orderType="2" @success="success" />
    <factoryAdd
      ref="factoryAddRef"
      :isAdd="false"
      :factoryType="3"
      @close="factoryClose"
    ></factoryAdd> -->
  </div>
</template>

<script>
  import {
    findMaterialInfoByPlanId,
    findAssistMaterialInfoByPlanId,
    bomVersionList,
    listBomType,
    getProductKitting
  } from '@/api/productionPlan/index.js';
  import factoryAdd from './factoryAdd';
  import stockDetailDialog from './stockDetailDialog.vue';
  import currentDetailDialog from './currentDetailDialog.vue';
  import producePlan from '@/views/materialPlan/components/producePlan.vue';
  import purchaseDialog from './purchaseDialog.vue';
  import { issueProductionPlan } from '@/api/productionPlan/index.js';
  export default {
    components: {
      stockDetailDialog,
      currentDetailDialog,
      producePlan,
      purchaseDialog,
      factoryAdd
    },
    computed: {
      fieldShow() {
        return this.produceType != 2 && this.quota_calculation === 2;
      },
      columns() {
        return [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            fixed: 'left'
          },

          {
            prop: 'categoryCode',
            label: '物品编码',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'categoryName',
            label: '物品名称',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'availableCountBase',
            slot: 'availableCountBase',
            label: '库存数量',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },

          {
            prop: 'baseCount',
            slot: 'baseCount',
            label: '基础数量',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'demandQuantity',
            slot: 'demandQuantity',
            label: '定额数量',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          },
          {
            prop: 'count',
            slot: 'count',
            label: '数量',
            align: 'center',
            minWidth: 100,
            showOverflowTooltip: true
          }
        ];
      }
    },
    data() {
      return {
        visible: false,
        datasourceList: []
      };
    },
    watch: {
      leftShow(newVal, oldVal) {
        if (newVal) {
          this.leftWidth = '230px';
          this.rightWidth = 'calc(100% - 240px)';
        } else {
          this.leftWidth = '0';
          this.rightWidth = '100%';
        }
      }
    },
    mounted() {},
    methods: {
      async open(itemDataList) {
        this.visible = true;
        console.log('itemDataList', itemDataList);
        this.datasourceList = itemDataList;
        console.log('datasourceList', this.datasourceList);
      },

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

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

  .el-form-item {
    margin-bottom: 0 !important;
  }
  .optionButton {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 3px;
  }
  .statusRed {
    color: red;
    :deep(.el-input__inner) {
      color: red;
    }
  }

  .statusGreen {
    color: green;
    :deep(.el-input__inner) {
      color: green;
    }
  }
  .form-wrapper {
    display: flex;
  }
  .planInfo {
    // display: flex;
    font-size: 16px;
  }
  .plan_form {
    .el-col {
      margin-bottom: 16px;
    }
  }

  .left_tree {
    max-height: 600px;
    min-height: 300px;
    overflow: auto;
    border: 1px solid #ccc;
    margin-right: 10px;
  }

  .tool {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    border-left: 1px solid #ededed;
    border-right: 1px solid #ededed;
  }
</style>
