From ccc4b13593c3dddb4e8c1d6373535abc7765950d Mon Sep 17 00:00:00 2001 From: lingxiao <493263159@qq.com> Date: Wed, 6 Apr 2022 10:04:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=97=E5=AE=BD=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 5 ++++- src/utils/tableHeight.js | 13 ++++++++++++- src/views/system/field/index.vue | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 16cc997..6b2803d 100644 --- a/src/main.js +++ b/src/main.js @@ -14,7 +14,7 @@ import DragBar from "@/components/DragBar"; import { getWorkshopName, getWorkshopList } from "@/server/base.js"; import { getStanderOne } from "@/server/api.js"; import { getColumnName, mappingText, permissions } from "@/utils/allField.js"; -import { calculationTableHeight } from "@/utils/tableHeight.js"; +import { calculationTableHeight, saveRowWidth, getRowWidth } from "@/utils/tableHeight.js"; import { dragChangeSize } from "@/utils/dragChangeSize.js"; import SvgIcon from '@/components/SvgIcon' // svg组件 import SearchTemplate from "@/components/SearchTemplate.vue"; @@ -43,7 +43,10 @@ app.config.globalProperties.getWorkshopList = getWorkshopList; // 获取工厂 app.config.globalProperties.getWorkshopName = getWorkshopName; // 获取工厂名称 app.config.globalProperties.transFormat = transFormat; // 秒转化HH:ss app.config.globalProperties.timeTransSeconds = timeTransSeconds; // 时间转化为秒 +app.config.globalProperties.getRowWidth = getRowWidth; // table读取列宽 +app.config.globalProperties.saveRowWidth = saveRowWidth; // table保存列宽 app.config.globalProperties.calculationTableHeight = calculationTableHeight; // table固定高度计算 + app.config.globalProperties.dragChangeSize = dragChangeSize; // table固定高度计算 app.config.globalProperties.msgSuccess = function (msg) { this.$message({ showClose: true, message: msg, type: "success" }); diff --git a/src/utils/tableHeight.js b/src/utils/tableHeight.js index aea20d1..813c661 100644 --- a/src/utils/tableHeight.js +++ b/src/utils/tableHeight.js @@ -1,4 +1,15 @@ // tableHeight高度 export function calculationTableHeight(ref, plusHeight) { return ref.offsetHeight - plusHeight || 0; -}; \ No newline at end of file +}; +// 保存列宽 +export function saveRowWidth({rawColumnKey}, width) { + let allRowWidth = localStorage.allRowWidth ? JSON.parse(localStorage.allRowWidth) : {}; + allRowWidth[rawColumnKey] = width; + localStorage.allRowWidth = JSON.stringify(allRowWidth); +} +// 获取列表 +export function getRowWidth(field) { + let allRowWidth = localStorage.allRowWidth ? JSON.parse(localStorage.allRowWidth) : {}; + return allRowWidth[field] || ''; +} \ No newline at end of file diff --git a/src/views/system/field/index.vue b/src/views/system/field/index.vue index 2f0c9b4..35ede67 100644 --- a/src/views/system/field/index.vue +++ b/src/views/system/field/index.vue @@ -49,6 +49,7 @@ :data="tableData" border size="mini" + @header-dragend="(newWidth, oldWidth, column)=>saveRowWidth(column, newWidth)" v-if="tableHeight" :height="tableHeight" >