<template>
  <div>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model="form"
      v-model:page="page"
      ref="crud"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left>
        <!-- <el-button type="danger" icon="el-icon-delete" @click="handleDelete">删 除
            </el-button> -->
      </template>
      <template #menu-right>
        <el-button type="success" icon="el-icon-upload" @click="handleImport">导入 </el-button>
      </template>
    </avue-crud>
    <!-- 导入 -->
    <basic-import
      v-if="isShowImport"
      title="导入"
      :isShow="isShowImport"
      templateUrl="/blade-safety/wasteWaterMeterParameter/download-excel-template"
      templateName="废水计量参数导入模板.xls"
      importUrl="/blade-safety/wasteWaterMeterParameter/import-excel"
      @closeDialog="closeDialog"
    ></basic-import>
  </div>
</template>
<script>
import basicImport from '@/components/basic-import/main.vue';
import { getList } from '@/api/safetyManagement/meterParameter.js';
export default {
  components: {
    basicImport,
  },
  data() {
    return {
      isShowImport: false,
      loading: false,
      selectionList: [],
      option: {
        height: 'auto',
        calcHeight: 32,
        tip: false,
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: true,
        viewBtn: false,
        delBtn: false,
        addBtn: false,
        editBtnText: '修改',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        viewBtnText: '详情',
        labelWidth: 120,
        menuWidth: 120,
        dialogWidth: 1040,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        index: false,
        showOverflowTooltip: true,
        menu: false,
        header: false,
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        align: 'center',
        column: [
          {
            label: '池体名称',
            prop: 'poolName',
            sortable: true,
            filter: true,
            span: 12,
            search: false,
            searchLabelWidth: 140,
          },
          {
            label: '测量值',
            prop: 'poolName',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
          },
          {
            label: '设定值',
            align: 'center',
            children: [
              {
                label: '上限',
                prop: 'upLimit',
              },
              {
                label: '下限',
                prop: 'downLimit',
              },
            ],
          },

          {
            label: '参考值',
            prop: 'consult',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
          },
        ],
      },
      form: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
    };
  },
  methods: {
    // 点击导入按钮
    handleImport() {
      this.isShowImport = true
    },

    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {});
    },
    // 多选
    selectionChange(list) {
      this.selectionList = list;
    },
    // 加载页面数据
    onLoad(page, params = {}) {
      this.loading = true;
      getList({
        deviceId:"9651128"
      }).then(res => {
          // const data = res.data.data;
          // this.page.total = data.total;
          // this.data = data.records;
          // this.loading = false;
          const obj = {};
          res.data.data.forEach((item) => {
            obj[item.identifierName] = item.defaultValue;
          });
          this.objData = obj;
          this.pageData = [
            {
              name: 'PH-102 pH调整池I(混)',
              gageValue: obj['PH102'],
              lowerLimit: obj['PH102L'],
              superiorLimit: obj['PH102H'], // 上限
              consultValue: '10——11'
            },
            {
              name: 'PH-104 pH调整池II(混)',
              gageValue: obj['PH104'],
              lowerLimit: obj['PH104L'],
              superiorLimit: obj['PH104H'], // 上限
              consultValue: '7.0——8.0'
            },
            {
              name: 'PH-203 pH调整池I(铬)',
              gageValue: obj['PH203'],
              lowerLimit: obj['PH203L'],
              superiorLimit: obj['PH203H'], // 上限
              consultValue: '2.0——3.0'
            },
            {
              name: 'PH-205 pH调整池II(铬)',
              gageValue: obj['PH205'],
              lowerLimit: obj['PH205L'],
              superiorLimit: obj['PH205H'], // 上限
              consultValue: '8.0——9.0'
            },
            {
              name: 'PH-402 pH调整池(电镍)',
              gageValue: obj['PH402'],
              lowerLimit: obj['PH402L'],
              superiorLimit: obj['PH402H'], // 上限
              consultValue: '9.0——10'
            },
            {
              name: 'PH-502 pH调整池I(氰)',
              gageValue: obj['PH502'],
              lowerLimit: obj['PH502L'],
              superiorLimit: obj['PH502H'], // 上限
              consultValue: '10——11'
            },
            {
              name: 'PH-504 pH调整池II(氰)',
              gageValue: obj['PH504'],
              lowerLimit: obj['PH504L'],
              superiorLimit: obj['PH504H'], // 上限
              consultValue: '7.0——8.0'
            },
            {
              name: 'PH-506 pH调整池III(氰)',
              gageValue: obj['PH506'],
              lowerLimit: obj['PH506L'],
              superiorLimit: obj['PH506H'], // 上限
              consultValue: '8.0——9.0'
            },
            {
              name: 'PH-511 中间水池(综)',
              gageValue: obj['PH511'],
              lowerLimit: obj['PH511L'],
              superiorLimit: obj['PH511H'], // 上限
              consultValue: '7.0——8.0'
            },
            {
              name: 'PH-601 化学镍调节池',
              gageValue: obj['PH601'],
              lowerLimit: obj['PH601L'],
              superiorLimit: obj['PH601H'], // 上限
              consultValue: '2.0——3.0'
            },
            {
              name: 'PH-607 pH调整池(化镍)',
              gageValue: obj['PH607'],
              lowerLimit: obj['PH607L'],
              superiorLimit: obj['PH607H'], // 上限
              consultValue: '9.0——10'
            },
            {
              name: 'PH-701 前处理调节池',
              gageValue: obj['PH701'],
              lowerLimit: obj['PH701L'],
              superiorLimit: obj['PH701H'], // 上限
              consultValue: '2.0——3.0'
            },
            {
              name: 'PH-706 pH调整池(前)',
              gageValue: obj['PH706'],
              lowerLimit: obj['PH706L'],
              superiorLimit: obj['PH706H'], // 上限
              consultValue: '8.0——9.0'
            },
            {
              name: 'PH-710 中间水池(前)',
              gageValue: obj['PH710'],
              lowerLimit: obj['PH710L'],
              superiorLimit: obj['PH710H'], // 上限
              consultValue: '7.0——8.0'
            },
            {
              name: 'ORP-103 一级破氰池(混)',
              gageValue: obj['ORP103'],
              lowerLimit: obj['ORP103L'],
              superiorLimit: obj['ORP103H'], // 上限
              consultValue: '350——400'
            },
            {
              name: 'ORP-105 二级破氰池(混)',
              gageValue: obj['ORP105'],
              lowerLimit: obj['ORP105L'],
              superiorLimit: obj['ORP105H'], // 上限
              consultValue: '600——650'
            },
            {
              name: 'ORP-204 还原池(铬)',
              gageValue: obj['ORP204'],
              lowerLimit: obj['ORP204L'],
              superiorLimit: obj['ORP204H'], // 上限
              consultValue: '600——650'
            },
            {
              name: 'ORP-503 一级破氰池(氰)',
              gageValue: obj['ORP503'],
              lowerLimit: obj['ORP503L'],
              superiorLimit: obj['ORP503H'], // 上限
              consultValue: '350——400'
            },
            {
              name: 'ORP-505 二级破氰池(氰)',
              gageValue: obj['ORP505'],
              lowerLimit: obj['ORP505L'],
              superiorLimit: obj['ORP505H'], // 上限
              consultValue: '600——650'
            },
            {
              name: 'ORP-604 Feton池(化镍)',
              gageValue: obj['ORP604'],
              lowerLimit: obj['ORP604L'],
              superiorLimit: obj['ORP604H'], // 上限
              consultValue: '600——650'
            },
            {
              name: 'ORP-703 Feton池(前)',
              gageValue: obj['ORP703'],
              lowerLimit: obj['ORP703L'],
              superiorLimit: obj['ORP703H'], // 上限
              consultValue: '600——650'
            },
            {
              name: 'DL-101 混排废水流量计',
              gageValue: obj['DL101'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-201 含铬废水流量计',
              gageValue: obj['DL201'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-202 酸性废水流量计',
              gageValue: obj['DL202'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-301 焦铜废水流量计',
              gageValue: obj['DL301'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-401 电镀镍废水流量计',
              gageValue: obj['DL401'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-501 含氰废水流量计',
              gageValue: obj['DL501'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-601 化镍废水流量计',
              gageValue: obj['DL601'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-701 前处理废水流量计',
              gageValue: obj['DL701'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-710 中继提升泵流量计',
              gageValue: obj['DL710'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            },
            {
              name: 'DL-600 化镍废液流量计',
              gageValue: obj['DL600'],
              lowerLimit: '',
              superiorLimit: '', // 上限
              consultValue: ''
            }
          ];
          this.data = this.pageData
          this.loading = false
        })
        .catch(() => {
          this.loading = false;
        });
    },
  },
};
</script>
<style lang="scss" scoped></style>
