<template>
  <div class="mod-config">

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

    <!-- 条件查询 -->
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'工厂'">
        <el-select v-model="searchData.site" placeholder="请选择" style="width: 120px">
          <el-option
            v-for = "i in userBuList"
            :key = "i.site"
            :label = "i.site"
            :value = "i.site">
            <span style="float: left;width: 120px">{{ i.sitename }}</span>
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="年份">
        <el-input v-model="searchData.statisticMonth" placeholder="格式：YYYY"></el-input>
      </el-form-item>
      <el-form-item>
        <span slot="label" style="" @click="getBaseList(501)"><a herf="#">供应商编码</a></span>
        <el-input v-model="searchData.supplierId" filterable placeholder="请选择或输入供应商编码"></el-input>
      </el-form-item>
      <el-form-item label="供应商名称">
        <el-input v-model="searchData.supplierName" placeholder="请输入供应商名称"></el-input>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</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-button type="primary" @click="computeFlag = true">供应商绩效统计计算</el-button>
      </el-form-item>
    </el-form>

    <!-- 展示列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      style="width: 100%;">
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :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="80"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" class="highlight" @click="totalPoints(scope.row)">详情</a>
        </template>
      </el-table-column>
    </el-table>

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

    <el-dialog title="详情" :close-on-click-modal="false" v-drag :visible.sync="suppPerTheMonthTotalPointsFlag" width="951px" style="margin-top: -5vh">
      <el-table
        :data="suppPerThisMonthDetailsList"
        :height="height - 27"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnSuppPerTheMonthTotalPointsList" :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"
          :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>
      <span slot="footer" class="dialog-footer">
        <el-button @click="suppPerTheMonthTotalPointsFlag = false">关闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="供应商绩效统计计算" :close-on-click-modal="false" v-drag :visible.sync="computeFlag" width="500px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="工厂">
          <el-input v-model="this.$store.state.user.site" style="width: 221px" disabled></el-input>
        </el-form-item>
        <el-form-item label="月份" prop="statisticMonth" :rules="rules.statisticMonth">
          <el-date-picker
            v-model="modalData.statisticMonth"
            type="month"
            value-format="yyyy-MM"
            placeholder="选择月"
            style="width: 221px">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="supplierPerformanceCalculation()">计算</el-button>
        <el-button @click="computeFlag = false">关闭</el-button>
      </span>
    </el-dialog>

    <!--列表的组件-->
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import {
    supplierPerformanceQuerySummarySearch,
    supplierPerformanceTheMonthTotalPoints
  } from "@/api/performance/performance.js"
  import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  import {getSiteAndBuByUserName} from "../../../api/qc/qc";
  import Chooselist from '@/views/modules/common/Chooselist';
  import {performanceIndicatorDefinitionCalculation, verifyData} from "../../../api/performance/performance";
  /* 列表组件 */
  export default {
    components: {
      Chooselist, /* 选择的组件 */
    },
    data () {
      return {
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "供应商年度绩效信息" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["供应商年度绩效信息"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        searchData: {
          site: this.$store.state.user.site,
          userName: this.$store.state.user.name,
          statisticMonth: new Date().getFullYear(),
          supplierId: '',
          supplierName: '',
          page: 1,
          limit: 10,
        },
        modalData: {
          site: '',
          bu: '',
          flag: '',
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          itemNo: '',
          indicatorDesc: '',
          indicatorGroup: '',
          active: 'Y',
          createDate: '',
          statisticMonth: '',
        },
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        height: 200,
        dataList: [],
        modalFlag: false,
        modalDisableFlag: false,
        computeFlag: false,
        suppPerTheMonthTotalPointsFlag: false,
        // 标头展示
        columnList: [
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableSite', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 50, columnProp: 'site', headerAlign: 'center', align: "center", columnLabel: '工厂', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableSupplierId', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 80, columnProp: 'supplierId', headerAlign: 'center', align: "center", columnLabel: '供应商编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableSupplierName', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 200, columnProp: 'supplierName', headerAlign: 'center', align: "center", columnLabel: '供应商名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService01', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService01', headerAlign: 'center', align: "center", columnLabel: '01-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery01', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery01', headerAlign: 'center', align: "center", columnLabel: '01-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality01', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality01', headerAlign: 'center', align: "center", columnLabel: '01-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll01', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll01', headerAlign: 'center', align: "center", columnLabel: '01-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel01', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel01', headerAlign: 'center', align: "center", columnLabel: '01-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService02', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService02', headerAlign: 'center', align: "center", columnLabel: '02-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery02', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery02', headerAlign: 'center', align: "center", columnLabel: '02-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality02', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality02', headerAlign: 'center', align: "center", columnLabel: '02-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll02', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll02', headerAlign: 'center', align: "center", columnLabel: '02-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel02', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel02', headerAlign: 'center', align: "center", columnLabel: '02-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService03', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService03', headerAlign: 'center', align: "center", columnLabel: '03-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery03', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery03', headerAlign: 'center', align: "center", columnLabel: '03-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality03', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality03', headerAlign: 'center', align: "center", columnLabel: '03-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll03', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll03', headerAlign: 'center', align: "center", columnLabel: '03-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel03', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel03', headerAlign: 'center', align: "center", columnLabel: '03-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService04', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService04', headerAlign: 'center', align: "center", columnLabel: '04-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery04', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery04', headerAlign: 'center', align: "center", columnLabel: '04-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality04', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality04', headerAlign: 'center', align: "center", columnLabel: '04-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll04', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll04', headerAlign: 'center', align: "center", columnLabel: '04-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel04', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel04', headerAlign: 'center', align: "center", columnLabel: '04-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService05', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService05', headerAlign: 'center', align: "center", columnLabel: '05-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery05', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery05', headerAlign: 'center', align: "center", columnLabel: '05-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality05', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality05', headerAlign: 'center', align: "center", columnLabel: '05-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll05', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll05', headerAlign: 'center', align: "center", columnLabel: '05-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel05', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel05', headerAlign: 'center', align: "center", columnLabel: '05-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService06', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService06', headerAlign: 'center', align: "center", columnLabel: '06-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery06', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery06', headerAlign: 'center', align: "center", columnLabel: '06-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality06', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality06', headerAlign: 'center', align: "center", columnLabel: '06-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll06', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll06', headerAlign: 'center', align: "center", columnLabel: '06-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel06', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel06', headerAlign: 'center', align: "center", columnLabel: '06-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService07', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService07', headerAlign: 'center', align: "center", columnLabel: '07-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery07', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery07', headerAlign: 'center', align: "center", columnLabel: '07-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality07', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality07', headerAlign: 'center', align: "center", columnLabel: '07-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll07', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll07', headerAlign: 'center', align: "center", columnLabel: '07-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel07', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel07', headerAlign: 'center', align: "center", columnLabel: '07-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService08', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService08', headerAlign: 'center', align: "center", columnLabel: '08-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery08', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery08', headerAlign: 'center', align: "center", columnLabel: '08-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality08', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality08', headerAlign: 'center', align: "center", columnLabel: '08-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll08', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll08', headerAlign: 'center', align: "center", columnLabel: '08-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel08', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel08', headerAlign: 'center', align: "center", columnLabel: '08-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService09', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService09', headerAlign: 'center', align: "center", columnLabel: '09-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery09', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery09', headerAlign: 'center', align: "center", columnLabel: '09-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality09', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality09', headerAlign: 'center', align: "center", columnLabel: '09-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll09', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll09', headerAlign: 'center', align: "center", columnLabel: '09-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel09', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel09', headerAlign: 'center', align: "center", columnLabel: '09-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService10', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService10', headerAlign: 'center', align: "center", columnLabel: '10-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery10', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery10', headerAlign: 'center', align: "center", columnLabel: '10-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality10', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality10', headerAlign: 'center', align: "center", columnLabel: '10-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll10', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll10', headerAlign: 'center', align: "center", columnLabel: '10-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel10', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel10', headerAlign: 'center', align: "center", columnLabel: '10-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService11', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService11', headerAlign: 'center', align: "center", columnLabel: '11-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery11', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery11', headerAlign: 'center', align: "center", columnLabel: '11-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality11', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality11', headerAlign: 'center', align: "center", columnLabel: '11-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll11', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll11', headerAlign: 'center', align: "center", columnLabel: '11-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel11', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel11', headerAlign: 'center', align: "center", columnLabel: '11-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },

          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalService12', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalService12', headerAlign: 'center', align: "center", columnLabel: '12-服务总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalDelivery12', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalDelivery12', headerAlign: 'center', align: "center", columnLabel: '12-交货总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalQuality12', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 90, columnProp: 'scoreTotalQuality12', headerAlign: 'center', align: "center", columnLabel: '12-质量总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableScoreTotalAll12', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 70, columnProp: 'scoreTotalAll12', headerAlign: 'center', align: "center", columnLabel: '12-总得分', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108003, serialNumber: '301001TableGradeLevel12', tableId: "301001Table", tableName: "供应商绩效概览表", columnWidth: 60, columnProp: 'gradeLevel12', headerAlign: 'center', align: "center", columnLabel: '12-等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
        ],
        columnSuppPerTheMonthTotalPointsList : [
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableStatisticMonth', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 80, columnProp: 'statisticMonth', headerAlign: 'center', align: "center", columnLabel: '月份', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableIndicatorItemNo', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 140, columnProp: 'indicatorItemNo', headerAlign: 'center', align: "center", columnLabel: '绩效指标简码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableIndicatorDesc', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnProp: 'indicatorDesc', headerAlign: 'center', align: "left", columnLabel: '绩效项目', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableIndicatorCount', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 80, columnProp: 'indicatorCount', headerAlign: 'center', align: "center", columnLabel: '绩效条数', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableIndicatorScore', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 80, columnProp: 'indicatorScore', headerAlign: 'center', align: "center", columnLabel: '绩效分数', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableIndicatorGroup', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 90, columnProp: 'indicatorGroup', headerAlign: 'center', align: "center", columnLabel: '绩效分类', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
          { userId: this.$store.state.user.name, functionId: 108002, serialNumber: '301001TableGradeLevel', tableId: "301001Table", tableName: "供应商绩效概览总得分表", columnWidth: 50, columnProp: 'gradeLevel', headerAlign: 'center', align: "center", columnLabel: '等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '' },
        ],
        rules: {
          site: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
          itemNo: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
          indicatorDesc: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
          indicatorGroup: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
          active: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
          statisticMonth: [
            {required: true, message: ' ', trigger: 'blur'}
          ],
        },
        userBuList: [],
        suppPerThisMonthDetailsList: [],
        authSearch: false,
        downLoading: false,
        menuId: this.$route.meta.menuId,
      }
    },

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

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

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

      // 查询获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        this.searchData.site = this.$store.state.user.site
        supplierPerformanceQuerySummarySearch(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
          }
        })
      },

      // 获取方法数据列表
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 501) {
            strVal = this.searchData.supplierId
          }
          this.$refs.baseList.init(val, strVal)
        })
      },

      /* 列表方法的回调 */
      getBaseData(val) {
        if (this.tagNo === 501) {
          this.searchData.supplierId = val.SupplierID
        }
      },

      totalPoints (row) {
        let inData = {
          site: row.site,
          statisticMonth: this.searchData.statisticMonth,
          supplierId: row.supplierId,
          limit: 10,
          page: 1,
        }
        supplierPerformanceTheMonthTotalPoints (inData).then(({data}) => {
          if (data.code === 0) {
            this.suppPerThisMonthDetailsList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          }
          this.suppPerTheMonthTotalPointsFlag = true
        })
      },

      supplierPerformanceCalculation () {
        if (this.modalData.statisticMonth === '' || this.modalData.statisticMonth == null) {
          this.$message.warning('请选择月份！')
          return
        }
        let inData = {
          site: this.$store.state.user.site,
          statisticMonth: this.modalData.statisticMonth,
        }
        performanceIndicatorDefinitionCalculation(inData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
            this.computeFlag = false
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // setupSupplierBlur (tagNo) {
      //   if (this.searchData.supplierId != null && this.searchData.supplierId !== '') {
      //     let tempData = {
      //       tagno: tagNo,
      //       conditionSql: " and SupplierID = '" + this.searchData.supplierId + "'" + " and site  = '" + this.searchData.site + "'"
      //     }
      //     verifyData(tempData).then(({data}) => {
      //       if (data && data.code === 0) {
      //         if (data.baseListData.length > 0) {
      //           this.searchData.supplierName = data.baseListData[0].SupplierName
      //         } else {
      //           this.$message.warning('供应商编码不存在')
      //           this.searchData.supplierName = ''
      //         }
      //       } else {
      //         this.$message.warning(data.msg)
      //         this.modalData.supplierName = ''
      //       }
      //     })
      //   }
      // },

      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },

      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },

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

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

      // 动态列开始 获取 用户保存的 格式列
      async getTableUserColumn (tableId, columnId) {
        let queryTableUser = {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          status: true,
          languageCode: this.$i18n.locale
        }
        await getTableUserListLanguage(queryTableUser).then(({data}) => {
          if (data.rows.length > 0) {
            //this.columnList1 = []
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              // case 2:
              //   this.columnDetailList = data.rows
              //   break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = 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;
              // case 2:
              //   this.columnDetailList = data.rows
              //   break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            // this.showDefault = true.
          }
        })
      },

      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let saveFlag = this.isAuth(this.menuId+":save")
        let updateFlag = this.isAuth(this.menuId+":update")
        let deleteFlag = this.isAuth(this.menuId+":delete")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authSave = !saveFlag
        this.authUpdate = !updateFlag
        this.authDelete = !deleteFlag
      },

      //导出excel
      async createExportData () {
        this.searchData.limit = -1
        this.searchData.page = 1
        await supplierPerformanceQuerySummarySearch(this.searchData).then(({data}) => {
          this.exportList = data.page.list
        })
        return this.exportList
      },
      startDownload () {},
      finishDownload () {},
      fields () {
        let json = "{"
        this.columnList.forEach((item, index) => {
          if (index == this.columnList.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")
        return s
      },
    }
  }
</script>
<style>
.highlight {
  font-weight: bold;
  color: red;
}
</style>
```
