From 1abb6a9ca01cc76f271542a063d1b19839448019 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期五, 27 九月 2024 17:42:05 +0800 Subject: [PATCH] 1.新增评估结果批量导入功能(未完成) --- src/components/table/FYTable.vue | 21 ++++++ src/composables/tablePaste.js | 67 ++++++++++++++++++++++ src/api/index.js | 2 src/components.d.ts | 9 -- src/components/search-option/FYSearchBar.vue | 9 ++ src/views/fysp/evaluation/EvalutationRecord.vue | 41 +++++++++++-- 6 files changed, 132 insertions(+), 17 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index a31a27c..243b99c 100644 --- a/src/api/index.js +++ b/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/'; diff --git a/src/components.d.ts b/src/components.d.ts index 99aa4bb..893003c 100644 --- a/src/components.d.ts +++ b/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'] diff --git a/src/components/search-option/FYSearchBar.vue b/src/components/search-option/FYSearchBar.vue index eaca995..e968e58 100644 --- a/src/components/search-option/FYSearchBar.vue +++ b/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> diff --git a/src/components/table/FYTable.vue b/src/components/table/FYTable.vue index bec9d06..42c7a99 100644 --- a/src/components/table/FYTable.vue +++ b/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() { diff --git a/src/composables/tablePaste.js b/src/composables/tablePaste.js new file mode 100644 index 0000000..ee0a4e9 --- /dev/null +++ b/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 }; +} diff --git a/src/views/fysp/evaluation/EvalutationRecord.vue b/src/views/fysp/evaluation/EvalutationRecord.vue index 190fc16..0d61791 100644 --- a/src/views/fysp/evaluation/EvalutationRecord.vue +++ b/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> -- Gitblit v1.9.3