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