riku
2024-09-27 1abb6a9ca01cc76f271542a063d1b19839448019
1.新增评估结果批量导入功能(未完成)
已修改5个文件
已添加1个文件
149 ■■■■ 文件已修改
src/api/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components.d.ts 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search-option/FYSearchBar.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/table/FYTable.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/composables/tablePaste.js 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/fysp/evaluation/EvalutationRecord.vue 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -11,7 +11,7 @@
let ip2_file = 'https://fyami.com.cn/';
if (debug) {
  ip1 = 'http://192.168.0.138:9091/';
  ip1 = 'http://192.168.0.138:8080/';
  // ip1_file = 'http://192.168.0.138:8080/';
  // ip2 = 'http://192.168.0.138:8080/';
  // ip2_file = 'https://fyami.com.cn/';
src/components.d.ts
@@ -18,7 +18,6 @@
    ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
    ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
    ElButton: typeof import('element-plus/es')['ElButton']
    ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
    ElCard: typeof import('element-plus/es')['ElCard']
    ElCascader: typeof import('element-plus/es')['ElCascader']
    ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
@@ -31,9 +30,6 @@
    ElDialog: typeof import('element-plus/es')['ElDialog']
    ElDivider: typeof import('element-plus/es')['ElDivider']
    ElDrawer: typeof import('element-plus/es')['ElDrawer']
    ElDropdown: typeof import('element-plus/es')['ElDropdown']
    ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
    ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
    ElEmpty: typeof import('element-plus/es')['ElEmpty']
    ElForm: typeof import('element-plus/es')['ElForm']
    ElFormItem: typeof import('element-plus/es')['ElFormItem']
@@ -49,6 +45,7 @@
    ElOption: typeof import('element-plus/es')['ElOption']
    ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
    ElPagination: typeof import('element-plus/es')['ElPagination']
    ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
    ElPopover: typeof import('element-plus/es')['ElPopover']
    ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
@@ -62,14 +59,10 @@
    ElSwitch: typeof import('element-plus/es')['ElSwitch']
    ElTable: typeof import('element-plus/es')['ElTable']
    ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
    ElTabPane: typeof import('element-plus/es')['ElTabPane']
    ElTabs: typeof import('element-plus/es')['ElTabs']
    ElTag: typeof import('element-plus/es')['ElTag']
    ElText: typeof import('element-plus/es')['ElText']
    ElTooltip: typeof import('element-plus/es')['ElTooltip']
    ElTransfer: typeof import('element-plus/es')['ElTransfer']
    ElTree: typeof import('element-plus/es')['ElTree']
    ElUpload: typeof import('element-plus/es')['ElUpload']
    Footer: typeof import('./components/core/Footer.vue')['default']
    FormCol: typeof import('./components/layout/FormCol.vue')['default']
    FYBgTaskCard: typeof import('./components/bg-task/FYBgTaskCard.vue')['default']
src/components/search-option/FYSearchBar.vue
@@ -2,7 +2,14 @@
  <el-form :inline="true" :size="size">
    <slot name="options"></slot>
    <el-form-item>
      <el-button icon="Search" type="primary" :loading="loading" @click="search">{{ btnText }}</el-button>
      <el-button
        icon="Search"
        type="primary"
        :loading="loading"
        @click="search"
        @kekeyup.enter="search"
        >{{ btnText }}</el-button
      >
      <slot name="buttons"></slot>
    </el-form-item>
  </el-form>
src/components/table/FYTable.vue
@@ -28,12 +28,17 @@
    <slot name="options-expand2"></slot>
  </div>
  <el-table
    ref="tableRef"
    :data="tableData"
    v-loading="loading"
    table-layout="fixed"
    :row-class-name="tableRowClassName"
    :height="tableHeight"
    :size="fontSize"
    @cell-click="cellClick"
    :cell-class-name="cellClassName"
    @paste="handlePaste"
    @sort-change="handleSortChange"
    border
  >
    <slot name="table-column" :size="fontSize"></slot>
@@ -64,6 +69,7 @@
export default {
  props: {
    rowClassName: undefined,
    cellClassName: Function || String,
    pagination: {
      type: Boolean,
      default: true
@@ -85,7 +91,7 @@
      fontSize: 'default'
    };
  },
  emits: ['search'],
  emits: ['search', 'cellClick', 'tablePaste'],
  watch: {
    currentPage(nValue, oValue) {
      if (nValue != oValue) {
@@ -140,6 +146,7 @@
          this.tableData = res.data;
          this.total = res.total ? res.total : 0;
          this.loading = false;
          this.doLayout();
        }
      );
    },
@@ -163,6 +170,18 @@
      } else {
        return row.extension1 != '0' ? 'online-row' : 'offline-row';
      }
    },
    cellClick(row, column, cell, event) {
      this.$emit('cellClick', row, column, cell, event);
    },
    handlePaste(event) {
      this.$emit('tablePaste', event);
    },
    doLayout(){
      this.$refs.tableRef.doLayout();
    },
    handleSortChange({column, prop, order }){
    }
  },
  mounted() {
src/composables/tablePaste.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
import { ref, watch } from 'vue';
import { useEvent } from './event';
/**
 * è¡¨æ ¼å¤šè¡Œå¤šåˆ—粘贴事件
 * @param {object} obj éœ€è¦ç²˜è´´çš„属性以及对应的列索引值,其中字段名为属性名,值为索引值
 * @returns
 */
export function useTablePaste(obj) {
  const { invokeEvent, addEvent: addRefreshEvent } = useEvent();
  const rowIndex = ref(0);
  const columnIndex = ref(0);
  const tableData = ref([]);
  function setTableData(data) {
    tableData.value = data;
  }
  function cellClick(row, column, cell, event) {
    rowIndex.value = row.index;
    columnIndex.value = column.index;
  }
  function cellClassName({ row, column, rowIndex, columnIndex }) {
    row.index = rowIndex;
    column.index = columnIndex;
  }
  function handlePaste(event) {
    // é˜»æ­¢é»˜è®¤çš„粘贴行为和事件冒泡。
    event.preventDefault();
    event.stopPropagation();
    // èŽ·å–å‰ªè´´æ¿æ•°æ®å¹¶æå–çº¯æ–‡æœ¬å†…å®¹ã€‚
    const clipboardData = event.clipboardData;
    const text = clipboardData.getData('text/plain');
    // å°†æ–‡æœ¬å†…容按行和制表符分割,转换为二维数组
    let pastedText = text.split('\n').map((row) => {
      return row.split('\t').map((ele) => {
        return parseFloat(ele);
      });
    });
    // è¡¨æ ¼å¤šè¡Œå¤šåˆ—粘贴事件。
    // let obj = {
    //   score1: null,
    //   score2: null
    // };
    // éåŽ†å¤„ç†æ¯ä¸€è¡Œæ•°æ®ï¼Œæ ¹æ®è¡Œç´¢å¼•å’Œåˆ—ç´¢å¼•å°†æ•°æ®å¡«å……åˆ°è¡¨æ ¼ä¸­ã€‚
    pastedText.forEach((ele1, index) => {
      if (rowIndex.value + index <= tableData.value.length - 1) {
        // let item = JSON.parse(JSON.stringify(tableData[rowIndex + index]));
        let item = tableData.value[rowIndex.value + index];
        let num = 0;
        // ä½¿ç”¨å¾ªçŽ¯å’Œæ¡ä»¶åˆ¤æ–­ï¼Œå°†å¤„ç†åŽçš„æ•°æ®æŒ‰åˆ—ç´¢å¼•å¡«å……åˆ°å…‹éš†çš„è¡Œå¯¹è±¡ä¸­
        for (let key in obj) {
          const value = obj[key];
          if (num < ele1.length && value >= columnIndex.value) {
            item[key] = ele1[num] || ele1[num] == 0 ? ele1[num] : null;
            num++;
          }
        }
      }
    });
    invokeEvent();
  }
  return { cellClick, cellClassName, handlePaste, setTableData, addRefreshEvent, tableData };
}
src/views/fysp/evaluation/EvalutationRecord.vue
@@ -1,5 +1,12 @@
<template>
  <FYTable @search="onSearch" :pagination="false" ref="tableRef">
  <FYTable
    @search="onSearch"
    :pagination="false"
    ref="tableRef"
    @cell-click="cellClick"
    :cell-class-name="cellClassName"
    @table-paste="handlePaste"
  >
    <template #options>
      <!-- åŒºåŽ¿ -->
      <FYOptionLocation
@@ -70,6 +77,16 @@
      <el-table-column prop="evaluation.scenseaddress" label="地址" />
      <!-- <el-table-column prop="biArea" label="集中区" width="110" />
      <el-table-column prop="biManagementCompany" label="物业" min-width="110"/> -->
      <el-table-column fixed="right" align="right" label="监测数据超标" width="160">
        <template #default="{ row }">
          <el-input v-model="row.score1" />
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="right" label="监测数据超区月均值" width="160">
        <template #default="{ row }">
          <el-input v-model="row.score2" />
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="right" label="操作" width="160">
        <!-- <template #header>
          <el-button icon="Download" size="default" type="success" @click="exportExcel"
@@ -89,9 +106,17 @@
import evaluateApi from '@/api/fysp/evaluateApi';
import { envCreditCode } from '@/constants/index';
import CompReport from './components/CompReport.vue';
import { useTablePaste } from '@/composables/tablePaste';
export default {
  name: 'ResultManage',
  setup() {
    const { cellClick, cellClassName, handlePaste, setTableData, addRefreshEvent, tableData } =
      useTablePaste({
        score1: 8,
        score2: 9
      });
    return { cellClick, cellClassName, handlePaste, setTableData, addRefreshEvent, tableData };
  },
  components: { CompReport },
  data() {
    return {
@@ -129,11 +154,12 @@
    onSearch(page, func) {
      const area = this._getParam();
      evaluateApi.fetchAutoEvaluation(area).then((res) => {
        if (typeof func === 'function') {
          func({ data: res.data });
        }
        if (res.data) {
          this.tableData = res.data;
          this.getFilters(res.data);
          if (typeof func === 'function') {
            func({ data: this.tableData });
          }
        }
      });
    },
@@ -183,7 +209,10 @@
      const s1 = a.evaluation ? parseInt(a.evaluation.resultscorebef) : 0;
      const s2 = b.evaluation ? parseInt(b.evaluation.resultscorebef) : 0;
      return s1 - s2;
    }
    },
  },
  mounted() {
    this.addRefreshEvent(this.$refs.tableRef.doLayout);
  }
};
</script>