<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-MM"></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>
      </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" @click="details(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="suppPerThisMonthDetailsFlag" 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 columnSuppPerThisMonthDetailsList" :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="suppPerThisMonthDetailsFlag = false">关闭</el-button>
      </span>
    </el-dialog>

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

<script>
  import {
    suppPerformanceQueryDetailSearch,
    supplierPerformanceThisMonthDetails
  } 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 {verifyData} from "../../../api/performance/performance";
  /* 列表组件 */
  export default {
    components: {
      Chooselist, /* 选择的组件 */
    },
    data () {
      const date = new Date();
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取当前月份并补零
      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: `${year}-${month}`, // 设置默认为当前月份，格式为 YYYY-MM
          supplierId: '',
          supplierName: '',
          page: 1,
          limit: 10,
        },
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        height: 200,
        dataList: [],
        modalFlag: false,
        modalDisableFlag: false,
        computeFlag: false,
        suppPerThisMonthDetailsFlag: false,
        // 标头展示
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 108002,
            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: 108002, serialNumber: '301001TableSupplierId', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 100, 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: 108002, serialNumber: '301001TableSupplierName', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 180, 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: 108002, serialNumber: '301001TableCountBzsldqjs', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 115, columnProp: 'countBzsldqjs', 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: '301001TableCountBzfswagdyqzx', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 190, columnProp: 'countBzfswagdyqzx', 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: '301001TableCountDlslyjhslcy', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 145, columnProp: 'countDlslyjhslcy', 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: '301001TableCountXqjfzpc', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 115, columnProp: 'countXqjfzpc', 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: '301001TableCountYqjf', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 90, columnProp: 'countYqjf', 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: '301001TableCountZsjhpswcl', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 118, columnProp: 'countZsjhpswcl', 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: '301001TableCountXjfzsl', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 85, columnProp: 'countXjfzsl', 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: '301001TableCountYqjfSl', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 90, columnProp: 'countYqjfSl', 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: '301001TableCountZsjhslwcl', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 120, columnProp: 'countZsjhslwcl', 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: '301001TableCountJyzps', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 80, columnProp: 'countJyzps', 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: '301001TableCountPlthTxzps', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 125, columnProp: 'countPlthTxzps', 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: '301001TableCountHgpl', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 70, columnProp: 'countHgpl', 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: '301001TableCountChjybgwtj', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 155, columnProp: 'countChjybgwtj', 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: '301001TableCountChjybgbf', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 285, columnProp: 'countChjybgbf', 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: '301001TableCountBqbzqWt', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 145, columnProp: 'countBqbzqWt', 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: '301001TableScoreBzsldq', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 85, columnProp: 'scoreBzsldq', 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: '301001TableScoreBzfswagdyqzx', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 85, columnProp: 'scoreBzfswagdyqzx', 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: '301001TableScoreDlslyjhslcy', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 85, columnProp: 'scoreDlslyjhslcy', 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: '301001TableScoreYqjf', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 70, columnProp: 'scoreYqjf', 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: '301001TableScorePlth', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 125, columnProp: 'scorePlth', 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: '301001TableScoreChjybgwtj', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 120, columnProp: 'scoreChjybgwtj', 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: '301001TableScoreChjybgbf', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 250, columnProp: 'scoreChjybgbf', 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: '301001TableScoreBqbzqWt', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 110, columnProp: 'scoreBqbzqWt', 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: '301001TableScoreTotalService', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 80, columnProp: 'scoreTotalService', 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: '301001TableScoreTotalDelivery', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 80, columnProp: 'scoreTotalDelivery', 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: '301001TableScoreTotalQuality', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 80, columnProp: 'scoreTotalQuality', 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: '301001TableScoreTotalAll', tableId: "301001Table", tableName: "供应商本月绩效统计表", columnWidth: 55, columnProp: 'scoreTotalAll', 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: '' },
        ],
        columnSuppPerThisMonthDetailsList : [
          { 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: '' },
        ],
        userBuList: [],
        suppPerThisMonthDetailsList: [],
        authSearch: 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
        suppPerformanceQueryDetailSearch(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
        }
      },

      details (row) {
        let inData = {
          site: row.site,
          statisticMonth: this.searchData.statisticMonth,
          supplierId: row.supplierId,
          limit: 10,
          page: 1,
        }
        supplierPerformanceThisMonthDetails (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.suppPerThisMonthDetailsFlag = true
        })
      },

      // 每页数
      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
            }
          }
        })
      },

      // 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 = ''
      //       }
      //     })
      //   }
      // },

      // 收藏 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
      },
    }
  }
</script>
