mirror of
https://github.com/kuaifan/dootask.git
synced 2026-06-11 09:52:26 +00:00
feat(approve): 审批详情支持删除审批
- ApproveController 新增 process__delById 代理,转发至审批插件 process/delById; 服务端注入 is_admin(仅发起人或管理员可删) - 审批详情页新增「删除」按钮(仅已结束的审批可见),删除后独立路由返回上一页、 嵌入模式刷新列表 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7335c59b68
commit
84a90b7760
@ -348,6 +348,37 @@ class ApproveController extends AbstractController
|
||||
return Base::retSuccess('已撤回', Base::arrayKeyToUnderline($task['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/approve/process/delById 删除审批(流程实例)
|
||||
*
|
||||
* @apiDescription 需要token身份;仅可删除已结束的审批,且仅发起人或管理员可删
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup approve
|
||||
* @apiName process__delById
|
||||
*
|
||||
* @apiQuery {Number} proc_inst_id 流程实例ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function process__delById()
|
||||
{
|
||||
$user = User::auth();
|
||||
$data['userid'] = (string)$user->userid;
|
||||
$data['proc_inst_id'] = intval(Request::input('proc_inst_id'));
|
||||
$data['is_admin'] = $user->isAdmin();
|
||||
if ($data['proc_inst_id'] <= 0) {
|
||||
return Base::retError('参数错误');
|
||||
}
|
||||
$ret = Ihttp::ihttp_post($this->flow_url . '/api/v1/workflow/process/delById', json_encode(Base::arrayKeyToCamel($data)));
|
||||
$task = json_decode($ret['ret'] == 1 ? $ret['data'] : '{}', true);
|
||||
if (!$task || $task['status'] != 200) {
|
||||
return Base::retError($task['message'] ?? '删除失败');
|
||||
}
|
||||
return Base::retSuccess('已删除');
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/approve/process/findTask 查询需要我审批的流程(审批中)
|
||||
*
|
||||
|
||||
@ -181,6 +181,7 @@
|
||||
<Button type="primary" v-if="isShowAgreeBtn && !loadIng" @click="approve(1)">{{$L('同意')}}</Button>
|
||||
<Button type="error" v-if="isShowAgreeBtn && !loadIng" @click="approve(2)">{{$L('拒绝')}}</Button>
|
||||
<Button type="warning" v-if="isShowWarningBtn && !loadIng" @click="revocation">{{$L('撤销')}}</Button>
|
||||
<Button type="error" v-if="isShowDeleteBtn && !loadIng" @click="remove">{{$L('删除')}}</Button>
|
||||
<Button type="primary" @click="comment" :loading="loadIng > 0" ghost>+{{$L('添加评论')}}</Button>
|
||||
</div>
|
||||
|
||||
@ -259,7 +260,7 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapState(['formOptions']),
|
||||
...mapState(['formOptions', 'userIsAdmin']),
|
||||
|
||||
isShowAgreeBtn() {
|
||||
return (this.datas.candidate || '').split(',').indexOf(this.userId + '') != -1 && !this.datas.is_finished
|
||||
@ -273,6 +274,11 @@ export default {
|
||||
})
|
||||
return is;
|
||||
},
|
||||
// 仅已结束的审批(已通过2/已拒绝3/已撤回4)可删,且仅发起人或管理员
|
||||
isShowDeleteBtn() {
|
||||
return (this.userId == this.datas.start_user_id || this.userIsAdmin)
|
||||
&& [2, 3, 4].includes(Number(this.datas.state));
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
@ -415,6 +421,36 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
// 删除审批
|
||||
remove() {
|
||||
$A.modalConfirm({
|
||||
content: "删除后不可恢复,确定要删除该审批吗?",
|
||||
loading: true,
|
||||
okType: "error",
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'approve/process/delById',
|
||||
method: 'post',
|
||||
data: {
|
||||
proc_inst_id: this.datas.id,
|
||||
}
|
||||
}).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
resolve();
|
||||
// 删除后记录已不存在:独立路由返回上一页,嵌入模式通知父级刷新列表
|
||||
if (this.routeName == 'manage-approve-details' || this.routeName == 'manage-messenger') {
|
||||
this.$router.back()
|
||||
} else {
|
||||
this.$emit('revocation')
|
||||
}
|
||||
}).catch(({msg}) => {
|
||||
reject(msg);
|
||||
});
|
||||
})
|
||||
},
|
||||
});
|
||||
},
|
||||
// 评论
|
||||
comment() {
|
||||
this.commentData.content = ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user