<template>
  <div class="mode-config">
    <div style="width: 1200px">
      <el-form label-position="top" :model="searchData">
        <el-row :gutter="10">
          <el-col :span="3">
            <el-form-item label="客户编码">
              <el-input v-model="searchData.customerNo" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="客户名称">
              <el-input v-model="searchData.customerName" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="采购专员">
              <el-input v-model="searchData.trackerName" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="报价单号">
              <el-input v-model="searchData.quotationNo" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="客户询价单号">
              <el-input v-model="searchData.customerInquiryNo" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="内部询价单号">
              <el-input v-model="searchData.internalInquiryNo" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="3">
            <el-form-item label="项目编码">
              <el-input v-model="searchData.projectId" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="项目名称">
              <el-input v-model="searchData.projectName" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="报价专员">
              <el-input v-model="searchData.quoterName" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="状态">
              <el-select v-model="searchData.quotationStatus">
                <el-option label="全部" value=""></el-option>
                <el-option label="草稿" value="草稿"></el-option>
                <el-option label="下达" value="下达"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-row>
              <el-col :span="11">
                <el-form-item label="报价日期">
                  <el-date-picker
                    value-format="yyyy-MM-dd"
                    v-model="searchData.startDate"
                    style="width: 100%"
                    type="date"
                    placeholder=" ">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <el-form-item label=" ">
                  <div style="text-align: center;"><i class="el-icon-right"></i></div>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label=" ">
                  <el-date-picker
                    value-format="yyyy-MM-dd"
                    style="width: 100%"
                    v-model="searchData.endDate"
                    type="date"
                    placeholder=" ">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="3">
            <el-form-item label=" ">
              <el-button plain type="primary" @click="initDataBtn">查 询</el-button>
              <el-button type="primary" @click="insertDiaLogFlag = true">新 增</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-table :data="tableData" v-loading="initQuotationHeaderLoading" :row-style="quotationHeaderRowStyle"
              element-loading-text="数据正在加载中"
              element-loading-spinner="el-icon-loading" @row-click="rowClickQuotation" border
              style="width: 100%;margin-top: 12px" :height="height">
      <el-table-column
        label="操作"
        align="center"
        fixed
        width="160">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" v-if="scope.row.quotationStatus === '草稿'"
                   @click="handleUpdateStatus(scope.row)">下达
          </el-link>
          <el-link style="cursor: pointer" v-if="scope.row.quotationStatus === '下达'" @click="handleUpdateStatus(scope.row,true)">取消下达</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.quotationStatus !== '草稿'" @click="handleDetail(scope.row)">详情</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.quotationStatus === '草稿'" @click="editQuotationHeader(scope.row)">编辑</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.quotationStatus === '草稿'" @click="deleteQuotationHeader(scope.row)">删除</el-link>
          <el-link style="cursor: pointer" @click="quotationAgain(scope.row)">重新报价</el-link>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed===''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <template v-if="item.columnProp === 'internalInquiryNo'">
            <a @click="handleRouter(scope.row[item.columnProp])" v-if="scope.row[item.columnProp]">{{ scope.row[item.columnProp] }}</a>
          </template>
          <template v-else>
            <span v-if="!item.columnHidden"> {{`${scope.row[item.columnProp]}${index === 0 ? ("-" + scope.row['versionCode']) : ''}`}}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页插件 -->
    <el-pagination style="margin-top: 0px"
                   @size-change="quotationHeaderSizeChange"
                   @current-change="quotationHeaderCurrentChange"
                   :current-page="no"
                   :page-sizes="[20, 50, 100, 200, 500]"
                   :page-size="size"
                   :total="total"
                   layout="total,sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 标签页 -->
    <el-tabs v-model="activeTabName" @tab-click="handleClickTab"
             style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border: 2px;min-height: 420px;margin-top: 5px;">
      <el-tab-pane label="报价明细" name="quote_detail">
        <quote-detail :header="quotationHeader"></quote-detail>
      </el-tab-pane>
      <el-tab-pane label="项目信息" name="quotation_project_information">
        <quotation-project-information :quotation-header="quotationHeader"></quotation-project-information>
      </el-tab-pane>
      <el-tab-pane label="客户信息" name="quotation_customer_information">
        <customer-info :project="quotationHeader"></customer-info>
      </el-tab-pane>
      <el-tab-pane label="客户联系人" name="quotation_customer_contact">
        <quotation-customer-contact :quotation-header="quotationHeader"></quotation-customer-contact>
      </el-tab-pane>
      <el-tab-pane label="报价-附件信息" name="quote_oss">
        <oss-components label="报价单号"
                        :columns="ossColumns"
                        :order-ref1="quotationHeader.site?quotationHeader.site:''"
                        :order-ref2="`${quotationHeader.quotationNo}-${quotationHeader.versionCode}`">
        </oss-components>
      </el-tab-pane>
      <el-tab-pane label="询价-基本信息" name="request">
        <price-check-properties ref="tabProperties"
                                v-model:data-list="priceCheckPropertiesList"
                                height="35vh"></price-check-properties>
      </el-tab-pane>
      <el-tab-pane label="询价-附件信息" name="oss">
        <oss-components label="询价单号"
                        :columns="ossColumns"
                        :order-ref1="quotationHeader.site"
                        :order-ref2="quotationHeader.internalInquiryNo?quotationHeader.internalInquiryNo:''">
        </oss-components>
      </el-tab-pane>
      <!-- 审批信息 -->
      <el-tab-pane label="审批信息" name="approvalInformation">
        <approval-information ref="approvalTable" v-model:data-list="approvalList" :height="300"></approval-information>
      </el-tab-pane>
    </el-tabs>

    <!-- 新增弹框 -->
    <el-dialog
      :title="insertData.quotationHeaderId?`编辑销售报价-${insertData.quotationNo}-${insertData.versionCode}`:`销售报价`"
      @close="closeInsertDialog" :close-on-click-modal="false" v-drag :visible.sync="insertDiaLogFlag" width="500px">
      <el-form :rules="rules" label-position="top" ref="insertQuotationForm" :model="insertData"
               label-width="120px">
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="内部询价单号" prop="internalInquiryNo">
              <span slot="label" v-if="!detailDialogVisible" @click="clickInternalInquiryNoHandle"><a herf="#">内部询价单号</a></span>
              <el-input v-model="insertData.internalInquiryNo" :disabled="detailDialogVisible" @blur="blurInternalInquiryNoHandle"  clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="客户询价单号" prop="customerInquiryNo">
              <el-input v-model="insertData.customerInquiryNo" :disabled="detailDialogVisible" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item prop="customerNo" label="客户编码">
              <span slot="label" v-if="insertData.internalInquiryNo ==='' && !detailDialogVisible" @click="getBaseList(102,1)">
                <a>客户编码</a>
              </span>
              <el-input v-model="insertData.customerNo" :disabled="insertData.internalInquiryNo !=='' || detailDialogVisible"
                         clearable @change="clearCustomer" @blur="handleQueryCustomer"/>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item prop="customerName" label="客户名称">
              <el-input v-model="insertData.customerName" disabled  clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item prop="projectId" label="项目编码">
              <span slot="label" v-if="insertData.customerNo !=='' && insertData.internalInquiryNo ==='' && !detailDialogVisible " @click="clickProject">
                <a>项目编码</a>
              </span>
              <el-input v-model="insertData.projectId" :disabled="insertData.customerNo ==='' || insertData.internalInquiryNo !=='' || detailDialogVisible" clearable @blur="handleQueryProjectByCustomer"/>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item prop="projectName" label="项目名称">
              <el-input v-model="insertData.projectName" disabled  clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="终端客户编码">
              <el-input disabled v-model="insertData.finalCustomerId"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="终端客户名称">
              <el-input disabled v-model="insertData.finalCustomerName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="货币" prop="currency">
              <dict-data-select v-model="insertData.currency" :disabled="insertData.internalInquiryNo !=='' || detailDialogVisible" dict-type="plm_customer_information_customer_customer_currency"></dict-data-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="报价日期" prop="quotationDate">
              <el-date-picker
                style="width: 100%"
                v-model="insertData.quotationDate"
                type="date"
                size="mini"
                :disabled="detailDialogVisible"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="报价专员" prop="quoterName">
              <span slot="label" @click="getBaseList(2002)" v-if="!detailDialogVisible"><a>报价专员</a></span>
              <el-input v-model="insertData.quoterName" @clear="clearQuoter" readonly :disabled="detailDialogVisible" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="采购专员" prop="trackerName">
              <span slot="label" v-if="!detailDialogVisible" @click="getBaseList(2000)">
                <a>采购专员</a>
              </span>
              <el-input v-model="insertData.trackerName" :disabled="detailDialogVisible" @clear="clearTracker"  readonly clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" style="width: 100%;min-height: 90px">
              <el-input type="textarea" style="width: 100%" :disabled="detailDialogVisible" resize="none" :autosize="{minRows: 3, maxRows: 3}"
                        v-model="insertData.remark"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" :loading="insertQuotationHeaderBtn" @click="saveQuotationHeader">确定</el-button>
        <el-button @click="insertDiaLogFlag = false">关闭</el-button>
      </span>
    </el-dialog>

    <!--询价单号选择弹框-->
    <el-dialog title="内部询价单号"
               @close="closeQuotationNoDialog"
               @open="openQuotationNoDialog"
               :close-on-click-modal="false"
               width="1200px"
               :visible.sync="quotationNoDialogFlag" v-drag>
      <el-form label-position="top"
               :model="quotationNoSearchData"
               size="mini">
        <el-row :gutter="10">
          <el-col :span="3">
            <el-form-item label="询价单号">
              <el-input v-model="quotationNoSearchData.quotationNo" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="申请批次号">
              <el-input v-model="quotationNoSearchData.quotationBatchNo" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="序号">
              <el-input v-model="quotationNoSearchData.quotationItemNo" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="物料编码">
              <el-input v-model="quotationNoSearchData.testPartNo" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="物料名称">
              <el-input v-model="quotationNoSearchData.partName" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="'状态'">
              <el-select v-model="quotationNoSearchData.quotationStatus" style="width:100%">
                <el-option label="全部" value=""></el-option>
                <el-option label="草稿" value="草稿"></el-option>
                <el-option label="审批中" value="审批中"></el-option>
                <el-option label="已完成" value="已完成"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item label=" ">
            <el-button type="primary" style="padding: 3px 12px" @click="searchQuotationData">查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="quotationNoData" height="300" stripe border @row-dblclick="dblclickQuotationNo">
        <el-table-column prop="quotationNo" header-align="center" min-width="120" label="询价单号"/>
        <el-table-column prop="quotationBatchNo" header-align="center" label="询价批次号"/>
        <el-table-column width="60" align="center" header-align="center" prop="quotationItemNo" label="询价序号"/>
        <el-table-column prop="projectName" header-align="center" label="项目名称"/>
        <el-table-column width="180" prop="testPartNo" header-align="center" label="物料编码"/>
        <el-table-column prop="partName" header-align="center" label="状态"/>
        <el-table-column prop="quotationStatus" header-align="center" label="物料名称"/>
        <el-table-column label="终端客户编码" header-align="center" prop="finalCustomerId"/>
        <el-table-column label="终端客户名称" header-align="center" prop="finalCustomerName"/>
      </el-table>
      <el-footer style="height:30px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="quotationNoDialogFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

    <el-dialog title="选择-项目" @close="closeProjectInfoDialog" @open="searchProjectInfoList"
               :visible.sync="chooseProjectListFlag" width="35%" :close-on-click-modal="false">
      <el-form label-position="top" :model="searchProjectData" ref="closeProjectInfoForm">
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="项目编码">
              <el-input v-model="searchProjectData.projectId"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目名称">
              <el-input v-model="searchProjectData.projectName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label=" ">
              <el-button type="primary" @click="searchProjectInfoList">查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-table :height="223"
                  :data="projectList"
                  border
                  @row-click="projectClickRow">
          <el-table-column label="项目编码" prop="projectId"/>
          <el-table-column label="项目名称" prop="projectName"/>
          <el-table-column label="终端客户编码" prop="finalCustomerId"/>
          <el-table-column label="终端客户名称" prop="finalCustomerName"/>
        </el-table>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import quotationExamineAndApprove from "./sellForQuotation/quotationExamineAndApprove.vue";
import quotationProjectInformation from "./sellForQuotation/quotationProjectInformation.vue";
import quotationCustomerInformation from "./sellForQuotation/quotationCustomerInformation.vue";
import quotationCustomerContact from "./sellForQuotation/quotationCustomerContact.vue";
import Chooselist from '@/views/modules/common/Chooselist';
import {
  getQuotationHeaderByPage,
  saveQuotationHeader,
  deleteByQuotationHeaderId,
  quotationAgain,
} from '@/api/quotation/quotationHeader.js';
import {
  searchQuotationByQuotationNo,
} from '@/api/quotation/quotationInformation.js';
import {
  getNodeAuthority, // 获取节点权限
  getApprovalList, // 查询审批信息
} from '@/api/changeManagement/changeManagement.js'
import QuoteDetail from "./sellForQuotation/quoteDetail.vue";
import {searchProjectInfoList} from "../../../api/quotation/quotationInformation";
import {getQuotationHeaderByPagePost, updateQuoteStatus} from "../../../api/quotation/quotationHeader";
import {getQuotePage} from "../../../api/quotation/quote";
import {queryCustomer} from "../../../api/customer/customerInformation";
import {queryProjectByCustomer} from "../../../api/project/project";
import ApprovalInformation from "../changeManagement/approvalInformation.vue";
import OssComponents from "../oss/ossComponents.vue";
import PriceCheckProperties from "./priceCheckProperties.vue";
import {getPriceCheckPropertiesList} from "../../../api/quotation/priceCheckProperties";
import CustomerInfo from "./sellForQuotation/customerInfo.vue";
import DictDataSelect from "../sys/dict-data-select.vue";

export default {
  components: {
    DictDataSelect,
    CustomerInfo,
    PriceCheckProperties,
    ApprovalInformation,
    OssComponents,
    QuoteDetail,
    Chooselist,
    quotationExamineAndApprove,
    quotationProjectInformation,
    quotationCustomerInformation,
    quotationCustomerContact,
  },
  props:{
    height:{
      type:[Number,String],
      default:'30vh'
    }
  },
  data() {
    return {
      initPage:false,
      // 搜索条件对象
      searchData: {
        site: this.$store.state.user.site,// 工厂编号
        customerNo: "", // 客户编码
        customer: "", // 客户名称
        tracker: "", // 采购专员
        quotationStatus: "", //状态
        projectId: "", // 项目编码
        projectName: "", // 项目名称
        quoterName: "", // 报价专员
        startDate: "", // 开始日期
        endDate: "", // 结束日期
        dateValue: [],// 开始时间结束时间数组
      },
      chooseProjectListFlag: false,
      searchProjectData: {
        site: this.$store.state.user.site,
        projectId: undefined,
        projectName: undefined,
        customerId: undefined,
      },
      projectList: [],
      tableData: [],// 查询的数据
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1QuotationNo',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'quotationNo',
          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: 102003,
          serialNumber: '102003Table1QuotationDate',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'quotationDate',
          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: 102003,
          serialNumber: '102003Table1CustomerNo',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'customerNo',
          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: 102003,
          serialNumber: '102003Table1CustomerName',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'customerName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '客户名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        }, {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1ProjectId',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'projectId',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '项目编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        }, {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1ProjectName',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'projectName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '项目名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1QuoterName',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'quoterName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '报价专员',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1TrackerName',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'trackerName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '采购专员',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102003,
          serialNumber: '102003Table1Currency',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'currency',
          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: 102003,
          serialNumber: '102003Table1QuotationStatus',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'quotationStatus',
          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: 102003,
          serialNumber: '102003Table1CustomerInquiryNo',
          tableId: '102003Table1',
          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: 102003,
          serialNumber: '102003Table1InternalInquiryNo',
          tableId: '102003Table1',
          tableName: '报价信息表',
          columnProp: 'internalInquiryNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '内部询价单号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
      ],
      initQuotationHeaderLoading: false,//表格加载状态
      // 分页信息
      no: 1,//页码
      size: 20,//每页条数
      total: 0,//总页数
      // 标签页
      activeTabName: "quote_detail",
      //dialog 控制开关
      insertDiaLogFlag: false,
      quotationNoDialogFlag: false,
      // 新增对象
      insertData: {
        site: this.$store.state.user.site,
        quotationNo: "",//客户报价单号
        quotationDate: new Date(),//报价日期
        customerNo: "", // 客户编号
        customerName: "",//客户名称
        versionCode: "001",
        projectId: "",//项目编码
        projectName: "",//项目名称
        tracker: "",//采购专员
        quoter: "",//销售编号
        quoterName: "",//报价专员
        trackerName: "",//采购专员
        currency: "",//货币
        quotationStatus: "草稿",//状态
        remark: "",//备注
        customerInquiryNo: "",//客户询价单号
        internalInquiryNo: "",//内部询价单号
        internalInquiryBatchNo: "",//内部询价单号
        requireApproval: "",//需要审批
        approvalStatus: "",//审批状态
        createBy: this.$store.state.user.id,//当前登录账号
        createTime: new Date(),//当前时间
      },
      quotationHeaderColumns: [
        {label: "quotationNo", value: "客户报价单号"},
        {label: "quotationDate", value: "报价日期"},
        {label: "customerNo", value: "客户编码"},
        {label: "customerName", value: "客户名称"},
        {label: "versionCode", value: "版本号"},
        {label: "projectId", value: "项目编码"},
        {label: "projectName", value: "项目名称"},
        {label: "quoterName", value: "报价专员"},
        {label: "trackerName", value: "采购专员"},
        {label: "currency", value: "货币"},
        {label: "quotationStatus", value: "状态"},
        {label: "remark", value: "备注"},
        {label: "customerInquiryNo", value: "客户询价单号"},
        {label: "internalInquiryNo", value: "内部询价单号"},
        {label: "requireApproval", value: "需要审批"},
        {label: "approvalStatus", value: "审批状态"},
        {label: "createBy", value: "创建人"},
        {label: "createDate", value: "创建时间"},
        {label: "updateBy", value: "更新人"},
        {label: "updateDate", value: "更新时间"},
      ],
      // 规则
      rules: {
        customerNo: [
          {required: true, message: ' '},
        ],
        customerName: [
          {required: true, message: ' '},
        ],
        projectId: [
          {required: true, message: ' '}
        ],
        projectName: [
          {required: true, message: ' '}
        ],
        tracker: [
          {required: true, message: ' '}
        ],
        trackerName: [
          {required: true, message: ' '}
        ],
        currency: [
          {required: true, message: ' '}
        ],
        quoter: [
          {required: true, message: ' '}
        ],
        quoterName: [
          {required: true, message: ' '}
        ],
        quotationStatus: [
          {required: true, message: ' '}
        ],
        quotationDate: [
          {required: true, message: ' '}
        ],
      },
      // 参数 选择框
      tagNo1: "",
      tagNo: "",
      // 内部报价单搜索表单对象
      quotationNoSearchData: {
        quotationNo: "",//单号
        quotationBatchNo: "",//批次号
        quotationItemNo: '',//序号
        quotationStatus: "",//状态
        partName:'',//物料描述
        testPartNo:'',//物料编码
        site: this.$store.state.user.site,//工厂编号
      },
      //内部报价单搜索表格数据对象
      quotationNoData: [],
      // 行对象
      quotationHeader: {
        quotationNo: "",
        versionCode: "",
        site: "",
      },
      // 按钮防重复
      insertQuotationHeaderBtn: false,
      approvalList: [],

      ossColumns:[
        {
          userId: this.$store.state.user.name,
          functionId: 103001,
          serialNumber: '103001Table2FileName',
          tableId: '103001Table2',
          tableName: '文件信息表',
          columnProp: 'fileName',
          headerAlign: 'center',
          align: 'left',
          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: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 240
        },
        {
          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: 'createBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '上传人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 140
        }
      ],
      detailDialogVisible: false,

      priceCheckPropertiesList:[],
    }
  },
  methods: {

    // 查询审批信息
    getApprovalList () {
      let tempData = {
        site: this.$store.state.user.site,
        menuId: this.$route.meta.menuId,
        documentNo: this.quotationHeader.quotationNo
      }
      getApprovalList(tempData).then(({data}) => {
        if (data && data.code === 0) {
          this.approvalList = data.rows
        } else {
          this.approvalList = []
        }
      })
    },

    // 点击quotation行事件
    rowClickQuotation(row, column, event) {
      if (column.label !== '操作') {
        this.quotationHeader = row;
      }
    },
    clickProject() {
      if (!this.insertData.customerNo) {
        this.$message.warning("客户编码不存在")
        return
      }
      this.searchProjectData.projectId = this.insertData.projectId
      // setTimeout(()=>{
      //   this.searchProjectData.projectId = ''
      // },200)
      this.chooseProjectListFlag = true
    },
    projectClickRow(row) {
      this.insertData.projectId = row.projectId
      this.insertData.projectName = row.projectName
      this.insertData.finalCustomerId = row.finalCustomerId
      this.insertData.finalCustomerName = row.finalCustomerName
      this.chooseProjectListFlag = false
    },
    // 查询
    initDataBtn() {
      this.$route.params.ids = null;
      this.initData();
    },
    // 初始化数据
    initData() {
      //如果是跳转过来的
      let value = localStorage.getItem('quotationData');
      if(value){
        let data=JSON.parse(value);
        this.searchData.quotationNo=data.quotationNo
        localStorage.removeItem('quotationData');
      }
      let params = {
        site: this.$store.state.user.site,
        ...this.searchData,
        ids: this.$route.params.ids,
      }
      getQuotationHeaderByPagePost(params,undefined,this.no,this.size).then(({data})=>{
        if (data && data.code === 0){
          this.tableData = data.rows;
          this.total = data.total;
          if (this.tableData.length > 0) {
            this.quotationHeader = this.tableData[0];
          } else {
            this.quotationHeader = {};
          }
        }else {
          this.$message.warning(data.msg)
        }
      }).catch((error)=>{
        this.$message.error(error)
      })
      // let ids = ""
      // if (this.$route.params.ids) {
      //   ids = "?"
      //   for (let i = 0; i < this.$route.params.ids.length; i++) {
      //     ids += 'ids=' + this.$route.params.ids[i] + '&'
      //   }
      //   ids = ids.substring(0, ids.length - 1);
      // }
      // let params = {
      //   no: this.no,
      //   size: this.size,
      //   site: this.$store.state.user.site,
      //   customerNo: this.searchData.customerNo,
      //   customerName: this.searchData.customerName,
      //   trackerName: this.searchData.trackerName,
      //   quotationNo: this.searchData.quotationNo,
      //   customerInquiryNo: this.searchData.customerInquiryNo,
      //   internalInquiryNo: this.searchData.internalInquiryNo,
      //   quotationStatus: this.searchData.quotationStatus,
      //   projectId: this.searchData.projectId,
      //   projectName: this.searchData.projectName,
      //   quoterName: this.searchData.quoterName,
      //   startDate: this.searchData.startDate,
      //   endDate: this.searchData.endDate,
      // }
      // this.init(params, ids)
    },
    init(params, ids) {
      this.initQuotationHeaderLoading = true;
      getQuotationHeaderByPage(params, ids).then(({data}) => {
        this.tableData = data.data.records;
        this.total = data.data.total;
        if (this.tableData.length > 0) {
          this.quotationHeader = this.tableData[0];
        } else {
          this.quotationHeader = null;
        }
        this.initQuotationHeaderLoading = false;
      }).catch((error) => {
        this.initQuotationHeaderLoading = false;
      })
    },
    // 删除方法
    deleteQuotationHeader(row) {
      this.$confirm('确定删除该报价单吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteByQuotationHeaderId(row).then(({data}) => {
          if (data.code === 200) {
            this.$message.success(data.msg);
            this.initData();
          } else {
            this.$message.error(data.msg);
          }
        })
      })
    },
    // 修改方法
    editQuotationHeader(row) {
      this.insertData = JSON.parse(JSON.stringify(row));
      this.insertData.internalInquiryBatchNo = this.insertData.internalInquiryNo.split("-")[0]
      this.insertDiaLogFlag = true;
    },
    // size 发送改变
    quotationHeaderSizeChange(val) {
      this.size = val;
      this.initData();
    },
    // no发生改变
    quotationHeaderCurrentChange(val) {
      this.no = val;
      this.initData();
    },
    // 新增QuotationHeader
    saveQuotationHeader() {
      // 校验
      this.$refs['insertQuotationForm'].validate((valid, objects) => {
        if (valid) {
          this.insertQuotationHeaderBtn = true;
          // 请求
          saveQuotationHeader(this.insertData).then(({data}) => {
            // 返回提示
            if (data.code === 200) {
              this.initData();
              this.insertQuotationHeaderBtn = false;
              this.insertDiaLogFlag = false;
            }
            this.$message.success(data.msg);
          })
        } else {
          this.rulesValidateLabel(objects, this.quotationHeaderColumns);
        }
      })
    },
    // 校验处理
    rulesValidateLabel(objects, labels) {
      for (let filed in objects) {
        for (let i = 0; i < labels.length; i++) {
          let quotationToolColumn = labels[i];
          if (quotationToolColumn.label === filed) {
            this.$message.warning(quotationToolColumn.value + "填写不正确");
            return
          }
        }
      }
    },
    // resetInsertData 重置新增对象
    resetInsertData() {
      this.insertData = {
        site: this.$store.state.user.site,
        quotationNo: "",//客户报价单号
        quotationDate: new Date(),//报价日期
        customerNo: "", // 客户编号
        customerName: "",//客户名称
        versionCode: "001",
        projectId: "",//项目编码
        projectName: "",//项目名称
        tracker: "",//采购专员
        quoter: "",//销售编号
        quoterName: "",//报价专员
        trackerName: "",//采购专员
        currency: "",//货币
        quotationStatus: "草稿",//状态
        remark: "",//备注
        customerInquiryNo: "",//客户询价单号
        internalInquiryNo: "",//内部询价单号
        requireApproval: "",//需要审批
        approvalStatus: "",//审批状态
        createBy: this.$store.state.user.id,//当前登录账号
        createDate: new Date(),//当前时间
      }
    },
    // 销售员输入框清除事件
    clearQuoter() {
      this.insertData.quoter = "";
      this.insertData.quoterName = "";
    },
    // 采购专员输入框清除事件
    clearTracker() {
      this.insertData.tracker = "";
      this.insertData.trackerName = "";
    },
    // 新增弹框关闭事件
    closeInsertDialog() {
      this.resetInsertData();
      this.$refs['insertQuotationForm'].resetFields();
      this.insertData = {
        site: this.$store.state.user.site,
        quotationNo: "",//客户报价单号
        quotationDate: new Date(),//报价日期
        customerNo: "", // 客户编号
        customerName: "",//客户名称
        versionCode: "001",
        projectId: "",//项目编码
        projectName: "",//项目名称
        tracker: "",//采购专员
        quoter: "",//销售编号
        quoterName: "",//报价专员
        trackerName: "",//采购专员
        currency: "",//货币
        quotationStatus: "草稿",//状态
        remark: "",//备注
        customerInquiryNo: "",//客户询价单号
        internalInquiryNo: "",//内部询价单号
        internalInquiryBatchNo: "",//内部询价单号
        requireApproval: "",//需要审批
        approvalStatus: "",//审批状态
        createBy: this.$store.state.user.id,//当前登录账号
        createTime: new Date(),//当前时间
      }
    },
    // 点击标签页
    handleClickTab(tab, event) {

    },

    // ======== chooseList相关方法 ========
    /**
     * 获取基础数据列表S
     * @param val
     * @param type
     */
    getBaseList(val, type) {
      this.tagNo = val
      this.tagNo1 = type
      this.$nextTick(() => {
        let strVal = ''
        let conSql = ''
        if (val === 102) {
          if (type === 1) {
            strVal = this.insertData.customerNo
          }
        }
        if (val === 103) {
          if (type === 1) {
            strVal = this.insertData.tracker
          }
          if (type === 2) {
            strVal = this.insertData.quoter
          }
        }
        if (val === 104) {
          if (type === 1) {
            strVal = this.insertData.projectId
          }
        }
        if (val === 2000) {
          strVal = this.insertData.tracker
          conSql = " and b.site = '" + this.$store.state.user.site + "'"
        }
        if (val === 2002) {
          strVal = this.insertData.quoter
          conSql = " and b.site = '" + this.$store.state.user.site + "'"
        }
        this.$refs.baseList.init(val, strVal, conSql)
      })
    },
    /**
     * 列表方法的回调
     * @param val
     */
    getBaseData(val) {
      if (this.tagNo === 102) {
        if (this.tagNo1 === 1) {
          if (this.insertData.customerNo !== val.Customer_no) {
            this.insertData.projectId = '';
            this.insertData.projectName = '';
          }
          this.insertData.customerNo = val.Customer_no
          this.insertData.customerName = val.Customer_desc
        }
      }
      if (this.tagNo === 103) {
        if (this.tagNo1 === 1) {
          this.insertData.tracker = val.username
          this.insertData.trackerName = val.user_display
        }
        if (this.tagNo1 === 2) {
          this.insertData.quoter = val.username
          this.insertData.quoterName = val.user_display
        }
      }
      if (this.tagNo === 104) {
        if (this.tagNo1 === 1) {
          this.insertData.projectId = val.project_id
          this.insertData.projectName = val.project_name
        }
      }
      if (this.tagNo === 2002) {
        this.insertData.quoter = val.username
        this.insertData.quoterName = val.user_display
      }
      if (this.tagNo === 2000) {
        this.insertData.tracker = val.username
        this.insertData.trackerName = val.user_display
      }
    },
    // 查询 内部报价单编号
    searchQuotationData() {
      searchQuotationByQuotationNo(this.quotationNoSearchData).then(({data}) => {
        if (data && data.code === 0){
          this.quotationNoData = data.data;
        }
      })
    },
    // 打开 内部报价单拟态框
    openQuotationNoDialog() {
      // 请求
      this.searchQuotationData();
    },
    // 关闭
    closeQuotationNoDialog() {
      this.quotationNoSearchData = {
        quotationNo: "",//单号
        quotationBatchNo: "",//批次号
        quotationItemNo: '',//序号
        quotationStatus: '',
        partName:'',//物料描述
        testPartNo:'',//物料编码
        site: this.$store.state.user.site,//工厂编号
      }
    },
    // 询价表双击事件
    dblclickQuotationNo(row) {
      this.insertData.customerNo = row.customerNo;
      this.insertData.customerName = row.customerDesc;//客户名称
      this.insertData.projectId = row.projectId;//项目编码
      this.insertData.projectName = row.projectName;//项目名称
      this.insertData.finalCustomerId = row.finalCustomerId;
      this.insertData.finalCustomerName = row.finalCustomerName;
      this.insertData.tracker = row.tracker;//采购专员
      this.insertData.trackerName = row.trackerName;
      this.insertData.quoter = row.quoter;//销售编号
      this.insertData.quoterName = row.quoterName;//销售编号
      this.insertData.internalInquiryNo = row.quotationNo;//内部询价单号
      this.insertData.internalInquiryBatchNo = row.quotationBatchNo;//内部询价单号
      this.insertData.currency = row.customerCurrency;//内部询价单号
      // 关闭弹框
      this.quotationNoDialogFlag = false;
    },
    quotationAgain(row) {
      quotationAgain(row).then(({data}) => {
        if (data && data.code === 0) {
          this.$message.success(data.msg)
          this.initData();
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      }).catch((error) => {
        this.$message.error(error)
      })
    },
    closeProjectInfoDialog() {
      this.$refs.closeProjectInfoForm.resetFields();
      this.searchProjectData = {
        site: this.$store.state.user.site,
        projectId: undefined,
        projectName: undefined,
        customerId: undefined,
      }
    },
    searchProjectInfoList() {
      this.projectList = [];
      this.searchProjectData.customerId = this.insertData.customerNo
      searchProjectInfoList(this.searchProjectData).then(({data}) => {
        if (data && data.code === 0) {
          this.projectList = data.rows
        } else {
          this.projectList = []
        }
      }).catch((error) => {
        this.$message.error('查询项目信息失败')
      })
    },
    handleUpdateStatus(row, status) {
      this.$confirm(`是否确认${status?'取消下达':'下达'}?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(()=>{
        let params = {
          ...row,
          quotationStatus:status?'草稿':'下达',
        }
        updateQuoteStatus(params).then(({data})=>{
          if (data && data.code === 0){
            this.$message.success(data.msg)
            this.initData()
          }else {
            this.$message.warning(data.msg)
          }
        }).catch((error)=>{
          this.$message.error(error)
        })
      })
    },
    restQuoteHeader() {
      this.insertData = {
        site: this.$store.state.user.site,
        quotationNo: "",//客户报价单号
        quotationDate: new Date(),//报价日期
        customerNo: "", // 客户编号
        customerName: "",//客户名称
        versionCode: "001",
        projectId: "",//项目编码
        projectName: "",//项目名称
        tracker: "",//采购专员
        quoter: "",//销售编号
        quoterName: "",//报价专员
        trackerName: "",//采购专员
        currency: "",//货币
        quotationStatus: "草稿",//状态
        remark: "",//备注
        customerInquiryNo: "",//客户询价单号
        internalInquiryNo: "",//内部询价单号
        internalInquiryBatchNo: "",//内部询价单号
        requireApproval: "",//需要审批
        approvalStatus: "",//审批状态
        createBy: this.$store.state.user.id,//当前登录账号
        createTime: new Date(),//当前时间
      }
    },
    clearCustomer() {
      this.insertData.projectId = '';
      this.insertData.projectName = '';
    },
    quotationHeaderRowStyle({row}) {
      if (!this.quotationHeader){
        return {}
      }
      if (row.quotationHeaderId === this.quotationHeader.quotationHeaderId) {
        return {'background-color': '#E8F7F6'}
      }
    },
    clickInternalInquiryNoHandle(){
      this.quotationNoSearchData.quotationNo = this.insertData.internalInquiryNo;
      // setTimeout(()=>{
      //   this.quotationNoSearchData.quotationNo = ''
      // },200)
      this.quotationNoDialogFlag = true
    },
    blurInternalInquiryNoHandle(){
      let params = {
        quotationNo:this.insertData.internalInquiryNo,
        site:this.$store.state.user.site
      }
      searchQuotationByQuotationNo(params).then(({data}) => {
        if (data && data.code === 0){
          // this.quotationNoData = data.data;
          let rows = data.data
          if (rows.length === 1){
            this.dblclickQuotationNo(rows[0])
          }
        }
      })
    },
    routerWatch(){
      if (this.$route.params && this.$route.params.from && this.$route.params.from === 'inquiry'){
        let params = {
          quotationHeaderId:this.$route.params.quotationHeaderId,
          no:1,
          size:this.size,
        }
        getQuotePage(params).then(({data})=>{
          if (data && data.code === 0){
            this.tableData = data.rows;
            this.total = data.total;
            if (this.tableData.length > 0) {
              this.quotationHeader = this.tableData[0];
            } else {
              this.quotationHeader = null;
            }
          }else {
            this.$message.warning(data.msg)
          }
        }).catch((error)=>{
          this.$message.error(error)
        })
      }else if (this.$route.params.quotationNo || this.$route.params.version) {
        let params = {
          quotationNo: this.$route.params.quotationNo,
          versionCode: this.$route.params.version,
          site: this.$store.state.user.site,
        }
        getQuotationHeaderByPagePost(params,undefined,this.no,this.size).then(({data})=>{
          if (data && data.code === 0){
            this.tableData = data.rows;
            this.total = data.total;
            if (this.tableData.length > 0) {
              this.quotationHeader = this.tableData[0];
            } else {
              this.quotationHeader = null;
            }
          }else {
            this.$message.warning(data.msg)
          }
        }).catch((error)=>{
          this.$message.error(error)
        })
      }else if (this.$route.params && this.$route.params.ids && this.$route.params.ids.length > 0){
        let params = {
          site : this.$store.state.user.site,
        }
        getQuotationHeaderByPagePost(params,this.$route.params.ids,this.no,this.size).then(({data})=>{
          if (data && data.code === 0){
            this.tableData = data.rows;
            this.total = data.total;
            if (this.tableData.length > 0) {
              this.quotationHeader = this.tableData[0];
            } else {
              this.quotationHeader = null;
            }
          }else {
            this.$message.warning(data.msg)
          }
        }).catch((error)=>{
          this.$message.error(error)
        })
      }else if (this.initPage === false){
        this.initData();//初始化数据
      }
      this.initPage = true;
    },
    handleQueryCustomer(){
      let params = {
        site:this.$store.state.user.site,
        customerNo:this.insertData.customerNo
      }
      queryCustomer(params).then(({data})=>{
        if (data && data.code === 0 ) {
          if (data.rows && data.rows.length === 1){
            this.insertData.customerName = data.rows[0].customerDesc
          }else {
            this.insertData.customerName = ''
          }
        }else {
          this.$message.warning(data.msg)
        }
      }).catch((error)=>{
        this.$message.error(error)
      })
    },
    handleQueryProjectByCustomer(){
      let params = {
        site:this.$store.state.user.site,
        customerId:this.insertData.customerNo,
        projectId:this.insertData.projectId
      }
      queryProjectByCustomer(params).then(({data})=>{
        if (data && data.code === 0 ){
          if (data.rows && data.rows.length === 1){
            this.insertData.projectName = data.rows[0].projectName
            this.insertData.finalCustomerId = data.rows[0].finalCustomerId
            this.insertData.finalCustomerName = data.rows[0].finalCustomerName
          }else {
            this.insertData.projectName = ''
            this.insertData.finalCustomerId = ''
            this.insertData.finalCustomerName = ''
          }
        }else {
          this.$message.warning(data.msg)
        }
      }).catch((error)=>{
        this.$message.error(error)
      })
    },
    handleDetail(row){
      this.insertData = {
        ...row,
      };
      this.insertData.internalInquiryBatchNo = this.insertData.internalInquiryNo.split("-")[0]
      this.detailDialogVisible = true;
      this.insertDiaLogFlag = true;
    },
    getPriceCheckProperties() {
      if (!this.quotationHeader && !this.quotationHeader.internalInquiryNo){
        this.priceCheckPropertiesList = []
        return
      }
      let params = {
        site: this.quotationHeader.site,
        quotationNo: this.quotationHeader.internalInquiryNo
      }
      getPriceCheckPropertiesList(params).then(({data}) => {
        if (data && data.code === 0) {
          this.priceCheckPropertiesList = data.rows
        } else {
          this.$message.warning(data.msg)
        }
      }).catch((error) => {
        this.$message.error(error)
      })
    },

    handleRouter(internalInquiryNo){
      if (this.$router.resolve('quotation-requestForQuote').resolved.name === '404') {
        this.$alert('权限不足,访问失败', '警告', {confirmButtonText: '确定',})
      } else {
        this.$router.push({
          name: 'quotation-requestForQuote',
          params:{
            quotationNo:internalInquiryNo,
          }
        })
      }
    }
  },
  computed: {},
  watch: {
    "insertData.customerNo": {
      handler() {
        if (!this.insertData.customerNo || this.insertData.customerNo.length === 0) {
          this.insertData.customerName = '';
          this.insertData.projectId = '';
        }
      }
    },
    "insertData.projectId": {
      handler() {
        if (!this.insertData.projectId || this.insertData.projectId.length === 0) {
          this.insertData.projectName = '';
        }
      }
    },
    insertDiaLogFlag(newVal,oldVal){
      if (newVal === false){
        this.detailDialogVisible = false;
      }
    },
    quotationHeader(newVal,oldVal){
      if (newVal){
        this.getApprovalList()
        this.getPriceCheckProperties();
      }
    },
    "searchData.customerNo"(newVal,oldVal){
      this.searchData.customerNo = newVal.toUpperCase()
    },
    "searchData.quotationNo"(newVal,oldVal){
      this.searchData.quotationNo = newVal.toUpperCase()
    },
    "searchData.internalInquiryNo"(newVal,oldVal){
      this.searchData.internalInquiryNo = newVal.toUpperCase()
    },
    "searchData.projectId"(newVal,oldVal){
      this.searchData.projectId = newVal.toUpperCase()
    },
  },
  mounted() {
  },
  activated() {
    this.routerWatch()
  },
}
</script>

<style scoped>
/deep/ .el-range-editor--mini.el-input__inner {
  height: 20px;
}

/deep/ .el-range-editor.el-input__inner {
  padding: 0px 10px;
}

/deep/ .el-input--mini .el-input__icon {
  line-height: 20px;
}

/deep/ .el-table__body tr.current-row > td {
  background-color: #E8F7F6 !important;
  color: #fff;
}

</style>

