mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-16 12:08:12 +00:00
优化等待
This commit is contained in:
parent
3cc6a3317e
commit
f3e9ac2b56
@ -82,7 +82,7 @@
|
||||
</div>
|
||||
|
||||
<!--等待/时间/阅读-->
|
||||
<div v-if="!msgData.created_at" class="dialog-foot"><Loading/></div>
|
||||
<div v-if="isLoading" class="dialog-foot"><Loading/></div>
|
||||
<div v-else class="dialog-foot">
|
||||
<!--时间-->
|
||||
<div v-if="timeShow" class="time" @click="timeShow=false">{{msgData.created_at}}</div>
|
||||
@ -172,7 +172,15 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['dialogMsgs', 'dialogReplys', 'audioPlaying', 'windowActive']),
|
||||
...mapState(['loads', 'dialogMsgs', 'dialogReplys', 'audioPlaying', 'windowActive']),
|
||||
|
||||
isLoading() {
|
||||
if (!this.msgData.created_at) {
|
||||
return true;
|
||||
}
|
||||
const load = this.loads.find(({key}) => key === `msg-${this.msgData.id}`);
|
||||
return load && load.num > 0
|
||||
},
|
||||
|
||||
viewClass() {
|
||||
const {msgData, replyData, operateAction, operateEnter} = this;
|
||||
|
||||
@ -1127,16 +1127,23 @@ export default {
|
||||
},
|
||||
|
||||
onEmoji(emoji) {
|
||||
const msg_id = this.operateItem.id;
|
||||
this.$store.dispatch("setLoad", {
|
||||
key: `msg-${msg_id}`,
|
||||
delay: 600
|
||||
})
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/msg/emoji',
|
||||
data: {
|
||||
msg_id: this.operateItem.id,
|
||||
msg_id,
|
||||
emoji,
|
||||
},
|
||||
}).then(({data}) => {
|
||||
this.$store.dispatch("saveDialogMsg", data);
|
||||
}).catch(({msg}) => {
|
||||
$A.messageError(msg);
|
||||
}).finally(_ => {
|
||||
this.$store.dispatch("cancelLoad", `msg-${msg_id}`)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,13 +50,13 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapState(['taskLoading', 'taskFlows']),
|
||||
...mapState(['loads', 'taskFlows']),
|
||||
|
||||
loadIng() {
|
||||
if (this.loadStatus) {
|
||||
return true;
|
||||
}
|
||||
const load = this.taskLoading.find(({id}) => id == this.task.id);
|
||||
const load = this.loads.find(({key}) => key === `task-${this.task.id}`);
|
||||
return load && load.num > 0
|
||||
},
|
||||
},
|
||||
|
||||
@ -96,13 +96,13 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['taskOperation', 'taskColorList', 'taskLoading', 'taskFlows', 'taskFlowItems']),
|
||||
...mapState(['loads', 'taskOperation', 'taskColorList', 'taskFlows', 'taskFlowItems']),
|
||||
|
||||
loadIng() {
|
||||
if (this.loadStatus) {
|
||||
return true;
|
||||
}
|
||||
const load = this.taskLoading.find(({id}) => id == this.task.id);
|
||||
const load = this.loads.find(({key}) => key === `task-${this.task.id}`);
|
||||
return load && load.num > 0
|
||||
},
|
||||
|
||||
|
||||
106
resources/assets/js/store/actions.js
vendored
106
resources/assets/js/store/actions.js
vendored
@ -1362,19 +1362,22 @@ export default {
|
||||
reject({msg: 'Parameter error'});
|
||||
return;
|
||||
}
|
||||
dispatch("taskLoadStart", data.task_id)
|
||||
dispatch("setLoad", {
|
||||
key: `task-${data.task_id}`,
|
||||
delay: 300
|
||||
})
|
||||
dispatch("call", {
|
||||
url: 'project/task/remove',
|
||||
data,
|
||||
}).then(result => {
|
||||
dispatch("forgetTask", data.task_id)
|
||||
dispatch("taskLoadEnd", data.task_id)
|
||||
resolve(result)
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
dispatch("getTaskOne", data.task_id).catch(() => {})
|
||||
dispatch("taskLoadEnd", data.task_id)
|
||||
reject(e)
|
||||
}).finally(_ => {
|
||||
dispatch("cancelLoad", `task-${data.task_id}`)
|
||||
});
|
||||
});
|
||||
},
|
||||
@ -1395,19 +1398,22 @@ export default {
|
||||
reject({msg: 'Parameter error'});
|
||||
return;
|
||||
}
|
||||
dispatch("taskLoadStart", data.task_id)
|
||||
dispatch("setLoad", {
|
||||
key: `task-${data.task_id}`,
|
||||
delay: 300
|
||||
})
|
||||
dispatch("call", {
|
||||
url: 'project/task/archived',
|
||||
data,
|
||||
}).then(result => {
|
||||
dispatch("saveTask", result.data)
|
||||
dispatch("taskLoadEnd", data.task_id)
|
||||
resolve(result)
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
dispatch("getTaskOne", data.task_id).catch(() => {})
|
||||
dispatch("taskLoadEnd", data.task_id)
|
||||
reject(e)
|
||||
}).finally(_ => {
|
||||
dispatch("cancelLoad", `task-${data.task_id}`)
|
||||
});
|
||||
});
|
||||
},
|
||||
@ -1613,20 +1619,23 @@ export default {
|
||||
taskUpdate({state, dispatch}, data) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch("taskBeforeUpdate", data).then(({confirm, post}) => {
|
||||
dispatch("taskLoadStart", post.task_id)
|
||||
dispatch("setLoad", {
|
||||
key: `task-${post.task_id}`,
|
||||
delay: 300
|
||||
})
|
||||
dispatch("call", {
|
||||
url: 'project/task/update',
|
||||
data: post,
|
||||
method: 'post',
|
||||
}).then(result => {
|
||||
dispatch("taskLoadEnd", post.task_id)
|
||||
dispatch("saveTask", result.data)
|
||||
resolve(result)
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
dispatch("taskLoadEnd", post.task_id)
|
||||
dispatch("getTaskOne", post.task_id).catch(() => {})
|
||||
setTimeout(() => { reject(e) }, confirm === true ? 301 : 0)
|
||||
}).finally(_ => {
|
||||
dispatch("cancelLoad", `task-${post.task_id}`)
|
||||
});
|
||||
}).catch(reject)
|
||||
});
|
||||
@ -1735,42 +1744,6 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 任务增加等待
|
||||
* @param state
|
||||
* @param task_id
|
||||
*/
|
||||
taskLoadStart({state}, task_id) {
|
||||
setTimeout(() => {
|
||||
const load = state.taskLoading.find(({id}) => id == task_id)
|
||||
if (!load) {
|
||||
state.taskLoading.push({
|
||||
id: task_id,
|
||||
num: 1
|
||||
})
|
||||
} else {
|
||||
load.num++;
|
||||
}
|
||||
}, 300)
|
||||
},
|
||||
|
||||
/**
|
||||
* 任务减少等待
|
||||
* @param state
|
||||
* @param task_id
|
||||
*/
|
||||
taskLoadEnd({state}, task_id) {
|
||||
const load = state.taskLoading.find(({id}) => id == task_id)
|
||||
if (!load) {
|
||||
state.taskLoading.push({
|
||||
id: task_id,
|
||||
num: -1
|
||||
})
|
||||
} else {
|
||||
load.num--;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取任务流程信息
|
||||
* @param state
|
||||
@ -2335,6 +2308,49 @@ export default {
|
||||
}, 50);
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
/** ************************************* loads *********************************************/
|
||||
/** *****************************************************************************************/
|
||||
|
||||
/**
|
||||
* 设置等待
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param key
|
||||
*/
|
||||
setLoad({state, dispatch}, key) {
|
||||
if ($A.isJson(key)) {
|
||||
setTimeout(_ => {
|
||||
dispatch("setLoad", key.key)
|
||||
}, key.delay || 0)
|
||||
return;
|
||||
}
|
||||
const load = state.loads.find(item => item.key == key)
|
||||
if (!load) {
|
||||
state.loads.push({key, num: 1})
|
||||
} else {
|
||||
load.num++;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消等待
|
||||
* @param state
|
||||
* @param key
|
||||
*/
|
||||
cancelLoad({state}, key) {
|
||||
const load = state.loads.find(item => item.key == key)
|
||||
if (!load) {
|
||||
state.loads.push({key, num: -1})
|
||||
} else {
|
||||
load.num--;
|
||||
}
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
/** *********************************** websocket *******************************************/
|
||||
/** *****************************************************************************************/
|
||||
|
||||
/**
|
||||
* 初始化 websocket
|
||||
* @param state
|
||||
|
||||
2
resources/assets/js/store/state.js
vendored
2
resources/assets/js/store/state.js
vendored
@ -19,6 +19,7 @@ const stateData = {
|
||||
routeHistoryLast: {},
|
||||
|
||||
// 加载状态
|
||||
loads: [],
|
||||
loadDashboardTasks: false,
|
||||
loadUserBasic: false,
|
||||
loadProjects: 0,
|
||||
@ -90,7 +91,6 @@ const stateData = {
|
||||
taskOperation: {},
|
||||
|
||||
// 任务等待状态
|
||||
taskLoading: [],
|
||||
taskOneLoad: {},
|
||||
|
||||
// 任务流程信息
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user