<template>
  <div class="mod-config">
    <div>
        <span @click="favoriteFunction()">
         <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
        </span>
    </div>

    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'项目编码'">
        <el-input v-model="searchData.projectId" style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'项目名称'">
        <el-input v-model="searchData.projectDesc" style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'客户编码'">
        <el-input v-model="searchData.customerNo" style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'客户名称'">
        <el-input v-model="searchData.customerDesc" style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 130px">
          <el-option
            v-for = "i in userBuList"
            :key = "i.buNo"
            :label = "i.buDesc"
            :value = "i.buDesc">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'项目分类'">
        <el-select v-model="searchData.projectCategory" placeholder="请选择" clearable style="width: 130px">
          <el-option
            v-for = "i in projectCategoryList"
            :key = "i.projectCategory"
            :label = "i.projectCategory"
            :value = "i.projectCategory">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'项目状态'">
        <el-select v-model="searchData.status" placeholder="请选择" clearable style="width: 130px">
          <el-option
            v-for = "i in statusList"
            :key = "i.status"
            :label = "i.status"
            :value = "i.status">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'立项日期：'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.startDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      -
        <el-date-picker
          style="width: 120px"
          v-model="searchData.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
<!--      <el-form-item :label="'在用'">-->
<!--        <el-select filterable v-model="searchData.active" style="width: 130px">-->
<!--          <el-option label="全部" value=""></el-option>-->
<!--          <el-option label="是" value="Y"></el-option>-->
<!--          <el-option label="否" value="N"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item :label="' '">
        <el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
        <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :height="height + 110"
      :data="dataList"
      ref="mainTable"
      highlight-current-row
      @row-click="proofingClickRow"
      @current-change="changeCurrentRow"
      border
      style="width: 100%;">
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="178"
        label="操作">
        <template slot-scope="scope">
          <a v-if="!authUpdate" type="text" size="small" @click="addProofRecord(scope.row)">新增打样</a>
          <a v-if="!authUpdate" type="text" size="small" @click="changeFormalPartNo(scope.row)">转正式料号</a>
          <a v-if="!authUpdate" type="text" size="small" @click="updateModal(scope.row)">修改</a>
          <a v-if="!authDelete" type="text" size="small" @click="eamProjectInfoDelete(scope.row)">删除</a>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 200, 500]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <el-dialog title="项目" :close-on-click-modal="false" @close="closeClear" v-drag :visible.sync="modalFlag" width="600px">
<!--      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">-->
<!--        <el-form-item label="是否在用" prop="active" :rules="rules.activeType">-->
<!--          <el-select filterable v-model="modalData.active" style="width: 140px">-->
<!--            <el-option label="是" value="Y"></el-option>-->
<!--            <el-option label="否" value="N"></el-option>-->
<!--          </el-select>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="BU" prop="bu" :rules="rules.bu">
          <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 110px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.buNo"
              :value = "i.buNo">
              <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
                {{ i.buDesc }}
              </span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目编码" prop="projectId" :rules="rules.projectId">
          <el-input v-model="modalData.projectId" style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="项目名称" prop="projectDesc" :rules="rules.projectDesc">
          <el-input v-model="modalData.projectDesc" style="width: 170px"></el-input>
        </el-form-item>
        <el-form-item label="区域" prop="cProjectRegion" :rules="rules.cProjectRegion">
          <el-select v-model="modalData.cProjectRegion" placeholder="请选择" clearable style="width: 110px">
            <el-option
              v-for = "i in cProjectRegionList"
              :key = "i.cProjectRegion"
              :label = "i.cProjectRegion"
              :value = "i.cProjectRegion">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
        <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目分类" prop="projectCategory" :rules="rules.projectCategory">
          <el-select v-model="modalData.projectCategory" placeholder="请选择" clearable style="width: 110px">
            <el-option
              v-for = "i in projectCategoryList"
              :key = "i.projectCategory"
              :label = "i.projectCategory"
              :value = "i.projectCategory">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="customerNo" :rules="rules.customerNo" >
          <span slot="label" style="" @click="getBaseList(509)"><a herf="#">客户编码</a></span>
          <el-input v-model="modalData.customerNo" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="客户名称" prop="customerDesc" :rules="rules.customerDesc">
          <el-input v-model="modalData.customerDesc" disabled style="width: 170px"></el-input>
        </el-form-item>
        <el-form-item label="优先级" prop="priority" :rules="rules.priority">
          <el-select v-model="modalData.priority" placeholder="请选择" clearable style="width: 110px">
            <el-option
              v-for = "i in priorityList"
              :key = "i.priority"
              :label = "i.priority"
              :value = "i.priority">
            </el-option>
          </el-select>
        </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="'立项日期：'">
          <el-date-picker
            style="width: 110px"
            v-model="modalData.projectCreationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="项目料号" prop="testPartNo" :rules="rules.testPartNo" >
          <el-input v-model="modalData.testPartNo"  disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="料号描述" prop="partDesc" :rules="rules.partDesc" >
          <el-input v-model="modalData.partDesc"  style="width: 170px"></el-input>
        </el-form-item>
        <el-form-item :label="'预计完成日期：'" :rules="rules.needDate">
          <el-date-picker
            style="width: 110px"
            v-model="modalData.needDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
<!--        <el-form-item label="文档类型ID" prop="documentTypeId" :rules="rules.documentTypeIdType">-->
<!--          <el-input v-model="modalData.documentTypeId" style="width: 230px"></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
<!--        <el-form-item prop="projectManager" :rules="rules.projectManager">-->
<!--          <el-input v-model="modalData.projectManager" disabled style="width: 110px"></el-input>-->
<!--        </el-form-item>-->

        <el-form-item label="PM/Sales" prop="projectManagerName" :rules="rules.projectManagerName">
          <span slot="label" style="" @click="projectManagerFlag = true "><a herf="#">PM/Sales</a></span>
          <el-input v-model="modalData.projectManagerName" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="PjM" prop="projectOwner" :rules="rules.projectOwner">
          <span slot="label" style="" @click="projectOwnerFlag = true"><a herf="#">PjM</a></span>
          <el-input v-model="modalData.projectOwnerName" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="Engineer" prop="engineerName" :rules="rules.engineerName">
          <span slot="label" style="" @click="engineer6Flag = true"><a herf="#">Engineer</a></span>
          <el-input v-model="modalData.engineerName" disabled style="width: 170px"></el-input>
        </el-form-item>
<!--        <el-form-item prop="cQualityEngineer2" :rules="rules.cQualityEngineer2">-->
<!--          <el-input v-model="modalData.cQualityEngineer2" disabled style="width: 110px"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="IPQC-Lam/Pri/Etch/Slit" prop="cQualityEngineer1Name" :rules="rules.cQualityEngineer1Name">
          <span slot="label" style="" @click="engineerFlag = true"><a herf="#">IPQC-Lam/Pri/Etch/Slit</a></span>
          <el-input v-model="modalData.cQualityEngineer1Name" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="IPQC-Converting" prop="cQualityEngineer2Name" :rules="rules.cQualityEngineer2Name">
          <span slot="label" style="" @click="IPQCFlag = true"><a herf="#">IPQC-Converting</a></span>
          <el-input v-model="modalData.cQualityEngineer2Name" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="FQC" prop="cQualityEngineer3Name" :rules="rules.cQualityEngineer3Name">
          <span slot="label" style="" @click="FQCFlag = true"><a herf="#">FQC</a></span>
          <el-input v-model="modalData.cQualityEngineer3Name" disabled style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="MFG" prop="cManufactureEngineerName" :rules="rules.cManufactureEngineerName">
          <span slot="label" style="" @click="MFGlag = true"><a herf="#">MFG</a></span>
          <el-input v-model="modalData.cManufactureEngineerName" disabled style="width: 170px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveData()">保存</el-button>
        <el-button @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!--项目经理选择弹框-->
    <el-dialog title="PM/Sales" @close="closeProjectManagerInfoDialog" @open="openProjectManagerInfoDialog" :visible.sync="projectManagerFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList"
        stripe
        highlight-current-row
        border
        @row-dblclick="projectManagerRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo()">确定</el-button>
        <el-button @click="projectManagerFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!--PjM选择弹框-->
    <el-dialog title="PjM" @close="closeProjectOwnerInfoDialog" @open="openProjectOwnerInfoDialog" :visible.sync="projectOwnerFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData1" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData1.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData1.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData1.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList1()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList1"
        stripe
        highlight-current-row
        border
        @row-dblclick="projectOwnerRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top:
      10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo1()">确定</el-button>
        <el-button @click="projectOwnerFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!--工程师选择弹框-->
    <el-dialog title="Engineer" @close="closeEngineer6InfoDialog" @open="openEngineer6InfoDialog" :visible.sync="engineer6Flag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData6" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData6.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData6.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData6.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList6()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList6"
        stripe
        highlight-current-row
        border
        @row-dblclick="engineer6RowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top:
      10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo6()">确定</el-button>
        <el-button @click="engineer6Flag = false">关闭</el-button>
      </el-footer>

    </el-dialog>

    <!--工程师选择弹框-->
    <el-dialog title="IPQC-Lam/Pri/Etch/Slit" @close="closeEngineerInfoDialog" @open="openEngineerInfoDialog" :visible.sync="engineerFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData2" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData2.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData2.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData2.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList2()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList2"
        stripe
        highlight-current-row
        border
        @row-dblclick="engineerRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top:
      10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo2()">确定</el-button>
        <el-button @click="engineerFlag = false">关闭</el-button>
      </el-footer>

    </el-dialog>

    <!--IPQC选择弹框-->
    <el-dialog title="IPQC-Converting" @close="closeIPQCInfoDialog" @open="openIPQCInfoDialog" :visible.sync="IPQCFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData3" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData3.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData3.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData3.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList3()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList3"
        stripe
        highlight-current-row
        border
        @row-dblclick="IPQCRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo3()">确定</el-button>
        <el-button @click="IPQCFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!--FQC选择弹框-->
    <el-dialog title="FQC" @close="closeFQCInfoDialog" @open="openFQCInfoDialog" :visible.sync="FQCFlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData4" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData4.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData4.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData4.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList4()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList4"
        stripe
        highlight-current-row
        border
        @row-dblclick="FQCRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo4()">确定</el-button>
        <el-button @click="FQCFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!--MFG选择弹框-->
    <el-dialog title="MFG" @close="closeMFGInfoDialog" @open="openMFGInfoDialog" :visible.sync="MFGlag" width="559px" v-drag>
      <el-form inline="inline" label-position="top" :model="searchBusinessData5" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="用户账号">
          <el-input v-model="searchBusinessData5.username" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="searchBusinessData5.userDisplay" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="是否在用">
          <el-select filterable v-model="searchBusinessData5.active" style="width: 140px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchBusinessInfoList5()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 110"
        :data="businessDataList5"
        stripe
        highlight-current-row
        border
        @row-dblclick="MFGRowDblclick"
        @selection-change="selectionBusiness"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="username"
          header-align="center"
          align="center"
          label="用户账号">
        </el-table-column>
        <el-table-column
          prop="userDisplay"
          header-align="center"
          align="center"
          label="用户名">
        </el-table-column>
        <el-table-column
          prop="active"
          header-align="center"
          align="center"
          label="是否在用">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSelectionInfo5()">确定</el-button>
        <el-button @click="MFGlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="转正式料号" :visible.sync="formalPartNoFlag" width="639px" v-drag>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目编码" prop="projectId" >
          <el-input v-model="modalData.projectId" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目名称" prop="projectDesc" >
          <el-input v-model="modalData.projectDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="客户编码" prop="customerNo" >
          <el-input v-model="modalData.customerNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="客户名称" prop="customerDesc" >
          <el-input v-model="modalData.customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目料号" prop="testPartNo" >
          <el-input v-model="modalData.testPartNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="料号描述" prop="partDesc"  >
          <el-input v-model="modalData.partDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="BU" prop="bu" >
          <el-input v-model="modalData.bu" readonly style="width: 100px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
        <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="ERP正式料号" prop="finalPartNo" :rules="rules.finalPartNo">
          <el-input v-model="modalData.finalPartNo" style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="ERP正式料号描述" prop="finalPartDesc" :rules="rules.finalPartDesc">
          <el-input v-model="modalData.finalPartDesc" style="width: 170px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveFormalPartNo()">保存</el-button>
        <el-button @click="formalPartNoFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-tabs style="margin-top: 0px; width: 100%; height: 250px;" v-model="activeName" class="customer-tab" type="border-card" @tab-click="tabClick">
      <el-tab-pane label="打样记录" name="proofRecord" style="margin-left: -10px">
        <proofRecord ref="proofRecord"></proofRecord>
      </el-tab-pane>
      <el-tab-pane label="转量产阶段文档" name="massProductionStage">
        <el-button type="primary" icon="el-icon-upload" style="margin-top: -5px" @click="projectDocumentList()">文档清单定义</el-button>
          <el-button type="primary" icon="el-icon-upload" style="margin-top: -5px" @click="uploadOtherDocument()">上传其他文档</el-button>
        <el-table
            :data="projectOtherDocumentList"
            border
            style="width: 100%;margin-top: 5px;"
            :height="height + 128"
            ref="proofDocumentTable"
            @row-click="projectOtherDocumentClickRow"
            @current-change="changeCurrentRow1"
            :row-style="rowStyle"
            v-loading="dataListLoading">
            <el-table-column
              header-align="center"
              align="center"
              width="130"
              fixed="left"
              label="操作">
              <template slot-scope="scope">
                <a type="primary" v-if="scope.row.documentDefinitionListId !== '-1'" @click="uploadFile(scope.row)">上传文件</a>
                <a type="text" size="small" v-if="scope.row.documentDefinitionListId !== '-1'" @click="addOrUpdateHandle(scope.row.projectId)">提醒</a>
                <a type="text" size="small" v-if="shouldShowDelete(scope.row)" @click="massProductionDocumentDelete(scope.row)">删除</a>
              </template>
            </el-table-column>
            <el-table-column label="序号" type="index" align="center" :index="indexMethod"></el-table-column>
            <el-table-column label="文档类型" align="center">
              <template slot-scope="scope">
                {{ getCombinedDocumentType(scope.row) }}
              </template>
            </el-table-column>
            <el-table-column
              v-for="(item,index) in columnFileContentArray" :key="index"
              :sortable="item.columnSortable"
              :prop="item.columnProp"
              :header-align="item.headerAlign"
              :show-overflow-tooltip="item.showOverflowTooltip"
              :align="item.align"
              :fixed="item.fixed==''?false:item.fixed"
              :min-width="item.columnWidth"
              :label="item.columnLabel">
              <template slot-scope="scope">
                <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
                <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                   style="width: 100px; height: 80px"/></span>
              </template>
            </el-table-column>
          </el-table>
      </el-tab-pane>
      <el-tab-pane label="所有文档" name="allDocument">
        <el-button type="primary" icon="el-icon-upload" style="margin-top: -5px" @click="projectProductionValidationDocument()">选择生产确认文档</el-button>
        <el-table
          :data="projectAllDocumentList"
          border
          style="width: 100%;margin-top: 5px;"
          :height="height + 128"
          ref="projectAllDocumentDocumentTable"
          @row-click="projectAllDocumentClickRow"
          :row-style="rowStyle"
          v-loading="dataListLoading">
          <el-table-column
            header-align="center"
            align="center"
            width="70"
            fixed="left"
            label="操作">
            <template slot-scope="scope">
              <a type="text" size="small" @click="addOrUpdateHandle(scope.row.projectId)">提醒</a>
            </template>
          </el-table-column>
          <el-table-column label="序号" type="index" align="center" :index="indexMethod"></el-table-column>
          <el-table-column label="文档类型" align="center">
            <template slot-scope="scope">
              {{ getCombinedDocumentType(scope.row) }}
            </template>
          </el-table-column>
          <el-table-column
            v-for="(item,index) in columnProjectAllDocumentList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                 style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="生产文档确认进度" name="productionDocumentsConfirmProgress">
        <el-row>
          <el-col :span="8" class="left-section">
            <div class="table-container" style="height: 214px;margin-top: -10px">
              <p style="margin-top: -5px">文档清单</p>
              <el-table :data="confirmProgressDocumentList"
                        border
                        style="width: 100%;margin-top: -10px;"
                        :height="this.height + 128">
                <el-table-column header-align="center" align="center" width="50" prop="itemNo" label="序号"></el-table-column>
                <el-table-column header-align="center" align="center" prop="documentType" label="文档类型"></el-table-column>
                <el-table-column header-align="center" align="center" prop="fileName" label="文件名"></el-table-column>
              </el-table>
            </div>
          </el-col>
          <el-col :span="15" class="right-section">
            <div class="table-container" style="height: 214px;margin-top: -10px">
              <p style="margin-top: -5px">推送人员清单</p>
              <el-table :data="confirmProgressPusherList"
                        border
                        style="width: 100%;margin-top: -10px;"
                        :height="this.height + 128">
                <el-table-column header-align="center" align="center" width="40" prop="itemNo" label="序号"></el-table-column>
                <el-table-column header-align="center" align="center" width="70" prop="userDisplay" label="指定确认人"></el-table-column>
                <el-table-column header-align="center" align="center" :formatter="formatDate" prop="wantedConfirmDate" label="要求确认日期"></el-table-column>
                <el-table-column header-align="center" align="center" prop="confirmFlag" label="是否确认"></el-table-column>
                <el-table-column header-align="center" align="center" prop="confirmedBy" label="实际确认人"></el-table-column>
                <el-table-column header-align="center" align="center" prop="remark" label="备注"></el-table-column>
                <el-table-column header-align="center" align="center" prop="confirmedDate" label="实际确认时间"></el-table-column>
                <el-table-column header-align="center" align="center" prop="createDate" label="推送时间"></el-table-column>
                <el-table-column header-align="center" align="center" prop="createBy" label="推送人"></el-table-column>
                <el-table-column
                  header-align="center"
                  align="center"
                  width="90"
                  fixed="left"
                  label="操作">
                  <template slot-scope="scope">
                    <a type="text" size="small" @click="viewDocumentFile(scope.row)">查看附件</a>
                    <a type="text" size="small" @click="confirmDocument(scope.row)">确认</a>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
    </el-tabs>

    <el-dialog title="文档清单定义" @close="projectDocumentListVisibleFalse" :visible.sync="projectDocumentListVisible" width="561px" style="margin-top: 10vh" :close-on-click-modal="false">
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目编码" prop="projectId" class="red-label">
          <el-input v-model="modalData.projectId" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目名称" prop="projectDesc" >
          <el-input v-model="modalData.projectDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="BU" prop="bu">
          <el-input v-model="modalData.bu" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="客户编码" prop="customerNo" >
          <el-input v-model="modalData.customerNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="客户名称" prop="customerDesc" >
          <el-input v-model="modalData.customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目分类" prop="cProjectTypeDb">
          <el-input v-model="modalData.cProjectTypeDb" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目料号" prop="testPartNo" :rules="rules.testPartNo" >
          <el-input v-model="modalData.testPartNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="料号描述" prop="partDesc"  >
          <el-input v-model="modalData.partDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="打样单号" prop="proofingNo">
          <el-input v-model="modalData.proofingNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" icon="el-icon-upload" style="margin-top: -5px" @click="addProjectDocumentTypeFlag = true">新增</el-button>
      <el-table
        height="200"
        :data="proofDocumentListDefinition"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnProjectDocumentManifestDefinitionList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{ getColumnValue(scope.row, item) }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="100"
          label="操作">
          <template slot-scope="scope">
            <a v-if="!authDelete" type="text" size="small" @click="deleteProjectDocumentType(scope.row)">删除</a>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="projectDocumentListVisible = false">关闭</el-button>
      </div>
    </el-dialog>

    <!--  新增文档类型  -->
    <el-dialog title="新增文档类型" @close="closeAddProjectDocumentTypeFlag" @open="searchProjectDocumentTypeList" :visible.sync="addProjectDocumentTypeFlag" width="559px" v-drag :close-on-click-modal="false">
      <el-form inline="inline" label-position="top" :model="searchProjectDocumentTypeData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="文档类型ID">
          <el-input v-model="searchProjectDocumentTypeData.documentTypeId" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="文档类型">
          <el-input v-model="searchProjectDocumentTypeData.documentType" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label="责任部门">
          <el-input v-model="searchProjectDocumentTypeData.responsibleDepartment" clearable style="width: 110px"></el-input>
        </el-form-item>
        <el-form-item label=" ">
          <el-button type="primary" style="padding: 3px 12px" @click="searchProjectDocumentTypeList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="200"
        :data="extraProjectDocumentList"
        stripe
        border
        @selection-change="selectionProjectDocument"
        style="width: 100%;">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          prop="documentTypeId"
          header-align="center"
          align="center"
          label="文档类型ID">
        </el-table-column>
        <el-table-column
          prop="documentType"
          header-align="center"
          align="center"
          label="文档类型">
        </el-table-column>
        <el-table-column
          prop="responsibleDepartment"
          header-align="center"
          align="center"
          label="责任部门">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSelectionProjectDocumentType()">确定</el-button>
        <el-button @click="addProjectDocumentTypeFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="选择生产确认文档" :visible.sync="projectProductionValidationDocumentVisible" width="763px" style="margin-top: -5vh" :close-on-click-modal="false">
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目编码" prop="projectId" class="red-label">
          <el-input v-model="modalData.projectId" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目名称" prop="projectDesc" >
          <el-input v-model="modalData.projectDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="BU" prop="bu">
          <el-input v-model="modalData.bu" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目料号" prop="testPartNo" >
          <el-input v-model="modalData.testPartNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="料号描述" prop="partDesc"  >
          <el-input v-model="modalData.partDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="客户编码" prop="customerNo" >
          <el-input v-model="modalData.customerNo" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="客户名称" prop="customerDesc" >
          <el-input v-model="modalData.customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目分类" prop="cProjectTypeDb">
          <el-input v-model="modalData.cProjectTypeDb" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="要求最晚确认日期" prop="wantedConfirmDate" :rules="rules.wantedConfirmDate">
          <el-date-picker
            v-model="modalData.wantedConfirmDate"
            type="date"
            placeholder="选择日期"
            style="width: 110px;">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-tabs v-model="activeName1" style="margin-top: 0px; width: 100%; height: 100%;" type="border-card" @tab-click="tabClick" class="customer-tab">
        <el-tab-pane label="文档选择" name="selectDocument" style="width: 104%">
          <el-table
            v-model="selectedDocumentItems"
            :height="height + 250"
            :data="projectAllDocumentList1"
            border
            style="width: 100%;margin-top: -13px;margin-left: -14px !important; margin-right: 0 !important;"
            @selection-change="handleDocumentSelectionChange">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column label="序号" type="index" align="center" :index="indexMethod"></el-table-column>
            <el-table-column label="文档类型" align="center">
              <template slot-scope="scope">
                {{ getCombinedDocumentType(scope.row) }}
              </template>
            </el-table-column>
            <el-table-column
              v-for="(item,index) in columnProjectAllDocumentList" :key="index"
              :sortable="item.columnSortable"
              :prop="item.columnProp"
              :header-align="item.headerAlign"
              :show-overflow-tooltip="item.showOverflowTooltip"
              :align="item.align"
              :fixed="item.fixed==''?false:item.fixed"
              :min-width="item.columnWidth"
              :label="item.columnLabel">
              <template slot-scope="scope">
                <span v-if="!item.columnHidden">{{ getColumnValue(scope.row, item) }}</span>
                <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="确认人员清单" name="confirmatory" style="width: 104%">
          <el-table
            :height="height + 105"
            :data="projectAllDocumentConfirmatorList"
            border
            style="width: 100%;margin-top: -13px;margin-left: -14px !important;">
            <el-table-column
              prop="username"
              header-align="center"
              align="center"
              min-width="60"
              label="用户账号">
            </el-table-column>
            <el-table-column
              prop="userDisplay"
              header-align="center"
              align="center"
              min-width="80"
              label="用户名">
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <div slot="footer" class="dialog-footer" style="margin-top: 6px">
        <el-button type="primary" @click="saveProductionValidationDocument()">确定</el-button>
        <el-button @click="closeProjectProductionValidationDocumentVisibleDialog">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="确认" @close="closeUploadFileVisible" :visible.sync="confirmVisible" width="579px" style="margin-top: 0vh;height: 100%;" :close-on-click-modal="false">
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="项目编码" prop="projectId" class="red-label">
          <el-input v-model="modalData.projectId" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目名称" prop="projectDesc" >
          <el-input v-model="modalData.projectDesc" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="BU" prop="bu">
          <el-input v-model="modalData.bu" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
        <el-form-item label="项目分类" prop="cProjectTypeDb">
          <el-input v-model="modalData.cProjectTypeDb" readonly style="width: 110px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="指定确认人" prop="userDisplay">
          <el-input v-model="confirmData.userDisplay" readonly style="width: 110px;"></el-input>
        </el-form-item>
        <el-form-item label="要求确认日期" prop="wantedConfirmDate">
          <el-input v-model="confirmData.wantedConfirmDate" readonly style="width: 170px;" class="red-text"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="confirmData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="备注" prop="remark">
          <el-input v-model="confirmData.remark" style="width: 541px" type="textarea" :rows="1"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="confirmData" style="margin-left: 7px;margin-top: -15px;">
        <el-form-item label=" ">
          <a href="javascript:void(0);" @click="triggerUpload" type="text" size="small">点击选择文件</a>
          <tr></tr>
          <el-input v-model="this.fileName" readonly placeholder="文件名称" style="width: 541px"></el-input>
          <el-upload class="custom-upload" :file-list="fileList"
                     action="javascript:void(0);" ref="uploadFile"
                     :on-change="onChange" :on-close="closeFileUpdate"
                     multiple :auto-upload="false"
                     style="text-align: left;margin-top: 0px;margin-left: 6px;display: none;">
          </el-upload>
        </el-form-item>
      </el-form>
      <el-table
        :height="height + 120"
        :data="projectConfirmatorFileList"
        border
        style="width: 100%;margin-top: 17px;margin-left: 0px;">
        <el-table-column
          prop="fileName"
          header-align="center"
          align="center"
          min-width="120"
          label="文件名">
        </el-table-column>
        <el-table-column
          prop="createDate"
          header-align="center"
          align="center"
          min-width="80"
          label="上传时间">
        </el-table-column>
        <el-table-column
          prop="createdBy"
          header-align="center"
          align="center"
          min-width="60"
          label="上传人">
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer" style="margin-top: 0px">
        <el-button type="primary" @click="saveUploadFile()">确定</el-button>
        <el-button @click="closeUploadFileVisible()">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="查看附件" @close="closeViewDocumentFileVisible" :visible.sync="viewDocumentFileVisible" width="520px" style="margin-top: 0vh" :close-on-click-modal="false">
      <el-table
        :height="height + 200"
        :data="projectConfirmatorFileList"
        border
        style="width: 100%;margin-top: 0px;margin-left: 0px;">
        <el-table-column
          prop="fileName"
          header-align="center"
          align="center"
          min-width="120"
          label="文件名">
        </el-table-column>
        <el-table-column
          prop="createDate"
          header-align="center"
          align="center"
          min-width="80"
          label="上传时间">
        </el-table-column>
        <el-table-column
          prop="createdBy"
          header-align="center"
          align="center"
          min-width="50"
          label="上传人">
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          width="100"
          label="操作">
          <template slot-scope="scope">
            <a type="text" size="small" @click="viewFile(scope.row)">查看</a>
            <a type="text" size="small" @click="downloadFile(scope.row)">下载</a>
            <a type="text" size="small" @click="deleteFile(scope.row)">删除</a>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer" style="margin-top: 0px">
        <el-button @click="closeViewDocumentFileVisible()">关闭</el-button>
      </div>
    </el-dialog>

    <upload-file-list-1 folder="projectOtherDocument" title="上传文档" :file-list.sync="fileList" :label="'文档类型ID:'" :no="otherDocumentCurrentRow.documentTypeId" :no-type="otherDocumentCurrentRow.documentType"
                        :proofing-id='proofingCurrentRow.proofingId' :bu="proofingCurrentRow.buNo" :site="proofingCurrentRow.site" :upload-dialog.sync="uploadDialog" :no-desc="otherDocumentCurrentRow.documentDesc" :id="otherDocumentCurrentRow.id"
                        :project-id="proofingCurrentRow.projectId" :project-desc="proofingCurrentRow.projectDesc" :document-type="proofingCurrentRow.documentType" :conclusion="'N/A'"
                        :customer-no="proofingCurrentRow.customerNo" :customer-desc="proofingCurrentRow.customerDesc" :test-part-no="proofingCurrentRow.testPartNo"
                        :part-desc="proofingCurrentRow.partDesc" :column-file-content-array="columnFileContentArray" :proof-document-list="projectOtherDocumentList"
                        path="/upload/test" :is-editable="isEditable" :is-mass-production-stage="isMassProductionStage"></upload-file-list-1>

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

  </div>
</template>

<script>
import {getSiteAndBuByUserName} from "@/api/eam/eam.js"
import {
  searchBusinessInfo,
  searchBusinessInfo1,
  searchBusinessInfo2,
  searchBusinessInfo3,
  searchBusinessInfo4,
  searchBusinessInfo5,
  searchBusinessInfo6
} from "@/api/factory/site.js"
import Chooselist from '@/views/modules/common/Chooselist_eam'
import {removeUserFavorite, saveUserFavorite, userFavoriteList} from '@/api/userFavorite.js'
import {getTableDefaultListLanguage, getTableUserListLanguage,} from "@/api/table.js";
import proofRecord from "./com_project_proof_record";
import {
  eamProjectInfoDelete,
  eamProjectInfoEdit,
  eamProjectInfoSave,
  eamProjectInfoSearch,
  getTestPartNo,
  saveFormalPartNo
} from "@/api/eam/eamProject.js";
import {getProjectOtherDocument} from "@/api/eam/eamProofing.js";
import UploadFileList1 from "../common/uploadFileList1.vue";
import {
  deleteDocumentType, deleteProofDocument,
  editProjectDocument,
  getExtraDocumentList,
  projectDocumentSave,
  proofingDocumentNEW,
  searchProjectAllDocument
} from "../../../api/eam/eamProofing";
import {
  checkConfirmationRecord,
  checkProductionValidationDocument, deleteDocumentInformation,
  deleteProjectFile,
  saveProductionValidationDocument,
  saveProductionValidationDocumentConfirmator,
  searchConfirmatorList,
  searchConfirmProgressDocumentList,
  searchConfirmProgressPusherList,
  searchProjectConfirmatorFileList,
  updateProjectDocumentConfirm,
  uploadProjectFile
} from "../../../api/eam/eamProject";
import row from "element-ui/packages/row";
import moment from 'moment';
import 'moment/locale/zh-cn';
import {downLoadObjectFile} from "../../../api/eam/eam_object_list";
/*打样记录組件*/

  export default {
    computed: {
      row() {
        return row
      }
    },
    components: {
      UploadFileList1,
      Chooselist,
      proofRecord,
    },
    watch: {
      searchData: {
        deep: true,
        handler: function (newV, oldV) {
          this.searchData.customerNo = this.searchData.customerNo.toUpperCase()
        }
      },
      uploadDialog (newValue,oldValue) {
        if (newValue === false) {
          this.getProjectOtherDocument()
        }
      },
      projectProductionValidationDocumentVisible(newVal) {
        if (newVal) {
          this.activeName1 = 'selectDocument';
        }
      }
    },
    data () {
      return {
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "customerNo" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["customerNo"],
        exportFooter: [],
        exportList:[],
        // 导出 end
        tagNo:'',
        fileName:'',
        folder: 'projectConfirm',
        searchData: {
          site: this.$store.state.user.site,
          userName: this.$store.state.user.name,
          projectId: '',
          projectDesc: '',
          partDesc: '',
          customerNo: '',
          customerDesc: '',
          buDesc: '',
          projectCategory: '',
          status: '',
          startDate:'',
          endDate:'',
          projectCreationDate: new Date(),
          projectCloseDate:'',
          needDate:'',
          // active: 'Y',
          page: 1,
          limit: 10,
        },
        height: 200,
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        businessDataList: [],
        businessDataList1: [],
        businessDataList2: [],
        businessDataList3: [],
        businessDataList4: [],
        businessDataList5: [],
        businessDataList6: [],
        dataList: [],
        dataListSelections: [],
        //用于储存选中的行数据
        selectedDocumentItems: [],
        // ======== 复选数据集 ========
        businessSelections: [],
        // ======== 选中的当前行数据 ========
        proofingCurrentRow: {},
        otherDocumentCurrentRow: {},
        projectAllDocumentCurrentRow: {},
        fileList: [],
        projectOtherDocumentList: [],
        extraProjectDocumentList: [],
        projectDocumentSelection: [],
        projectAllDocumentList: [],
        projectAllDocumentList1: [],
        projectAllDocumentConfirmatorList: [],
        proofDocumentListDefinition: [],
        confirmProgressPusherList: [],
        confirmProgressDocumentList: [],
        projectConfirmatorFileList: [],
        viewDocumentFileVisible: false,
        searchProjectDocumentTypeData: {
          site: this.$store.state.user.site,
          projectId: '',
          proofingNo: '*',
          documentTypeId: '',
          documentType: '',
          documentDesc: '',
          responsibleDepartment: '',
          estimatedCompletionDays: '',
          page: 1,
          limit: 1000
        },
        dataListLoading: false,
        modalFlag:false,
        modalDisableFlag:false,
        formalPartNoFlag:false,
        projectManagerFlag:false,
        projectOwnerFlag:false,
        engineerFlag:false,
        engineer6Flag:false,
        IPQCFlag:false,
        FQCFlag:false,
        MFGlag:false,
        uploadDialog:false,
        isEditable: true,
        isMassProductionStage: true,
        projectDocumentListVisible: false,
        addProjectDocumentTypeFlag: false,
        projectProductionValidationDocumentVisible: false,
        confirmVisible: false,
        confirmationPrompted: false, // 是否已经进行过确认提示的标志
        modalData:{
          flag:'',
          bu: '',
          buNo: '',
          site: this.$store.state.user.site,
          projectId: '',
          oriProjectId: '',
          projectDesc:'',
          projectCloseDate:'',
          proofingNo:'',
          needDate:'',
          customerNo:'',
          finalCustomerId:'',
          customerDesc:'',
          projectCategory:'',
          testPartNo:'',
          partDesc:'',
          priority:'',
          projectManager:'',
          projectManagerName:'',
          projectOwner:'',
          projectOwnerName:'',
          cProjectRegion:'',
          cProjectBuildDate:'',
          cQualityEngineer1:'',
          cQualityEngineer1Name:'',
          cQualityEngineer2:'',
          cQualityEngineer2Name:'',
          cQualityEngineer3:'',
          cQualityEngineer3Name:'',
          cManufactureEngineer:'',
          cManufactureEngineerName:'',
          engineer:'',
          engineerName:'',
          //projectCreationDate为当前服务器的时间
          projectCreationDate: new Date(),
          finalPartNo:'',
          finalPartDesc:'',
          wantedConfirmDate: new Date(),
          // active:'',
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
        },
        searchBusinessData:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData1:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData2:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData3:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData4:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData5:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        searchBusinessData6:{
          site: this.$store.state.user.site,
          username: '',
          roleDesc: '',
          userDisplay: '',
          active: '',
          page: 1,
          limit: 10,
        },
        confirmData:{
          site: '',
          projectId: '',
          orderRef1: '',
          documentId: '',
          documentType: '',
          itemNo: '',
          userid: '',
          wantedConfirmDate: '',
          confirmFlag: '',
          confirmedBy: '',
          remark: '',
          confirmedDate: '',
          createDate: '',
          createBy: '',
          page: 1,
          limit: 1000
        },
        departmentList:[],
        activeName: 'proofRecord',
        activeName1: 'selectDocument',
        // 日期限制
        // pickerOptions: {
        //   disabledDate(time) {
        //     return time.getTime() > Date.now();
        //   },
        // },
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1BuDesc',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'buDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectId',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectId',
            headerAlign: "center",
            align: "center",
            columnLabel: '项目编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectDesc',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '项目',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1TestPartNo',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'testPartNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '料号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1customerNo',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: "customerNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "客户编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1customerDesc',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: "customerDesc",
            headerAlign: "center",
            align: "left",
            columnLabel: "客户名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectCreationDate',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: "projectCreationDate",
            headerAlign: "center",
            align: "left",
            columnLabel: "立项日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectCategory',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectCategory',
            headerAlign: "center",
            align: "left",
            columnLabel: '项目分类',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1Priority',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'priority',
            headerAlign: "center",
            align: "left",
            columnLabel: '优先级',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          //区域
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CProjectRegion',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'cProjectRegion',
            headerAlign: "center",
            align: "left",
            columnLabel: '区域',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectManager',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectManager',
            headerAlign: "center",
            align: "left",
            columnLabel: 'PM/Sales',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectOwner',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectOwner',
            headerAlign: "center",
            align: "left",
            columnLabel: 'PjM',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1Engineer',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'engineer',
            headerAlign: "center",
            align: "left",
            columnLabel: 'Engineer',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CQualityEngineer1',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'cQualityEngineer1',
            headerAlign: "center",
            align: "center",
            columnLabel: 'IPQC-Lam/Pri/Etch/Slit',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CQualityEngineer2',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'cQualityEngineer2',
            headerAlign: "center",
            align: "center",
            columnLabel: 'IPQC-Converting',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CQualityEngineer3',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'cQualityEngineer3',
            headerAlign: "center",
            align: "center",
            columnLabel: 'FQC',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CManufactureEngineer',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'cManufactureEngineer',
            headerAlign: "center",
            align: "center",
            columnLabel: 'MFG',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1Status',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'status',
            headerAlign: "center",
            align: "left",
            columnLabel: '项目状态' ,
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1NeedDate',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'needDate',
            headerAlign: "center",
            align: "left",
            columnLabel: '预计完成日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1ProjectCloseDate',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'projectCloseDate',
            headerAlign: "center",
            align: "left",
            columnLabel: '结案日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1FinalPartNo',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'finalPartNo',
            headerAlign: "center",
            align: "left",
            columnLabel: 'ERP正式料号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 101001014,
          //   serialNumber: '101001014Table1Active',
          //   tableId: "101001014Table1",
          //   tableName: "项目信息表",
          //   columnProp: 'active',
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: '在用',
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          //   columnWidth: 120,
          // },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CreateDate',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'createDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1CreateBy',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'createBy',
            headerAlign: "center",
            align: "left",
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1UpdateDate',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'updateDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1UpdateBy',
            tableId: "101001014Table1",
            tableName: "项目信息表",
            columnProp: 'updateBy',
            headerAlign: "center",
            align: "left",
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
        ],
        columnFileContentArray: [
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1FileName',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'fileName',
            headerAlign: "center",
            align: "left",
            columnLabel: '文件名',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 180,
          },
          //是否上传
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1UploadedFlag',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'uploadedFlag',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否上传',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },

          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1Conclusion',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'conclusion',
            headerAlign: "center",
            align: "center",
            columnLabel: '结论',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1DocumentGroupDesc',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'documentGroupDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '文档种类',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table1CreateDate',
            tableId: '103001Table1',
            tableName: '打样文档表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table1CreateBy',
            tableId: '103001Table1',
            tableName: '打样文档表',
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          }
        ],
        columnProjectDocumentManifestDefinitionList:[
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1DocumentTypeId',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'documentTypeId',
            headerAlign: "center",
            align: "center",
            columnLabel: '文档类型ID',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1DocumentType',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'documentType',
            headerAlign: "center",
            align: "left",
            columnLabel: '文档类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1ResponsibleDepartment',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'responsibleDepartment',
            headerAlign: "center",
            align: "left",
            columnLabel: '责任部门',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1EstimatedCompletionDays',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'estimatedCompletionDays',
            headerAlign: "center",
            align: "left",
            columnLabel: '预计完成天数',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
        ],
        columnProjectAllDocumentList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1ProofingId',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'proofingNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '打样单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001013,
            serialNumber: '101001013Table1ProjectPhase',
            tableId: "101001013Table1",
            tableName: "BU文档清单表",
            columnProp: 'projectPhase',
            headerAlign: "center",
            align: "center",
            columnLabel: '项目阶段',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1FileName',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'fileName',
            headerAlign: "center",
            align: "left",
            columnLabel: '文件名',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 180,
          },
          //是否上传
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1UploadedFlag',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'uploadedFlag',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否上传',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },

          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1Conclusion',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'conclusion',
            headerAlign: "center",
            align: "center",
            columnLabel: '结论',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101001014,
            serialNumber: '101001014Table1DocumentGroupDesc',
            tableId: "101001014Table1",
            tableName: "打样文档表",
            columnProp: 'documentGroupDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '文档种类',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table1CreateDate',
            tableId: '103001Table1',
            tableName: '打样文档表',
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 130
          },
          {
            userId: this.$store.state.user.name,
            functionId: 103001,
            serialNumber: '103001Table1CreateBy',
            tableId: '103001Table1',
            tableName: '打样文档表',
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          }
          ],
        levelList: [],
        rules:{
          projectId:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectDesc:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          customerNo:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          customerDesc:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          testPartNo:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          partDesc:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectManager:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          engineer:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectOwner:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          cProjectRegion:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          cQualityEngineer1:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          cQualityEngineer2:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectManagerName:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          engineerName:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          cQualityEngineer1Name:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          cQualityEngineer2Name:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectCategoryType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          documentTypeIdType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          documentTypeType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          responsibleDepartmentType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          estimatedCompletionDaysType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          activeType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          bu:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          finalPartNo:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          finalPartDesc:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          needDate:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          projectCreationDate:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          wantedConfirmDate:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
        },
        projectCategoryList: [
          {
            projectCategory: 'Low Risk',
          },
          {
            projectCategory: 'High Risk',
          },
          {
            projectCategory: 'Sustaining',
          }
        ],
        cProjectRegionList: [
          {
            cProjectRegion: 'Global',
          },
          {
            cProjectRegion: 'APAC',
          },
          {
            cProjectRegion: 'CHINA',
          },
          {
            cProjectRegion: 'EU',
          },
          {
            cProjectRegion: 'US',
          },
          {
            cProjectRegion: 'Mexico',
          },
          {
            cProjectRegion: 'Other',
          },
        ],
        priorityList: [
          {
            priority: 'Low',
          },
          {
            priority: 'Risk',
          },
        ],
        statusList: [
          {
            status: '进行中',
          },
          {
            status: '已结束',
          }
        ],
        userBuList: [],
        authSearch: false,
        authSave: false,
        authUpdate: false,
        authDelete: false,
        menuId: this.$route.meta.menuId,
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 558
      })
    },

    created () {
      // 按钮控制
      this.getButtonAuthData()
      // 获取用户的 site 和 bu
      this.getSiteAndBuByUserName()
      // 校验用户是否收藏
      this.favoriteIsOk()
      // 动态列
      this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      if (!this.authSearch) {
        // 获取数据列表
        this.getDataList()
      }
    },

    methods: {
      // 获取用户的bu
      getSiteAndBuByUserName () {
        let tempData = {
          username: this.$store.state.user.name,
        }
        getSiteAndBuByUserName(tempData).then(({data}) => {
          if (data.code === 0) {
            this.userBuList = data.rows
          }
        })
      },

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 509 ) {
            strVal = this.modalData.customerNo
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 301 ) {
            strVal = this.modalData.projectManager
            this.$refs.baseList.init(val, strVal)
          }
        })
      },

      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 509) {
          this.modalData.customerNo = val.customer_no
          this.modalData.customerDesc = val.customer_desc
        }
        if (this.tagNo === 301) {
          this.modalData.projectManager = val.project_manager
          this.modalData.projectManagerName = val.project_manager
        }
      },

      // 校验用户是否收藏
      favoriteIsOk () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          languageCode: this.$i18n.locale
        }
        userFavoriteList(userFavorite).then(({data}) => {
          for (let i = 0; i < data.list.length; i++) {
            if (this.$route.meta.menuId === data.list[i].menuId) {
              this.favorite = true
            }
          }
        })
      },

      // 收藏 OR 取消收藏
      favoriteFunction () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          functionId: this.$route.meta.menuId,
        }
        if (this.favorite) {
          removeUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = false
          })
        } else {
          // 收藏
          saveUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = true
          })
        }
      },

      //导出excel
      async createExportData () {
        this.searchData.limit = -1
        this.searchData.page = 1
        await eamProjectInfoSearch(this.searchData).then(({data}) => {
          this.exportList = data.page.list
        })
        return this.exportList
      },

      startDownload () {},

      finishDownload () {},

      fields () {
        let json = "{"
        this.columnList.forEach((item, index) => {
          if (index == this.columnList.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")
        return s
      },

      // 获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        eamProjectInfoSearch(this.searchData).then(({data}) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
            // 判断是否全部存在数据
            if (this.totalPage > 0) {
              // 设置选中行
              this.$refs.mainTable.setCurrentRow(this.dataList[0])
              // 加载当前的页签的table
              this.refreshCurrentTabTable()
              this.proofingClickRow(this.dataList[0])
            }
          }
        })
      },
      // ======== 列表操作方法 ========
      /**
       * 单机选中物料信息
       * @param row
       */
      proofingClickRow(row){
        row.proofingId = '*'
        this.proofingCurrentRow=JSON.parse(JSON.stringify(row));
      },
      /**
       * 当前值发生变化的时候修改
       * @param row
       * @param oldRow
       */
      changeCurrentRow (row, oldRow) {
        row.proofingId = '*'
        // 判断是否是获取焦点的事件
        if (row) {
          this.proofingCurrentRow = JSON.parse(JSON.stringify(row))
          //刷新当前页表
          this.refreshCurrentTabTable()
        }
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },

      addModal () {
        //控制台打印打印this.generateNextPartNo()
        this.modalData = {
          flag: '1',
          bu: this.userBuList[0].buNo,
          site: this.$store.state.user.site,
          customerNo:'',
          customerDesc:'',
          projectCategory:'',
          testPartNo:'',
          partDesc:'',
          projectId: '',
          projectDesc:'',
          projectCloseDate:'',
          needDate:'',
          cProjectRegion: '',
          projectManager:'',
          ProjectOwner:'',
          ProjectOwnerName:'',
          projectManagerName:'',
          engineer: '',
          engineerName: '',
          cQualityEngineer1:'',
          cQualityEngineer1Name:'',
          cQualityEngineer2:'',
          cQualityEngineer2Name:'',
          cQualityEngineer3:'',
          cQualityEngineer3Name:'',
          cManufactureEngineer: '',
          cManufactureEngineerName: '',
          projectCreationDate:new Date(),
          createDate: '',
          // active: 'Y',
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
        }
        this.generateNextPartNo().then(testPartNo => {
          this.modalData.testPartNo = testPartNo; // 在异步操作完成后再赋值
        })
        console.log('testPartNo',this.modalData.testPartNo)
        this.modalDisableFlag = false
        this.modalFlag = true
      },
      generateNextPartNo() {
        return new Promise((resolve, reject) => {
          getTestPartNo().then(({ data }) => {
            const stringData = String(data); // 显式转换为字符串
            console.log('stringData',stringData)
            if (stringData === 'null' || stringData === 'undefined' || stringData === '' || stringData === '0') {
              resolve('P00001');
            } else {
              const lastPartNo = parseInt(stringData.substring(1));
              const nextPartNo = lastPartNo + 1;
              let testPartNo;

              if (nextPartNo < 10) {
                testPartNo = 'P0000' + nextPartNo;
              } else if (nextPartNo < 100) {
                testPartNo = 'P000' + nextPartNo;
              } else if (nextPartNo < 1000) {
                testPartNo = 'P00' + nextPartNo;
              } else if (nextPartNo < 10000) {
                testPartNo = 'P0' + nextPartNo;
              } else {
                testPartNo = 'P' + nextPartNo;
              }

              resolve(testPartNo);
            }
          }).catch(error => {
            reject('Failed to fetch testPartNo: ' + error);
          });
        });
      },
      changeFormalPartNo (row) {
        this.modalData = {
          flag: '2',
          site: row.site,
          bu: row.site + '_' + row.buNo,
          customerNo: row.customerNo,
          customerDesc: row.customerDesc,
          projectCategory: row.projectCategory,
          testPartNo: row.testPartNo,
          partDesc: row.partDesc,
          projectId: row.projectId,
          projectDesc: row.projectDesc,
          projectCloseDate: row.projectCloseDate,
          needDate: row.needDate,
          cProjectRegion: row.cProjectRegion,
          projectManager: row.projectManager,
          projectManagerName: row.projectManagerName,
          projectOwner: row.projectOwner,
          projectOwnerName: row.projectOwnerName,
          engineer: row.engineer,
          engineerName: row.engineerName,
          cQualityEngineer1: row.cQualityEngineer1,
          cQualityEngineer1Name: row.cQualityEngineer1Name,
          cQualityEngineer2: row.cQualityEngineer2,
          cQualityEngineer2Name: row.cQualityEngineer2Name,
          projectCreationDate: row.projectCreationDate,
          cQualityEngineer3: row.cQualityEngineer3,
          cQualityEngineer3Name: row.cQualityEngineer3Name,
          cManufactureEngineer: row.cManufactureEngineer,
          cManufactureEngineerName: row.cManufactureEngineerName,
          finalPartNo: row.finalPartNo,
          finalPartDesc: row.finalPartDesc,
          // active: row.active,
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
        }
        this.formalPartNoFlag = true
      },
      addProofRecord (row) {
        let inData1={
          site: row.site,
          buNo: row.buNo,
          projectId: row.projectId,
          projectDesc: row.projectDesc,
          customerNo: row.customerNo,
          customerDesc: row.customerDesc,
          bu: row.site + '_' + row.buNo,
          testPartNo: row.testPartNo,
          partDesc: row.partDesc,
          projectCategory: row.projectCategory,
          cProjectTypeDb: row.projectCategory,
          proofingNo: '',
          rrequiredDeliveryDate: '',
          createDate: new Date(),
          createBy: this.$store.state.user.name,
        }
        this.$refs.proofRecord.init1(inData1)
      },
      updateModal (row) {
        this.modalData = {
          flag: '2',
          site: row.site,
          bu: row.site + '_' + row.buNo,
          customerNo: row.customerNo,
          customerDesc: row.customerDesc,
          projectCategory: row.projectCategory,
          testPartNo: row.testPartNo,
          partDesc: row.partDesc,
          projectId: row.projectId,
          projectDesc: row.projectDesc,
          priority: row.priority,
          projectCloseDate: row.projectCloseDate,
          needDate: row.needDate,
          cProjectRegion: row.cProjectRegion,
          projectManager: row.projectManager,
          projectManagerName: row.projectManager,
          projectOwner: row.projectOwner,
          projectOwnerName: row.projectOwner,
          engineer: row.engineer,
          engineerName: row.engineer,
          cQualityEngineer1: row.cQualityEngineer1,
          cQualityEngineer1Name: row.cQualityEngineer1,
          cQualityEngineer2: row.cQualityEngineer2,
          cQualityEngineer2Name: row.cQualityEngineer2,
          cQualityEngineer3: row.cQualityEngineer3,
          cQualityEngineer3Name: row.cQualityEngineer3,
          cManufactureEngineer: row.cManufactureEngineer,
          cManufactureEngineerName: row.cManufactureEngineer,
          projectCreationDate: row.projectCreationDate,
          // active: row.active,
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
        }
        this.modalDisableFlag = true
        this.modalFlag = true
      },

      // 删除
      eamProjectInfoDelete (row) {
        this.$confirm(`是否删除这个项目信息?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          eamProjectInfoDelete(row).then(({data}) => {
            if (data && data.code === '0') {
              this.getDataList()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },
      getRowProjectInfo(){
        let inData={
          site: this.proofingCurrentRow.site,
          projectId: this.proofingCurrentRow.projectId,
          testPartNo: this.proofingCurrentRow.testPartNo,
          // username:this.$store.state.user.name,
          page: 1,
          limit: 1000
        }
        this.$refs.proofRecord.init(inData)
      },
      saveData () {
        this.modalData.projectManager = this.modalData.projectManagerName
        this.modalData.projectOwner = this.modalData.projectOwnerName
        this.modalData.cQualityEngineer1 = this.modalData.cQualityEngineer1Name
        this.modalData.cQualityEngineer2 = this.modalData.cQualityEngineer2Name
        this.modalData.cQualityEngineer3 = this.modalData.cQualityEngineer3Name
        this.modalData.cManufactureEngineer = this.modalData.cManufactureEngineerName
        this.modalData.engineer = this.modalData.engineerName
        this.modalData.oriProjectId = this.modalData.projectId
        this.modalData.finalCustomerId = this.modalData.customerNo
        if (this.modalData.projectId === '' || this.modalData.projectId == null) {
          this.$message.warning('请输入项目编码！')
          return
        }
        if (this.modalData.projectDesc === '' || this.modalData.projectDesc == null) {
          this.$message.warning('请输入项目名称！')
          return
        }
        if (this.modalData.customerNo === '' || this.modalData.customerNo == null) {
          this.$message.warning('请输入客户编码！')
          return
        }
        if (this.modalData.customerDesc === '' || this.modalData.customerDesc == null) {
          this.$message.warning('请输入客户名称！')
          return
        }
        //请选择立项日期
        if (this.searchData.projectCreationDate === '' || this.searchData.projectCreationDate == null) {
          this.$message.warning('请选择立项日期！')
          return
        }
        if (this.modalData.needDate === '' || this.modalData.needDate == null) {
          this.$message.warning('请选择预计完成日期！')
          return
        }
        if (this.modalData.projectCategory === '' || this.modalData.projectCategory == null) {
          this.$message.warning('请选择项目分类！')
          return
        }
        if (this.modalData.testPartNo === '' || this.modalData.testPartNo == null) {
          this.$message.warning('请输入项目料号！')
          return
        }
        if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
          this.$message.warning('请输入料号描述！')
          return
        }
        if (this.modalData.bu === '' || this.modalData.bu == null) {
          this.$message.warning('请选择BU！')
          return
        }
        if (this.modalData.projectManager === '' || this.modalData.projectManager == null) {
          this.$message.warning('请输入PM/Sales！')
          return
        }if (this.modalData.projectOwner === '' || this.modalData.projectOwner == null) {
          this.$message.warning('请输入PjM！')
          return
        }
        if (this.modalData.engineer === '' || this.modalData.engineer == null) {
          this.$message.warning('请输入Engineer！')
          return
        }
        if (this.modalData.cQualityEngineer1 === '' || this.modalData.cQualityEngineer1 == null) {
          this.$message.warning('请输入IPQC-Lam/Pri/Etch/Slit！')
          return
        }
        if (this.modalData.cQualityEngineer2 === '' || this.modalData.cQualityEngineer2 == null) {
          this.$message.warning('请输入IPQC-Converting！')
          return
        }
        if (this.modalData.cQualityEngineer3 === '' || this.modalData.cQualityEngineer3 == null) {
          this.$message.warning('请输入FQC！')
          return
        }
        if (this.modalData.cManufactureEngineer === '' || this.modalData.cManufactureEngineer == null) {
          this.$message.warning('请输入MFG！')
          return
        }
        // if (this.modalData.active === '' || this.modalData.active == null) {
        //   this.$message.warning('选择是否在用！')
        //   return
        // }
        if (this.modalData.flag === '1') {
          this.newProjectDocument(this.modalData)
          eamProjectInfoSave(this.modalData).then(({data}) => {
            if (data && data.code === '0') {
              this.getDataList()
              this.modalFlag=false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {},
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        } else {
          this.editProjectDocument(this.modalData)
          eamProjectInfoEdit(this.modalData).then(({data}) => {
            if (data && data.code === '0') {
              this.getDataList()
              this.modalFlag=false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },
      editProjectDocument(modalData) {
        modalData.buNo = modalData.bu.split('_')[1]
        modalData.proofingNo = '*'
        editProjectDocument(modalData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code === 0) {
            this.$message({
              message: '编辑成功',
              type: 'success'
            })
            //刷新表格
            this.refreshCurrentTabTable()
          }
        })
      },
      newProjectDocument(modalData) {
        modalData.buNo = modalData.bu.split('_')[1]
        modalData.proofingNo = '*'
        projectDocumentSave(modalData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code === 0) {
            this.$message({
              message: '新增成功',
              type: 'success'
            })
            this.documentListVisible = false
            //刷新表格
            this.refreshCurrentTabTable()
          }
        })
      },
      searchBusinessInfoList1 () {
        searchBusinessInfo1(this.searchBusinessData1).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList1 = data.rows;
          }
        })
      },
      searchBusinessInfoList () {
        searchBusinessInfo(this.searchBusinessData).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList = data.rows;
          }
        })
      },
      searchBusinessInfoList2 () {
        searchBusinessInfo2(this.searchBusinessData2).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList2 = data.rows;
          }
        })
      },
      searchBusinessInfoList3 () {
        searchBusinessInfo3(this.searchBusinessData3).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList3 = data.rows;
          }
        })
      },
      searchBusinessInfoList4 () {
        searchBusinessInfo4(this.searchBusinessData4).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList4 = data.rows;
          }
        })
      },
      searchBusinessInfoList5 () {
        searchBusinessInfo5(this.searchBusinessData5).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList5 = data.rows;
          }
        })
      },
      searchBusinessInfoList6 () {
        searchBusinessInfo6(this.searchBusinessData6).then(({data}) => {
          if (data && data.code === 0){
            this.businessDataList6 = data.rows;
          }
        })
      },
      saveFormalPartNo (){
        saveFormalPartNo(this.modalData).then(({data}) => {
          if (data && data.code === '0') {
            this.getDataList()
            this.formalPartNoFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      // 打开项目经理
      openProjectManagerInfoDialog () {
        //请求
        this.searchBusinessInfoList();
      },
      // 打开项目负责人
      openProjectOwnerInfoDialog () {
        //请求
        this.searchBusinessInfoList1();
      },
      // 打开工程师
      openEngineerInfoDialog () {
        //请求
        this.searchBusinessInfoList2();
      },
      // 打开IPQC
      openIPQCInfoDialog () {
        //请求
        this.searchBusinessInfoList3();
      },
      // 打开FQC
      openFQCInfoDialog () {
        //请求
        this.searchBusinessInfoList4();
      },
      // 打开MFG
      openMFGInfoDialog () {
        //请求
        this.searchBusinessInfoList5();
      },
      openEngineer6InfoDialog () {
        //请求
        this.searchBusinessInfoList6();
      },
      // 关闭
      closeProjectManagerInfoDialog () {
        this.businessDataList = []
        this.projectManagerFlag = false
      },
      closeProjectOwnerInfoDialog () {
        this.businessDataList1 = []
        this.projectOwnerFlag = false
      },
      //关闭
      closeEngineerInfoDialog () {
        this.businessDataList2 = []
        this.engineerFlag = false
      },
      closeEngineer6InfoDialog () {
        this.businessDataList6 = []
        this.engineer6Flag = false
      },
      //关闭
      closeIPQCInfoDialog () {
        this.businessDataList3 = []
        this.IPQCFlag = false
      },
      //关闭
      closeFQCInfoDialog () {
        this.businessDataList4 = []
        this.FQCFlag = false
      },
      //关闭
      closeMFGInfoDialog () {
        this.businessDataList5 = []
        this.MFGlag = false
      },
      projectManagerRowDblclick (row) {
        this.modalData.projectManager = row.username
        this.modalData.projectManagerName = row.userDisplay
        this.projectManagerFlag = false
      },
      projectOwnerRowDblclick (row) {
        this.modalData.projectOwner = row.username
        this.modalData.projectOwnerName = row.userDisplay
        this.projectOwnerFlag = false
      },
      engineerRowDblclick (row) {
        this.modalData.cQualityEngineer1 = row.username
        this.modalData.cQualityEngineer1Name = row.userDisplay
        this.engineerFlag = false
      },
      engineer6RowDblclick (row) {
        this.modalData.engineer = row.username
        this.modalData.engineerName = row.userDisplay
        this.engineer6Flag = false
      },
      IPQCRowDblclick (row) {
        this.modalData.cQualityEngineer2 = row.username
        this.modalData.cQualityEngineer2Name = row.userDisplay
        this.IPQCFlag = false
      },
      FQCRowDblclick (row) {
        this.modalData.cQualityEngineer3 = row.username
        this.modalData.cQualityEngineer3Name = row.userDisplay
        this.FQCFlag = false
      },
      MFGRowDblclick (row) {
        this.modalData.cManufactureEngineer = row.username
        this.modalData.cManufactureEngineerName = row.userDisplay
        this.MFGlag = false
      },
      selectionBusiness (val) {
        this.businessSelections = val
        this.$refs.selectDiv.init(this.businessSelections)
      },
      saveSelectionInfo () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.projectManager = str
        this.modalData.projectManagerName = strName
        this.projectManagerFlag = false
      },
      saveSelectionInfo1 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.projectOwner = str
        this.modalData.projectOwnerName = strName
        this.projectOwnerFlag = false
      },
      saveSelectionInfo2 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.cQualityEngineer1 = str
        this.modalData.cQualityEngineer1Name = strName
        this.engineerFlag = false
      },
      saveSelectionInfo3 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.cQualityEngineer2 = str
        this.modalData.cQualityEngineer2Name = strName
        this.IPQCFlag = false
      },
      saveSelectionInfo4 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.cQualityEngineer3 = str
        this.modalData.cQualityEngineer3Name = strName
        this.FQCFlag = false
      },
      saveSelectionInfo5 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        })
        this.modalData.cManufactureEngineer = str
        this.modalData.cManufactureEngineerName = strName
        this.MFGlag = false
      },
      saveSelectionInfo6 () {
        let str = ''
        let strName = ''
        this.businessSelections.forEach((item, index) => {
          if (index === this.businessSelections.length - 1) {
            str += item.username
            strName += item.userDisplay
          } else {
            str += item.username + ','
            strName += item.userDisplay + ','
          }
        }
        )
        this.modalData.engineer = str
        this.modalData.engineerName = strName
        this.engineer6Flag = false
      },
      closeClear () {
        this.modalData.bu = ''
        this.modalData.projectId = ''
        this.modalData.projectDesc = ''
        this.modalData.projectCloseDate = ''
        this.modalData.needDate = ''
        this.modalData.customerNo = ''
        this.modalData.customerDesc = ''
        this.modalData.projectCategory = ''
        this.modalData.testPartNo = ''
        this.modalData.partDesc = ''
        this.modalData.projectManager = ''
        this.modalData.projectManagerName = ''
        this.modalData.engineer = ''
        this.modalData.engineerName = ''
        this.modalData.cQualityEngineer1 = ''
        this.modalData.cQualityEngineer1Name = ''
        this.modalData.cQualityEngineer2 = ''
        this.modalData.cQualityEngineer2Name = ''
        this.modalData.projectCreationDate = new Date()
      },
      projectOtherDocumentClickRow (row) {
        row.id = row.documentDefinitionListId
        this.otherDocumentCurrentRow = JSON.parse(JSON.stringify(row))
        console.log('row',row)
        console.log('this.otherDocumentCurrentRow',this.otherDocumentCurrentRow)
      },
      changeCurrentRow1 (row, oldRow) {
        row.id = row.documentDefinitionListId
        // 判断是否是获取焦点的事件
        if (row) {
          this.otherDocumentCurrentRow.bu = this.otherDocumentCurrentRow.site + "-" + this.otherDocumentCurrentRow.buNo
          this.otherDocumentCurrentRow = JSON.parse(JSON.stringify(row))
          console.log('row1',row)
          console.log('this.otherDocumentCurrentRow1',this.otherDocumentCurrentRow)
          //刷新当前页表
          this.refreshCurrentTabTable()
        }
      },
      projectAllDocumentClickRow (row) {
        this.projectAllDocumentCurrentRow = JSON.parse(JSON.stringify(row))
      },
      /**
       * 上传文件
       */
      uploadFile () {
        this.isEditable = false;
        this.fileList = []
        this.otherDocumentCurrentRow.proofingId= '*'
        this.uploadDialog = true
        //打开组件 去做新增业务
        // this.$nextTick(() => {
        //   this.$refs.partUploadFile.init(currentData);
        // })
      },
      uploadOtherDocument () {
        this.isEditable = true;
        this.fileList = []
        this.otherDocumentCurrentRow = {
          proofingId: '*',
          documentTypeId: '', // 清空文档类型ID
          id: '-1'
        };
        this.uploadDialog = true
        //打开组件 去做新增业务
        // this.$nextTick(() => {
        //   this.$refs.partUploadFile.init(currentData);
        // })
      },
      massProductionDocumentDelete(row) {
        let tempData = {
          site: row.site,
          username: this.$store.state.user.name,
          buNo: row.buNo,
          proofingNo: row.proofingNo,
          projectId: row.projectId,
          projectDesc: row.projectDesc,
          customerId: row.customerNo,
          customerDesc: row.customerDesc,
          testPartNo: row.testPartNo,
          partDesc: row.partDesc,
          id: row.id,
          fileName: row.fileName,
          uploadedFlag: row.uploadedFlag,
          cAdditionalInfo: row.cAdditionalInfo,
          createBy: row.createdBy,
          documentDefinitionListId: row.documentDefinitionListId,
          documentType: row.documentType,
          documentId: row.documentId,
        }
        if (tempData.createBy !== tempData.username) {
          this.$message({
            message: '只能删除自己创建的打样记录',
            type: 'warning'
          })
        }else {
          this.$confirm('是否删除该转量产阶段文档的文件?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            deleteProofDocument(tempData).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                //刷新表格
                this.getProjectOtherDocument()
                this.getProofDocument()
              }
              // 否则提示后端返回的错误信息
              else {
                this.$message.warning(data.msg)
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });
          });
        }
      },
      getProjectOtherDocument () {
        let tempData = {
          site: this.$store.state.user.site,
          username: this.$store.state.user.name,
          buNo: this.proofingCurrentRow.buNo,
          proofingId: '*',
          projectId: this.proofingCurrentRow.projectId,
          projectDesc: this.proofingCurrentRow.projectDesc,
          testPartNo: this.proofingCurrentRow.testPartNo,
          partDesc: this.proofingCurrentRow.partDesc,
          customerId: this.proofingCurrentRow.customerNo,
          customerDesc: this.proofingCurrentRow.customerDesc,
          page: 1,
          limit: 1000
        }
        getProjectOtherDocument(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.projectOtherDocumentList = data.page.list
            for (let i = 0; i < this.projectOtherDocumentList.length; i++) {
              this.projectOtherDocumentList[i].buNo = this.proofingCurrentRow.buNo
            }
          } else {
            this.projectOtherDocumentList = []
          }
        })
      },
      getColumnValue(row, column) {
        // 根据列的配置信息决定显示的值
        if (column.columnProp === 'documentType') {
          return this.getCombinedDocumentType(row);
        }
        else if (column.columnProp === 'documentDesc') {
          return row.documentDesc; // 或者根据实际需求处理其他字段的显示
        }
        else {
          return row[column.columnProp]; // 默认返回对应列的值
        }
      },
      getCombinedDocumentType(row) {
        // 根据您的需求，组合或拼接需要显示的字段
        if (row.documentType === null || row.documentType === undefined) {
          return row.documentDesc
        }else {
          return row.documentType
        }
      },
      // 动态列开始 获取 用户保存的 格式列
      async getTableUserColumn(tableId, columnId) {
        let queryTableUser = {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          status: true,
          languageCode: this.$i18n.locale
        }
        await getTableUserListLanguage(queryTableUser).then(({data}) => {
          if (data.rows.length > 0) {
            //this.columnList1 = []
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              // case 2:
              //   this.detailColumnList = data.rows
              //   break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            this.getColumnList(tableId, columnId)
          }
        })
      },
      projectDocumentList () {
        this.modalData = {
          site: this.proofingCurrentRow.site,
          buNo: this.proofingCurrentRow.buNo,
          projectId: this.proofingCurrentRow.projectId,
          projectDesc: this.proofingCurrentRow.projectDesc,
          customerNo: this.proofingCurrentRow.customerNo,
          customerDesc: this.proofingCurrentRow.customerDesc,
          bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo,
          testPartNo: this.proofingCurrentRow.testPartNo,
          partDesc: this.proofingCurrentRow.partDesc,
          projectCategory: this.proofingCurrentRow.projectCategory,
          cProjectTypeDb: this.proofingCurrentRow.projectCategory,
          proofingNo: '*',
          rrequiredDeliveryDate: '',
          createDate: new Date(),
          createBy: this.$store.state.user.name,
          limit: 1000,
          page: 1
        }
        this.getProjectOtherDocument()
// 遍历proofDocumentList
        for (let i = 0; i < this.projectOtherDocumentList.length; i++) {
          if (this.projectOtherDocumentList[i].documentTypeId !== 'N/A') {
            this.proofDocumentListDefinition.push(this.projectOtherDocumentList[i])
          }
        }
        this.projectDocumentListVisible = true
      },
      projectDocumentListVisibleFalse() {
        this.projectDocumentListVisible = false
        this.proofDocumentListDefinition = []
      },
      deleteProjectDocumentType(row) {
        this.$confirm('是否删除该文档清单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteDocumentType(row).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '删除成功',
                type: 'success',
              })
              this.getProjectOtherDocument()
              this.getProofDocument()
            } else {
              this.$message.warning(data.msg)
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      closeAddProjectDocumentTypeFlag() {
        this.addProjectDocumentTypeFlag = false
        this.searchProjectDocumentTypeData = {
          site: this.$store.state.user.site,
          projectId: '',
          proofingNo: '*',
          documentTypeId: '',
          documentType: '',
          responsibleDepartment: '',
          estimatedCompletionDays: '',
          page: 1,
          limit: 1000
        }
        this.extraProjectDocumentList = []
      },
      filteredProjectAllDocumentList() {
        this.projectAllDocumentList.map(item => {
          item.id = item.documentDefinitionListId
        })
        return this.projectAllDocumentList.filter(item => item.uploadedFlag !== 'N')
      },
      searchProjectDocumentTypeList() {
        this.searchProjectDocumentTypeData.proofingNo = '*'
        this.searchProjectDocumentTypeData.projectId = this.modalData.projectId
        getExtraDocumentList(this.searchProjectDocumentTypeData).then(({data}) => {
          if (data && data.code === 0) {
            this.extraProjectDocumentList = data.page.list
          } else {
            this.extraProjectDocumentList = []
          }
        })
      },
      selectionProjectDocument(val) {
        this.projectDocumentSelection = val
      },
      saveSelectionProjectDocumentType() {
        if (this.projectDocumentSelection.length === 0) {
          this.$message({
            message: '请选择文档类型',
            type: 'error'
          })
          this.extraProjectDocumentList = []
          return
        }
        this.projectDocumentSelection.forEach((item) => {
          const inData = {
            site: this.$store.state.user.site,
            proofingNo: '*',
            projectId: this.modalData.projectId,
            documentTypeId: item.documentTypeId,
            documentType: item.documentType,
            responsibleDepartment: item.responsibleDepartment,
            estimatedCompletionDays: item.estimatedCompletionDays,
            createBy: this.$store.state.user.name,
          }
          proofingDocumentNEW(inData).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code === 0) {
              this.$message({
                message: '新增成功',
                type: 'success'
              })
              this.addProjectDocumentTypeFlag = false
              //刷新表格
              this.getProjectOtherDocument()
              this.refreshCurrentTabTable()
            } else {
              this.$message({
                message: '新增失败',
                type: 'error'
              })
            }
          })
        })
      },
      searchProjectAllDocumentList () {
        let inData = {
          site: this.$store.state.user.site,
          username: this.$store.state.user.name,
          buNo: this.proofingCurrentRow.buNo,
          proofingNo: 'ALL',
          projectId: this.proofingCurrentRow.projectId,
          projectDesc: this.proofingCurrentRow.projectDesc,
          testPartNo: this.proofingCurrentRow.testPartNo,
          partDesc: this.proofingCurrentRow.partDesc,
          customerId: this.proofingCurrentRow.customerNo,
          customerDesc: this.proofingCurrentRow.customerDesc,
          page: 1,
          limit: 1000
        }
        searchProjectAllDocument(inData).then(({data}) => {
          if (data && data.code === 0){
            this.projectAllDocumentList = data.page.list;
          }
        })
      },
      projectProductionValidationDocument () {
        this.modalData = {
          site: this.proofingCurrentRow.site,
          buNo: this.proofingCurrentRow.buNo,
          projectId: this.proofingCurrentRow.projectId,
          projectDesc: this.proofingCurrentRow.projectDesc,
          customerNo: this.proofingCurrentRow.customerNo,
          customerDesc: this.proofingCurrentRow.customerDesc,
          bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo,
          testPartNo: this.proofingCurrentRow.testPartNo,
          partDesc: this.proofingCurrentRow.partDesc,
          projectCategory: this.proofingCurrentRow.projectCategory,
          cProjectTypeDb: this.proofingCurrentRow.projectCategory,
          proofingNo: 'ALL',
          requiredDeliveryDate: '',
          wantedConfirmDate: new Date(),
          createDate: new Date(),
          createBy: this.$store.state.user.name,
          limit: 1000,
          page: 1
        }
        this.projectProductionValidationDocumentVisible = true
        this.projectAllDocumentList1 = this.filteredProjectAllDocumentList()
      },
      handleDocumentSelectionChange(val) {
        // 文档选择页签中选中数据发生变化时的处理
        this.selectedDocumentItems = val;
      },
      searchConfirmatorList() {
        let inData = {
          site: this.proofingCurrentRow.site,
          username: this.$store.state.user.name,
          buNo: this.proofingCurrentRow.buNo,
          proofingNo: 'ALL',
          projectId: this.proofingCurrentRow.projectId,
          projectDesc: this.proofingCurrentRow.projectDesc,
          testPartNo: this.proofingCurrentRow.testPartNo,
          partDesc: this.proofingCurrentRow.partDesc,
          customerId: this.proofingCurrentRow.customerNo,
          customerDesc: this.proofingCurrentRow.customerDesc,
          page: 1,
          limit: 1000
        }
        searchConfirmatorList(inData).then(({data}) => {
          if (data && data.code === 0){
            this.projectAllDocumentConfirmatorList = data.page.list;
          }
        })
      },
      saveProductionValidationDocument() {
        let confirmatorPromises = this.projectAllDocumentConfirmatorList.map(item => {
          let inData = {
            site: this.proofingCurrentRow.site,
            orderRef1: this.proofingCurrentRow.projectId,
            userid: item.userid,
            itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1,
            wantedConfirmDate: this.modalData.wantedConfirmDate,
            createBy: this.$store.state.user.name
          };
          return saveProductionValidationDocumentConfirmator(inData);
        });

        Promise.all(confirmatorPromises)
          .then(confirmatorResults => {
            let allConfirmatorSuccess = confirmatorResults.every(result => result.data && result.data.code === 0);
            if (allConfirmatorSuccess) {
              let inData = {
                site: this.proofingCurrentRow.site,
                orderRef1: this.proofingCurrentRow.projectId,
                selectedDocumentItems: this.selectedDocumentItems,
              }
              let saveDocumentPromises = this.handleDocumentSave(inData);
              saveDocumentPromises
                .then(() => {
                  this.$message({
                    message: '新增成功',
                    type: 'success'
                  });
                  this.projectProductionValidationDocumentVisible = false;
                  this.confirmationPrompted = false;
                })
                .catch(error => {
                  console.error('保存文档出错:', error);
                  this.$message({
                    message: '新增失败，请检查文档',
                    type: 'error'
                  });
                });
            } else {
              this.$message({
                message: '新增失败，请检查确认人员',
                type: 'error'
              });
            }
          })
          .catch(error => {
            console.error('保存确认人员出错:', error);
            this.$message({
              message: '新增失败，请检查确认人员',
              type: 'error'
            });
          });
      },

      handleDocumentSave(inData) {
        return new Promise((resolve, reject) => {
          checkProductionValidationDocument(inData)
            .then(({ data }) => {
              if (data) {
                // 存在生产确认记录，且尚未进行过确认提示
                if (!this.confirmationPrompted) {
                  this.confirmationPrompted = true; // 标记已进行过确认提示
                  this.askForDeleteConfirmation()
                    .then(confirmDelete => {
                      if (confirmDelete === 'true') {
                        this.handleDeleteAndSave(inData)
                          .then(() => resolve())
                          .catch(() => reject());
                      } else {
                        resolve(); // 用户取消操作，直接结束
                      }
                    })
                    .catch(() => {
                      reject('对话框出错'); // 对话框出错处理
                    });
                } else {
                  // 已经进行过一次确认提示，直接保存文档信息
                  this.handleDeleteAndSave(inData)
                    .then(() => resolve())
                    .catch(() => reject());
                }
              } else {
                // 不存在生产确认记录，直接保存文档信息
                this.handleDeleteAndSave(inData)
                  .then(() => resolve())
                  .catch(() => reject());
              }
            })
            .catch(error => {
              console.error('检查生产确认文档出错:', error);
              reject('检查生产确认文档失败');
            });
        });
      },

      handleDeleteAndSave(inData) {
        return new Promise((resolve, reject) => {
          checkConfirmationRecord(inData)
            .then(({ data }) => {
              if (data) {
                this.$confirm('该项目已经有人员进行了确认，是否删除重新推送确认信息？', '提示', {
                  confirmButtonText: '是',
                  cancelButtonText: '否',
                  type: 'warning'
                })
                  .then(() => {
                    // 用户确认删除，执行删除操作
                    deleteDocumentInformation(inData)
                      .then(() => {
                        this.projectAllDocumentConfirmatorList.map(item => {
                          let inData1 = {
                            site: this.proofingCurrentRow.site,
                            orderRef1: this.proofingCurrentRow.projectId,
                            userid: item.userid,
                            itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1,
                            wantedConfirmDate: this.modalData.wantedConfirmDate,
                            createBy: this.$store.state.user.name
                          };
                          saveProductionValidationDocumentConfirmator(inData1);
                        });
                        this.saveDocumentInformation(inData)
                          .then(() => resolve())
                          .catch(() => reject());
                      })
                      .catch(() => reject('删除确认记录失败'));
                  })
                  .catch(() => {
                    reject('用户取消操作');
                  });
              } else {
                deleteDocumentInformation(inData)
                  .then(() => {
                    this.projectAllDocumentConfirmatorList.map(item => {
                      let inData1 = {
                        site: this.proofingCurrentRow.site,
                        orderRef1: this.proofingCurrentRow.projectId,
                        userid: item.userid,
                        itemNo: this.projectAllDocumentConfirmatorList.indexOf(item) + 1,
                        wantedConfirmDate: this.modalData.wantedConfirmDate,
                        createBy: this.$store.state.user.name
                      };
                      saveProductionValidationDocumentConfirmator(inData1);
                    });
                    this.saveDocumentInformation(inData)
                      .then(() => resolve())
                      .catch(() => reject());
                  })
                  .catch(() => reject('删除确认记录失败'));
              }
            })
            .catch(() => {
              reject('检查确认记录失败');
            });
        });
      },

      saveDocumentInformation(inData) {
        return saveProductionValidationDocument(inData)
          .then(response => {
            if (response.data && response.data.code === 0) {
              return Promise.resolve();
            } else {
              return Promise.reject('保存文档失败');
            }
          })
          .catch(() => {
            return Promise.reject('保存文档失败');
          });
      },

      askForDeleteConfirmation() {
        return new Promise((resolve, reject) => {
          this.$confirm('该项目已存在生产确认记录，是否删除重新推送确认信息？', '提示', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning'
          })
            .then(() => {
              resolve('true');
            })
            .catch(() => {
              resolve('false');
            });
        });
      },


      getConfirmProgressDocumentList() {
        let inData = {
          site: this.proofingCurrentRow.site,
          orderRef1: this.proofingCurrentRow.projectId,
          page: 1,
          limit: 1000
        }
        searchConfirmProgressDocumentList(inData).then(({data}) => {
          if (data && data.code === 0){
            this.confirmProgressDocumentList = data.page.list;
          }
        })
      },
      getConfirmProgressPusherList() {
        let inData = {
          site: this.proofingCurrentRow.site,
          orderRef1: this.proofingCurrentRow.projectId,
          page: 1,
          limit: 1000
        }
        searchConfirmProgressPusherList(inData).then(({data}) => {
          if (data && data.code === 0){
            this.confirmProgressPusherList = data.page.list;
          }
        })
      },
      confirmDocument(row) {
        // 将this.$store.state.user.id转为字符串
        let userId = this.$store.state.user.id.toString()
        if (row.userid !== userId) {
          // 提示指定确认人为row.confirmedBy,是否继续
          this.$confirm('指定确认人为' + row.userDisplay + '，是否继续确认？', '提示', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning'
          })
            .then(() => {
              this.confirmData = {
                site: row.site,
                documentType: row.documentType,
                orderRef1: row.orderRef1,
                itemNo: row.itemNo,
                userid: row.userid,
                username: row.username,
                userDisplay: row.userDisplay,
                wantedConfirmDate: row.wantedConfirmDate,
                confirmFlag: row.confirmFlag,
                confirmedDate: new Date(),
                createBy: row.createBy,
                createDate: row.createDate,
                confirmedBy: this.$store.state.user.userDisplay,
                documentId: row.documentId,
                remark: row.remark
              }
              this.modalData = {
                site: this.proofingCurrentRow.site,
                projectId: this.proofingCurrentRow.projectId,
                projectDesc: this.proofingCurrentRow.projectDesc,
                testPartNo: this.proofingCurrentRow.testPartNo,
                partDesc: this.proofingCurrentRow.partDesc,
                customerNo: this.proofingCurrentRow.customerNo,
                customerDesc: this.proofingCurrentRow.customerDesc,
                buNo: this.proofingCurrentRow.buNo,
                bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo,
                cProjectTypeDb: this.proofingCurrentRow.projectCategory,
              }
              this.getProjectConfirmatorFileList(row)
              this.confirmVisible = true
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消操作'
              });
            });
        }else {
          this.confirmData = {
            site: row.site,
            documentType: row.documentType,
            orderRef1: row.orderRef1,
            itemNo: row.itemNo,
            userid: row.userid,
            username: row.username,
            userDisplay: row.userDisplay,
            wantedConfirmDate: row.wantedConfirmDate,
            confirmFlag: row.confirmFlag,
            confirmedDate: new Date(),
            createBy: row.createBy,
            createDate: row.createDate,
            confirmedBy: this.$store.state.user.name,
            documentId: row.documentId,
            remark: row.remark
          }
          this.modalData = {
            site: this.proofingCurrentRow.site,
            projectId: this.proofingCurrentRow.projectId,
            projectDesc: this.proofingCurrentRow.projectDesc,
            testPartNo: this.proofingCurrentRow.testPartNo,
            partDesc: this.proofingCurrentRow.partDesc,
            customerNo: this.proofingCurrentRow.customerNo,
            customerDesc: this.proofingCurrentRow.customerDesc,
            buNo: this.proofingCurrentRow.buNo,
            bu: this.proofingCurrentRow.site + '_' + this.proofingCurrentRow.buNo,
            cProjectTypeDb: this.proofingCurrentRow.projectCategory,
          }
          this.getProjectConfirmatorFileList(row)
          this.confirmVisible = true
        }
      },
      /*选择上传文件时*/
      onChange(file,fileList){
        const newFileName = file.name;
        if (this.fileName) {
          this.fileName += ', ' + newFileName;
        } else {
          this.fileName = newFileName;
        }
        this.fileList.push(file);
      },
      triggerUpload() {
        this.$refs.uploadFile.$el.querySelector('input').click()
      },
      saveUploadFile(){
        this.confirmData.confirmedDate = moment(this.confirmData.confirmedDate).utcOffset('+8').format('YYYY-MM-DD HH:mm:ss');
        this.confirmData.confirmedBy = this.$store.state.user.userDisplay;
        console.log('this.confirmData',this.confirmData)
        updateProjectDocumentConfirm(this.confirmData) .then(({data}) => {
          if (data.code === 0) {
            this.confirmVisible = false;
            this.getConfirmProgressDocumentList();
            this.getConfirmProgressPusherList();
          }else {
            this.$message.warning(data.msg);
          }
        })
        let remark = this.confirmData.remark;
        const formData = new FormData();
        //片接文件
        for (let i = 0; i < this.fileList.length; i++) {
          formData.append("file",this.fileList[i].raw)
        }
        formData.append("folder", this.folder);
        formData.append("orderRef1", this.confirmData.site);
        formData.append("orderRef4", this.confirmData.orderRef1);
        formData.append("orderRef2", this.confirmData.itemNo);
        formData.append("orderRef3", this.confirmData.userid);
        formData.append("remark", remark);
        uploadProjectFile(formData).then(({data}) => {
          if (data.code === 0) {
            this.$message.success('操作成功');
            //清空文件上传记录
            this.$refs.uploadFile.clearFiles();
            this.closeFileUpdate();
            this.projectConfirmatorFileList = [];
          }else {
            this.$message.warning(data.msg);
          }
        })
      },
      closeFileUpdate() {
        this.fileName = '';
        this.uploadDialog = false;
        //this.fileRemark = ''
        this.$refs.uploadFile.clearFiles()
        this.fileList = []
      },
      getProjectConfirmatorFileList (row) {
        let inData = {
          orderRef1: row.site,
          orderRef3: row.userid,
          orderRef2: row.itemNo,
          orderRef4: row.orderRef1,
          page: 1,
          limit: 1000
        }
        searchProjectConfirmatorFileList(inData).then(({data}) => {
          if (data && data.code === 0){
            this.projectConfirmatorFileList = data.page.list;
          }
        })
      },
      closeUploadFileVisible(){
        this.confirmVisible = false;
        this.projectConfirmatorFileList = [];
        this.fileList = [];
        this.closeFileUpdate()
      },
      closeViewDocumentFileVisible(){
        this.viewDocumentFileVisible = false;
        this.projectConfirmatorFileList = [];
      },
      viewDocumentFile(row) {
        this.confirmData = {
          site: row.site,
          documentType: row.documentType,
          orderRef1: row.orderRef1,
          itemNo: row.itemNo,
          userid: row.userid,
          username: row.username,
          userDisplay: row.userDisplay,
          wantedConfirmDate: row.wantedConfirmDate,
          confirmFlag: row.confirmFlag,
          confirmedDate: new Date(),
          createBy: row.createBy,
          createDate: row.createDate,
          confirmedBy: this.$store.state.user.userDisplay,
          documentId: row.documentId,
          remark: row.remark
        }
        let inData = {
          orderRef1: row.site,
          orderRef2: row.itemNo,
          orderRef3: row.userid,
          orderRef4: row.orderRef1,
          page: 1,
          limit: 1000
        }
        searchProjectConfirmatorFileList(inData).then(({data}) => {
          if (data && data.code === 0){
            this.projectConfirmatorFileList = data.page.list;
          }
        })
        this.viewDocumentFileVisible = true
      },
      deleteFile(row) {
        if (this.confirmData.confirmedBy === this.$store.state.user.userDisplay) {
          this.$confirm('是否删除该文件?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let inData = {
              id: row.id,
              orderRef1: row.orderRef1,
              orderRef2: row.orderRef2,
              orderRef3: row.orderRef3,
              orderRef4: row.orderRef4,
              createdBy: this.$store.state.user.name
            }
            deleteProjectFile(inData).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getProjectConfirmatorFileList(this.confirmData)
              } else {
                this.$message({
                  message: '删除失败',
                  type: 'error'
                })
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });
          });
        } else {
          this.$message({
            message: '只有确认人员才能删除文件',
            type: 'error'
          })
        }
      },
      shouldShowDelete(row) {
        console.log('row.documentId',row.documentId)
        console.log('row.projectPhase',row.projectPhase)
        console.log('Y/N',row.documentId !== null || row.projectPhase !== 'SOP文档')
        // 根据条件判断是否显示删除操作
        if (row.projectPhase === 'SOP文档') {
          return false
        }else return row.documentId !== null;
      },
      // 查看文件
      viewFile(row) {
        // 预览文件
        let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
        let type = ''
        if (image.includes(row.fileType.toLowerCase())) {
          type = 'image/' + row.fileType
        }
        let video = ['mp4', 'avi', 'mov', 'wmv', 'flv']
        if (video.includes(row.fileType.toLowerCase())) {
          type = 'video/' + row.fileType
        }
        let txt = ['txt']
        if (txt.includes(row.fileType.toLowerCase())) {
          type = 'text/plain'
        }
        let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
        if (office.includes(row.fileType.toLowerCase())) {
          if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx') {
            type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
          } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx') {
            type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
          } else {
            type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
          }
        }
        let pdf = ['pdf']
        if (pdf.includes(row.fileType.toLowerCase())) {
          type = 'application/pdf'
        }
        downLoadObjectFile(row).then(({data}) => {
          const blob = new Blob([data], { type: type });
          // 创建URL来生成预览
          const fileURL = URL.createObjectURL(blob);
          // 在新标签页中打开文件预览
          const newTab = window.open(fileURL, '_blank')
        })
      },
      // 下载
      downloadFile (row) {
        downLoadObjectFile(row)
          .then(({data}) => {
            // 不限制文件下载类型
            const blob = new Blob([data], {type:'application/octet-stream;charset=utf-8'})
            // 下载文件名称
            const fileName = row.fileName
            // a标签下载
            const linkNode = document.createElement('a')
            linkNode.download = fileName // a标签的download属性规定下载文件的名称
            linkNode.style.display = 'none'
            linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
            document.body.appendChild(linkNode)
            linkNode.click() // 模拟在按钮上的一次鼠标单击
            URL.revokeObjectURL(linkNode.href) // 释放URL 对象
            document.body.removeChild(linkNode)
          })
      },
      closeProjectProductionValidationDocumentVisibleDialog() {
        this.projectProductionValidationDocumentVisible = false;
        this.activeName1 = 'selectDocument';
      },
      formatDate(row, column) {
        // row 是当前行的数据对象
        // column 是当前列的属性信息对象
        const date = row[column.property];
        if (date) {
          const s = new Date(date).toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' });
          return s.replace(/\//g, '-')
        } else {
          return '';
        }
      },
      indexMethod(index) {
        return index + 1;
      },
      // 获取 tableDefault 列
      async getColumnList (tableId, columnId) {
        let queryTable= {
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          languageCode: this.$i18n.locale
        }
        await getTableDefaultListLanguage(queryTable).then(({data}) => {
          if (!data.rows.length == 0) {
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              // case 2:
              //   this.detailColumnList = data.rows
              //   break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            // this.showDefault = true.
          }
        })
      },
      // 列表表格选择替换
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },
      refreshCurrentTabTable () {
        if (this.activeName == 'proofRecord') {
          this.getRowProjectInfo();
        }
        if (this.activeName == 'massProductionStage') {
          this.getProjectOtherDocument();
        }
        if (this.activeName == 'allDocument'){
          this.searchProjectAllDocumentList()
          this.searchConfirmatorList()
        }
        if (this.activeName == 'productionDocumentsConfirmProgress'){
          this.getConfirmProgressDocumentList()
          this.getConfirmProgressPusherList()
        }
      },
      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let saveFlag = this.isAuth(this.menuId+":save")
        let updateFlag = this.isAuth(this.menuId+":update")
        let deleteFlag = this.isAuth(this.menuId+":delete")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authSave = !saveFlag
        this.authUpdate = !updateFlag
        this.authDelete = !deleteFlag
      },
      rowStyle ({row}) {
        if (this.proofingCurrentRow.documentTypeId === row.documentTypeId) {
          return { 'background-color': '#E8F7F6', cursor: 'pointer' };
        }
      },
    }
  }
</script>
<style scoped lang="scss">
.el-tabs__nav {
  margin-left: 0 !important;
}
.red-text /deep/ .el-input__inner {
  color: red;
}
/deep/ .left-section {
  flex: 1; /* 左边部分占据剩余空间 */
  margin-right: 10px; /* 右边与左边之间的间隔 */
  margin-left: -10px; /* 左边与父元素之间的间隔 */
}

/deep/ .right-section {
  width: 66%; /* 右边部分宽度占满剩余空间 */
  margin-right: 5px;
}

/deep/ .custom-upload .el-upload-dragger {
  width: 150px;
  height: 150px;
  text-align: center;
  position: relative;
  overflow: hidden;
  /* 添加其他样式 */
}

/deep/ .table-container {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
}
</style>
