This commit is contained in:
mkm 2024-01-08 10:44:39 +08:00
parent 0574775a95
commit 8eb0fa4aae
2 changed files with 31 additions and 3 deletions

View File

@ -21,6 +21,22 @@ class Task extends CommonModel
{ {
protected $append = ['priText', 'statusText', 'liked', 'stared', 'tags', 'childCount', 'hasUnDone', 'parentDone', 'hasComment', 'hasSource', 'canRead']; protected $append = ['priText', 'statusText', 'liked', 'stared', 'tags', 'childCount', 'hasUnDone', 'parentDone', 'hasComment', 'hasSource', 'canRead'];
public function getExchangeListAttr($value)
{
if($value){
return explode(',',$value);
}else{
return[];
}
}
public function getTransferredtAttr($value)
{
if($value){
return explode(',',$value);
}else{
return[];
}
}
public function read($code) public function read($code)
{ {
if (!$code) { if (!$code) {
@ -435,7 +451,7 @@ class Task extends CommonModel
* @throws DbException * @throws DbException
* @throws ModelNotFoundException * @throws ModelNotFoundException
*/ */
public function createComment($taskCode, $comment, $mentions = []) public function createComment($taskCode, $comment, $mentions = [],$type=0)
{ {
if (!$taskCode) { if (!$taskCode) {
throw new Exception('请选择任务', 1); throw new Exception('请选择任务', 1);
@ -455,6 +471,18 @@ class Task extends CommonModel
// 'type' => 'comment' // 'type' => 'comment'
// ]; // ];
self::taskHook(getCurrentMember()['code'], $taskCode, 'comment', '', 1, '', $comment, '', $mentions); self::taskHook(getCurrentMember()['code'], $taskCode, 'comment', '', 1, '', $comment, '', $mentions);
if($type==1){
$data['status']=2;
if($task['exchange_list']){
$task['transferred'][]=$task['exchange_list'][0];
$task['assign_to']=$task['exchange_list'][0];
unset($task['exchange_list'][0]);
Db::name('task')->where('id',$task['id'])->update($data);
}
}elseif($type==2){
$data['status']=2;
Db::name('task')->where('id',$task['id'])->update($data);
}
return true; return true;
// return ProjectLog::create($data); // return ProjectLog::create($data);
} }

View File

@ -270,7 +270,7 @@ class Task extends BasicApi
*/ */
public function createComment(Request $request) public function createComment(Request $request)
{ {
$data = $request::only('taskCode,comment,mentions'); $data = $request::only('taskCode,comment,mentions,type');
if (!$request::post('taskCode')) { if (!$request::post('taskCode')) {
$this->error("请选择任务"); $this->error("请选择任务");
} }
@ -278,7 +278,7 @@ class Task extends BasicApi
$data['mentions'] = json_decode($data['mentions']); $data['mentions'] = json_decode($data['mentions']);
} }
try { try {
$result = $this->model->createComment($data['taskCode'], $data['comment'], $data['mentions']); $result = $this->model->createComment($data['taskCode'], $data['comment'], $data['mentions'],$data['type']);
} catch (Exception $e) { } catch (Exception $e) {
$this->error($e->getMessage(), $e->getCode());; $this->error($e->getMessage(), $e->getCode());;
} }