<template>
  <div class="form-page" v-loading="loading">
    <PageTitle>
      {{ pageTitle }}
      <!-- 申请按钮显示 -->
      <template slot="buttons" v-if="mode == 'apply'">
        <el-button size="mini" @click="resetForm">重置</el-button>
        <el-button size="mini" type="primary" @click="saveForm">提交</el-button>
      </template>

      <!-- 修改 按钮显示 -->
      <template slot="buttons" v-if="mode == 'edit'">
        <el-button size="mini" type="primary" @click="saveForm">提交</el-button>
      </template>
    </PageTitle>

    <PageWrapper>
      <el-form
        class="page-form"
        :model="form"
        ref="form"
        size="small"
        :inline="true"
        label-width="8em"
      >
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="制作单编码" prop="prototypeMakeCode">
              <el-input
                disabled
                v-model="form.prototypeMakeCode"
                placeholder="自动生成"
              ></el-input>
            </el-form-item>
          </el-col>

          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="申请单编码" prop="prototypeRequestCode">
              <el-input
                v-model="form.prototypeRequestCode"
                readonly
                disabled
                :placeholder="mode == 'edit' ? '' : '请输入申请单编码'"
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12" style="height: 50.5px">
            <el-form-item label="产品" prop="itemId">
              <el-input
                v-model="form.itemName"
                readonly
                disabled
                :placeholder="mode == 'edit' ? '' : '请选择产品'"
              />
              <!-- <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="$refs['ItemSelectRef'].showFlag = true"
                ></el-button>
              </el-input>
              <ItemSelect ref="ItemSelectRef" @onSelected="onItemSelect" />-->
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12" style="height: 50.5px">
            <el-form-item label="工艺路线" prop="routeId">
              <el-input
                v-model="form.routeName"
                readonly
                disabled
                :placeholder="mode == 'edit' ? '' : '请选择工艺路线'"
              />
              <!-- <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="$refs['RoutesProcessSelectRef'].showFlag = true"
                ></el-button>
              </el-input>
              <RoutesProcessSelect
                ref="RoutesProcessSelectRef"
                @onSelected="onRoutesProcessSelect"
              /> -->
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="简称" prop="abbreviation">
              <el-input
                v-model="form.abbreviation"
                disabled
                :placeholder="mode == 'edit' ? '' : '请输入简称'"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="样品英文名" prop="enName">
              <el-input
                v-model="form.enName"
                readonly
                :placeholder="mode == 'edit' ? '' : '请输入样品英文名称'"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="样品数量" prop="num">
              <el-input
                v-model="form.num"
                :placeholder="mode == 'edit' ? '' : '请输入样品数量'"
                disabled
              >
                <template slot="suffix">{{ form.unit }}</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="打样形式" prop="type">
              <el-input
                v-model="form.type"
                :placeholder="mode == 'edit' ? '' : '请选择打样形式'"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="分配方式" prop="modality">
              <el-input
                v-model="form.modality"
                :placeholder="mode == 'edit' ? '' : '请选择分配方式'"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="表面处理" prop="surfaceTreatment">
              <el-input
                v-model="form.surfaceTreatment"
                :placeholder="mode == 'edit' ? '' : '请输入表面处理'"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="NG原因" prop="ngReason">
              <el-input
                v-model="form.ngReason"
                placeholder="请输入NG原因"
                disabled
              ></el-input>
            </el-form-item>
          </el-col> -->
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="计划完成日期" prop="plannedFinishDate">
              <el-date-picker
                value-format="yyyy-MM-dd"
                v-model="form.plannedFinishDate"
                :placeholder="mode == 'edit' ? '' : '请输入计划完成日期'"
                disabled
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="版面需求时间" prop="plannedLayoutDate">
              <el-date-picker
                value-format="yyyy-MM-dd"
                v-model="form.plannedLayoutDate"
                :placeholder="mode == 'edit' ? '' : '请输入版面需求时间'"
                disabled
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="测试标准" prop="testStandard">
              <el-input
                v-model="form.testStandard"
                :placeholder="mode == 'edit' ? '' : '测试标准'"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="网版目数" prop="screenItem">
              <el-input
                v-model="form.screenItem"
                placeholder="请输入网版目数"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="啤版目数" prop="pibanItem">
              <el-input v-model="form.pibanItem" placeholder="请输入啤版目数" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="模切版目数" prop="diecuttingItem">
              <el-input
                v-model="form.diecuttingItem"
                placeholder="请输入模切版目数"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="标准色号" prop="standardColor">
              <el-input
                v-model="form.standardColor"
                placeholder="请输入标准色号"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="模数" prop="module">
              <el-input v-model="form.module" placeholder="请输入模数" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="列" prop="colNum">
              <el-input v-model="form.colNum" placeholder="请输入列" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="行" prop="rowNum">
              <el-input v-model="form.rowNum" placeholder="请输入行" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="搭板数" prop="buttstrapNum">
              <el-input
                v-model="form.buttstrapNum"
                placeholder="请输入搭板数"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="列双刀位" prop="coldoubleCutspacing">
              <el-input
                v-model="form.coldoubleCutspacing"
                placeholder="请输入列双刀位"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="行双刀位" prop="rowdoubleCutspacing">
              <el-input
                v-model="form.rowdoubleCutspacing"
                placeholder="请输入行双刀位"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="派工倍数" prop="sendworkMultiple">
              <el-input
                v-model="form.sendworkMultiple"
                placeholder="请输入派工倍数"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="印张长度" prop="printingPaperlenth">
              <el-input
                v-model="form.printingPaperlenth"
                placeholder="请输入印张长度"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="印张宽度" prop="printPaperwidth">
              <el-input
                v-model="form.printPaperwidth"
                placeholder="请输入印张宽度"
              />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="印刷正面颜色" prop="frontColorId">
              <el-input
                v-model="form.frontColorName"
                readonly
                placeholder="请输入印刷正面颜色"
              >
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="$refs['colorFrontSelect'].showFlag = true"
                ></el-button>
              </el-input>
              <ColorSelect
                ref="colorFrontSelect"
                @onSelected="onColorFrontSelected"
              >
              </ColorSelect>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="印刷反面颜色" prop="oppositeColorId">
              <el-input
                v-model="form.oppositeColorName"
                readonly
                placeholder="请输入印刷反面颜色"
              >
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="$refs['colorOppositeSelect'].showFlag = true"
                ></el-button>
              </el-input>
              <ColorSelect
                ref="colorOppositeSelect"
                @onSelected="onColorOppositeSelected"
              >
              </ColorSelect>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="长度cm" prop="length">
              <el-input v-model="form.length" type="number" :precision="2" placeholder="请输入长度" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="宽度cm" prop="width">
              <el-input v-model="form.width" type="number" :precision="2" placeholder="请输入宽度" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="高度cm" prop="height">
              <el-input v-model="form.height" type="number" :precision="2" placeholder="请输入高度" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="厚度mm" prop="thick">
              <el-input v-model="form.thick" type="number" :precision="2" placeholder="请输入厚度" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="成品克重g" prop="weight">
              <el-input v-model="form.weight" type="number" :precision="2" placeholder="请输入成品克重" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="单重(KG)" prop="singleWeight">
              <el-input v-model="form.singleWeight" type="number" :precision="2" placeholder="请输入单重" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="圆角" prop="fillet">
              <el-input v-model="form.fillet" type="number" :precision="2" placeholder="请输入圆角" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="是否异型" prop="fillet">
              <el-radio-group v-model="form.isAllotype" >
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item :lg="6" :md="8" :sm="12" :xs="12" label="是否直角" prop="isRightAngle">
              <el-radio-group v-model="form.isRightAngle">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="角度(mm)" prop="angle">
              <el-input v-model="form.angle" type="number" :precision="2" placeholder="请输入角度" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="孔径(mm)" prop="aperture">
              <el-input v-model="form.aperture" type="number" :precision="2" placeholder="请输入孔径" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="单层厚(丝)" prop="singleLayerThick">
              <el-input v-model="form.singleLayerThick" type="number" :precision="2" placeholder="请输入单层厚(单位丝)" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="层数" prop="layerNum">
              <el-input v-model="form.layerNum" type="number" :precision="2" placeholder="请输入层数" />
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="是否防霉" prop="isMould">
              <el-radio-group v-model="form.isMould" >
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="是否写码" prop="isCoding">
              <el-radio-group v-model="form.isCoding" >
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="体系认证" prop="certification">
              <el-input v-model="form.certification" placeholder="请输入体系认证" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="样品形状" prop="shape">
              <el-select v-model="form.shape" placeholder="请选择样品形状">
                <el-option
                  v-for="dict in dict.type.product_shape"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="样品形状大小" prop="shapeSize">
              <el-input v-model="form.shapeSize" type="number" :precision="4" placeholder="请输入样品形状大小" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="备注" prop="remark">
              <el-input
                type="textarea"
                :rows="3"
                v-model="form.remark"
                placeholder="备注"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="产品正面" prop="frontImg">
              <ImageUpload
                :limit="1"
                :value="form.frontImg"
                :fileSize="5"
                @onUploaded="handleFrontImgUploaded"
                @onRemoved="handleFrontImgRemoved"
              ></ImageUpload>
            </el-form-item>
          </el-col>
          <el-col :lg="6" :md="8" :sm="12" :xs="12">
            <el-form-item label="产品背面" prop="backImg">
              <ImageUpload
                :limit="1"
                :value="form.backImg"
                :fileSize="5"
                @onUploaded="handleBackImgUploaded"
                @onRemoved="handleBackImgRemoved"
              ></ImageUpload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-tabs type="border-card" @tab-click="tabClick">
        <el-tab-pane label="BOM">
          <ProogingBom ref="ProogingBomRef" />
        </el-tab-pane>
        <el-tab-pane label="工艺">
          <ProogingProcess ref="ProogingProcessRef" :bomList="bomList" />
        </el-tab-pane>
      </el-tabs>
    </PageWrapper>
  </div>
</template>

<script>
import { genCode } from "@/api/system/autocode/rule";
import ProogingBom from "./components/ProogingBom.vue";
import ProogingProcess from "./components/ProogingProcess.vue";
import ItemSelect from "@/components/itemSelect/single.vue";
import RoutesProcessSelect from "@/components/routesProcessSelect/index.vue";
import { listRouteprocess } from "@/api/mes/pro/routeprocess";
import tabPlugins from "@/plugins/tab";
import {
  listPrototypeMake,
  getPrototypeMake,
  delPrototypeMake,
  addPrototypeMake,
  updatePrototypeMake,
  dofinish,
} from "@/api/mes/pro/prototypeMake";
import { getPrototypeRequest } from "@/api/mes/pro/prototypeRequest";
import ColorSelect from "@/components/colorSelect/index.vue";

export default {
  components: {
    ProogingBom,
    ProogingProcess,
    ItemSelect,
    RoutesProcessSelect,
    ColorSelect,
  },
  dicts: ["sys_yes_no","product_shape"],
  provide() {
    return {
      mode: this.mode,
    };
  },
  data() {
    return {
      loading: false,
      bomList: [],
      // 表单参数
      form: {
        prototypeRequestCode: "",
        itemId: "",
        itemName: "",
        unit: "",
        routeId: "",
        routeName: "",
        abbreviation: "",
        enName: "",
        num: "",
        type: "",
        modality: "",
        surfaceTreatment: "",
        ngReason: "",
        plannedFinishDate: "",
        plannedLayoutDate: "",
        testStandard: "",
        remark: "",
        prototypeMakeId: null,
        prototypeMakeCode: null,
        prototypeRequestId: null,
        screenItem: null,
        pibanItem: null,
        diecuttingItem: null,
        standardColor: null,
        module: null,
        colNum: null,
        rowNum: null,
        buttstrapNum: null,
        coldoubleCutspacing: null,
        rowdoubleCutspacing: null,
        sendworkMultiple: null,
        printingPaperlenth: null,
        printPaperwidth: null,
        frontColorId: null,
        oppositeColorId: null,
        frontColorName: null,
        oppositeColorName: null,
        length: null,
        width: null,
        height: null,
        thick: null,
        weight: null,
        angleType: null,
        isAllotype:null,
        isRightAngle:null,
        fillet:null,
        angle: null,
        aperture: null,
        singleLayerThick: null,
        singleWeight: null,
        layerNum: null,
        isMould: null,
        isCoding: null,
        certification: null,
        shape: null,
        shapeSize: null,
        frontImg:null,
        backImg:null,
      },
      rules: {},
    };
  },
  computed: {
    scrollHeight() {
      return "calc(100vh - 73px - 83px)";
    },
    mode() {
      return this.$route.path.split("/").at(-1);
    },
    pageTitle() {
      const titles = {
        edit: "样品制作单修改",
        info: "样品制作单查看",
        apply: "样品制作单申请",
      };
      return titles[this.mode];
    },
  },
  created() {
    this.getFormInfo();
    if (this.mode == "apply") {
      this.gCode();
    }
  },
  methods: {
    /** 根据 id 获取页面数据 */
    getFormInfo() {
      if (this.mode == "apply") {
        const id = this.$route.query.prototypeRequestId;
        this.loading = true;
        getPrototypeRequest(id)
          .then(({ data }) => {
            Object.assign(this.form, data);
            this.bomList = data.bomList;
            this.itemId = data.itemId;
            // 设置组件数据
            this.$refs["ProogingBomRef"].tableData = data.bomList;
            this.$refs["ProogingProcessRef"].tableData = data.processList;
          })
          .finally(() => {
            this.loading = false;
          });
      } else {
        const id = this.$route.query.prototypeMakeId;
        this.loading = true;
        getPrototypeMake(id)
          .then(({ data }) => {
            Object.assign(this.form, data);
            this.bomList = data.bomList;
            // 设置组件数据
            this.$refs["ProogingBomRef"].tableData = data.bomList;
            this.$refs["ProogingProcessRef"].tableData = data.processList;
            this.prototypeRequestId = data.prototypeRequestId;
            getPrototypeRequest(prototypeRequestId).then(({ data }) => {
              Object.assign(this.form, data);
            });
          })
          .finally(() => {
            this.loading = false;
          });
      }
    },
    /** 生成编码 */
    gCode() {
      genCode("PROTOTYPE_MAKE_CODE").then((response) => {
        this.form.prototypeMakeCode = response;
      });
    },
    /** 点击tab 获取bom的数据,将参数传递给后面的组件 */
    tabClick(val) {
      if (val.index != 0) {
        this.bomList = this.$refs["ProogingBomRef"].getComData();
      }
    },
    onItemSelect(row) {
      if (row != undefined && row != null) {
        this.form.itemId = row.itemId;
        this.form.itemName = row.itemName;
        this.form.unit = row.unitOfMeasure;
      }
    },
    onRoutesProcessSelect(row) {
      if (row != undefined && row != null) {
        this.form.routeId = row.routeId;
        this.form.routeName = row.routeName;

        const params = {
          pageNum: 1,
          pageSize: 1000,
          routeId: row.routeId,
        };
        listRouteprocess(params).then(({ rows }) => {
          this.$refs["ProogingProcessRef"].setList(rows);
        });
      }
    },
    /**提交 */
    saveForm() {
      const bomList = this.$refs.ProogingBomRef.getComData();
      const processList = this.$refs.ProogingProcessRef.getComData();
      const params = {
        ...this.form,
        bomList,
        processList,
      };
      this.loading = true;
      if (this.mode == "apply") {
        addPrototypeMake(params)
          .then((res) => {
            this.loading = false;
            this.$modal.msgSuccess("提交成功！");

            this.$nextTick(() => {
              // 关闭页签
              tabPlugins.closeOpenPage();
              this.$router.replace({
                path: '/mes/pro/prototypeMake/query'
              })
            })
          })
          .catch(() => {
            this.loading = false;
          });
      } else {
        updatePrototypeMake(params)
          .then(() => {
            this.loading = false;
            this.$modal.msgSuccess("提交成功！");
          })
          .catch(() => {
            this.loading = false;
          });
      }
    },
    /**重置表单 */
    resetForm() {
      this.form = {
        prototypeRequestCode: "",
        itemId: "",
        itemName: "",
        routeId: "",
        abbreviation: "",
        enName: "",
        num: "",
        type: "",
        modality: "",
        surfaceTreatment: "",
        ngReason: "",
        plannedFinishDate: "",
        plannedLayoutDate: "",
        testStandard: "",
        remark: "",
        prototypeMakeId: "",
        prototypeMakeCode: "",
        prototypeRequestId: "",
        screenItem: "",
        pibanItem: "",
        diecuttingItem: "",
        standardColor: "",
        module: "",
        colNum: "",
        rowNum: "",
        buttstrapNum: "",
        coldoubleCutspacing: "",
        rowdoubleCutspacing: "",
        sendworkMultiple: "",
        printingPaperlenth: "",
        printPaperwidth: "",
        frontColorId: "",
        oppositeColorId: "",
        frontColorName: "",
        oppositeColorName: "",
        length: '',
        width: '',
        height: '',
        thick: '',
        weight: '',
        angleType: '',
        isAllotype:'',
        isRightAngle:'',
        fillet:'',
        angle: '',
        aperture: '',
        singleLayerThick: '',
        singleWeight: '',
        layerNum: '',
        isMould: '',
        isCoding: '',
        certification: '',
        shape: '',
        shapeSize: '',
        frontImg:'',
        backImg:'',
      };
      this.$refs["ProogingBomRef"].resetState();
      this.$refs["ProogingProcessRef"].resetState();
      this.gCode();
    },

    onColorFrontSelected(obj) {
      this.form.itemId = this.itemId;
      if (obj != undefined && obj != null) {
        obj.forEach((element) => {
          //this.form.itemId = element.itemId;
          this.form.frontColorId = element.colorId;
          this.form.frontColorName = element.colorName;
          // this.form.face = "front";
          // var retFlag = false;
          // const idx = this.faceColorList.findIndex(
          //   (itm) => itm.colorId == element.colorId
          // );
        });
      }
    },
    onColorOppositeSelected(obj) {
      this.form.itemId = this.itemId;
      if (obj != undefined && obj != null) {
        obj.forEach((element) => {
          //this.form.itemId = element.itemId;
          this.form.oppositeColorId = element.colorId;
          this.form.oppositeColorName = element.colorName;
          // this.form.face = "front";
          //   var retFlag = false;
          //   const idx = this.faceColorList.findIndex(
          //     (itm) => itm.colorId == element.colorId
          //   );
        });
      }
    },
    //图片上传成功
    handleFrontImgUploaded(imgUrl) {
      this.form.frontImg = imgUrl;
    },
    handleBackImgUploaded(imgUrl) {
      this.form.backImg = imgUrl;
    },
    //图片移除
    handleFrontImgRemoved(imgUrl) {
      this.form.frontImg = null;
    },
    handleBackImgRemoved(imgUrl) {
      this.form.backImg = null;
    },
  },
};
</script>

<style lang="scss" scoped></style>
