<template>
  <div>
    <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="specificationSheetType">
            <el-select
              v-model="form.specificationSheetType"
              placeholder="请选择分配方式"
            >
              <el-option
                v-for="dict in dict.type.specification_sheet_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
            <!-- <el-radio-group v-model="form.specificationSheetType">
              <el-radio
                v-for="dict in dict.type.specification_sheet_type"
                :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="brandName">
            <el-input v-model="form.brandName" placeholder />
          </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" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="单位" prop="unitOfMeasure"
            ><el-input v-model="form.unitOfMeasure" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="采购单位" prop="purchaseUnit"
            ><el-input v-model="form.purchaseUnit" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="换算值" prop="conversionValue"
            ><el-input v-model="form.conversionValue" placeholder> </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="层数" prop="layerNum"
            ><el-input
              v-model="form.layerNum"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="长度cm" prop="length"
            ><el-input
              v-model="form.length"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="印刷正面颜色" prop="frontColorName"
            ><el-input v-model="form.frontColorName" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="印刷背面颜色" prop="oppositeColorName">
            <el-input v-model="form.oppositeColorName" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="仓库" prop="storePlace">
            <el-input v-model="form.storePlace" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <!-- <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="是否附样品" prop="isAddSimple">
            <el-select
              v-model="form.isAddSimple"
              placeholder="请选择是否附样品"
            >
              <el-option
                v-for="dict in dict.type.sys_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
            <el-radio-group v-model="form.isAddSimple">
              <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="isUniqueCode">
            <el-radio-group v-model="form.isUniqueCode">
              <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="isConsiderColor">
            <!-- <el-select
              v-model="form.isConsiderColor"
              placeholder="请选择是否不考虑型体配色"
            >
              <el-option
                v-for="dict in dict.type.sys_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select> -->
            <el-radio-group v-model="form.isConsiderColor">
              <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">
          <el-form-item label="实物样/参考样" prop="isAddSimple">
            <el-select v-model="form.isAddSimple" disabled>
              <el-option label="无" value="无"></el-option>
              <el-option label="实物样" value="实物样"></el-option>
              <el-option label="参考样" value="参考样"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12">
          <el-form-item label="AI/PDF文档" prop="aiOrPdfDocuments">
            <el-select v-model="form.aiOrPdfDocuments" disabled>
              <el-option label="无" value="无"></el-option>
              <el-option label="AI文档" value="AI文档"></el-option>
              <el-option label="PDF文档" value="PDF文档"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="配方" prop="formula"
            ><el-input v-model="form.formula" placeholder> </el-input>
          </el-form-item>
        </el-col>
        <!-- <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="产品材质" prop="productMaterial"
            ><el-input v-model="form.productMaterial" placeholder> </el-input>
          </el-form-item>
        </el-col> -->
        <!-- <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="打样形式" prop="type">
            <el-select v-model="form.type" placeholder="请选择打样形式">
              <el-option
                v-for="dict in dict.type.pro_proof_form"
                :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="modality">
            <el-select v-model="form.modality" placeholder="请选择分配方式">
              <el-option
                v-for="dict in dict.type.pro_distribution_profing"
                :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="surfaceTreatment"
            ><el-input
              v-model="form.surfaceTreatment"
              placeholder="请输入表面处理"
            ></el-input>
          </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> </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 type="number">
            </el-input>
          </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 type="number">
            </el-input>
          </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 type="number">
            </el-input>
          </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-input>
          </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 type="number">
            </el-input>
          </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 type="number">
            </el-input>
          </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 type="number">
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </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
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <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="角度(mm)" prop="angle">
            <el-input
              v-model="form.angle"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </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"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="是否防霉" prop="isMould">
             <el-select v-model="form.isMould" placeholder="请选择是否防霉">
              <el-option
                v-for="dict in dict.type.sys_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
            <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-select v-model="form.isCoding" placeholder="请选择是否写码">
              <el-option
                v-for="dict in dict.type.sys_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
            <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-input>
          </el-form-item>
        </el-col>
        <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"
              placeholder
              type="number"
              :precision="2"
            ></el-input>
          </el-form-item>
        </el-col> -->

        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="吹膜宽度" prop="blownFilmWidth"
            ><el-input
              v-model="form.blownFilmWidth"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12"
          ><el-form-item label="吹膜厚度" prop="blownFilmThickness"
            ><el-input
              v-model="form.blownFilmThickness"
              placeholder
              type="number"
              :precision="2"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="印刷宽度" prop="printingWidth">
            <el-input
              v-model="form.printingWidth"
              placeholder
              type="number"
              :precision="2"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="Inlay" prop="inlay">
            <el-input v-model="form.inlay" placeholder />
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="产品材质" prop="productMaterial">
            <el-input v-model="form.productMaterial" placeholder />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col :span="23">
          <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 :md="8" :xs="12">
          <el-form-item label="产品正面" prop="frontImg">
            <ImageUpload
              :limit="1"
              :value="form.frontImg"
              fieldName="frontImg"
              :fileSize="5"
              @onUploaded="handleImgUploaded"
              @onRemoved="handleImgRemoved"
            ></ImageUpload>
          </el-form-item>
        </el-col>
        <el-col :md="8" :xs="12">
          <el-form-item label="产品背面" prop="backImg">
            <ImageUpload
              :limit="1"
              :value="form.backImg"
              fieldName="backImg"
              :fileSize="5"
              @onUploaded="handleImgUploaded"
              @onRemoved="handleImgRemoved"
            ></ImageUpload>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="客户确认人" prop="customerConfirmedBy">
            <el-input v-model="form.customerConfirmedBy" placeholder></el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="客户确认日期" prop="customerConfirmedDate">
            <el-input
              v-model="form.customerConfirmedDate"
              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="rdApprovedBy">
            <el-input v-model="form.rdApprovedBy" placeholder></el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="研发审核人" prop="rdReviewedBy">
            <el-input v-model="form.rdReviewedBy" placeholder></el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="8" :sm="12" :xs="12">
          <el-form-item label="研发制定人" prop="rdPreparedBy">
            <el-input v-model="form.rdPreparedBy" placeholder></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
// import ItemBomSelect from "@/components/itemBomSelect/single.vue";
// import ProcessProd from "./ProcessProd.vue";
// import ProcessQcindex from "./ProcessQcindex.vue";
// import ProcessTool from "./ProcessTool.vue";
// import WorkstationSelect from "@/components/workstationSelect/simpletableSingle.vue";
export default {
  // components: {
  //   ItemBomSelect,
  //   ProcessProd,
  //   ProcessQcindex,
  //   ProcessTool,
  //   WorkstationSelect,
  // },
  inject: ["mode"],
  dicts: [
    "sys_yes_no",
    "specification_sheet_type",
    "product_shape",
    "pro_proof_form",
    "pro_distribution_profing",
  ],
  props: {
    bomList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      /**弹窗状态 */
      showFlag: false,
      /**表格数据 */
      tableData: [],
      /**表单规则 */
      rules: {},
      /**表单初始化数据 */
      form: {
        specificationSheetId: "",
        productionSolutionId: "",
        specificationSheetType: "",
        brandName: "",
        enName: "",
        unitOfMeasure: "",
        conversionValue: "",
        singleLayerThick: "",
        singleWeight: "",
        layerNum: "",
        width: "",
        height: "",
        printingPaperlenth: "",
        printPaperwidth: "",
        sendworkMultiple: "",
        frontColorName: "",
        oppositeColorName: "",
        length: "",
        storePlace: "",
        isAddSimple: "",
        isUniqueCode: "",
        isConsiderColor: "",
        formula: "",
        productMaterial: "",
        coldoubleCutspacing: "",
        rowdoubleCutspacing: "",
        isFillet: "",
        isAllotype: "",
        isRightAngle: "",
        angle: "",
        frontImg: "",
        backImg: "",
        blownFilmWidth: "",
        blownFilmThickness: "",
        printingWidth: "",
        inlay: "",
        customerConfirmedBy: "",
        customerConfirmedDate: "",
        rdApprovedBy: "",
        rdReviewedBy: "",
        rdPreparedBy: "",
        purchaseUnit: "",
        rowNum: "",
        isCreateSpec: "",
        isNeedShoeImg: "",
      },
      currentRow: {},
      currentRowIndex: undefined,
    };
  },
  methods: {
    /**更新行 */
    updateRow(row, idx) {
      Object.assign(this.form, row);
      this.currentRowIndex = idx;
      this.showFlag = true;
    },
    /**表单提交 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.showFlag = false;
          this.form.splice(this.currentRowIndex, 1, {
            ...this.currentRow,
            ...this.form,
          });
        }
      });
    },
    getComData() {
      return this.form;
    },
    /**重置表单 */
    resetForm() {
      this.form = {
        specificationSheetId: "",
        productionSolutionId: "",
        specificationSheetType: "",
        brandName: "",
        enName: "",
        unitOfMeasure: "",
        conversionValue: "",
        singleLayerThick: "",
        singleWeight: "",
        layerNum: "",
        width: "",
        height: "",
        printingPaperlenth: "",
        printPaperwidth: "",
        sendworkMultiple: "",
        frontColorName: "",
        oppositeColorName: "",
        length: "",
        storePlace: "",
        isAddSimple: "",
        isUniqueCode: "",
        isConsiderColor: "",
        formula: "",
        productMaterial: "",
        coldoubleCutspacing: "",
        rowdoubleCutspacing: "",
        isFillet: "",
        isAllotype: "",
        isRightAngle: "",
        angle: "",
        frontImg: "",
        backImg: "",
        blownFilmWidth: "",
        blownFilmThickness: "",
        printingWidth: "",
        inlay: "",
        customerConfirmedBy: "",
        customerConfirmedDate: "",
        rdApprovedBy: "",
        rdReviewedBy: "",
        rdPreparedBy: "",
        purchaseUnit: "",
        rowNum: "",
        isCreateSpec: "",
        isNeedShoeImg: "",
      };
    },
    /**重置组件状态 */
    resetState() {
      this.resetForm();
    },
    /**查看行 */
    searchRow(row, idx) {
      this.form = Object.assign(this.form, row);
      this.currentRowIdx = idx;
      this.optType = "detail";
      this.showFlag = true;
    },
    //图片上传成功
    handleImgUploaded(imgUrl, obj) {
      this.form[obj.$attrs.fieldName] = imgUrl;
    },
    //图片移除
    handleImgRemoved(imgUrl, obj) {
      this.form[obj.$attrs.fieldName] = null;
    },
  },
};
</script>

<style></style>
