<template>
  <div class="mod-config">
    <!-- 查询条件 -->
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.bu" placeholder="请选择" clearable style="width: 120px">
          <el-option
            v-for = "i in userBuList"
            :key = "i.buNo"
            :label = "i.buDesc"
            :value = "i.buNo">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="询价单号">
        <el-input v-model="searchData.rfqNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item label="客户编码">
        <span style="cursor: pointer" slot="label" @click="getBaseList(509,2)"><a herf="#">客户编码</a></span>
        <el-input v-model="searchData.customerNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'客户名称'">
        <el-input v-model="searchData.customerDesc" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'询价日期'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.requestStartDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label=" ">
        <div style="text-align: center;"><i class="el-icon-right"></i></div>
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.requestEndDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
    </el-form>
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'优先等级'">
        <dict-data-select v-model="searchData.priorityLevel" clearable style="width: 120px" :use-default-value="false"
                          dict-type="inquiry_info_priority_level"/>
      </el-form-item>
      <el-form-item :label="'状态'">
        <el-select v-model="searchData.status" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option label="草稿" value="C"></el-option>
          <el-option label="下达" value="B"></el-option>
          <el-option label="已转报价" value="A"></el-option>
          <el-option label="已驳回" value="D"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'PjM'">
        <span style="cursor: pointer" slot="label" @click="getBaseList(2008,1)"><a herf="#">PjM</a></span>
        <el-input v-model="searchData.requesterName" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'报价专员'">
        <span style="cursor: pointer" slot="label" @click="getBaseList(2002,1)"><a herf="#">报价专员</a></span>
        <el-input v-model="searchData.quoterName" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'要求报价日期'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.requiredCompletionStartDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label=" ">
        <div style="text-align: center;"><i class="el-icon-right"></i></div>
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.requiredCompletionEndDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button @click="getDataList()">查询</el-button>
        <el-button type="primary" @click="addModal()">新增</el-button>
        <el-button type="primary" icon="el-icon-upload" @click="handleImportQuotation()">导入</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ "导出" }}
        </download-excel>
      </el-form-item>
    </el-form>

    <!-- 询价列表 -->
    <el-table
      @header-dragend="handleColumnResize"
      height="37vh"
      :data="dataList"
      border
      :row-style="rowStyle"
      ref="mainTable"
      @row-click="inquiryClickRow"
      @current-change="changeCurrentRow"
      v-loading="dataListLoading"
      style="width: 100%;margin-top: 5px">
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :align="item.align"
        :fixed="item.fixed === ''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <div v-if="item.columnProp !== 'status' && item.columnProp !== 'priorityLevel'">
            <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>
          </div>
          <div v-else-if="item.columnProp === 'status'">
            <span v-if="!item.columnHidden">
              <span v-if="scope.row.visible === 'N'">审批未通过</span>
              <span v-else-if="scope.row.status === 'C'">草稿</span>
              <span v-else-if="scope.row.status === 'B'">下达</span>
              <span v-else-if="scope.row.status === 'A'">已转报价</span>
              <span v-else-if="scope.row.status === 'D'">已驳回</span>
            </span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                               style="width: 100px; height: 80px"/></span>
          </div>
          <div v-else-if="item.columnProp === 'priorityLevel'">
            <span v-if="!item.columnHidden">
              <span v-if="scope.row.priorityLevel === 'A'">普通</span>
              <span v-if="scope.row.priorityLevel === ' B'">重要</span>
              <span v-if="scope.row.priorityLevel === ' C'">紧急</span>
            </span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                               style="width: 100px; height: 80px"/></span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="100"
        label="操作">
        <template slot-scope="scope">
<!--          <el-link style="cursor: pointer" @click="addInquiryPartModal(scope.row)">新增产品</el-link>-->
          <el-link style="cursor: pointer" v-if="scope.row.status === 'C' || scope.row.visible === 'N'"
                   @click="updateModalStatus(scope.row,'B')">下达
          </el-link>
          <el-link style="cursor: pointer" @click="updateModal(scope.row)">编辑</el-link>
          <el-link style="cursor: pointer" @click="delModal(scope.row)">删除</el-link>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页插件 -->
    <el-pagination style="margin-top: 0px"
                   @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="modalData.title" v-drag @close="closeSaveDataDialog"
               :close-on-click-modal="false" top="10%" :visible.sync="modalFlag" width="568px">
      <!--               @open="openSaveDataDialog"-->
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="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.buDesc"
              :value = "i.buNo">
            </el-option>
          </el-select>
        </el-form-item>
            <el-form-item prop="customerNo" label="客户编码">
              <span style="cursor: pointer" slot="label" @click="getBaseList(509,1)"><a herf="#">客户编码</a></span>
                  <el-input v-model="modalData.customerNo" @blur="customerNoBlur" style="width: 110px;"></el-input>
                  <el-input disabled v-model="modalData.customerDesc" style="width: 300px;"></el-input>
            </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-top: -5px;">
        <el-form-item label="询价日期" prop="requestDate" :rules="rules.requestDate">
          <el-date-picker
            v-model="modalData.requestDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            style="width: 110px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item prop="requesterName" label="PjM">
          <span style="cursor: pointer" slot="label" @click="getBaseList(2008,2)"><a herf="#">PjM</a></span>
          <el-input v-model="modalData.requester" @blur="requesterBlur(2008)" style="width: 110px;"></el-input>
          <el-input disabled v-model="modalData.requesterName" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item label="客户询价单号" prop="customerInquiryNo">
          <el-input v-model="modalData.customerInquiryNo" style="width: 166px;"></el-input>
        </el-form-item>
      </el-form>

          <!--          <el-col :span="4">-->
          <!--            <el-form-item prop="trackerName">-->
          <!--              <span v-if="quotationInformationFlag('tracker') === 'N' && modalData.flag === '2'" slot="label">采购专员</span>-->
          <!--              <span v-else style="cursor: pointer" slot="label" @click="getBaseList(2000)"><a herf="#">采购专员</a></span>-->
          <!--              <el-input :disabled="quotationInformationFlag('tracker') === 'N' && modalData.flag === '2'" v-model="modalData.trackerName" readonly></el-input>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-top: -5px;">
        <el-form-item label="要求报价日期" prop="requiredCompletionDate" :rules="rules.requiredCompletionDate">
          <el-date-picker
            v-model="modalData.requiredCompletionDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            style="width: 110px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item prop="quoterName" label="报价专员">
          <span style="cursor: pointer" slot="label" @click="getBaseList(2002,2)"><a herf="#">报价专员</a></span>
          <el-input v-model="modalData.quoter" @blur="quoterBlur(2002)" style="width: 110px;"></el-input>
          <el-input disabled v-model="modalData.quoterName" style="width: 120px;"></el-input>
        </el-form-item>
        <el-form-item label="优先等级" >
          <dict-data-select v-if="modalFlag"
                            v-model="modalData.priorityLevel" dict-type="inquiry_info_priority_level"
                            style="width: 166px;">
          </dict-data-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
            <el-form-item label="备注" style="display: block;min-height: 90px">
              <el-input type="textarea" :autosize="{minRows: 2, maxRows: 3}" resize='none'
                        v-model="modalData.remark"></el-input>
            </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: -10px;padding-bottom:5px;text-align:center">
        <el-button type="primary" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 页签 -->
    <el-tabs style="margin-top: 0px; width: 100%; height: 40vh;" v-model="activeTable" class="customer-tab" type="border-card" @tab-click="tabClick">
      <!-- 询价详细信息页签 -->
      <el-tab-pane label="产品明细" name="inquiryPart">
        <!-- 询价产品明细列表 -->
        <el-table
          @header-dragend="handleColumnResize"
          height="37vh"
          :data="inquiryPartDataList"
          border
          ref="secondaryTable"
          v-loading="dataListLoading"
          style="width: 100%;margin-top: 5px">
          <el-table-column
            v-for="(item,index) in inquiryPartColumnList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :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="120"
            label="操作">
            <template slot-scope="scope">
              <el-link style="cursor: pointer" @click="updateInquiryPartModal(scope.row)">编辑</el-link>
              <el-link style="cursor: pointer" @click="delInquiryPartModal(scope.row)">删除</el-link>
              <el-link style="cursor: pointer" @click="inquiryPartItemModal(scope.row)">属性</el-link>
              <el-link style="cursor: pointer" @click.native="navigateToMes(scope.row.id)">详情</el-link>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 询价明细 相关文档 -->
      <el-tab-pane label="相关文档" name="inquiryDocument">
        <oss-components label="申请单号" style="margin-top: 5px" height="44vh" :columns="ossColumns" :order-ref1="inquiryCurrentRow.site" :order-ref2="inquiryCurrentRow.id"
                        :rfq-no="inquiryCurrentRow.rfqNo">
        </oss-components>
      </el-tab-pane>
    </el-tabs>

    <el-dialog :title="inquiryPartModalData.title" v-drag @close="closeInquiryPartSaveDataDialog"
               :close-on-click-modal="false" top="10%" :visible.sync="inquiryPartModalFlag" width="422px">
<!--      @open="openInquiryPartSaveDataDialog"-->
      <el-form :inline="true" label-position="top" :model="inquiryPartModalData" :rules="inquiryPartRules" style="margin-top: -5px;">
<!--        <el-form-item prop="partNo" label="产品编码">-->
<!--          <el-input v-model="inquiryPartModalData.partNo" disabled style="width: 128px;"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item prop="partDesc" label="产品名称">
          <el-input v-model="inquiryPartModalData.partDesc" style="width: 128px"></el-input>
        </el-form-item>
        <el-form-item label="BU" prop="bu" :rules="inquiryPartRules.bu">
          <el-select v-model="inquiryPartModalData.bu" placeholder="请选择" :disabled="inquiryPartModalDisableFlag" style="width: 118px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.buDesc"
              :value = "i.buNo">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="询价数量" prop="inquiryQty" :rules="inquiryPartRules.inquiryQty">
          <el-input-number :controls="false" :step="0" v-model="inquiryPartModalData.inquiryQty" style="width: 118px;"></el-input-number>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="inquiryPartModalData" :rules="inquiryPartRules" style="margin-top: -5px;">
        <el-form-item prop="umId">
          <span style="cursor: pointer" slot="label" @click="getBaseList(510)"><a herf="#">计量单位</a></span>
          <el-input v-model="inquiryPartModalData.umId" @blur="umIdBlur(510)" style="width: 128px"></el-input>
          <el-input v-model="inquiryPartModalData.umName" disabled style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="inquiryPartModalData" :rules="inquiryPartRules" style="margin-top: -5px;">
        <el-form-item prop="codeNo" :rules="rules.codeNo">
          <span style="cursor: pointer" slot="label" @click="getBaseList(220)"><a herf="#">属性模板</a></span>
          <el-input v-model="inquiryPartModalData.codeNo" @blur="modelBlur(220)" style="width: 128px"></el-input>
          <el-input v-model="inquiryPartModalData.codeDesc" disabled style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item label="备注" style="display: block;min-height: 90px">
          <el-input type="textarea" :autosize="{minRows: 2, maxRows: 3}" resize='none'
                    v-model="inquiryPartModalData.remark"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: -10px;padding-bottom:5px;text-align:center">
        <el-button type="primary" @click="saveInquiryPartData()">保存</el-button>
        <el-button type="primary" @click="inquiryPartModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="询价产品属性维护" v-drag  :visible.sync="inquiryPartItemModalFlag" :close-on-click-modal="false"
               width="690px" style="height: 100%;margin-top: -60px" class="customer-dialog">
      <el-container style="height: 100%;">
        <el-form :inline="true"  label-position="top" label-width="80px">
          <!--  第一行   -->
          <el-row class="customer-row">
            <el-col :span="8">
              <el-form-item label="BU">
                <el-input v-model="this.inquiryPartItemModalData.buDesc" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="询价单号">
                <el-input v-model="this.inquiryPartItemModalData.rfqNo" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="产品编码">
                <el-input v-model="this.inquiryPartItemModalData.partNo" disabled></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!--工具属性的使用记录-->
          <fieldset class="customer-fieldset" style="width: 650px;">
            <legend>属性维护</legend>
            <div style="margin-top: 5px">
              <el-button type="primary" :loading="loading" @click="clickInquiryPartItemSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
<!--            <el-button type="primary" @click="refreshPropertiesModal" v-if="attributeDialog">刷新属性模板</el-button>-->
            </div>
            <div class="rq ">
              <el-table
                @header-dragend="handleColumnResize"
                :height="height - 78"
                :data="inquiryPartItemDataList"
                border
                style="width: 100%;margin-top: 5px">
                <el-table-column
                  v-for="(item,index) in inquiryPartItemColumnList" :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">
                    <div v-if="attributeDialog">
                      <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                        <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>
                      </div>
                      <div v-else>
                        {{scope.row.valueTypeDb==='T'?scope.row.textValue:scope.row.numValue}}
                      </div>
                    </div>
                    <div v-else>
                      <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
                        <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>
                      </div>
                      <div v-else>
                        <div v-if="scope.row.valueChooseFlag !== 'Y'">
                          <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueType === '数字'" :controls="false"></el-input-number>
                          <el-input v-model="scope.row.textValue" v-else></el-input>
                        </div>
                        <div v-else>
                          <el-select style="width: 100%;" v-if="scope.row.valueType === '文本'" v-model="scope.row.textValue">
                            <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                          </el-select>
                          <el-select style="width: 100%;" v-else v-model="scope.row.numValue">
                            <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
                          </el-select>
                        </div>
                      </div>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </fieldset>
        </el-form>
      </el-container>
      <el-footer style="height:30px;margin-top: 10px;padding-bottom:5px;text-align:center">
<!--        <el-button type="primary" @click="saveInquiryPartData()">保存</el-button>-->
        <el-button type="primary" @click="inquiryPartItemModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- chooseList模态框 -->
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

    <!-- 导入 -->
    <quotationUpload ref="quotationUpload" @refreshPageTables="getDataList()" v-drag></quotationUpload>

  </div>
</template>

<script>
import Chooselist from '@/views/modules/common/Chooselist_eam'
import {getSiteAndBuByUserName} from "../../../api/qc/qc";
import {searchInquiryApplicationInfo,addInquiryApplicationInfo,updateInquiryApplicationInfo,deleteInquiryApplicationInfo} from "@/api/inquiry/inquiryApplication";
import {searchInquiryDetailInfo,addInquiryDetailInfo,updateInquiryDetailInfo,deleteInquiryDetailInfo} from "@/api/inquiry/inquiryDetail";
import {getItemListByInquiryPartAndCodeNo,updateInquiryPartItemList} from "@/api/inquiry/inquiryDetail";
import DictDataSelect from "../sys/dict-data-select.vue";
import {queryCustomerList} from "@/api/customer/customer";
import {verifyData} from "@/api/part/partInformation";
import {EventBus} from "../../../main";
import {partInformationSearch} from "../../../api/part/partInformation";
import quotationUpload from "../quote/quotation_upload.vue";
import OssComponents from "../oss/ossComponents.vue";
import {getTableDefaultListLanguage, getTableUserListLanguage, updateColumnSize} from "../../../api/table";
import {deleteQuotationFile, downLoadQuotationFile} from "../../../api/quote/quotationInformation";

export default {
  computed: {
    //   quotationInformationFlag () {
    //     return (value) => {
    //       if (!this.plmQuotationInformationArr){
    //         return 'N'
    //       }
    //       let arr = this.plmQuotationInformationArr.filter(a => a.fieldId === value)
    //       if (arr.length > 0) {
    //         return arr[0].updateFlag
    //       }
    //       return 'N'
    //     }
    //   },
  },
  components: {
    OssComponents,
    quotationUpload,
    DictDataSelect,
    Chooselist
  },
  props:{
    height:{
      type:Number,
      default:200
    }
  },
  watch: {
    searchData: {
      deep: true,
      handler: function (newV, oldV) {
        if (this.searchData.customerNo !== '' || this.searchData.rfqNo !== ''){
          this.searchData.customerNo = this.searchData.customerNo.toUpperCase()
          this.searchData.rfqNo = this.searchData.rfqNo.toUpperCase()
        }
      }
    },
    modalData: {
      deep: true,
      handler: function (newV, oldV) {
        if (this.modalData.customerNo !== '' || this.modalData.rfqNo !== '') {
          this.modalData.customerNo = this.modalData.customerNo.toUpperCase()
          this.modalData.rfqNo = this.modalData.rfqNo.toUpperCase()
        }
      }
    },
    inquiryPartModalData: {
      deep: true,
      handler: function (newV, oldV) {
        if (this.inquiryPartModalData.partNo !== '' || this.inquiryPartModalData.codeNo !== '' || this.inquiryPartModalData.umId !== '') {
          this.inquiryPartModalData.partNo = this.inquiryPartModalData.partNo.toUpperCase()
          this.inquiryPartModalData.codeNo = this.inquiryPartModalData.codeNo.toUpperCase()
          this.inquiryPartModalData.umId = this.inquiryPartModalData.umId.toUpperCase()
        }
      }
    }
  },
  data() {
    return {
      userBuList: [],
      copyPriceCheckDetail:{},
      loading:false,
      attributeDialog:true,
      priceCheckRule: {
        associatedPartNo:[{required: true, message: ' ', trigger: 'change'},],
        materialRequired:[{required: true, message: ' ', trigger: 'change'},],
        yearlyOrMonthlyRequirement:[{required: true, message: ' ', trigger: 'change'},],
        runningWidth:[{required: true, message: ' ', trigger: 'change'},],
      },
      savePriceDetail:{
        site:'',
        quotationNo:'',
        associatedPartNo:'',
        materialRequired:'',
        yearlyOrMonthlyRequirement:'',
        runningWidth:'',
      },
      activeTab:'part',
      priceCheckPropertiesList: [],
      // 导出
      exportData: [],
      exportName: '询价申请' + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ['询价申请'],
      exportFooter: [],
      resultList: [],
      uploadUrl: '/plm/quotationInformation/uploadExcel',
      // ======== 行高 ========
      secondHeight: 200,
      // ======== 分页 ========
      pageIndex: 1,
      pageSize: 50,
      totalPage: 0,
      selectedDataNum: 0,
      // 条件查询
      searchData: {
        site: this.$store.state.user.site,
        id: '',
        customerNo: '',
        customerDesc: '',
        rfqNo: '',
        bu: '',
        requestStartDate: '',
        requestEndDate: '',
        requiredCompletionStartDate: '',
        requiredCompletionEndDate: '',
        status: '',
        quoterName: '',
        requesterName: '',
        priorityLevel: '',
        page: 1,
        limit: 10,
        menuId: this.$route.meta.menuId,
      },
      // 其它
      dataListLoading: false,
      // 选择项目弹框开关
      chooseProjectListFlag: false,
      // 初始页签
      activeTable: 'inquiryPart',
      // ======== 数据对象 ========
      modalData: {
        flag: '',
        title: '',
        site: this.$store.state.user.site,
        userName: this.$store.state.user.name,
        id: '',
        rfqNo: '',
        customerNo: '',
        customerDesc: '',
        requestDate: '',
        requester: '',
        requesterName: '',
        customerInquiryNo: '',
        priorityLevel: '',
        requiredCompletionDate: '',
        quoter: '',
        quoterName: '',
        status: '',
        bomStatusDb: '',
        remark: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
      },
      inquiryPartModalData: {
        flag: '',
        title: '',
        site: this.$store.state.user.site,
        userName: this.$store.state.user.name,
        id: '',
        rfqId: '',
        partNo: '',
        partDesc: '',
        inquiryQty: '',
        umId: '',
        umName: '',
        codeNo: '',
        codeDesc: '',
        remark: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
      },
      inquiryPartItemModalData: {
        bu: '',
        buDesc: '',
        rfqNo: '',
        partNo: '',
        partDesc: '',
        umId: '',
        umName: '',
        codeNo: '',
        codeDesc: '',
        textValue: '',
        numValue: '',
        valueType: '',
        valueTypeDb: '',
        valueChooseFlag: '',
        availableValueList: [],
      },
      ossColumns:[
        {
          userId: this.$store.state.user.name,
          functionId: 103001,
          serialNumber: '103001Table2FileName',
          tableId: '103001Table2',
          tableName: '文件信息表',
          columnProp: 'fileName',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '文件名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        },
        {
          userId: this.$store.state.user.name,
          functionId: 103001,
          serialNumber: '103001Table2FileRemark',
          tableId: '103001Table2',
          tableName: '文件信息表',
          columnProp: 'fileRemark',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 240
        },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 103001,
        //   serialNumber: '103001Table2OrderRef3',
        //   tableId: '103001Table2',
        //   tableName: '文件信息表',
        //   columnProp: 'orderRef3',
        //   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: '103001Table2CreateDate',
          tableId: '103001Table2',
          tableName: '文件信息表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '上传时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        },
        {
          userId: this.$store.state.user.name,
          functionId: 103001,
          serialNumber: '103001Table2CreatedBy',
          tableId: '103001Table2',
          tableName: '文件信息表',
          columnProp: 'createdBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '上传人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        }
      ],
      // ======== 数据列表 ========
      dataList: [],
      inquiryPartDataList: [],
      inquiryPartItemDataList: [],
      // ======== 列表表头 ========
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1BuDesc',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'buDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1rfqNo',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'rfqNo',
          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: 5022,
          serialNumber: '5022Table1CustomerNo',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'customerNo',
          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: 5022,
          serialNumber: '5022Table1CustomerDesc',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'customerDesc',
          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: 5022,
          serialNumber: '5022Table1RequestDate',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'requestDate',
          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: 5022,
          serialNumber: '5022Table1RequesterName',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'requesterName',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'PjM',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1QuoterName',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'quoterName',
          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: 5022,
          serialNumber: '5022Table1RequiredCompletionDate',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'requiredCompletionDate',
          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: 5022,
          serialNumber: '5022Table1CustomerInquiryNo',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'customerInquiryNo',
          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: 5022,
          serialNumber: '5022Table1PriorityLevel',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'priorityLevel',
          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: 5022,
          serialNumber: '5022Table1Status',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'status',
          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: 5022,
          serialNumber: '5022Table1BomStatus',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'bomStatus',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'BOM状态',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1BomStatusDb',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'bomStatusDb',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '是否创建技术资料',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 110
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1Status',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'remark',
          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: 5022,
          serialNumber: '5022Table1CreateDate',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1CreateBy',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'createBy',
          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: 5022,
          serialNumber: '5022Table1UpdateDate',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'updateDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table1UpdateBy',
          tableId: '5022Table1',
          tableName: '询价信息表',
          columnProp: 'updateBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      inquiryPartColumnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2BuDesc',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'buDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2PartNo',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'partNo',
          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: 5022,
          serialNumber: '5022Table2TestPartDesc',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'testPartDesc',
          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: 5022,
          serialNumber: '5022Table2InquiryQty',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'inquiryQty',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '询价数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2Unit',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'umName',
          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: 5022,
          serialNumber: '5022Table2CodeNo',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'codeNo',
          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: 5022,
          serialNumber: '5022Table2PartBomStatus',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'partBomStatus',
          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: 5022,
          serialNumber: '5022Table2Remark',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2CreateDate',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'createDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2CreateBy',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'createBy',
          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: 5022,
          serialNumber: '5022Table2UpdateDate',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'updateDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 160
        },
        {
          userId: this.$store.state.user.name,
          functionId: 5022,
          serialNumber: '5022Table2UpdateBy',
          tableId: '5022Table2',
          tableName: '询价产品表',
          columnProp: 'updateBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80
        }
      ],
      inquiryPartItemColumnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 100002001,
          serialNumber: '100002001TableItemNo',
          tableId: "100002001Table",
          tableName: "属性表",
          columnProp: 'itemNo',
          headerAlign: "center",
          align: "center",
          columnLabel: '属性编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },{
          userId: this.$store.state.user.name,
          functionId: 100002001,
          serialNumber: '100002001TableItemDesc',
          tableId: "100002001Table",
          tableName: "属性表",
          columnProp: 'itemDesc',
          headerAlign: "center",
          align: "center",
          columnLabel: '属性名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
        },
        {
          userId: this.$store.state.user.name,
          functionId: 100002001,
          serialNumber: '100002001TableValueType',
          tableId: "100002001Table",
          tableName: "属性表",
          columnProp: 'valueType',
          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: 100002001,
        //   serialNumber: '100002001TableMinValue',
        //   tableId: "100002001Table",
        //   tableName: "属性表",
        //   columnProp: 'minValue',
        //   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: 100002001,
        //   serialNumber: '100002001TableMaxValue',
        //   tableId: "100002001Table",
        //   tableName: "属性表",
        //   columnProp: 'maxValue',
        //   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: 100002001,
          serialNumber: '100002001TableMaxValue',
          tableId: "100002001Table",
          tableName: "属性表",
          columnProp: 'textValue',
          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: 100002001,
        //   serialNumber: '100002001TableMinValue',
        //   tableId: "100002001Table",
        //   tableName: "属性表",
        //   columnProp: 'numValue',
        //   headerAlign: "center",
        //   align: "right",
        //   columnLabel: '数字值',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        //   columnWidth:120,
        // },
        // {
        //   userId: this.$store.state.user.name,
        //   functionId: 100002001,
        //   serialNumber: '100002001TableDefaultValue',
        //   tableId: "100002001Table",
        //   tableName: "属性表",
        //   columnProp: 'defaultValue',
        //   headerAlign: "center",
        //   align: "right",
        //   columnLabel: '参照值',
        //   columnHidden: false,
        //   columnImage: false,
        //   columnSortable: false,
        //   sortLv: 0,
        //   status: true,
        //   fixed: '',
        // },
      ],
      // ======== 必填规则 ========
      rules: {
        bu: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        rfqNo: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        customerNo: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        customerDesc: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        requester: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        requesterName: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        quoter: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        quoterName: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        priorityLevel: [
          {required: true, message: ' ', trigger: 'change'},
        ],
        requiredCompletionDate: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        requestDate: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
      },
      inquiryPartRules: {
        bu: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        partNo: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        partDesc: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        inquiryQty: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        umId: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        codeNo: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
      },
      // ======== 选中的当前行数据 ========
      inquiryCurrentRow: {},
      // ======== 模态框开关控制 ========
      modalFlag: false,
      modalDisableFlag: false,
      inquiryPartModalFlag: false,
      inquiryPartModalDisableFlag: false,
      inquiryPartItemModalFlag: false,
    }
  },
  mounted() {
    this.$nextTick(() => {
      /*第二个表格高度的动态调整*/
      this.height = window.innerHeight - 210;
    })
    EventBus.$on('refreshInquiryOneDetail1', () => {
      this.refreshCurrentTabTable();
    });
  },
  created() {
    this.getSiteAndBuByUserName()
    // 动态列
    this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
    this.getDataList()
  },
  methods: {
    handleColumnResize(newWidth, oldWidth, column, event){
      let inData= this.columnList.filter(item => item.columnProp === column.property)[0]
      inData.columnWidth=newWidth
      updateColumnSize(inData).then(({data}) => {
        if (data.code === 0) {
          console.log("栏位宽度保存成功！")
        }
      })
    },
    // 获取用户的bu
    getSiteAndBuByUserName () {
      let tempData = {
        username: this.$store.state.user.name,
      }
      getSiteAndBuByUserName(tempData).then(({data}) => {
        if (data.code === 0) {
          this.userBuList = data.rows
        }
      })
    },
    // ======== 分页相关方法 ========
    /**
     * 每页数
     * @param val
     */
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    /**
     * 当前页
     * @param val
     */
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },


    // ======== 页签切换相关方法 ========
    /**
     * 列表表格选择替换
     * @param tab
     * @param event
     */
    tabClick(tab, event) {
      // 刷新列表数据
      this.refreshCurrentTabTable()
    },

    // ======== 列表操作方法 ========
    /**
     * 单机选中询价信息
     * @param row
     */
    inquiryClickRow(row) {
      this.inquiryCurrentRow = JSON.parse(JSON.stringify(row))
    },
    /**
     * 当前值发生变化的时候修改
     * @param row
     * @param oldRow
     */
    changeCurrentRow(row, oldRow) {
      // 判断是否是获取焦点的事件
      if (row) {
        this.inquiryCurrentRow = JSON.parse(JSON.stringify(row))
        //刷新当前页表
        this.refreshCurrentTabTable()
      }
    },
    /**
     * 刷新页签的table数据
     */
    refreshCurrentTabTable() {
      if (this.activeTable === 'inquiryPart') {
        this.searchInquiryDetailInfo()
      }
    },

    // ======== 列表数据刷新方法 ========
    /**
     * 获取数据列表
     */
    getDataList() {
      this.searchData.limit = this.pageSize
      this.searchData.page = this.pageIndex
      searchInquiryApplicationInfo(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])
            this.refreshCurrentTabTable() //加载当前的页签的table
            this.inquiryClickRow(this.dataList[0])
          }
        }
        this.dataListLoading = false
      })
    },

    // ======== 新增/编辑模态框 ========
    /**
     * 询价信息新增模态框
     */
    addModal() {
      this.modalData = {
        flag: '1',
        title: '询价新增',
        site: this.$store.state.user.site,
        bu: this.userBuList[0].buNo,
        buNo: this.userBuList[0].buNo.split('_')[1],
        buDesc: this.userBuList[0].buDesc,
        id: '',
        rfqNo: '',
        customerNo: '',
        customerDesc: '',
        requester:'',
        requesterName: '',
        quoter: '',
        quoterName: '',
        customerInquiryNo: '',
        status: 'C',
        bomStatusDb: '未创建',
        priorityLevel: '',
        requestDate: new Date(),
        requiredCompletionDate: '',
        remark: '',
        createBy: this.$store.state.user.name
      }
      this.modalDisableFlag = false
      this.modalFlag = true
    },
    /**
     * 询价信息编辑模态框
     * @param row
     */
    async updateModal(row) {
      this.modalData = {
        flag: '2',
        title: '询价编辑-' + row.rfqNo,
        site: row.site,
        bu: row.bu,
        buNo: row.buNo,
        buDesc: row.buDesc,
        id: row.id,
        rfqNo: row.rfqNo,
        customerNo: row.customerNo,
        customerDesc: row.customerDesc,
        requester: row.requester,
        requesterName: row.requesterName,
        quoter: row.quoter,
        quoterName: row.quoterName,
        customerInquiryNo: row.customerInquiryNo,
        status: row.status,
        priorityLevel: row.priorityLevel,
        requestDate: row.requestDate,
        requiredCompletionDate: row.requiredCompletionDate,
        remark: row.remark,
        updateBy: this.$store.state.user.name
      }
      if(this.modalData.buNo === null || this.modalData.buNo === ''){
        this.modalData.buDesc = ''
        this.modalData.bu = ''
        this.modalDisableFlag = false
      }else {
        this.modalDisableFlag = true
      }
      this.modalFlag = true
    },

    /**
     * 客户信息新增/编辑
     */
    async saveData() {
      await this.customerNoBlur()
      await this.requesterBlur(2008)
      await this.quoterBlur(2002)
          if (this.modalData.customerNo === '' || this.modalData.customerNo == null) {
            this.$message.warning('请选择客户编码！')
            return
          }
          if (this.modalData.customerDesc === '' || this.modalData.customerDesc == null) {
            this.$alert('该客户不存在，请重新输入客户编码！', '错误', {
              confirmButtonText: '确定'
            })
            return
          }
          if (this.modalData.requestDate === '' || this.modalData.requestDate == null) {
            this.$message.warning('请输入要求询价日期！')
            return
          }
          if (this.modalData.requester === '' || this.modalData.requester == null) {
            this.$message.warning('请输入PjM编码！')
            return
          }
          if (this.modalData.requesterName === '' || this.modalData.requesterName == null) {
            this.$alert('该PjM人员不存在，请重新输入PjM人员用户名！', '错误', {
              confirmButtonText: '确定'
            })
            return
          }
          if (this.modalData.priorityLevel === '' || this.modalData.priorityLevel == null) {
            this.$message.warning('请选择优先等级！')
            return
          }
          if (this.modalData.requiredCompletionDate === '' || this.modalData.requiredCompletionDate == null) {
            this.$message.warning('请输入要求报价日期！')
            return
          }
          if (this.modalData.quoter === '' || this.modalData.quoter == null) {
            this.$message.warning('请输入报价专员编码！')
            return
          }
          if (this.modalData.quoterName === '' || this.modalData.quoterName == null) {
            this.$alert('该报价专员人员不存在，请重新输入报价专员用户名！', '错误', {
              confirmButtonText: '确定'
            })
            return
          }
          if (this.modalData.flag === '1') {
            addInquiryApplicationInfo(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 {
            updateInquiryApplicationInfo(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: '确定'
                })
              }
            })
          }
    },
    /**
     * 询价信息删除
     */
    delModal(row) {
      let confirmMsg = '是否删除这条询价信息?'
        if (row.status === 'B') {
          confirmMsg = '该询价单已经下达，是否删除这条询价信息?'
        } else if (row.status === 'A') {
          confirmMsg = '该询价单已经报价，是否删除这条询价信息?'
        }
      this.$confirm(confirmMsg, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteInquiryApplicationInfo(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(() => {
      })
    },
    updateModalStatus(row,type) {
      if (type === 'B') {
        this.$confirm('是否确认下达该询价单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let inData = JSON.parse(JSON.stringify(row))
          inData.status = type
          updateInquiryApplicationInfo(inData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      }
    },

    // ======== 校验方法 ========
    async customerNoBlur(){
      if (this.modalData.customerNo !== '' || this.modalData.customerNo != null) {
        let params = {
          customerNo: this.modalData.customerNo,
          createBy: this.$store.state.user.name,
        }
        return queryCustomerList(params).then(({data}) => {
          if (data && data.code === 0) {
            if (data.rows.length === 1) {
              this.modalData.customerDesc = data.rows[0].customerDesc
            } else {
              this.modalData.customerDesc = ''
            }
          } else {
            this.$message.warning(data.message)
            this.modalData.customerDesc = ''
          }
        }).catch((error) => {
          this.$message.error('校验失败，请重试:' + error);
          this.modalData.customerDesc = ''
        })
      } else {
        this.modalData.customerDesc = ''
        return Promise.resolve()
      }
    },

    async requesterBlur (tagNo) {
      if (this.modalData.requester != null && this.modalData.requester !== '') {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and a.username = '" + this.modalData.requester + "'" +
            " and b.site  = '" + this.modalData.bu.split('_')[0] + "'"
        };

        // 返回 Promise
        return verifyData(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.modalData.requesterName = data.baseListData[0].user_display;
            } else {
              this.modalData.requesterName = '';
            }
          } else {
            this.$message.warning(data.msg);
            this.modalData.requesterName = '';
          }
        }).catch(error => {
          console.error(error);
          this.$message.error('校验失败，请重试:' + error);
          this.modalData.requesterName = '';
        });
      } else {
        this.modalData.requesterName = '';
        return Promise.resolve(); // 如果 requester 为空，直接返回 resolved Promise
      }
    },

    async quoterBlur (tagNo) {
      if (this.modalData.quoter != null && this.modalData.quoter !== '') {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and a.username = '" + this.modalData.quoter + "'" +
            " and b.site  = '" + this.modalData.bu.split('_')[0] + "'"
        };

        // 返回 Promise
        return verifyData(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.modalData.quoterName = data.baseListData[0].user_display;
            } else {
              this.modalData.quoterName = '';
            }
          } else {
            this.$message.warning(data.msg);
            this.modalData.quoterName = '';
          }
        }).catch(error => {
          console.error(error);
          this.$message.error('校验失败，请重试');
          this.modalData.quoterName = '';
        });
      } else {
        this.modalData.quoterName = '';
        return Promise.resolve(); // 如果 quoter 为空，直接返回 resolved Promise
      }
    },

    // /**
    //  * 获得这些询价号的全部附件
    //  */
    // getFileContentList () {
    //   let currentData = {
    //     orderRef1: this.$store.state.user.site,
    //     orderRef2: this.enterResultData.quotationNo
    //   }
    //   getFileContentList(currentData).then(({data}) => {
    //     if (data && data.code === 0) {
    //       this.enterResultData.fileContentList = data.rows
    //     } else {
    //       this.enterResultData.fileContentList = []
    //     }
    //   })
    // },
    /**
     * 上传文件
     */
    uploadFile() {
      let currentData = {
        titleCon: '询价附件上传',
        site: this.$store.state.user.site,
        createBy: this.$store.state.user.name,
        quotationNo: this.enterResultData.quotationNo,
        fileRemark: '',
        folder: 'quotationFile',
        // options: []
      }
      // let num = 0
      // let arr = this.enterResultData.quotationNo.split(';')
      // arr.forEach(val => {
      //   currentData.options.push({key: num++, value: val})
      // })
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.quotationUploadFile.init(currentData);
      })
    },
    /**
     * 文件删除
     * @param row
     */
    deleteFile(row) {
      this.$confirm('确定要删除此文件?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteQuotationFile(row).then(({data}) => {
          if (data && data.code === 0) {
            this.getFileContentList();
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },
    /**
     * 文件下载
     * @param row
     */
    downloadFile(row) {
      downLoadQuotationFile(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)
      })
    },

    // ======== chooseList相关方法 ========
    /**
     * 获取基础数据列表S
     * @param val
     * @param type
     */
    getBaseList(val, type) {
      this.tagNo = val
      this.tagNo1 = type
      this.$nextTick(() => {
        let strVal = ''
        let conSql = ''
        if (val === 220) {
          strVal = this.inquiryPartModalData.codeNo ? this.inquiryPartModalData.codeNo : ''
          conSql =" and function_type = 'PRICECHECK'" + " and site = '" + this.inquiryPartModalData.bu.split('_')[0] + "'" +
            " and bu_no = '" + this.inquiryPartModalData.bu.split('_')[1] + "'"
        }
        if (val === 509) {
          if (type === 1) {
            strVal = this.modalData.customerNo ? this.modalData.customerNo : ''
          }
          if (type === 2) {
            strVal = this.searchData.customerNo ? this.searchData.customerNo : ''
          }
        }
        if (val === 510) {
          strVal = this.inquiryPartModalData.umId ? this.inquiryPartModalData.umId : ''
          conSql = " and site = '" + this.inquiryPartModalData.bu.split('_')[0] + "'"
        }
        if (val === 2002) {
          if (type === 1) {
            strVal = this.searchData.quoterName ? this.searchData.quoterName : ''
            conSql = " and b.site = '" + this.$store.state.user.site + "'"
          }
          if (type === 2) {
            strVal = this.modalData.quoterName ? this.modalData.quoterName : ''
            conSql = " and b.site = '" + this.$store.state.user.site + "'"
          }
        }
          if (val === 2008) {
            if (type === 1) {
              strVal = this.searchData.requesterName ? this.searchData.requesterName : ''
              conSql = " and b.site = '" + this.$store.state.user.site + "'"
            }
            if (type === 2) {
              strVal = this.modalData.requesterName ? this.modalData.requesterName : ''
              conSql = " and b.site = '" + this.$store.state.user.site + "'"
            }
          }
        this.$refs.baseList.init(val, strVal, conSql)
      })
    },
    /**
     * 列表方法的回调
     * @param val
     */
    getBaseData(val) {
      if (this.tagNo ===220) {
          this.inquiryPartModalData.codeNo = val.code_no
          this.inquiryPartModalData.codeDesc = val.code_desc
      }
        if (this.tagNo === 509) {
        if (this.tagNo1 === 1) {
          if (val.customer_no === this.modalData.customerNo) {
            return
          }
          this.modalData.customerNo = val.customer_no
          this.modalData.customerDesc = val.customer_desc
        }
        if (this.tagNo1 === 2) {
          if (val.customer_no === this.searchData.customerNo) {
            return
          }
          this.searchData.customerNo = val.customer_no
        }
      }
      if (this.tagNo === 510) {
        this.inquiryPartModalData.umId = val.UMID
        this.inquiryPartModalData.umName = val.UMName
      }
      if (this.tagNo === 2002) {
        if (this.tagNo1 === 1) {
          this.searchData.quoter = val.username
          this.searchData.quoterName = val.user_display
        }
        if (this.tagNo1 === 2) {
          this.modalData.quoter = val.username
          this.modalData.quoterName = val.user_display
        }
      }
      if (this.tagNo === 2008) {
        if (this.tagNo1 === 1) {
          this.searchData.requester = val.username
          this.searchData.requesterName = val.user_display
        }
        if (this.tagNo1 === 2) {
          this.modalData.requester = val.username
          this.modalData.requesterName = val.user_display
        }
      }
    },

    // ======== 询价产品相关方法 ========
    searchInquiryDetailInfo() {
      let tempData = {
        rfqId: this.inquiryCurrentRow.id,
        buNo: this.inquiryCurrentRow.buNo,
        page: this.pageIndex,
        limit: this.pageSize
      }
      searchInquiryDetailInfo(tempData).then(({data}) => {
        if (data.code === 0) {
          this.inquiryPartDataList = data.page
          //判断是否全部存在数据
          if (this.inquiryPartDataList != null && this.inquiryPartDataList.length > 0) {
            //设置选中行
            this.$refs.secondaryTable.setCurrentRow(this.inquiryPartDataList[0])
          }
        }
      })
    },
    /**
     * 询价产品新增
     */
    addInquiryPartModal(row) {
      this.inquiryCurrentRow = JSON.parse(JSON.stringify(row))
      this.inquiryPartModalData = {
        title: '询价产品新增',
        site: this.inquiryCurrentRow.site,
        bu: this.inquiryCurrentRow.bu,
        buNo: this.inquiryCurrentRow.buNo,
        buDesc: this.inquiryCurrentRow.buDesc,
        rfqId: this.inquiryCurrentRow.id,
        partNo: '',
        partDesc: '',
        inquiryQty: '',
        umId: '',
        umName: '',
        codeNo: '',
        codeDesc: '',
        remark: '',
        createBy: this.$store.state.user.name
      }
      this.inquiryPartModalFlag = true
    },

    async saveInquiryPartData() {
      await this.modelBlur(220)
      await this.umIdBlur(510)
          if (this.inquiryPartModalData.partDesc === '' || this.inquiryPartModalData.partDesc == null) {
            this.$message.warning('请输入产品描述！')
            return
          }
          if (this.inquiryPartModalData.inquiryQty === '' || this.inquiryPartModalData.inquiryQty == null) {
            this.$message.warning('请输入询价数量！')
            return
          }
          if (this.inquiryPartModalData.inquiryQty < 0) {
            this.$message.warning('询价数量必须大于等于0！')
            return
          }
          if (this.inquiryPartModalData.umId === '' || this.inquiryPartModalData.umId == null) {
            this.$message.warning('请选择计量单位！')
            return
          }
      if (this.inquiryPartModalData.umName === '' || this.inquiryPartModalData.umName == null) {
        this.$alert('该计量单位不存在，请重新输入计量单位编码！', '错误', {
          confirmButtonText: '确定'
        })
      }
          if (this.inquiryPartModalData.codeNo === '' || this.inquiryPartModalData.codeNo == null) {
            this.$message.warning('请选择属性模版！')
            return
          }
      if (this.inquiryPartModalData.codeDesc === '' || this.inquiryPartModalData.codeDesc == null) {
        this.$alert('该属性模版不存在，请重新输入属性模版编码！', '错误', {
          confirmButtonText: '确定'
        })
      }
          if (this.inquiryPartModalData.title === '询价产品新增') {
            addInquiryDetailInfo(this.inquiryPartModalData).then(({data}) => {
              if (data && data.code === 0) {
                this.refreshCurrentTabTable()
                this.inquiryPartModalFlag = false
                EventBus.$emit('updateInquiryPartInfo')
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$alert(data.msg, '错误', {
                  confirmButtonText: '确定'
                })
              }
            })
          } else {
            updateInquiryDetailInfo(this.inquiryPartModalData).then(({data}) => {
              if (data && data.code === 0) {
                this.refreshCurrentTabTable()
                this.inquiryPartModalFlag = false
                EventBus.$emit('updateInquiryPartInfo')
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$alert(data.msg, '错误', {
                  confirmButtonText: '确定'
                })
              }
            })
          }
    },

    /**
     * 询价产品编辑
     * @param row
     */
    updateInquiryPartModal(row) {
      this.inquiryPartModalData = {
        flag: '2',
        title: '询价产品编辑',
        site: row.site,
        bu: row.site + '_' + row.buNo,
        buNo: row.buNo,
        buDesc: row.buDesc,
        id: row.id,
        testPartId: row.testPartId,
        rfqId: row.rfqId,
        partNo: row.partNo,
        partDesc: row.partDesc,
        inquiryQty: row.inquiryQty,
        umId: row.umId,
        umName: row.umName,
        codeNo: row.codeNo,
        codeDesc: row.codeDesc,
        remark: row.remark,
        updateBy: this.$store.state.user.name,
      }
      this.inquiryPartModalFlag = true
      this.inquiryPartModalDisableFlag = true
    },

    /**
     * 询价产品删除
     * @param row
     */
    async delInquiryPartModal(row) {
      let inData = {
        site: row.site,
        bu: row.bu,
        buNo: row.buNo,
        buDesc: row.buDesc,
        inquiryPartId: row.id,
        rfqId: this.inquiryCurrentRow.id,
        rfqNo: this.inquiryCurrentRow.rfqNo,
        testPartId: row.testPartId,
        partNo: row.partNo,
        codeNo: row.codeNo,
        recordType: 'PRICECHECK',
        codeDesc: '',
        remark: '',
      }
      await this.getItemListByInquiryPartAndCodeNo(inData)
      let confirmMassage = '是否删除这条询价产品信息以及相应的物料档案信息?'
      this.inquiryPartItemDataList.forEach((item) => {
        if ((item.textValue !== '' && item.textValue !== null) || (item.numberValue !== '' && item.numberValue !== null)) {
          confirmMassage = '该询价产品已录入属性值，确认继续删除这条询价产品信息及其物料档案、属性信息？'
        }
      })
      this.$confirm(confirmMassage, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteInquiryDetailInfo(row).then(({data}) => {
          if (data && data.code === 0) {
            this.refreshCurrentTabTable()
            EventBus.$emit('updateInquiryPartInfo')
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      }).catch(() => {
      })
    },

    inquiryPartItemModal(row) {
      this.inquiryPartItemModalData = {
        site: row.site,
        bu: row.bu,
        buNo: row.buNo,
        buDesc: row.buDesc,
        inquiryPartId: row.id,
        rfqId: this.inquiryCurrentRow.id,
        rfqNo: this.inquiryCurrentRow.rfqNo,
        testPartId: row.testPartId,
        partNo: row.partNo,
        codeNo: row.codeNo,
        recordType: 'PRICECHECK',
        codeDesc: '',
        remark: '',
        createBy: this.$store.state.user.name
      }
      this.getItemListByInquiryPartAndCodeNo(this.inquiryPartItemModalData)
      this.inquiryPartItemModalFlag = true
    },

    async getItemListByInquiryPartAndCodeNo(inquiryPartItemModalData){
     return  getItemListByInquiryPartAndCodeNo(inquiryPartItemModalData).then(({data})=>{
        if (data && data.code === 0){
          this.inquiryPartItemDataList = data.rows;
        }else {
          this.$message.warning(data.msg)
        }
      }).catch((error)=>{
        this.$message.error(error)
      })
    },

    clickInquiryPartItemSave(){
      if(this.inquiryPartItemDataList.length === 0){
        return false
      }
      if (!this.attributeDialog){
        this.updateInquiryPartItemList();
      }else {
        this.attributeDialog = false;
      }
    },

    updateInquiryPartItemList(){
      this.loading = true
      let list = JSON.parse(JSON.stringify(this.inquiryPartItemDataList));
      updateInquiryPartItemList(list).then(({data})=>{
        if (data && data.code === 0){
          this.$message.success(data.msg);
          this.getItemListByInquiryPartAndCodeNo(this.inquiryPartItemModalData);
          this.attributeDialog = true;
          EventBus.$emit('updateInquiryPartInfo')
        }else {
          this.$message.warning(data.msg);
        }
        this.loading = false
      }).catch((error)=>{
        this.$message.error(error)
        this.loading = false
      })
    },

    // 属性输入校验
    async modelBlur(tagNo) {
      if (this.inquiryPartModalData.codeNo != null && this.inquiryPartModalData.codeNo !== '') {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and code_no = '" + this.inquiryPartModalData.codeNo + "'" +
            " and site  = '" + this.inquiryPartModalData.bu.split('_')[0] + "'" +
            " and bu_no  = '" + this.inquiryPartModalData.bu.split('_')[1] + "'"
        };

        // 返回 Promise
        return verifyData(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.inquiryPartModalData.codeDesc = data.baseListData[0].code_desc;
            } else {
              this.inquiryPartModalData.codeDesc = '';
            }
          } else {
            this.$message.warning(data.msg);
            this.inquiryPartModalData.codeDesc = '';
          }
        }).catch(error => {
          console.error(error);
          this.$message.error('校验失败，请重试');
          this.inquiryPartModalData.codeDesc = '';
        });
      } else {
        this.inquiryPartModalData.codeDesc = '';
        return Promise.resolve(); // 如果 itemNo 为空，直接返回 resolved Promise
      }
    },

    // 计量单位输入校验
    async umIdBlur(tagNo) {
      if (this.inquiryPartModalData.umId != null && this.inquiryPartModalData.umId !== '') {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and UMID = '" + this.inquiryPartModalData.umId + "'" +
            " and site  = '" + this.inquiryPartModalData.bu.split('_')[0] + "'"
        };

        // 返回 Promise
        return verifyData(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.inquiryPartModalData.umName = data.baseListData[0].UMName;
            } else {
              this.inquiryPartModalData.umName = '';
            }
          } else {
            this.$message.warning(data.msg);
            this.inquiryPartModalData.umName = '';
          }
        }).catch(error => {
          console.error(error);
          this.$message.error('校验失败，请重试');
          this.inquiryPartModalData.umName = '';
        });
      } else {
        this.inquiryPartModalData.umName = '';
        return Promise.resolve(); // 如果 umId 为空，直接返回 resolved Promise
      }
    },

    // ======== 导出相关方法 ========
    /**
     * 导出excel
     */
    async createExportData() {
      this.searchData.limit = -1
      this.searchData.page = 1
      await searchInquiryApplicationInfo(this.searchData).then(({data}) => {
        this.resultList = data.page.list
        // 遍历dataList 取-后的值
        this.resultList.forEach((item) => {
          if (item.status === 'A') {
            item.status = '已转报价'
          } else if (item.status === 'B') {
            item.status = '下达'
          } else if (item.status === 'C') {
            item.status = '草稿'
          }
          if (item.priorityLevel === 'A') {
            item.priorityLevel = '普通'
          } else if (item.priorityLevel === ' B') {
            item.priorityLevel = '重要'
          } else if (item.priorityLevel === ' C') {
            item.priorityLevel = '紧急'
          }
        })
      })
      return this.resultList
    },
    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
    },
    // ========  导入相关方法 ========
    handleImportQuotation() {
      let currentData = {
        createBy: this.$store.state.user.name,
        site: this.$store.state.user.site,
      }
      //打开组件 去做新增业务
      this.$nextTick(() => {
        this.$refs.quotationUpload.init(currentData)
      })
    },

    // openSaveDataDialog(){
    //   if (this.modalData.title === '询价新增') {
    //     let rfqNos = [];
    //     this.dataList.forEach((item) => {
    //       // 如果item.rfqNo为XJ开头
    //       if (item.rfqNo.startsWith('XJ')) {
    //         // 解析数字部分
    //         const numPart = parseInt(item.rfqNo.replace('XJ', ''), 10);
    //         if (!isNaN(numPart)) {
    //           rfqNos.push(numPart);
    //         }
    //       }
    //     });
    //     if (rfqNos.length === 0) {
    //       // 如果没有XJ开头的rfqNo
    //       this.modalData.rfqNo = 'XJ00000001';
    //     } else {
    //       // 取到最大的XJ开头的rfqNo
    //       let maxRfqNo = Math.max(...rfqNos);
    //
    //       // 生成新的rfqNo，确保有9位数，前面补零
    //       maxRfqNo += 1; // 增加最大值
    //       this.modalData.rfqNo = 'XJ' + String(maxRfqNo).padStart(8, '0');
    //     }
    //   }
    // },
    // 保存弹框关闭事件
    closeSaveDataDialog() {
      this.modalData = {
        flag: '',
        title: '',
        site: '',
        bu: '',
        buNo: '',
        buDesc: '',
        id: '',
        rfqNo: '',
        customerNo: '',
        customerDesc: '',
        requester:'',
        requesterName: '',
        quoter: '',
        quoterName: '',
        customerInquiryNo: '',
        status: '',
        priorityLevel: '',
        requestDate: '',
        requiredCompletionDate: '',
        remark: '',
      }
      this.modalFlag = false
    },
    openInquiryPartSaveDataDialog() {
      if (this.inquiryPartModalData.title === '询价产品新增') {
        let partNos = [];
        this.inquiryPartModalData.queryType = 'TP';
        this.inquiryPartModalData.userName = this.$store.state.user.name;
        this.inquiryPartModalData.limit = -1;
        this.inquiryPartModalData.page = 1;
        this.inquiryPartModalData.buNo = '';
        partInformationSearch(this.inquiryPartModalData).then(({data}) => {
          if (data && data.code === 0) {
            data.page.list.forEach((item) => {
              // 如果item.partNo为TP开头
              if (item.partNo.startsWith('TP')) {
                // 解析数字部分
                const numPart = parseInt(item.partNo.replace('TP', ''), 10);
                if (!isNaN(numPart)) {
                  partNos.push(numPart);
                }
              }
            });

            if (partNos.length === 0) {
              // 如果没有TP开头的partNo
              this.inquiryPartModalData.partNo = 'TP00000001';
            } else {
              // 取到最大的TP开头的partNo
              let maxPartNo = Math.max(...partNos);

              // 生成新的partNo，确保有9位数，前面补零
              maxPartNo += 1; // 增加最大值
              this.inquiryPartModalData.partNo = 'TP' + String(maxPartNo).padStart(8, '0');
            }
          }
        });
      }
    },
    closeInquiryPartSaveDataDialog() {
      this.inquiryPartModalData = {
        title: '',
        site: '',
        bu: '',
        buNo: '',
        buDesc: '',
        rfqId: '',
        partNo: '',
        partDesc: '',
        inquiryQty: '',
        umId: '',
        umName: '',
        codeNo: '',
        codeDesc: '',
        remark: '',
        createBy: ''
      }
      this.inquiryPartModalFlag = false
    },
    rowStyle({row}) {
      if (this.inquiryCurrentRow.id === row.id) {
        return {'background-color': '#E8F7F6', cursor: 'pointer'};
      }
    },
    navigateToMes(id){
      this.$router.push({ path: 'inquiry-inquiryDetail', query: { id : id} });
    },
    // 动态列开始 获取 用户保存的 格式列
    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) {
          switch (columnId) {
            case 1:
              this.columnList = data.rows
              break;
          }
        } else {
          this.getColumnList(tableId, columnId)
        }
      })
    },

    // 获取 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;
          }
        }
      })
    },
  },
}
</script>

<style scoped>
/deep/ .customer-tab .el-tabs__content {
  padding: 0px !important;
  height: 100%;
}

/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  background-color: #17B3A3;
  border-color: #17B3A3;
}

/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #FFF
}
/deep/ .el-form-item--medium .el-form-item__content{
  height: auto;
}

.el-input-number /deep/ .el-input__inner {
  text-align: right;
  padding-right: 5px !important;
}

/deep/ .el-input .el-input--medium{
  line-height: 20px;
}
/deep/ .el-input-number .el-input--medium{
  line-height: 20px;
}

/*table中input 修改样式*/
/deep/ div.table-el-date {
  padding: 0px 0px;
  height: 25px !important;
}

/*table中input*/
div.table-el-date /deep/ input.el-input__inner{
  padding: 0px 0px;
  height: 23px !important;
  text-align: right;
}

/* 特殊的样式*/
/deep/ .el-table div.cell:has(.table-el-date) {
  /* 直接作用于 <td> 元素 */
  padding: 0px;
  height: 25px;
}

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

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

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

