Skip to content

Commit

Permalink
只有一列的时候默认版面为表格模式
Browse files Browse the repository at this point in the history
  • Loading branch information
wang authored and aipaw committed Dec 20, 2021
1 parent 40e8e47 commit 64d6060
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
49 changes: 39 additions & 10 deletions resources/assets/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
},

Expand Down Expand Up @@ -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--;
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
cache = {
project_id: state.projectId,
card: true,
cardInit: false,
chat: false,
showMy: true,
showUndone: true,
Expand Down

0 comments on commit 64d6060

Please sign in to comment.