<template>
  <a-card :bordered="false" style="height: 770px;">
    <a-row>
      <a-col :span="4">
        <locationaTree ref="locationaTree" :height="600" @onSelect="onSelectTree"></locationaTree>
      </a-col>
      <a-col :span="20">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :xl="5" :lg="7" :md="8" :sm="24">
                <a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource" placeholder="请选择领用人"
                  @select="onSelect" @search="onSearch" @change="onChange" />
              </a-col>
              <a-col :xl="7" :lg="7" :md="8" :sm="24">
                <a-form-item label="购置日期">
                  <j-date placeholder="开始日期" class="query-group-cust" v-model="queryParam.purchaseDate_begin"></j-date>
                  <span class="query-group-split-cust"></span>
                  <j-date placeholder="结束日期" class="query-group-cust" v-model="queryParam.purchaseDate_end"></j-date>
                </a-form-item>
              </a-col>
              <a-col :xl="5" :lg="7" :md="8" :sm="24">
                <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                </span>
              </a-col>
              <a-col :xl="2">
                <img style="height: 55px;" src="@/assets/collegelogo.jpg" alt="image">
              </a-col>
              <a-col :xl="4">
                <p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button @click="handleAdd" v-has="'furnitureCollege:add'" type="primary" icon="plus">新增</a-button>
          <a-button type="primary" v-has="'furnitureCollege:export'" icon="download"
            @click="handleExportXls('家具信息表（学院）')">导出</a-button>
          <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
            @change="handleImportExcel">
            <a-button type="primary" icon="import">导入</a-button>
          </a-upload> -->
          <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
            @change="ImportData">
            <a-button type="primary" v-has="'furnitureCollege:import'" icon="import">导入</a-button>
            <a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
              <!-- 居中显示表格标题 -->
              <div style="text-align: center; padding: 10px; background-color: #f0f0f0; 
                border-bottom: 1px solid #d9d9d9;">
                <span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
              </div>
              <a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
                :dataSource="ContrastData" :rowSelection="{
                  selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
                  onSelect: onSelectReserve, getCheckboxProps: record => ({
                    props: {
                      disabled: record.NotKeep === '1',
                    },
                  }),
                }" :pagination="false" bordered>
                <span slot="action" slot-scope="text, record">
                  <a @click="handleDetail(record)">详情</a>
                </span>
              </a-table>
              <!-- 展示新旧数据新增的数据按钮 -->
              <div style="display: flex; justify-content: space-between; margin-top: 10px;">
                <a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
                  icon="zoom-in">本地的新增数据</a-button>
                <a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
                  icon="zoom-in">存在差异的数据</a-button>
                <a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
                  icon="zoom-in">导入的新增数据</a-button>
              </div>
            </a-modal>
          </a-upload>
          <a-button type="primary" v-has="'furnitureCollege:history'" icon="zoom-in"
            @click="showHistoryModal">历史数据</a-button>
          <a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
            <div class="modal-content">
              <!-- 在这里显示历史数据 -->
              <div v-for="TimestampData in historyData" :key="TimestampData.id" class="container">
                <div class="left">
                  <p style="font-size: 17px;">{{ TimestampData }}</p>
                </div>
                <div class="right">
                  <a-button type="primary" icon="download" @click="ExportData('家具信息表（学院）', TimestampData)">导出</a-button>
                </div>
              </div>
            </div>
          </a-modal>
          <!-- 高级查询区域 -->
          <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal"
            @handleSuperQuery="handleSuperQuery"></j-super-query> -->
          <a-dropdown v-if="selectedRowKeys.length > 0">
            <a-menu slot="overlay">
              <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
            </a-menu>
            <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
          </a-dropdown>
        </div>

        <!-- table区域-begin -->
        <div>
          <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
            <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
              selectedRowKeys.length }}</a>项
            <a style="margin-left: 24px" @click="onClearSelected">清空</a>
          </div>
          <a-row>

            <!-- <a-col :span=""> -->

            <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
              :dataSource="dataSource" :pagination="ipagination" :loading="loading"
              :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" class="j-table-force-nowrap"
              @change="handleTableChange">

              <template slot="usageYears" slot-scope="text">
                {{ text + '年' }}
              </template>

              <span slot="action" slot-scope="text, record">
                <div v-has="'furnitureCollege:operate'" style="display: inline-block;">
                  <a @click="handleEdit(record)">编辑</a>
                  <a-divider type="vertical" />
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                  <a-divider type="vertical" />
                </div>
                <a @click="handleDetail(record)">详情</a>
              </span>

            </a-table>
            <!-- </a-col> -->
          </a-row>
        </div>
        <rms-furniture-college-modal ref="modalForm" @ok="modalFormOk"></rms-furniture-college-modal>
      </a-col>
    </a-row>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import RmsFurnitureCollegeModal from './modules/RmsFurnitureCollegeModal.vue'
import { getAction, postAction } from '../../../api/manage'
import RmsLocationModal from '../LocationList/modules/RmsLocationModal'
import locationaTree from '../components/locationaTree'

export default {
  name: 'RmsFurnitureCollegeList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    RmsFurnitureCollegeModal,
    RmsLocationModal,
    locationaTree
  },
  data() {
    // 通用的 customRender 函数
    function getDateCustomRender(text, record, differenceKey) {
      const isDifferenceKey = `is${differenceKey}Difference`;
      let backgroundColor = 'transparent';
      if (record.isOldData) {
        backgroundColor = record[isDifferenceKey] ? '#fde2e2' : '#d9d9d9';
      } else {
        backgroundColor = record[isDifferenceKey] ? '#fde2e2' : 'transparent';
      }      // 在这里添加购置日期列的特定逻辑，如果有的话
      const processedText = !text ? "" : (text.length > 10 ? text.substr(0, 10) : text);
      return {
        children: processedText,
        attrs: {
          style: `background-color: ${backgroundColor};`
        }
      };
    }
    function getCustomRender(text, record, differenceKey) {
      const isDifferenceKey = `is${differenceKey}Difference`;
      let backgroundColor = 'transparent';
      if (record.isOldData) {
        backgroundColor = record[isDifferenceKey] ? '#fde2e2' : '#d9d9d9';
      } else {
        backgroundColor = record[isDifferenceKey] ? '#fde2e2' : 'transparent';
      }
      return {
        children: text,
        attrs: {
          style: `background-color: ${backgroundColor};`
        }
      };
    }
    return {
      value: '',
      dataSource: [],
      UserdataSource: [],
      SelectReserveData: [],
      // 表头
      DiffrentColumns: [
        {
          title: '家具编号',
          align: "center",
          dataIndex: 'furnitureNumber',
          width: 100,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'furnitureNumber'),
        },
        {
          title: '家具名称',
          align: "center",
          dataIndex: 'furnitureName',
          width: 120,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'furnitureName'),
        },
        {
          title: '领用单位号',
          align: "center",
          dataIndex: 'collectingUnitNumber',
          width: 120,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'collectingUnitNumber'),
        },
        {
          title: '分类号',
          align: "center",
          dataIndex: 'categoryId',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'categoryId'),
        },
        {
          title: '型号',
          align: "center",
          dataIndex: 'model',
          width: 120,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'model'),
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'specifications',
          width: 150,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'specifications'),
        },
        {
          title: '数量',
          align: "center",
          dataIndex: 'number',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'number'),
        },
        {
          title: '单价',
          align: "center",
          dataIndex: 'unitPrice',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'unitPrice'),
        },
        {
          title: '金额',
          align: "center",
          dataIndex: 'amount',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'amount'),
        },
        {
          title: '厂家',
          align: "center",
          dataIndex: 'manufactuer',
          width: 200,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'manufactuer'),
        },
        {
          title: '购置日期',
          align: "center",
          dataIndex: 'purchaseDate',
          width: 100,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'purchaseDate'),
        },
        {
          title: '领用人',
          align: "center",
          dataIndex: 'recipient',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'recipient'),
        },
        {
          title: '单据号',
          align: "center",
          dataIndex: 'documentNumber',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'documentNumber'),
        },
        {
          title: '存放地址',
          align: "center",
          dataIndex: 'locationName',
          width: 120,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'locationName'),
        },
        {
          title: '备注',
          align: "center",
          dataIndex: 'note',
          width: 120,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'note'),
        },
        {
          title: '审核状态',
          align: "center",
          dataIndex: 'approvalStatus',
          width: 100,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'approvalStatus'),
        },
        {
          title: '初审状态',
          align: "center",
          dataIndex: 'initialAudit',
          width: 80,
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'initialAudit'),
        },
        {
          title: '使用年限',
          align: "center",
          dataIndex: 'usageYears',
          //如果是差异数据显示黄色，是新数据显示绿色
          customRender: (text, record) => getCustomRender(text, record, 'usageYears'),
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          width: 60,
          scopedSlots: { customRender: 'action' }
        }
      ],
      // 表头
      columns: [
        {
          title: '家具编号',
          align: "center",
          dataIndex: 'furnitureNumber',
          width: 120,
        },
        {
          title: '家具名称',
          align: "center",
          dataIndex: 'furnitureName',
          width: 120,
        },
        {
          title: '领用单位号',
          align: "center",
          dataIndex: 'collectingUnitNumber_dictText',
          width: 200
        },
        {
          title: '分类号',
          align: "center",
          dataIndex: 'categoryId',
          width: 120,
        },
        {
          title: '型号',
          align: "center",
          dataIndex: 'model',
          width: 120
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'specifications',
          width: 150
        },
        {
          title: '数量',
          align: "center",
          dataIndex: 'number',
          width: 80
        },
        {
          title: '单价',
          align: "center",
          dataIndex: 'unitPrice',
          width: 80
        },
        {
          title: '金额',
          align: "center",
          dataIndex: 'amount',
          width: 80
        },
        {
          title: '厂家',
          align: "center",
          dataIndex: 'manufactuer',
          width: 200
        },
        {
          title: '购置日期',
          align: "center",
          dataIndex: 'purchaseDate',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          },
          width: 120
        },
        {
          title: '领用人',
          align: "center",
          dataIndex: 'recipient_dictText',
          width: 80
        },
        {
          title: '单据号',
          align: "center",
          dataIndex: 'documentNumber',
          width: 80
        },
        {
          title: '存放地址',
          align: "center",
          dataIndex: 'locationName',
          width: 120
        },
        {
          title: '备注',
          align: "center",
          dataIndex: 'note',
          width: 180
        },
        {
          title: '审核状态',
          align: "center",
          dataIndex: 'approvalStatus_dictText',
          width: 120
        },
        {
          title: '初审状态',
          align: "center",
          dataIndex: 'initialAudit_dictText',
          width: 120
        },
        {
          title: '使用年限',
          align: "center",
          dataIndex: 'usageYears',
          scopedSlots: { customRender: 'usageYears' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 160,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/rms/rmsFurnitureCollege/list",
        delete: "/rms/rmsFurnitureCollege/delete",
        deleteBatch: "/rms/rmsFurnitureCollege/deleteBatch",
        exportXlsUrl: "/rms/rmsFurnitureCollege/exportXls",
        importExcelUrl: "rms/rmsFurnitureCollege/importExcel",
        userUrl: "/sys/user/queryUserComponentData?column=createTime&order=desc&field=id,,username,realname,sex,phone,orgCodeTxt&pageNo=1&pageSize=100",
        timestampUrl: "/rms/rmsFurnitureCollege/getTimestamp",
      },
      UserList: {},
      historyModalVisible: false, // 控制历史数据模态框的显示与隐藏
      historyData: [], // 历史数据数组，用于存储所有历史数据
      ContrastData: [], // 用于存储对比表格的数据
      NotOldRmsData: [],  //新数据中存在但旧数据中不存在的
      NotNewRmsData: [],  //旧数据中存在但新数据中不存在的
      NewDifferentData: [], //新数据中存在差异的
      NewTempDifferentData: [], //新数据中存在差异的
      OldDifferentData: [], //旧数据中存在差异的
      returnData: [], //返回的数据
      tableTitle: "存在差异的数据：",
      showDifference: false,
    }
  },
  created() {
    this.getUserInfo();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    //重写导入方法
    ImportData(info) {
      // 设置加载状态为true，表示正在上传
      this.loading = true;
      // 如果文件状态不是'uploading'，在控制台输出文件信息
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      // 处理文件上传完成的情况
      if (info.file.status === 'done') {
        // 设置加载状态为false，表示上传完成
        this.loading = false;
        if (info.file.response.success) {
          if (info.file.response.code === 201) {
            let { message, result: { msg, fileUrl, fileName } } = info.file.response;
            let href = window._CONFIG['domianURL'] + fileUrl;
            this.$warning({
              title: message,
              content: (
                <div>
                  <span>{msg}</span><br />
                  <span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
                </div>
              )
            });
          } else {
            const resultList = info.file.response.result;
            //接收List中的第一个
            this.NotOldRmsData = resultList[0];
            this.NotNewRmsData = resultList[1];
            this.NewDifferentData = resultList[2];
            this.OldDifferentData = resultList[3];
            console.log("新数据中存在但旧数据中不存在的:" + this.NotOldRmsData);
            console.log("旧数据中存在但新数据中不存在的:" + this.NotNewRmsData);
            console.log("新数据中存在差异的:" + this.NewDifferentData);
            console.log("旧数据中存在差异的:" + this.OldDifferentData);
            this.SelectReserveData = [];
            this.showDifference = true;
            // 标记差异数据
            this.markDifferenceData();
            // this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`);
          }
          this.loadData();
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.message}.`);
        }
      } else if (info.file.status === 'error') {
        this.loading = false;
        if (info.file.response.status === 500) {
          let data = info.file.response;
          const token = Vue.ls.get(ACCESS_TOKEN);
          if (token && data.message.includes("Token失效")) {
            this.$error({
              title: '登录已过期',
              content: '很抱歉，登录已过期，请重新登录',
              okText: '重新登录',
              mask: false,
              onOk: () => {
                store.dispatch('Logout').then(() => {
                  Vue.ls.remove(ACCESS_TOKEN);
                  window.location.reload();
                });
              }
            });
          }
        } else {
          this.$message.error(`文件上传失败: ${info.file.msg} `);
        }
      }
    },
    DifferenceOk() {
      this.returnData = [];
      for (const item of this.SelectReserveData) {
        this.returnData.push(this.NewTempDifferentData[item]);
      }
      this.SelectReserveData = [];
      console.log(this.returnData)
      postAction("/rms/rmsFurnitureCollege/SureImportExcel", this.returnData).then(res => {
        if (res && res.success) {
          this.$message.success(res.message);
          this.loadData();
          this.showDifference = false;
        } else {
          // 处理导入失败的情况
          this.$message.error("导入失败：" + (res ? res.message : "未知错误"));
        }
        this.loadData();
        this.showDifference = false;
      });
    },
    // 检查并标记两个对象间不同的字段
    checkAndMarkDifferences(source, target, field) {
      if (source[field] !== target[field]) {
        source['is' + field + 'Difference'] = true;
        target['is' + field + 'Difference'] = true;
      }
    },
    markDifferenceData() {
      let temp = 0;
      if (this.NewTempDifferentData.length > 0) {
        this.NewTempDifferentData = [];
      }
      // 比较 NewDifferentData 和 OldDifferentData标出差异字段
      for (const oldItem of this.OldDifferentData) {
        const newItem = this.NewDifferentData.find(item => item.furnitureNumber === oldItem.furnitureNumber); // 假设你有一个唯一标识字段 id
        newItem.uniqueKey = temp++;
        oldItem.uniqueKey = temp++;
        //初始化差异标记
        oldItem.isOldData = true;
        // 定义需要比较的字段
        const fieldsToCompare = [
          'furnitureNumber',
          'furnitureName',
          'collectingUnitNumber',
          'categoryId',
          'model',
          'specifications',
          'number',
          'unitPrice',
          'amount',
          'manufactuer',
          'purchaseDate',
          'recipient',
          'documentNumber',
          'locationName',
          'note',
          'approvalStatus',
          'initialAudit',
          'usageYears',
        ];
        // 循环比较字段
        fieldsToCompare.forEach(field => {
          this.checkAndMarkDifferences(oldItem, newItem, field);
        });
        this.NewTempDifferentData.push(newItem);
        this.NewTempDifferentData.push(oldItem);
        console.log("oldItem=" + oldItem.collectingUnitNumber + " 值  " + oldItem.iscollectingUnitNumberDifference)
      }
      for (const oldItem of this.NotNewRmsData) {
        oldItem.isOldData = true;
        oldItem.NotKeep = '1';
      }
      for (const newItem of this.NotOldRmsData) {
        newItem.NotKeep = '1';
      }
      this.ContrastData = this.NewTempDifferentData;
    },
    // 展示本地的新增数据
    showLocalData() {
      this.ContrastData = this.NotNewRmsData;
      console.log(this.ContrastData)
      this.tableTitle = "本地的新增数据：";
      this.SelectReserveData = [];
    },
    // 展示导入的新增数据
    showImportData() {
      this.ContrastData = this.NotOldRmsData;
      this.tableTitle = "导入的新增数据：";
      this.SelectReserveData = [];
    },
    // 展示存在差异的数据
    showDifferenceData() {
      this.ContrastData = this.NewTempDifferentData;
      console.log(this.ContrastData)
      this.tableTitle = "存在差异的数据：";
      this.SelectReserveData = [];
    },
    //全选时触发
    onSelectReserveAll(selected, selectedRows, changeRows) {
      if (selected) {
        this.SelectReserveData = this.NewTempDifferentData.filter((item, index) => index % 2 === 0).map(item => item.uniqueKey);
      } else {
        this.SelectReserveData = [];
      }
      this.NewTempDifferentData.forEach(item => {
        item.NotKeep = '0';
      });
      this.SelectReserveData.forEach(selectedRowKey => {
        if (selectedRowKey % 2 == 0) {
          if (this.NewTempDifferentData[selectedRowKey + 1]) {
            this.NewTempDifferentData[selectedRowKey + 1].NotKeep = '1';
          }
        } else {
          if (this.NewTempDifferentData[selectedRowKey - 1]) {
            this.NewTempDifferentData[selectedRowKey - 1].NotKeep = '1';
          }
        }
      });
      this.ContrastData = [...this.NewTempDifferentData];
    },
    onSelectReserveChange(selectedRowKeys, selectedRows) {
      if (selectedRowKeys.length == this.NewTempDifferentData.length) {
        // 如果全选框被选中，则选取所有偶数行
        selectedRowKeys = this.NewTempDifferentData.filter((item, index) => index % 2 === 0).map(item => item.uniqueKey);
      }
      console.log(selectedRowKeys, selectedRows);
      this.SelectReserveData = selectedRowKeys;
      this.NewTempDifferentData.forEach(item => {
        item.NotKeep = '0';
      });
      selectedRowKeys.forEach(selectedRowKey => {
        if (selectedRowKey % 2 == 0) {
          if (this.NewTempDifferentData[selectedRowKey + 1]) {
            this.NewTempDifferentData[selectedRowKey + 1].NotKeep = '1';
          }
        } else {
          if (this.NewTempDifferentData[selectedRowKey - 1]) {
            this.NewTempDifferentData[selectedRowKey - 1].NotKeep = '1';
          }
        }
      });
      this.ContrastData = [...this.NewTempDifferentData];
    },
    onSelectReserve(record, selected, selectedRows) {
      console.log(record, selected, selectedRows);
    },

    showHistoryModal() {
      getAction(this.url.timestampUrl).then(res => {
        console.log(res)
        this.historyData = res;
      })

      this.historyModalVisible = true; // 显示历史数据模态框
    },
    closeHistoryModal() {
      this.historyModalVisible = false; // 关闭历史数据模态框
    },
    //获取用户信息
    getUserInfo() {
      getAction(this.url.userUrl).then(res => {
        this.UserList = res.result.records;
      })
    },
    onSearch(query) {
      this.UserdataSource = this.UserList.filter(user =>
        user.username.includes(query) || user.realname.includes(query)
      ).map(user => ({
        value: user.username,
        text: user.realname
      }));
    },
    onSelectTree(selectedRowKeys) {
      //将其切分为字符串
      selectedRowKeys = selectedRowKeys.join(',')
      console.log(selectedRowKeys)
      this.queryParam.locationId = selectedRowKeys
      this.loadData(1)
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

.modal-content {
  max-height: 400px;
  /* 设置最大高度，根据需要进行调整 */
  overflow-y: auto;
  /* 添加垂直滚动条 */
}

.container {
  display: flex;
  align-items: center;
}

.left {
  flex: 1;
}

.right {
  margin-left: 10px;
}
</style>