From 64d606013d59af7675e648457dd3bae02ef76532 Mon Sep 17 00:00:00 2001 From: wang <339595811@qq.com> Date: Mon, 20 Dec 2021 23:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E4=B8=80=E5=88=97=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E9=BB=98=E8=AE=A4=E7=89=88=E9=9D=A2=E4=B8=BA?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/store/actions.js | 49 ++++++++++++++++++++++------ resources/assets/js/store/getters.js | 1 + 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 8803bc042..56f3a916c 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -135,22 +135,38 @@ export default { /** * 切换面板变量 * @param state - * @param key + * @param data|{key, project_id} */ - toggleTablePanel({state}, key) { - if (state.projectId) { - let index = state.cacheTablePanel.findIndex(({project_id}) => project_id == state.projectId) + toggleTablePanel({state}, data) { + let key = data; + let project_id = state.projectId; + if (state.method.isJson(data)) { + key = data.key; + project_id = data.project_id; + } + if (project_id) { + let index = state.cacheTablePanel.findIndex(item => item.project_id == project_id) if (index === -1) { state.cacheTablePanel.push({ - project_id: state.projectId, + project_id, + card: true, + cardInit: false, + chat: false, + showMy: true, + showUndone: true, + showCompleted: false, + completedTask: false, }); - index = state.cacheTablePanel.findIndex(({project_id}) => project_id == state.projectId) + index = state.cacheTablePanel.findIndex(item => item.project_id == project_id) } const cache = state.cacheTablePanel[index]; - state.cacheTablePanel.splice(index, 1, Object.assign(cache, { - [key]: !cache[key] - })) - state.method.setStorage("cacheTablePanel", state.cacheTablePanel); + if (!state.method.isJson(key)) { + key = {[key]: !cache[key]}; + } + state.cacheTablePanel.splice(index, 1, Object.assign(cache, key)) + setTimeout(() => { + state.method.setStorage("cacheTablePanel", state.cacheTablePanel); + }); } }, @@ -688,6 +704,19 @@ export default { state.columns = state.columns.filter((item) => item.project_id != project_id || ids.includes(item.id)); } dispatch("saveColumn", result.data.data); + // 判断只有1列的时候默认版面为表格模式 + if (state.columns.filter(item => item.project_id == project_id).length === 1) { + const cache = state.cacheTablePanel.find(item => item.project_id == project_id) || {}; + if (typeof cache.cardInit === "undefined") { + dispatch("toggleTablePanel", { + project_id, + key: { + card: false, + cardInit: true, + } + }); + } + } }).catch(e => { console.error(e); state.projectLoad--; diff --git a/resources/assets/js/store/getters.js b/resources/assets/js/store/getters.js index 23111b56d..29df02c53 100644 --- a/resources/assets/js/store/getters.js +++ b/resources/assets/js/store/getters.js @@ -60,6 +60,7 @@ export default { cache = { project_id: state.projectId, card: true, + cardInit: false, chat: false, showMy: true, showUndone: true,