优化确认弹窗

This commit is contained in:
kuaifan 2022-06-29 13:30:40 +08:00
parent 575e569048
commit 644f415d46
11 changed files with 178 additions and 183 deletions

View File

@ -367,14 +367,14 @@ export default {
content: '你确定要删除任务【' + data.name + '】吗?', content: '你确定要删除任务【' + data.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("removeTask", {task_id: data.id}).then(({msg}) => { this.$store.dispatch("removeTask", {task_id: data.id}).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
this.setRenderRange(); this.setRenderRange();
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
break; break;

View File

@ -213,6 +213,7 @@ export default {
content, content,
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'dialog/group/deluser', url: 'dialog/group/deluser',
data: { data: {
@ -220,7 +221,7 @@ export default {
userids, userids,
} }
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
if (userids.length > 0) { if (userids.length > 0) {
this.getDialogUser(); this.getDialogUser();
} else { } else {
@ -228,10 +229,9 @@ export default {
this.goForward({name: 'manage-messenger'}); this.goForward({name: 'manage-messenger'});
} }
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
}, },
}); });
}, },
@ -242,20 +242,20 @@ export default {
loading: true, loading: true,
okText: '解散', okText: '解散',
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'dialog/group/disband', url: 'dialog/group/disband',
data: { data: {
dialog_id: this.dialogId, dialog_id: this.dialogId,
} }
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.$store.dispatch("forgetDialog", this.dialogId); this.$store.dispatch("forgetDialog", this.dialogId);
this.goForward({name: 'manage-messenger'}); this.goForward({name: 'manage-messenger'});
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
}, },
}); });
}, },

View File

@ -1225,19 +1225,19 @@ export default {
okText: '撤回', okText: '撤回',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'dialog/msg/withdraw', url: 'dialog/msg/withdraw',
data: { data: {
msg_id: this.operateItem.id msg_id: this.operateItem.id
}, },
}).then(() => { }).then(() => {
$A.messageSuccess("消息已撤回"); resolve("消息已撤回");
this.$store.dispatch("forgetDialogMsg", this.operateItem.id); this.$store.dispatch("forgetDialogMsg", this.operateItem.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.messageError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },

View File

@ -423,6 +423,7 @@ export default {
okText: '确定', okText: '确定',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'file/content/restore', url: 'file/content/restore',
data: { data: {
@ -430,14 +431,13 @@ export default {
history_id: item.id, history_id: item.id,
} }
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.contentDetail = null; this.contentDetail = null;
this.getContent(); this.getContent();
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },

View File

@ -244,20 +244,20 @@ export default {
content: item.content, content: item.content,
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/task/resetfromlog', url: 'project/task/resetfromlog',
data: { data: {
id: item.id id: item.id
} }
}).then(({data, msg}) => { }).then(({data, msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.$store.dispatch("saveTask", data); this.$store.dispatch("saveTask", data);
this.getLists(true); this.getLists(true);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },

View File

@ -1047,15 +1047,15 @@ export default {
} }
this.$set(this.columnLoad, column.id, true); this.$set(this.columnLoad, column.id, true);
// //
this.$store.dispatch("removeColumn", column.id).then(({data, msg}) => { return new Promise((resolve, reject) => {
$A.messageSuccess(msg); this.$store.dispatch("removeColumn", column.id).then(({msg}) => {
this.$set(this.columnLoad, column.id, false); resolve(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
this.$set(this.columnLoad, column.id, false);
}).finally(_ => { }).finally(_ => {
this.$Modal.remove(); this.$set(this.columnLoad, column.id, false);
}); });
})
} }
}); });
}, },
@ -1129,13 +1129,13 @@ export default {
content: '你确定要归档项目【' + this.projectData.name + '】吗?', content: '你确定要归档项目【' + this.projectData.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("archivedProject", this.projectId).then(({msg}) => { this.$store.dispatch("archivedProject", this.projectId).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },
@ -1146,13 +1146,13 @@ export default {
content: '你确定要删除项目【' + this.projectData.name + '】吗?', content: '你确定要删除项目【' + this.projectData.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("removeProject", this.projectId).then(({msg}) => { this.$store.dispatch("removeProject", this.projectId).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },
@ -1163,13 +1163,13 @@ export default {
content: '你确定要退出项目【' + this.projectData.name + '】吗?', content: '你确定要退出项目【' + this.projectData.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("exitProject", this.projectId).then(({msg}) => { this.$store.dispatch("exitProject", this.projectId).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },

View File

@ -336,6 +336,7 @@ export default {
loading: true, loading: true,
onOk: () => { onOk: () => {
if (data.id > 0) { if (data.id > 0) {
return new Promise((resolve, reject) => {
this.loadIng++; this.loadIng++;
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/flow/delete', url: 'project/flow/delete',
@ -343,25 +344,23 @@ export default {
project_id: this.projectId, project_id: this.projectId,
}, },
}).then(({msg}) => { }).then(({msg}) => {
$.messageSuccess(msg); resolve(msg);
// //
let index = this.list.findIndex(({id}) => id == data.id) let index = this.list.findIndex(({id}) => id == data.id)
if (index > -1) { if (index > -1) {
this.list.splice(index, 1) this.list.splice(index, 1)
} }
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => { }).finally(_ => {
this.$Modal.remove();
this.loadIng--; this.loadIng--;
}); });
} else { })
let index = this.list.findIndex(({id}) => id == data.id) }
const index = this.list.findIndex(({id}) => id == data.id)
if (index > -1) { if (index > -1) {
this.list.splice(index, 1) this.list.splice(index, 1)
} }
this.$Modal.remove();
}
} }
}); });
}, },

View File

@ -106,9 +106,8 @@ export default {
$A.modalConfirm({ $A.modalConfirm({
title: '覆盖提交', title: '覆盖提交',
content: '你已提交过此日期的报告,是否覆盖提交?', content: '你已提交过此日期的报告,是否覆盖提交?',
loading: true,
onOk: () => { onOk: () => {
this.doSubmit(true); this.doSubmit();
} }
}); });
} else { } else {
@ -116,13 +115,12 @@ export default {
} }
}, },
doSubmit(isModal = false) { doSubmit() {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'report/store', url: 'report/store',
data: this.reportData, data: this.reportData,
method: 'post', method: 'post',
}).then(({data, msg}) => { }).then(({data, msg}) => {
isModal && this.$Modal.remove();
// data // data
this.reportData.offset = 0; this.reportData.offset = 0;
this.reportData.type = "weekly"; this.reportData.type = "weekly";
@ -132,7 +130,6 @@ export default {
!this.$isSubElectron && $A.messageSuccess(msg); !this.$isSubElectron && $A.messageSuccess(msg);
this.$emit("saveSuccess", {data, msg}); this.$emit("saveSuccess", {data, msg});
}).catch(({msg}) => { }).catch(({msg}) => {
isModal && this.$Modal.remove();
// msg // msg
$A.messageError(msg); $A.messageError(msg);
}); });

View File

@ -303,17 +303,16 @@ export default {
loading: true, loading: true,
onOk: () => { onOk: () => {
if (this.loadIng) { if (this.loadIng) {
this.$Modal.remove();
return; return;
} }
return new Promise((resolve, reject) => {
this.$store.dispatch(typeDispatch, typeData).then(({msg}) => { this.$store.dispatch(typeDispatch, typeData).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.$store.dispatch("saveTaskBrowse", typeData.task_id); this.$store.dispatch("saveTaskBrowse", typeData.task_id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },

View File

@ -1160,19 +1160,19 @@ export default {
content: '你确定要退出【' + item.name + '】共享成员吗?', content: '你确定要退出【' + item.name + '】共享成员吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'file/share/out', url: 'file/share/out',
data: { data: {
id: item.id, id: item.id,
}, },
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.$store.dispatch("forgetFile", item.id); this.$store.dispatch("forgetFile", item.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
break; break;
@ -1288,20 +1288,20 @@ export default {
content: '你确定要删除' + fileName + '吗?', content: '你确定要删除' + fileName + '吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'file/remove', url: 'file/remove',
data: { data: {
ids, ids,
}, },
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); resolve(msg);
this.$store.dispatch("forgetFile", ids); this.$store.dispatch("forgetFile", ids);
this.selectIds = this.selectIds.filter(id => !ids.includes(id)) this.selectIds = this.selectIds.filter(id => !ids.includes(id))
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); reject(msg);
}).finally(_ => {
this.$Modal.remove();
}); });
})
} }
}); });
}, },
@ -1466,7 +1466,7 @@ export default {
} }
}) })
} else { } else {
$A.modalError(msg, force === true ? 301 : 0) $A.modalError(msg)
} }
}).finally(_ => { }).finally(_ => {
this.shareLoad--; this.shareLoad--;
@ -1512,7 +1512,7 @@ export default {
}) })
} else { } else {
item.permission = item._permission; item.permission = item._permission;
$A.modalError(msg, force === true ? 301 : 0) $A.modalError(msg)
} }
}) })
}, },

View File

@ -452,7 +452,7 @@ export default {
}); });
}) })
}, },
onCancel: _ => setTimeout(nameReject, 301) onCancel: _ => nameReject
}); });
}, 100) }, 100)
}); });
@ -1629,7 +1629,7 @@ export default {
}).catch(e => { }).catch(e => {
console.warn(e); console.warn(e);
dispatch("getTaskOne", post.task_id).catch(() => {}) dispatch("getTaskOne", post.task_id).catch(() => {})
setTimeout(() => { reject(e) }, confirm === true ? 301 : 0) reject(e)
}).finally(_ => { }).finally(_ => {
dispatch("cancelLoad", `task-${post.task_id}`) dispatch("cancelLoad", `task-${post.task_id}`)
}); });