<template>
  <el-dialog
    :visible.sync="visible"
    title="计划提交"
    width="60vw"
    append-to-body
  >
    <div class="main_container">
      <el-descriptions title="" :column="3" size="medium" border>
        <el-descriptions-item>
          <template slot="label"> 计划编号 </template>
          {{ info.code }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 计划类型 </template>
          {{ getDictValue('订单计划类型', info.planType) }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 物料编码</template>
          {{ info.productCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 牌号 </template>
          {{ info.brandNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 型号 </template>
          {{ info.model }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 订单数量 </template>
          {{ info.codeNum }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 生产版本 </template>
          {{ info.produceVersionName }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label"> 工艺路线 </template>
          {{ info.produceRoutingName }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label"> 产品数量 </template>
          {{ info.contractNum }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 产品重量 </template>
          {{ info.sumOrderWeight }} {{  info.newWeightUnit }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 要求生产数量 </template>
          {{ Number(info.requiredFormingNum) }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 要求生产重量 </template>
          {{ info.newSumOrderWeight }} {{  info.newWeightUnit }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 生产完成日期 </template>
          {{ info.reqMoldTime }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label"> 批次号 </template>
          {{ info.batchNo }}
        </el-descriptions-item>

        <el-descriptions-item :span="3">
          <template slot="label"> 计划备注 </template>
          {{ info.notes }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <div slot="footer" class="footer">
      <div>
        <el-button @click="cancel">取消</el-button>
        <el-button @click="submit(2)" type="primary" :loading="loading" v-if="type != 'edit'"
          >提交并发布</el-button
        >
        <el-button type="primary" @click="submit(1)" :loading="loading"
          >提交</el-button
        >
      </div>
    </div>
  </el-dialog>
</template>

<script>
  import { getCode } from '@/api/codeManagement';
  import dictMixins from '@/mixins/dictMixins';
  export default {
    mixins: [dictMixins],
    props: {
      info: Object,
      type: String
    },
    data() {
      return {
        visible: false,
        loading: false,
        tableList: []
      };
    },
    computed: {},
    created() {
      this.requestDict('订单计划类型');
    },
    methods: {
      open() {
        this.visible = true;
        if (this.type != 'edit') {
          this.getPlanCode();
        }
      },
      cancel() {
        this.visible = false;
      },
      async getPlanCode() {
        this.loading = true;
        try {
          const code = await getCode('product_code');
          this.$set(this.info, 'code', code);
        } catch (err) {}
        this.loading = false;
      },
      submit(type) {
        this.$emit('publish', type);
        this.visible = false;
      }
    }
  };
</script>
<style lang="scss" scoped>
  .basic-details-title {
    margin: 10px 0;
  }
</style>
