From 9fd073fcc90164dfde02af41c177d9a49c0bef40 Mon Sep 17 00:00:00 2001 From: jary Date: Mon, 6 Mar 2023 11:45:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=AB=AF=E7=9A=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E5=8E=BB=E6=8E=89=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mixins/JeecgListMixin.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/mixins/JeecgListMixin.js b/src/mixins/JeecgListMixin.js index 2a09ddf2..cd813e5d 100644 --- a/src/mixins/JeecgListMixin.js +++ b/src/mixins/JeecgListMixin.js @@ -8,6 +8,7 @@ import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/man import Vue from 'vue' import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" import store from '@/store' +import { mapState } from 'vuex' export const JeecgListMixin = { data(){ @@ -68,7 +69,10 @@ export const JeecgListMixin = { head['tenant-id'] = tenantid } return head; - } + }, + ...mapState({ + 'device': state => state.app.device, + }) }, methods:{ loadData(arg) { @@ -369,6 +373,30 @@ export const JeecgListMixin = { let url = getFileAccessHttpUrl(text) window.open(url); }, + }, + watch: { + device: { + immediate: true, + handler(val) { + const isMobile = val === 'mobile' + + // 判断是否有值 + if (typeof this.columns !== "undefined" && typeof this.columns[Symbol.iterator] === "function") { + for (const valKey in this.columns) { + if (isMobile && typeof this.columns[valKey].fixed === "string") { + // 如果是手机端,并且已设置为固定['left','right'],则缓存其固定状态,以便切换回电脑端时,恢复其固定状态。 + // 并将fixed设置为false + this.$set(this.columns[valKey], 'fixedCache', this.columns[valKey].fixed); + this.$set(this.columns[valKey], 'fixed', false); + } else if (!isMobile && typeof this.columns[valKey].fixedCache === "string") { + // 如果切换回电脑端,并且缓存中有值,则从缓存中取出固定状态 + this.$set(this.columns[valKey], 'fixed', this.columns[valKey].fixedCache); + } + } + } + } + } } + } \ No newline at end of file From 1f4d72606477623c12d3f5c0e718dae35de73bb8 Mon Sep 17 00:00:00 2001 From: jary Date: Tue, 7 Mar 2023 10:47:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=AB=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9j-vxe-table=E5=88=97=E8=A1=A8=E9=A1=B5=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=9B=BA=E5=AE=9A=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/JVxeTable/components/JVxeTable.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/jeecg/JVxeTable/components/JVxeTable.js b/src/components/jeecg/JVxeTable/components/JVxeTable.js index b9018d21..ed4fe0c9 100644 --- a/src/components/jeecg/JVxeTable/components/JVxeTable.js +++ b/src/components/jeecg/JVxeTable/components/JVxeTable.js @@ -14,6 +14,7 @@ import JVxePagination from './JVxePagination' import { cloneObject, getVmParentByName, pushIfNotExist, randomString, simpleDebounce } from '@/utils/util' import { UtilTools } from 'vxe-table/packages/tools/src/utils' import { getNoAuthCols } from '@/utils/authFilter' +import { mapState } from 'vuex' export default { name: 'JVxeTable', @@ -163,6 +164,8 @@ export default { // vxe 最终 columns vxeColumns() { + const isMobile = this.device === 'mobile' + this.innerColumns.forEach(column => { let renderOptions = { caseId: this.caseId, @@ -173,6 +176,17 @@ export default { reloadEffectRowKeysMap: this.reloadEffectRowKeysMap, listeners: this.cellListeners, } + + if (isMobile && typeof column.fixed === "string") { + // 如果是手机端,并且已设置为固定['left','right'],则缓存其固定状态,以便切换回电脑端时,恢复其固定状态。 + // 并将fixed设置为false + column.fixedCache = column.fixed + column.fixed = false + } else if (!isMobile && typeof column.fixedCache === "string") { + // 如果切换回电脑端,并且缓存中有值,则从缓存中取出固定状态 + column.fixed = column.fixedCache + } + if (column.$type === JVXETypes.rowDragSort) { renderOptions.dragSortKey = this.dragSortKey } @@ -288,6 +302,9 @@ export default { rowInsertDown: rowIndex => this.insertRows({}, rowIndex + 1), } }, + ...mapState({ + 'device': state => state.app.device, + }), }, watch: { dataSource: { @@ -794,7 +811,7 @@ export default { } }) }) - // 【issues/3828】数据更新后,重新计算统计列 + // 【issues/3828】数据更新后,重新计算统计列 if (updated && this.statistics.has) { this.$nextTick(async () => { let {xTable} = this.$refs.vxe.$refs;