Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

手机端的列表页去掉固定列 #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/components/jeecg/JVxeTable/components/JVxeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -163,6 +164,8 @@ export default {

// vxe 最终 columns
vxeColumns() {
const isMobile = this.device === 'mobile'

this.innerColumns.forEach(column => {
let renderOptions = {
caseId: this.caseId,
Expand All @@ -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
}
Expand Down Expand Up @@ -288,6 +302,9 @@ export default {
rowInsertDown: rowIndex => this.insertRows({}, rowIndex + 1),
}
},
...mapState({
'device': state => state.app.device,
}),
},
watch: {
dataSource: {
Expand Down Expand Up @@ -794,7 +811,7 @@ export default {
}
})
})
// 【issues/3828】数据更新后,重新计算统计列
// 【issues/3828】数据更新后,重新计算统计列
if (updated && this.statistics.has) {
this.$nextTick(async () => {
let {xTable} = this.$refs.vxe.$refs;
Expand Down
30 changes: 29 additions & 1 deletion src/mixins/JeecgListMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -68,7 +69,10 @@ export const JeecgListMixin = {
head['tenant-id'] = tenantid
}
return head;
}
},
...mapState({
'device': state => state.app.device,
})
},
methods:{
loadData(arg) {
Expand Down Expand Up @@ -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);
}
}
}
}
}
}


}