<template>
  <div class="mod-config">
    <el-dialog width="600px" :title="!dataForm.id ? '添加' : '编辑'" :close-on-click-modal="false" :visible.sync="visible">
      <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
        <el-form-item  >
          <span slot="label" @click="chooseProofingModel()"><a herf="#">打样单号</a></span>
          <el-input v-model="dataForm.proofingNo" style="width: 130px" @change="changeProofingNoChange" :disabled="dataForm.id!=0"></el-input>
        </el-form-item>
        <el-form-item label=" ">
        <el-checkbox v-model="jumpFlag">保存后跳转至详情</el-checkbox>
        </el-form-item>
<!--        <el-form-item prop="testPartNo"  style="margin-left: 12px" :label="'IFS料号'">-->
<!--&lt;!&ndash;          <span slot="label" style="" @click="getBaseList(134,1)"  ><a herf="#">IFS料号</a></span>&ndash;&gt;-->
<!--          <el-input v-model="dataForm.testPartNo" @change="changeTestDesc" style="width: 130px" disabled ></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
        <el-form-item  :rules="dataRole.testPartNo">
          <span slot="label" @click="choosePartModel()"><a herf="#">IFS料号</a></span>
          <el-input v-model="dataForm.finalPartNo" style="width: 130px" readonly></el-input>
        </el-form-item>
        <el-form-item :label="'项目号'">
          <el-input v-model="dataForm.projectId" style="width: 130px" disabled></el-input>
        </el-form-item>
        <el-form-item :label="'物料描述'">
          <el-input v-model="dataForm.partDesc" style="width: 274px" disabled></el-input>
        </el-form-item>
      </el-form>

      <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
        <el-form-item :label="'BU'" >
          <el-input v-model="dataForm.buNo" disabled style="width: 130px" ></el-input>
        </el-form-item>
<!--        <el-form-item :label="'参数卡编码'" >-->
<!--          <el-input v-model="dataForm.oriCodeNo" disabled style="width: 130px" ></el-input>-->
<!--        </el-form-item>-->
        <el-form-item :label="'系统版本号'" prop="revNo" :rules="dataRole.revNo">
          <el-input v-model="dataForm.revNo" style="width: 130px" disabled></el-input>
        </el-form-item>
        <el-form-item label="Rev No" prop="rev" :rules="dataRole.rev">
          <el-input v-model="dataForm.rev" style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item label="Customer Rev" prop="customerRev" :rules="dataRole.customerRev">
          <el-input v-model="dataForm.customerRev" style="width: 130px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
        <el-form-item>
          <span slot="label" @click="getUserList(4)"><a herf="#">Select CS</a></span>
          <el-input v-model="dataForm.csOperaterName" ref="csOperaterName" placeholder="请选择人员" readonly style="width: 130px" ></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getUserList(7)"><a herf="#">Select Engineer</a></span>
          <el-input v-model="dataForm.engineer" readonly style="width: 130px" placeholder="请选择人员" ></el-input>
        </el-form-item>
        <el-form-item >
          <span slot="label" @click="getUserList(8)"><a herf="#">Select Artwork</a></span>
          <el-input v-model="dataForm.technician" readonly style="width: 130px" placeholder="请选择人员" ></el-input>
        </el-form-item>
        <el-form-item >
          <span slot="label" @click="getUserList(6)"><a herf="#">Select Technical</a></span>
          <el-input v-model="dataForm.mpOperatorName" ref="mpOperatorName" placeholder="请选择人员" readonly style="width: 130px" ></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getUserList(1)"><a herf="#">Select CQC</a></span>
          <el-input v-model="dataForm.cqcOperatorName" ref="cqcOperatorName" placeholder="请选择人员" readonly style="width: 130px" ></el-input>
        </el-form-item>
        <el-form-item>
          <span slot="label" @click="getUserList(2)"><a herf="#">Select FAI</a></span>
          <el-input v-model="dataForm.faiOperatorName" ref="faiOperatorName" placeholder="请选择人员" readonly style="width: 130px" ></el-input>
        </el-form-item>
<!--        <el-form-item >-->
<!--          <span slot="label" style="" @click="quotationOfficerChooseModal()"><a herf="#">报价员</a></span>-->
<!--          <el-input v-model="dataForm.quotationOfficer" readonly style="width: 274px"  @focus="quotationOfficerChooseModal()"></el-input>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--      <el-form :inline="true" label-position="top" label-width="100px" >-->

<!--        <el-form-item >-->
<!--          <span slot="label" style="" @click="engineerChooseModal()"><a herf="#">Select PE Engineer</a></span>-->
<!--          <el-input v-model="dataForm.engineer" readonly style="width: 130px"  @focus="engineerChooseModal()"></el-input>-->
<!--        </el-form-item>-->
<!--        274px-->
<!--        <el-form-item >-->
<!--          <span slot="label" style="" @click="technicianModal()"><a herf="#">Select Artwork</a></span>-->
<!--          <el-input v-model="dataForm.technician" readonly style="width: 130px"  @focus="technicianModal()"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item >-->
<!--          <span slot="label" style="" @click="getUserList(3)"><a herf="#">PE人员</a></span>-->
<!--          <el-input v-model="dataForm.peOperaterName" ref="peOperaterName"  placeholder="请选择人员" readonly style="width: 130px" ></el-input>-->
<!--        </el-form-item>-->

<!--        <el-form-item >-->
<!--          <span slot="label" style="" @click="getUserList(5)"><a herf="#">DCC人员</a></span>-->
<!--          <el-input v-model="dataForm.dccOperaterName" ref="dccOperaterName"  placeholder="请选择人员" readonly style="width: 130px" ></el-input>-->
<!--        </el-form-item>-->
        <el-form-item >
          <span slot="label" @click="dccChooseModal()"><a herf="#">Select DCC</a></span>
          <el-input v-model="dataForm.dcc"  ref="dcc" readonly style="" @focus="dccChooseModal()" style="width: 130px"></el-input>
        </el-form-item>

      </el-form>
      <el-form :inline="true" label-position="top" label-width="100px" >
        <el-form-item :label="'备注'">
          <el-input
            type="textarea"
            v-model="dataForm.remark "
            :rows="3"
            resize='none'
            maxlength="120"
            show-word-limit
            style="width: 562px;height: 60px">
          </el-input>
        </el-form-item>
      </el-form>
      <el-form label-position="top" style="margin-top: 60px; margin-left: 0px;text-align:center">
        <el-button type="primary" @click="dataFormSubmit()">{{'确定'}}</el-button>
        <el-button type="primary" @click="visible = false">{{'关闭'}}</el-button>
      </el-form>
    </el-dialog>
    <el-dialog
      width="530px"
      title="报价员"
      :close-on-click-modal="false"
      :visible.sync="quotationOfficerFlag">
      <el-transfer v-model="quotationOfficerList" class="rq" filterable  :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="saveQuotationOfficerList()">确定</el-button>
                <el-button @click="quotationOfficerFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>
    <el-dialog
      width="530px"
      title="工程师"
      :close-on-click-modal="false"
      :visible.sync="engineerFlag">
      <el-transfer v-model="engineerList" class="rq" filterable :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="saveEngineerList()">确定</el-button>
                <el-button @click="engineerFlag = false" type="primary">取消</el-button>
        </div>
      </span>
    </el-dialog>
    <el-dialog
      width="530px"
      title="项目负责人"
      :close-on-click-modal="false"
      :visible.sync="ownerFlag">
      <el-transfer v-model="technicianList" class="rq" filterable :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="savetechnicianList()">确定</el-button>
                <el-button @click="ownerFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>
    <el-dialog
      width="950px"
      title="选择打样单"
      :close-on-click-modal="false"
      :visible.sync="proofingModelFlag">
      <el-form :inline="true" label-position="top" label-width="100px" >
        <el-form-item  style="margin-left: 0px">
          <span slot="label" style="" @click="getBaseList(104,2)" ><a herf="#">项目号</a></span>
          <el-input v-model="proofingSearch.projectId"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item style="margin-left: 0px">
          <span slot="label" style="" @click="getBaseList(501,2)" ><a herf="#">打样单</a></span>
          <el-input v-model="proofingSearch.proofingNo"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item  style="margin-left: 0px">
          <span slot="label" style="" @click="getBaseList(102,2)" ><a herf="#">直接客户</a></span>
          <el-input v-model="proofingSearch.customerId"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item  style="margin-left: 0px">
          <span slot="label" style="" @click="getBaseList(102,3)" ><a herf="#">最终客户</a></span>
          <el-input v-model="proofingSearch.finalCustomerId"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item  label=" ">
          <el-button type="primary" @click="refreshProofingList()">{{'查询'}}</el-button>
        </el-form-item>
      </el-form>
        <el-table
          height="450"
          :data="proofingList"
          border
          @row-dblclick="chooseProofingNo"
          style="width: 100%;">
          <el-table-column
            prop="proofingNo"
            header-align="center"
            align="left"
            min-width="120"
            style="font-size: 20px"
            label="打样单">
          </el-table-column>
          <el-table-column
            prop="projectId"
            header-align="center"
            align="left"
            min-width="120"
            style="font-size: 20px"
            label="项目号">
          </el-table-column>
          <el-table-column
            prop="projectName"
            header-align="center"
            align="left"
            min-width="120"
            style="font-size: 20px"
            label="项目名称">
          </el-table-column>
          <el-table-column
            prop="testPartNo"
            header-align="center"
            align="left"
            min-width="120"
            label="测试料号">
          </el-table-column>
          <el-table-column
            prop="partDesc"
            header-align="center"
            align="left"
            min-width="120"
            label="物料名称">
          </el-table-column>
          <el-table-column
            prop="buNo"
            header-align="center"
            align="left"
            min-width="80"
            label="BU">
          </el-table-column>
          <el-table-column
            prop="customerDesc"
            header-align="center"
            align="left"
            min-width="120"
            label="直接客户">
          </el-table-column>
          <el-table-column
            prop="finalCustomerDesc"
            header-align="center"
            align="left"
            min-width="120"
            label="最终客户">
          </el-table-column>
        </el-table>
    </el-dialog>
    <el-dialog
      width="750px"
      title="选择物料"
      :close-on-click-modal="false"
      :visible.sync="partModelFlag">
      <el-form :inline="true" label-position="top" label-width="100px" >
        <el-form-item  style="margin-left: 0px" label="项目编码">

          <el-input v-model="partSearch.projectId"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item style="margin-left: 0px" label="IFS料号">
          <el-input v-model="partSearch.finalPartNo"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item  style="margin-left: 0px"  label="物料编码">
          <el-input v-model="partSearch.testPartNo"  style="width: 130px"  ></el-input>
        </el-form-item>
<!--        <el-form-item  style="margin-left: 0px" label="物料名称">-->
<!--          <el-input v-model="partSearch.partDesc"  style="width: 130px"  ></el-input>-->
<!--        </el-form-item>-->
        <el-form-item  style="margin-left: 0px" label="客户料号">
          <el-input v-model="partSearch.customerPartNo"  style="width: 130px"  ></el-input>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" @click="refreshPartList()">{{'查询'}}</el-button>
        </el-form-item>
      </el-form>
      <el-table
        height="450"
        :data="partList"
        border
        @row-dblclick="choosePartNo"
        style="width: 100%;">
        <el-table-column
          prop="finalPartNo"
          header-align="center"
          align="left"
          min-width="120"
          style="font-size: 20px"
          label="IFS料号">
        </el-table-column>
        <el-table-column
          prop="testPartNo"
          header-align="center"
          align="left"
          min-width="120"
          style="font-size: 20px"
          label="物料编码">
        </el-table-column>
        <el-table-column
          prop="projectId"
          header-align="center"
          align="left"
          min-width="120"
          style="font-size: 20px"
          label="项目编码">
        </el-table-column>
        <el-table-column
          prop="customerPartNo"
          header-align="center"
          align="left"
          min-width="120"
          label="客户料号">
        </el-table-column>
        <el-table-column
          prop="partDesc"
          header-align="center"
          align="left"
          min-width="120"
          label="物料名称">
        </el-table-column>
        <el-table-column
          prop="buNo"
          header-align="center"
          align="left"
          min-width="70"
          label="BU">
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[20, 50, 100, 1000]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </el-dialog>
    <el-dialog
      width="530px"
      title="DCC人员"
      :close-on-click-modal="false"
      :visible.sync="dccFlag">
      <el-transfer v-model="dccList" class="rq" filterable :props="{
      key: 'operatorId',
      label: 'operatorName'
    }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer>
      <span slot="footer" class="dialog-footer">
        <div style="margin-top: 5px">
                <el-button type="primary" @click="savetDccList()">确定</el-button>
                <el-button @click="dccFlag = false" type="primary">取消</el-button>
        </div>
    </span>
    </el-dialog>
    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
    <ChooseUser ref="userList"  @getBaseData="getUserData"></ChooseUser>
  </div>
</template>

<script>
  import {
    searchOperatorWithSite,
  } from "@/api/project/project.js"
  import {technicalSpecificationListSearch,
    saveTechnicalSpecificationSheet,
    searchTechnicalSpecificationTeamStr,
    getTestPartChangeData,
    getProofingDataByUserRole,
    getFinalPartData,
    searchBMUser,
  } from "@/api/sampleManagement/technicalSpecificationList.js"
  import Chooselist from '@/views/modules/common/Chooselist'
  import ChooseUser from '@/views/modules/common/ChooseUser'
  export default {
    components: {
      Chooselist,ChooseUser
    },
    data () {
      return {
        jumpFlag:true,
        tagNo:'',
        tagNo1:'',
        visible: false,
        treeVisible: false,
        quotationOfficerFlag:false,
        engineerFlag:false,
        userRoleFlag:false,
        ownerFlag:false,
        operatorList:[],
        dataForm: {
          id: 0,
          finalPartNo:'',
          site:this.$store.state.user.site,
          proofingNo:'',
          projectId:'',
          codeNo:'',
          testPartNo:'',
          partDesc:'',
          status:'',
          revNo:'',
          remark:'',
          technician:'',
          quotationOfficer:'',
          engineer:'',
          quotationOfficerList:[],
          engineerList:[],
          technicianList:[],
          engineerNo:'',
          technicianNo:'',
          oriCodeNo:'',
          cqcOperator:'',
          faiOperator:'',
          cqcOperatorName:'',
          faiOperatorName:'',
          peOperater:'',
          peOperaterName:'',
          csOperater:'',
          csOperaterName:'',
          dccOperater:'',
          dccOperaterName:'',
          mpOperatorName:'',
          mpOperator:'',
          buNo:'',
          dcc:'',
          dccList:[],
          rev:'',
          customerRev:''
        },
        dccList:'',
        dccFlag:false,
        proofingSearch:{
          projectId:'',
          proofingNo:'',
          customerId:'',
          finalCustomerId:'',
          site:this.$store.state.user.site,
          username:this.$store.state.user.name,
        },
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        partSearch:{
          projectId:'',
          finalPartNo:'',
          testPartNo:'',
          partDesc:'',
          site:this.$store.state.user.site,
          username:this.$store.state.user.name,
          customerPartNo:'',
          page: 1,
          limit: 100,
        },
        quotationOfficerList:[],
        engineerList:[],
        technicianList:[],
        dataRole: {
          testPartNo: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          revNo: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          quotationOfficer: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          engineer: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          technician: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],

        },
        proofingList:[],
        proofingModelFlag:false,
        partList:[],
        partModelFlag:false,
      }
    },
    created () {

    },
    methods: {
      getUserList (type) {
        this.tagNo1 = type
        this.$nextTick(() => {
          let strVal = ''

          if(type==1) {
            strVal = this.dataForm.cqcOperator
          }
          if(type==2) {
            strVal = this.dataForm.faiOperator
          }
          if(type==3) {
            strVal = this.dataForm.peOperater
          }
          if(type==4) {
            strVal = this.dataForm.csOperater
          }
          if(type==5) {
            strVal = this.dataForm.dccOperater
          }
          if(type==6) {
            strVal = this.dataForm.mpOperator
          }
          if(type==7) {
            strVal = this.dataForm.engineerNo
          }
          if(type==8) {
            strVal = this.dataForm.technicianNo
          }
          this.$refs.userList.init(this.$store.state.user.site,this.dataForm.buNo!==''?this.dataForm.buNo:'%%', strVal)
        })
      },
      /* 列表方法的回调 */
      getUserData (val) {

        if(this.tagNo1==1) {
          this.dataForm.cqcOperator = val.username
          this.dataForm.cqcOperatorName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.cqcOperatorName);
          // });
        }
        if(this.tagNo1==2) {
          this.dataForm.faiOperator = val.username
          this.dataForm.faiOperatorName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.faiOperatorName);
          // });
        }
        if(this.tagNo1==3) {
          this.dataForm.peOperater = val.username
          this.dataForm.peOperaterName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.peOperaterName);
          // });
        }
        if(this.tagNo1==4) {
          this.dataForm.csOperater = val.username
          this.dataForm.csOperaterName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.csOperaterName);
          // });
        }
        if(this.tagNo1==5) {
          this.dataForm.dccOperater = val.username
          this.dataForm.dccOperaterName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.dccOperaterName);
          // });
        }
        if(this.tagNo1==6) {
          this.dataForm.mpOperator = val.username
          this.dataForm.mpOperatorName = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.mpOperatorName);
          // });
        }
        if(this.tagNo1==7) {
          this.dataForm.engineerNo = val.username
          this.dataForm.engineer = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.mpOperatorName);
          // });
        }
        if(this.tagNo1==8) {
          this.dataForm.technicianNo = val.username
          this.dataForm.technician = val.userDisplay
          // this.$nextTick(() => {
          //   this.$triggerInputEvent(this.$refs.mpOperatorName);
          // });
        }
      },
      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tagNo1 = type
        this.$nextTick(() => {
          let strVal = ''
          if (val === 134) {
            if(type==1) {
              if(this.dataForm.id!=0){
                return false
              }
              strVal = this.dataForm.testPartNo
            }
          }
          if (val === 102) {
            if(type==1) {
              strVal = this.dataForm.customerId
            }
            if(type==2) {
              strVal = this.proofingSearch.customerId
            }
            if(type==3) {
              strVal = this.proofingSearch.finalCustomerId
            }
          }
          if (val === 104) {
            if(type==2) {
              strVal = this.proofingSearch.projectId
            }
          }
          if (val === 501) {
            if(type==2) {
              strVal = this.proofingSearch.proofingNo
            }
          }
          if (val === 1011) {
            if(type==1) {
              strVal = this.dataForm.projectSource
            }
          }
          if (val === 1012) {
            if(type==1) {
              strVal = this.dataForm.priority
            }
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 134) {
          if(this.tagNo1==1) {
            this.dataForm.testPartNo = val.Test_part_no
            this.dataForm.proofingNo = ''
            this.changeTestDesc();
          }
        }
        if (this.tagNo === 102) {
          if(this.tagNo1==1) {
            this.dataForm.customerId = val.Customer_no
            this.dataForm.customerName = val.Customer_desc
          }
          if(this.tagNo1==2) {
            this.proofingSearch.customerId = val.Customer_no
          }
          if(this.tagNo1==3) {
            this.proofingSearch.finalCustomerId = val.Customer_no
          }
        }
        if (this.tagNo === 104) {
          if(this.tagNo1==2) {
            this.proofingSearch.projectId = val.project_id
          }
        }
        if (this.tagNo === 501) {
          if(this.tagNo1==2) {
            this.proofingSearch.proofingNo = val.Proofing_no
          }
        }
        if (this.tagNo === 1011) {
          if(this.tagNo1==1) {
            this.dataForm.projectSource = val.Base_id
            this.dataForm.projectSourceDesc = val.Base_desc
          }
        }
        if (this.tagNo === 1012) {
          if(this.tagNo1==1) {
            this.dataForm.priority = val.Base_id
            this.dataForm.priorityDesc = val.Base_desc
          }
        }
      },
      init (id) {
        this.jumpFlag = true
        this.dataForm.id = id || 0
        if (this.dataForm.id !== 0) {
          let inData={
            page: 1,
            limit: 10,
            id:id,
            userName:this.$store.state.user.name,
            site:this.$store.state.user.site,
          }
          technicalSpecificationListSearch(inData).then(({data}) => {
            if(data.page.list.length>0){
              this.dataForm= data.page.list[0];
              let inData={
                site:this.dataForm.site,
                codeNo:this.dataForm.codeNo,
                type:'quotationOfficer',
              }
              searchTechnicalSpecificationTeamStr(inData).then(({data}) => {
                this.dataForm.quotationOfficerList=data.rows
              })
              let inData2={
                site:this.dataForm.site,
                codeNo:this.dataForm.codeNo,
                type:'technician',
              }
              searchTechnicalSpecificationTeamStr(inData2).then(({data}) => {
                this.dataForm.technicianList=data.rows
              })
              let inData3={
                site:this.dataForm.site,
                codeNo:this.dataForm.codeNo,
                type:'engineer',
              }
              searchTechnicalSpecificationTeamStr(inData3).then(({data}) => {
                this.dataForm.engineerList=data.rows
              })
              let inData5 = {
                site: this.dataForm.site,
                codeNo: this.dataForm.codeNo,
                type: 'dcc',
              }
              searchTechnicalSpecificationTeamStr(inData5).then(({data}) => {
                this.dataForm.dccList = data.rows
              })
              this.visible = true
            }else {

              this.$message.error('技术参数卡数据有误！')
            }
          })
        } else {
          this.dataForm = {
            id: 0,
            finalPartNo: '',
            site: this.$store.state.user.site,
            proofingNo: '',
            projectId: '',
            codeNo: '',
            testPartNo: '',
            partDesc: '',
            status: '',
            revNo: 1,
            remark: '',
            technician: '',
            quotationOfficer: '',
            engineer: '',
            quotationOfficerList: [],
            engineerList: [],
            technicianList: [],
            cqcOperator: '',
            faiOperator: '',
            cqcOperatorName: '',
            faiOperatorName: '',
            peOperater: '',
            peOperaterName: '',
            csOperater: this.$store.state.user.name,
            csOperaterName: this.$store.state.user.userDisplay,
            dccOperater: '',
            dccOperaterName: '',
            mpOperatorName: '',
            mpOperator: '',
            oriCodeNo: '',
            engineerNo: '',
            technicianNo: '',
            buNo: '',
            dcc: '',
            dccList: [],
            rev:'',
            customerRev:''
          }
          this.visible = true
        }
      },
      chooseProofingModel () {
        if (this.dataForm.id !== 0 ) {
          return false;
        }
        this.proofingSearch={
            projectId:'',
            proofingNo:'',
            customerId:'',
            finalCustomerId:'',
            site:this.$store.state.user.site,
            username:this.$store.state.user.name,
        }
        getProofingDataByUserRole(this.proofingSearch).then(({data}) => {
          this.proofingList=data.rows
        })

        this.proofingModelFlag=true
      },

      choosePartModel(){
        this.partSearch={
          projectId:'',
          finalPartNo:'',
          customerPartNo:'',
          partDesc:'',
          testPartNo:'',
          site:this.$store.state.user.site,
          username:this.$store.state.user.name,
        }
        this.pageIndex=1
        this.pageSize=100
        this.totalPage=0
       this.refreshPartList();

        this.partModelFlag=true
      },
      refreshPartList(){
        this.partSearch.limit = this.pageSize
        this.partSearch.page = this.pageIndex
        getFinalPartData(this.partSearch).then(({data}) => {
          this.partList=data.page.list
          this.pageIndex = data.page.currPage
          this.pageSize = data.page.pageSize
          this.totalPage = data.page.totalCount
        })
      },
      refreshProofingList(){
        getProofingDataByUserRole(this.proofingSearch).then(({data}) => {
          this.proofingList=data.rows
        })
      },
      changeProofingNoChange(){
        let inData={
          site:this.dataForm.site,
          username:this.$store.state.user.name,
          proofingNo:this.dataForm.proofingNo,
        }
        getProofingDataByUserRole(inData).then(({data}) => {
          let row={
            projectId:'',
            testPartNo:'',
            partDesc:'',
          }
          if(data.rows.length>0){
             row=data.rows[0]
          }
          this.changeProofingNo(row)
        })
      },
      choosePartNo(row){
        this.dataForm.projectId=row.projectId
        this.dataForm.testPartNo=row.testPartNo
        this.dataForm.partDesc=row.partDesc
        this.dataForm.finalPartNo=row.finalPartNo
        this.dataForm.buNo=row.buNo
        this.partModelFlag=false
      },
      chooseProofingNo(row){
        this.dataForm.proofingNo=row.proofingNo
        this.dataForm.projectId=row.projectId
        this.dataForm.testPartNo=row.testPartNo
        this.dataForm.partDesc=row.partDesc
        this.dataForm.buNo=row.buNo
        let inData={
          site:this.$store.state.user.site,
          testPartNo: row.testPartNo
        }
        getTestPartChangeData(inData).then(({data}) => {
          if (data && data.code === 0) {
            if(data.row!=null){
              this.dataForm.partDesc=data.row.partDesc
              this.dataForm.finalPartNo=data.row.finalPartNo
            }else {
              this.dataForm.partDesc=''
            }
          }
        })
        this.proofingModelFlag=false
      },
      changeProofingNo(row){
        this.dataForm.projectId=row.projectId
        this.dataForm.testPartNo=row.testPartNo
        this.dataForm.partDesc=row.partDesc
        this.proofingModelFlag=false
      },
      quotationOfficerChooseModal(){
        let inData={
          site:this.dataForm.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.quotationOfficerList = JSON.parse(JSON.stringify(this.dataForm.quotationOfficerList));
        this.quotationOfficerFlag=true
      },

      saveQuotationOfficerList(){
        let quotationOfficerName='';
        for (let i = 0; i < this.quotationOfficerList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.quotationOfficerList[i])
          if(select.length>0){
            quotationOfficerName+=select[0].operatorName+';'
          }
        }
        this.dataForm.quotationOfficer=quotationOfficerName
        this.dataForm.quotationOfficerList=JSON.parse(JSON.stringify(this.quotationOfficerList));
        this.quotationOfficerFlag=false
      },

      engineerChooseModal(){
        let inData={
          site:this.dataForm.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.engineerList = JSON.parse(JSON.stringify(this.dataForm.engineerList));
        this.engineerFlag=true
      },

      saveEngineerList(){
        let engineerName='';
        for (let i = 0; i < this.engineerList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.engineerList[i])
          if(select.length>0){
            engineerName+=select[0].operatorName+';'
          }
        }
        this.dataForm.engineer=engineerName
        this.dataForm.engineerList=JSON.parse(JSON.stringify(this.engineerList));
        this.engineerFlag=false
      },
      technicianModal(){
        let inData={
          site:this.dataForm.site,
        }
        searchOperatorWithSite(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.technicianList = JSON.parse(JSON.stringify(this.dataForm.technicianList));
        this.ownerFlag=true
      },
      savetechnicianList(){
        let technicianName='';
        for (let i = 0; i < this.technicianList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.technicianList[i])
          if(select.length>0){
            technicianName+=select[0].operatorName+';'
          }
        }
        this.dataForm.technician=technicianName
        this.dataForm.technicianList=JSON.parse(JSON.stringify(this.technicianList));
        this.ownerFlag=false
      },
      savetDccList(){
        let dccName='';
        for (let i = 0; i < this.dccList.length; i++) {
          let select= this.operatorList.filter(item => item.operatorId === this.dccList[i])
          if(select.length>0){
            dccName+=select[0].operatorName+';'
          }
        }
        this.dataForm.dcc=dccName
        this.dataForm.dccList=JSON.parse(JSON.stringify(this.dccList));
        this.dccFlag=false
      },
      // 表单提交
      dataFormSubmit () {
        if(this.dataForm.testPartNo===''){

          this.$message.error('请输入测试料号！')
          return false
        }
        if(this.dataForm.revNo===''){
          this.$message.error('请输入版本号！')
          return false
        }
        this.dataForm.engineerList = [];
        this.dataForm.engineerList.push(this.dataForm.engineerNo);
        this.dataForm.technicianList = [];
        this.dataForm.technicianList.push(this.dataForm.technicianNo);
        saveTechnicalSpecificationSheet(this.dataForm).then(({data}) => {
          if (data && data.code === 0) {
            this.$message.success( '操作成功')
            this.visible = false
            this.$emit('refreshDataList')
            if(this.jumpFlag){
              this.$nextTick(function () {
                setTimeout(() => {
                  let inData = {
                    site: this.$store.state.user.site,
                    codeNo: data.row.codeNo,
                    buNo: data.row.buNo,
                    username: this.$store.state.user.name
                  };
                  localStorage.setItem('tsfData', JSON.stringify(inData))
                  window.open('#/BMPage');
                },500)
              })
            }

          } else {
            this.$message.error(data.msg)
          }
        })

      },
      changeTestDesc(){
        this.dataForm.proofingNo="";
        let inData={
          site:this.$store.state.user.site,
          testPartNo: this.dataForm.testPartNo
        }
        getTestPartChangeData(inData).then(({data}) => {
          if (data && data.code === 0) {
            if(data.row!=null){
              this.dataForm.projectId=data.row.projectId
              this.dataForm.partDesc=data.row.partDesc
              this.dataForm.finalPartNo=data.row.finalPartNo
            }else {
              this.dataForm.projectId=''
              this.dataForm.partDesc=''
            }

          }
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.refreshPartList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.refreshPartList()
      },
      dccChooseModal(){
        let inData={
          site:this.dataForm.site,
          buNo:this.dataForm.buNo,
        }
        searchBMUser(inData).then(({data}) => {
          this.operatorList=data.rows
        })
        this.dccList = JSON.parse(JSON.stringify(this.dataForm.dccList));
        this.dccFlag=true
      },

    },
  }
</script>

<style >
  .el-transfer-panel {
    border: 2px solid #17b3a3;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    display: inline-block;
    vertical-align: middle;
    width: 200px;
    max-height: 100%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    position: relative;
  }

  .el-transfer-panel .el-transfer-panel__header {
    height: 40px;
    line-height: 40px;
    background: #17b3a3;
    margin: 0;
    padding-left: 15px;
    border-bottom: 1px solid #17b3a3;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #000;
  }

  .el-transfer-panel .el-transfer-panel__header .el-checkbox .el-checkbox__label {
    font-size: 14px;
    color: #303133;
    font-weight: 400;
  }
</style>
