优化:任务删除功能,如果任务存在关联的工作记录无法删除

This commit is contained in:
HDM58\hdm58 2023-12-10 17:12:29 +08:00
parent 83302f2501
commit 6f0389b16c
2 changed files with 7 additions and 0 deletions

View File

@ -169,6 +169,10 @@ class Task extends BaseController
if ($detail['admin_id'] != $this->uid) {
return to_assign(1, "你不是该任务的创建人,无权限删除");
}
$count_schedule = Db::name('Schedule')->where(['tid'=>$id,'delete_time'=>0])->count();
if($count_schedule>0){
return to_assign(1, "该任务已经关联的工作记录,无法删除,如果不需要可以关闭该任务即可");
}
if (Db::name('ProjectTask')->where('id', $id)->update(['delete_time' => time()]) !== false) {
$log_data = array(
'module' => 'task',

View File

@ -24,6 +24,7 @@ class ProjectLog extends Model
'status' => array('icon' => 'icon-wodedianping', 'title' => '状态'),
'content' => array('icon' => 'icon-wodedianping', 'title' => '描述'),
'file' => array('icon' => 'icon-sucaiziyuan', 'title' => '文件'),
'file_ids' => array('icon' => 'icon-sucaiziyuan', 'title' => '文件'),
'contract_id' => array('icon' => 'icon-hetongguanli', 'title' => '合同'),
'customer_id' => array('icon' => 'icon-jiaoshiguanli', 'title' => '客户'),
'link' => array('icon' => 'icon-sucaiziyuan', 'title' => '链接'),
@ -50,6 +51,7 @@ class ProjectLog extends Model
'before_task' => array('icon' => 'icon-wodedianping', 'title' => '前置任务'),
'content' => array('icon' => 'icon-wodedianping', 'title' => '描述'),
'file' => array('icon' => 'icon-sucaiziyuan', 'title' => '文件'),
'file_ids' => array('icon' => 'icon-sucaiziyuan', 'title' => '文件'),
'new' => array('icon' => 'icon-zidingyishezhi', 'title' => '任务'),
'delete' => array('icon' => 'icon-shanchu', 'title' => '任务'),
]],
@ -58,6 +60,7 @@ class ProjectLog extends Model
'title' => array('icon' => 'icon-wodedianping', 'title' => '标题'),
'project_id' => array('icon' => 'icon-wodedianping', 'title' => '关联项目'),
'content' => array('icon' => 'icon-wodedianping', 'title' => '描述'),
'file_ids' => array('icon' => 'icon-sucaiziyuan', 'title' => '文件'),
'new' => array('icon' => 'icon-zidingyishezhi', 'title' => '任务'),
'delete' => array('icon' => 'icon-shanchu', 'title' => '任务'),
]]