只有一列的时候默认版面为表格模式

This commit is contained in:
wang 2021-12-20 23:23:44 +08:00 committed by aipaw
parent 40e8e47398
commit 64d606013d
2 changed files with 40 additions and 10 deletions

View File

@ -135,22 +135,38 @@ export default {
/** /**
* 切换面板变量 * 切换面板变量
* @param state * @param state
* @param key * @param data|{key, project_id}
*/ */
toggleTablePanel({state}, key) { toggleTablePanel({state}, data) {
if (state.projectId) { let key = data;
let index = state.cacheTablePanel.findIndex(({project_id}) => project_id == state.projectId) 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) { if (index === -1) {
state.cacheTablePanel.push({ 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]; const cache = state.cacheTablePanel[index];
state.cacheTablePanel.splice(index, 1, Object.assign(cache, { if (!state.method.isJson(key)) {
[key]: !cache[key] key = {[key]: !cache[key]};
})) }
state.cacheTablePanel.splice(index, 1, Object.assign(cache, key))
setTimeout(() => {
state.method.setStorage("cacheTablePanel", state.cacheTablePanel); 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)); state.columns = state.columns.filter((item) => item.project_id != project_id || ids.includes(item.id));
} }
dispatch("saveColumn", result.data.data); 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 => { }).catch(e => {
console.error(e); console.error(e);
state.projectLoad--; state.projectLoad--;

View File

@ -60,6 +60,7 @@ export default {
cache = { cache = {
project_id: state.projectId, project_id: state.projectId,
card: true, card: true,
cardInit: false,
chat: false, chat: false,
showMy: true, showMy: true,
showUndone: true, showUndone: true,