mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-26 12:38:13 +00:00
feat(task): 前端支持多工作流状态选择
- 处理 -4005/-4006 错误码,弹出工作流状态选择菜单 - 新增 showFlowItemSelector 方法展示可选状态列表 - 选择状态后自动更新任务的 flow_item_id 和 complete_at Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
773eead827
commit
37de721df9
@ -314,8 +314,12 @@ export default {
|
||||
complete_at: $A.daytz().format('YYYY-MM-DD HH:mm:ss')
|
||||
}).then(() => {
|
||||
completeTemp(true)
|
||||
}).catch(() => {
|
||||
}).catch((error) => {
|
||||
completeTemp(false)
|
||||
// 处理多结束状态的情况
|
||||
if (error && error.ret === -4005 && error.data?.flow_items) {
|
||||
this.showFlowItemSelector(error.data.flow_items, 'complete')
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
@ -330,8 +334,12 @@ export default {
|
||||
complete_at: false
|
||||
}).then(() => {
|
||||
completeTemp(false)
|
||||
}).catch(() => {
|
||||
}).catch((error) => {
|
||||
completeTemp(true)
|
||||
// 处理多开始状态的情况
|
||||
if (error && error.ret === -4006 && error.data?.flow_items) {
|
||||
this.showFlowItemSelector(error.data.flow_items, 'uncomplete')
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
@ -388,10 +396,16 @@ export default {
|
||||
if (typeof this.onUpdate === "function") {
|
||||
this.onUpdate(data)
|
||||
}
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
}).catch((error) => {
|
||||
// 对于需要选择工作流状态的情况,不弹出错误提示
|
||||
if (error && (error.ret === -4005 || error.ret === -4006)) {
|
||||
this.$store.dispatch("getTaskOne", updateData.task_id).catch(() => {})
|
||||
reject(error)
|
||||
return
|
||||
}
|
||||
$A.modalError(error?.msg);
|
||||
this.$store.dispatch("getTaskOne", updateData.task_id).catch(() => {})
|
||||
reject()
|
||||
reject(error)
|
||||
});
|
||||
})
|
||||
},
|
||||
@ -423,6 +437,38 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
showFlowItemSelector(flowItems, type) {
|
||||
const list = flowItems.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
color: item.color,
|
||||
}));
|
||||
this.$store.commit('menu/operation', {
|
||||
event: {target: this.$refs.icon},
|
||||
list,
|
||||
size: 'large',
|
||||
onUpdate: (flowItemId) => {
|
||||
if (flowItemId) {
|
||||
const selectedItem = flowItems.find(item => item.id === flowItemId);
|
||||
if (selectedItem) {
|
||||
const updateData = {
|
||||
flow_item_id: flowItemId,
|
||||
flow_item_status: selectedItem.status,
|
||||
flow_item_name: selectedItem.name,
|
||||
};
|
||||
// 同时传递 complete_at 以确保任务状态正确更新
|
||||
if (type === 'complete') {
|
||||
updateData.complete_at = $A.daytz().format('YYYY-MM-DD HH:mm:ss');
|
||||
} else {
|
||||
updateData.complete_at = false;
|
||||
}
|
||||
this.updateTask(updateData).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
archivedOrRemoveTask(type) {
|
||||
let typeDispatch = 'removeTask';
|
||||
let typeName = '删除';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user