<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-row :gutter="10">
        <el-col :span="3">
          <el-form-item :label="'BU'">
            <el-select v-model="searchData.bu" placeholder="请选择" clearable>
              <el-option
                v-for = "i in userBuList"
                :key = "i.buNo"
                :label = "i.buDesc"
                :value = "i.buNo">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="客户编码">
            <el-input v-model="searchData.customerNo"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="客户名称">
            <el-input v-model="searchData.customerDesc"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="采购专员">
            <el-input v-model="searchData.purchase"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="报价单号">
            <el-input v-model="searchData.quoteVersionNo"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="客户询价单号">
            <el-input v-model="searchData.customerInquiryNo"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="3">
          <el-form-item label="内部询价单号">
            <el-input v-model="searchData.insideInquiryNo"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="报价专员">
            <el-input v-model="searchData.quoter"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="状态">
            <el-select v-model="searchData.status" style="width: 100%">
              <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-form-item label="报价日期">
            <div style="display: flex">
              <el-date-picker style="width: 47%" v-model="searchData.startDate" type="date" value-format='yyyy-MM-dd' format='yyyy-MM-dd'></el-date-picker>
              <div style="width: 6%;text-align: center">-</div>
              <el-date-picker style="width: 47%" v-model="searchData.endDate" type="date" value-format='yyyy-MM-dd' format='yyyy-MM-dd'></el-date-picker>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label=" ">
            <el-button @click="getDataListAll">查 询</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 询价列表 -->
    <el-table
      height="30vh"
      :data="dataList"
      border
      ref="mainTable"
      highlight-current-row
      @row-click="quoteClickRow"
      @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">
          <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="180"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" @click="updateModal(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-tabs style="margin-top: 0px; width: 100%; height: 100%;" v-model="activeName" class="customer-tab" type="border-card" @tab-click="tabClick">
      <el-tab-pane label="报价信息" name="quotationInformation">
        <el-form :inline="true" label-width="120px" label-position="top">
          <el-form-item label="Application">
            <el-input v-model="quoteCurrentRow.application" style="width: 210px" readonly></el-input>
          </el-form-item>
          <el-form-item label="Customer">
            <el-input v-model="quoteCurrentRow.customerDesc" readonly></el-input>
          </el-form-item>
          <el-form-item label="年需求量">
            <el-input-number v-model="quoteCurrentRow.annualDemand" disabled :controls="false"></el-input-number>
          </el-form-item>
          <el-form-item label="Cost Model">
            <el-input v-model="quoteCurrentRow.costModel" style="width: 210px" readonly></el-input>
          </el-form-item>
          <el-form-item label="Markup">
            <el-input-number v-model="quoteCurrentRow.markup" disabled :controls="false"></el-input-number>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-width="120px" label-position="top">
          <el-form-item label="报价备注">
            <el-input type="textarea" :rows="2" v-model="quoteCurrentRow.remark" style="width: 1019px" readonly></el-input>
          </el-form-item>
        </el-form>
          <quote-detail :quote="quoteCurrentRow" :auth-flag="true" :height="'33vh'"></quote-detail>
      </el-tab-pane>
    </el-tabs>

    <el-dialog title="申请单审核" :visible.sync="reviewFlag" width="520px" :close-on-click-modal="false"
               v-drag>
      <el-row>
        <el-col :span="24" style="margin-top: 30px">
          <div style="margin-left: 45px;margin-top: -30px">
            <el-form :inline="true" label-width="120px" label-position="top">
              <el-form-item label="申请单号">
                <el-input style="width: 200px;" readonly placeholder="" :value="modalData.quoteVersionNo"></el-input>
              </el-form-item>
              <el-form-item label="审批步骤号">
                <el-input style="width: 200px;" readonly placeholder="" :value="modalData.stepId"></el-input>
              </el-form-item>
            </el-form>
            <el-form :inline="true" label-width="120px" label-position="top">
              <el-form-item label="审批人">
                <el-input style="width: 200px;" readonly placeholder="" :value="modalData.userName"></el-input>
              </el-form-item>
              <el-form-item label="审批时间">
                <el-input style="width: 200px;" readonly placeholder=""
                          :value="modalData.strActAuthorizeDate"></el-input>
              </el-form-item>
              <el-form-item label="备注">
                <el-input type="textarea" :readonly="(modalData.canAuthFlag!=='Y') "
                          :rows="3"
                          style="text-align: left;width: 415px;" v-model="modalData.authHistRemark"></el-input>
              </el-form-item>
            </el-form>
            <el-footer style="height:30px;margin-top: 5px;margin-left:-35px;text-align:center">
              <el-button type="primary" v-if="( modalData.canAuthFlag === 'Y') "
                         @click="saveReview(modalData,'Y')">{{'同意'}}
              </el-button>
              <el-button type="primary" v-if="( modalData.canAuthFlag === 'Y') "
                         @click="saveReview(modalData ,'N')">{{'不同意'}}
              </el-button>
            </el-footer>
          </div>
        </el-col>
      </el-row>
    </el-dialog>

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

  </div>
</template>

<script>
import Chooselist from '@/views/modules/common/Chooselist_eam'
import {getSiteAndBuByUserName} from "../../../api/qc/qc";
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 {
  searchUserAuthQuoteApplicationInfo
} from "../../../api/quote/quote";
import quotationUpload from "../quote/quotation_upload.vue";
import {updateAuthHist} from "../../../api/auth/auth";
import TpCost from "../quote/detail/tpCost.vue";
import QuoteDetail from "../quote/detail/quoteDetail.vue";

export default {
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      // 跳转后清除 redirectPath
      localStorage.removeItem('redirectPath');
      console.log('redirectPath 已清除');
    });
  },
  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: {
    QuoteDetail,
    TpCost,
    quotationUpload,
    DictDataSelect,
    Chooselist
  },
  props:{
    height:{
      type:Number,
      default:200
    }
  },
  data() {
    return {
      userBuList: [],
      copyPriceCheckDetail:{},
      loading:false,
      attributeDialog:true,
      activeName: 'quotationInformation',
      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:'',
      },
      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: {
        userId: this.$store.state.user.id,
        site: this.$store.state.user.site,
        id: '',
        customerNo: '',
        customerDesc: '',
        quoteVersionNo: '',
        bu: '',
        requestStartDate: '',
        requestEndDate: '',
        requiredCompletionStartDate: '',
        requiredCompletionEndDate: '',
        status: '',
        quoterName: '',
        requesterName: '',
        priorityLevel: '',
        orderRef1: 'BJ',
        page: 1,
        limit: 10,
        menuId: this.$route.meta.menuId,
      },
      searchData1: {
        userId: this.$store.state.user.id,
        site: this.$store.state.user.site,
        id: '',
        customerNo: '',
        customerDesc: '',
        quoteVersionNo: '',
        bu: '',
        requestStartDate: '',
        requestEndDate: '',
        requiredCompletionStartDate: '',
        requiredCompletionEndDate: '',
        status: '',
        quoterName: '',
        requesterName: '',
        priorityLevel: '',
        orderRef1: 'BJ',
        page: 1,
        limit: 10,
        menuId: this.$route.meta.menuId,
      },
      // 其它
      dataListLoading: false,
      // 选择项目弹框开关
      chooseProjectListFlag: false,
      reviewFlag: false,
      // 初始页签
      activeTable: 'inquiryAuth',
      // ======== 数据对象 ========
      modalData: {
        flag: '',
        title: '',
        site: this.$store.state.user.site,
        userName: this.$store.state.user.name,
        id: '',
        quoteVersionNo: '',
        customerNo: '',
        customerDesc: '',
        requestDate: '',
        requester: '',
        requesterName: '',
        customerInquiryNo: '',
        priorityLevel: '',
        requiredCompletionDate: '',
        quoter: '',
        quoterName: '',
        status: '',
        remark: '',
        createDate: '',
        createBy: '',
        updateDate: '',
        updateBy: '',
        authHistId: '',
        approveResult: '',
        authHistRemark: '',
        canAuthFlag: '',
        actAuthorizator: '',
        strActAuthorizeDate: this.dayjs().format("YYYY-MM-DD HH:mm:ss"),
        actAuthorizeDate: ''
      },
      inquiryPartItemModalData: {
        bu: '',
        buDesc: '',
        quoteVersionNo: '',
        partNo: '',
        partDesc: '',
        umId: '',
        umName: '',
        codeNo: '',
        codeDesc: '',
        textValue: '',
        numValue: '',
        valueType: '',
        valueTypeDb: '',
        valueChooseFlag: '',
        availableValueList: [],
      },
      // ======== 数据列表 ========
      dataList: [],
      inquiryAuthDataList: [],
      // ======== 列表表头 ========
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 190006,
          serialNumber: '190006Table1BuDesc',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'buDesc',
          headerAlign: 'center',
          align: 'center',
          columnLabel: 'BU',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 190006,
          serialNumber: '190006Table1QuoteVersionNo',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'quoteVersionNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '报价单号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 180
        },
        {
          userId: this.$store.state.user.name,
          functionId: 190006,
          serialNumber: '190006Table1QuoteDate',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'quoteDate',
          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: 190006,
          serialNumber: '190006Table1CustomerNo',
          tableId: '190006Table1',
          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: 190006,
          serialNumber: '190006Table1CustomerDesc',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'customerDesc',
          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: 190006,
          serialNumber: '190006Table1QuoterName',
          tableId: '190006Table1',
          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: 190006,
          serialNumber: '190006Table1PurchaseName',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'purchaseName',
          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: 190006,
          serialNumber: '190006Table1Currency',
          tableId: '190006Table1',
          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: 190006,
          serialNumber: '190006Table1Status',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'status',
          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: 190006,
          serialNumber: '190006Table1CustomerInquiryNo',
          tableId: '190006Table1',
          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: 190006,
          serialNumber: '190006Table1InsideInquiryNo',
          tableId: '190006Table1',
          tableName: '报价信息表',
          columnProp: 'insideInquiryNo',
          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: 190006,
          serialNumber: '190006Table1Auth',
          tableId: '190006Table1',
          tableName: '询价产品表',
          columnProp: 'auth',
          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: 190006,
          serialNumber: '190006Table2StepId',
          tableId: '190006Table2',
          tableName: '询价产品表',
          columnProp: 'stepId',
          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: 190006,
          serialNumber: '190006Table1AuthHistRemark',
          tableId: '190006Table1',
          tableName: '询价信息表',
          columnProp: 'authHistRemark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '审批备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
      ],
      // ======== 必填规则 ========
      rules: {
        bu: [
          {required: true, message: ' ', trigger: 'change'},
          {required: true, message: ' ', trigger: 'blur'},
        ],
        quoteVersionNo: [
          {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'},
        ],
      },
      // ======== 选中的当前行数据 ========
      quoteCurrentRow: {},
      // ======== 模态框开关控制 ========
      modalFlag: false,
      modalDisableFlag: false,
      inquiryPartModalFlag: false,
      inquiryPartModalDisableFlag: false,
      inquiryPartItemModalFlag: false,
    }
  },
  mounted() {
    this.$nextTick(() => {
      /*第二个表格高度的动态调整*/
      this.height = window.innerHeight - 210;
    })
  },
  created() {
    this.getSiteAndBuByUserName()
    // 获取 URL 查询参数
    const {quoteVersionNo} = this.$route.query;
    // 将查询参数赋值给 searchData
    if (quoteVersionNo){
      this.searchData1.quoteVersionNo = this.$route.query.quoteVersionNo;
    }
    this.getDataList()
  },
  methods: {
    // 获取用户的bu
    getSiteAndBuByUserName () {
      let tempData = {
        username: this.$store.state.user.name,
      }
      getSiteAndBuByUserName(tempData).then(({data}) => {
        if (data.code === 0) {
          this.userBuList = data.rows
        }
      })
    },
    // ======== 分页相关方法 ========
    /**
     * 每页数
     * @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
     */
    quoteClickRow(row) {
      this.quoteCurrentRow = JSON.parse(JSON.stringify(row))
    },
    /**
     * 当前值发生变化的时候修改
     * @param row
     * @param oldRow
     */
    changeCurrentRow(row, oldRow) {
      // 判断是否是获取焦点的事件
      if (row) {
        this.quoteCurrentRow = JSON.parse(JSON.stringify(row))
        //刷新当前页表
        this.refreshCurrentTabTable()
      }
    },
    /**
     * 刷新页签的table数据
     */
    refreshCurrentTabTable() {
    },

    // ======== 列表数据刷新方法 ========
    /**
     * 获取数据列表
     */
    getDataListAll(){
      this.searchData1 = null
      this.getDataList()
    },

    getDataList() {
      console.log(this.searchData1)
      this.searchData.limit = this.pageSize
      this.searchData.page = this.pageIndex
      let inData = this.searchData
      if (this.searchData1 !== null){
        this.searchData1.limit = this.pageSize
        this.searchData1.page = this.pageIndex
        inData = this.searchData1
      }
      searchUserAuthQuoteApplicationInfo(inData).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
          this.dataList.forEach(item => {
            if (item.groupDesc === '' || item.groupDesc === null) {
              item.auth = item.userDisplay
            } else {
              item.auth = item.groupDesc
            }
          })
          //判断是否全部存在数据
          if (this.totalPage > 0) {
            //设置选中行
            this.$refs.mainTable.setCurrentRow(this.dataList[0])
            this.refreshCurrentTabTable() //加载当前的页签的table
            this.quoteClickRow(this.dataList[0])
          }
        }
        this.dataListLoading = false
      })
    },

    // /**
    //  * 获得这些询价号的全部附件
    //  */
    // 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 = []
    //     }
    //   })
    // },

    // ======== chooseList相关方法 ========
    /**
     * 获取基础数据列表S
     * @param val
     * @param type
     */
    getBaseList(val, type) {
      this.tagNo = val
      this.tagNo1 = type
      this.$nextTick(() => {
        let strVal = ''
        let conSql = ''
        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 === 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 === 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 === 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
        }
      }
    },

    updateModal(row) {
      this.modalData = JSON.parse(JSON.stringify(row))
      this.modalData.strActAuthorizeDate = this.dayjs().format("YYYY-MM-DD HH:mm:ss")
      this.modalData.userName = this.$store.state.user.name
      this.reviewFlag = true
    },

    saveReview(row, val) {
      if (row.authHistRemark == '') {
        this.$alert(data.msg, '操作提示', {
          confirmButtonText: '确定',
          callback: action => {
            this.saveButton = false
          }
        });
      }
      this.modalData.id = row.authHistId
      this.modalData.actAuthorizator = row.userName
      this.modalData.remark = row.authHistRemark
      this.modalData.actAuthorizeDate = row.strActAuthorizeDate
      this.modalData.orderRef1 = row.quoteVersionNo
      if (val === "Y") {
        if (row.lastStepFlag === 'Y') {
          this.modalData.approveResult = "已审批"
        } else {
          this.modalData.approveResult = "已审批"
        }
      } else if (val === "N") {
        this.modalData.approveResult = "未通过"
      }
      updateAuthHist(this.modalData).then(({data}) => {
        if (data && data.code === 0) {
          this.getDataList()
          this.reviewFlag = false
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {}
          })
        } else {
          this.$alert(data.msg, '错误', {
            confirmButtonText: '确定'
          })
        }
      })
    },

    // ======== 导出相关方法 ========
    /**
     * 导出excel
     */
    async createExportData() {
      this.searchData.limit = -1
      this.searchData.page = 1
      await searchUserAuthQuoteApplicationInfo(this.searchData).then(({data}) => {
        this.resultList = data.page.list
      })
      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.quoteVersionNo.startsWith('XJ')) {
    //         // 解析数字部分
    //         const numPart = parseInt(item.quoteVersionNo.replace('XJ', ''), 10);
    //         if (!isNaN(numPart)) {
    //           rfqNos.push(numPart);
    //         }
    //       }
    //     });
    //     if (rfqNos.length === 0) {
    //       // 如果没有XJ开头的rfqNo
    //       this.modalData.quoteVersionNo = 'XJ00000001';
    //     } else {
    //       // 取到最大的XJ开头的rfqNo
    //       let maxRfqNo = Math.max(...rfqNos);
    //
    //       // 生成新的rfqNo，确保有9位数，前面补零
    //       maxRfqNo += 1; // 增加最大值
    //       this.modalData.quoteVersionNo = 'XJ' + String(maxRfqNo).padStart(8, '0');
    //     }
    //   }
    // },
    // 保存弹框关闭事件
    closeSaveDataDialog() {
      this.modalData = {
        flag: '',
        title: '',
        site: '',
        bu: '',
        buNo: '',
        buDesc: '',
        id: '',
        quoteVersionNo: '',
        customerNo: '',
        customerDesc: '',
        requester:'',
        requesterName: '',
        quoter: '',
        quoterName: '',
        customerInquiryNo: '',
        status: '',
        priorityLevel: '',
        requestDate: '',
        requiredCompletionDate: '',
        remark: '',
      }
      this.modalFlag = false
    },
    rowStyle({row}) {
      if (this.quoteCurrentRow.id === row.id) {
        return {'background-color': '#E8F7F6', cursor: 'pointer'};
      }
    },
  },
}
</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>

