<template>
  <div class="mod-config">
    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;" v-if="searchData.buNo==='Flexo'">
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'排废/Matrix Stripped'">
            <el-select clearable v-model="dataForm.matrixStripped" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'使用方式/AppliedType'">
            <el-input v-model="dataForm.appliedType" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'包装方式/Final Format'" >
            <el-input v-model="dataForm.finalFormat" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'横排数/if Rolls, No. Cross'">
            <el-input v-model="dataForm.rowCount" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯类型/CoreType'">
            <el-input v-model="dataForm.coreType" :disabled="ifDisableFlag"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯直径/Core Diameter'">
            <el-input v-model="dataForm.coreDiameter" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯宽度/CoreWidth'">
            <el-input v-model="dataForm.coreWidth" :disabled="ifDisableFlag"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'每卷/包数量/Qty Per Roll/Pack'">
            <el-input v-model="dataForm.rollPerQty" type="number" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否允许接头/Join Allowed'">
            <el-select clearable v-model="dataForm.joinAllowedFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否允许空缺/MissingAllowed'">
            <el-select clearable v-model="dataForm.missingAllowedFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'特殊出纸方向要求/Special Copy Positior'">
            <el-select clearable v-model="dataForm.specialPositiorFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'出纸方式/Copy Position'">
            <el-input v-model="dataForm.copyPosition" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-form-item style="margin-top: 60px; margin-left: 0px;text-align:center">
        <el-button type="primary" @click="saveData()" v-if="!ifDisableFlag">保存</el-button>
        </el-form-item>
      </el-row>


      <el-row :gutter="20">
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'执转移打印/Overprinting'">
            <el-select clearable v-model="dataForm.overprintingFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 0px">
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'其他特殊要求/Other Requirement'">
            <el-input
              type="textarea"
              v-model="dataForm.otherRequirement"
              :rows="3"
              resize='none'
              maxlength="120"
              show-word-limit
              style="height: 60px" :disabled="ifDisableFlag">
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

    </el-form>
    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;" v-if="searchData.buNo==='SS'">
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'包装方式/Final Format'" >
            <el-input v-model="dataForm.finalFormat" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'使用方式/AppliedType'">
            <el-input v-model="dataForm.appliedType" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>

        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'横排数/if Rolls, No. Cross'">
            <el-input v-model="dataForm.rowCount" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否允许空缺/MissingAllowed'">
            <el-select clearable v-model="dataForm.missingAllowedFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'每卷/包数量/Qty Per Roll/Pack'">
            <el-input v-model="dataForm.rollPerQty" type="number" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否隔离/底纸/AddingFilm/Linner'">
            <el-select clearable v-model="dataForm.addingFilmFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯类型/CoreType'">
            <el-input v-model="dataForm.coreType" :disabled="ifDisableFlag"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯直径/Core Diameter'">
            <el-input v-model="dataForm.coreDiameter" type="number" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否允许接头/Join Allowed'">
            <el-select clearable v-model="dataForm.joinAllowedFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'卷芯宽度/CoreWidth'">
            <el-input v-model="dataForm.coreWidth" :disabled="ifDisableFlag"></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'特殊出纸方向要求/Special Copy Positior'">
            <el-select clearable v-model="dataForm.specialPositiorFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 0px">
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'其他特殊要求/Other Requirement'">
            <el-input
              type="textarea"
              v-model="dataForm.otherRequirement"
              :rows="3"
              resize='none'
              maxlength="120"
              show-word-limit
              style="height: 60px" :disabled="ifDisableFlag">
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

    </el-form>
    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;" v-if="searchData.buNo==='DBE'">
      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'包装方式/Final Format'" >
            <el-input v-model="dataForm.finalFormat" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'使用方式/AppliedType'">
            <el-input v-model="dataForm.appliedType" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>

        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'横排数/No. of Cross'">
            <el-input v-model="dataForm.rowCount" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>

        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'纵排数/No. of Column'">
            <el-input v-model="dataForm.columnCount" :disabled="ifDisableFlag"  ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否允许空缺/MissingAllowed'">
            <el-select clearable v-model="dataForm.missingAllowedFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'每卷/包数量/Qty Per Roll/Pack'">
            <el-input v-model="dataForm.rollPerQty" type="number" :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'是否隔离/底纸/AddingFilm/Linner'">
            <el-select clearable v-model="dataForm.addingFilmFlag" :disabled="ifDisableFlag">
              <el-option label="Yes" value="Y"></el-option>
              <el-option label="No" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple">
          <el-form-item :label="'包装要求'">
            <el-input v-model="dataForm.packageRequest"  :disabled="ifDisableFlag" ></el-input>
          </el-form-item>
        </div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 0px">
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-form-item :label="'其他特殊要求/Other Requirement'">
            <el-input
              type="textarea"
              v-model="dataForm.otherRequirement"
              :rows="3"
              resize='none'
              maxlength="120"
              show-word-limit
              style="height: 60px" :disabled="ifDisableFlag">
            </el-input>
          </el-form-item>
        </div></el-col>
      </el-row>

    </el-form>

    <el-form label-position="top" style="margin-top: 60px; margin-left: 0px;text-align:center">
      <el-button type="primary" @click="saveData()" v-if="!ifDisableFlag">保存</el-button>
    </el-form>

    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import {
    searchBMPackageInfo,
    updateBMPackageInfo,
  } from "@/api/sampleManagement/technicalSpecificationList.js"
  import Chooselist from '@/views/modules/common/Chooselist'
  export default {
    components: {
      Chooselist
    },
    data() {
      return {
        searchData: {
          site: '',
          username: this.$store.state.user.name,
          codeNo: '',
          buNo:'',
        },
        ifDisableFlag:false,
        dataForm:{
          site: '',
          codeNo:'',
          matrixStripped:'',
          appliedType:'',
          finalFormat:'',
          rowCount:'',
          coreType:'',
          coreDiameter:'',
          coreWidth:'',
          rollPerQty:'',
          joinAllowedFlag:'',
          missingAllowedFlag:'',
          specialPositiorFlag:'',
          copyPosition:'',
          overprintingFlag:'',
          otherRequirement:'',
          addingFilmFlag:'',
          packageRequest:'',
          columnCount:'',
        },
        dataRole: {
          partTypeDesc: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          partName: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
        }
      }
    },
    methods: {
      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tagNo1 = type
        this.$nextTick(() => {
          let strVal = ''
          if (val === 1013) {
            if(type==1) {
              strVal = this.dataForm.partType
            }
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 1013) {
          if(this.tagNo1==1) {
            this.dataForm.partType = val.Base_id
            this.dataForm.partTypeDesc = val.Base_desc
          }
        }
      },
      //初始化组件的参数
      init(inData) {
        if(this.dataForm.codeNo!=null&&this.dataForm.codeNo!=''){
          return false;
        }
        //初始化参数
        this.searchData = JSON.parse(JSON.stringify(inData));
        //刷新表格
        this.searchTable();

      },
      searchTable(){
        searchBMPackageInfo(this.searchData).then(({data}) => {
          this.dataForm = data.rows[0];

        });
      },
      saveData(){
        this.$confirm("是否保存信息？", '保存提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          updateBMPackageInfo(this.dataForm).then(({data}) => {
            if (data && data.code === 0) {
              this.$message.success( '操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        }).catch(() => {
          return
        })
      },
    },
  }
</script>

<style scoped>

</style>
