增加批量设置任务执行者

Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
vilson 2019-01-24 17:47:34 +08:00
parent 8fc8650bf5
commit 4a71d922a2
4 changed files with 38 additions and 2 deletions

View File

@ -88,7 +88,7 @@ function error($errno, $message = '')
{
return [
'errno' => $errno,
'message' => $message,
'msg' => $message,
];
}

View File

@ -5,6 +5,9 @@ namespace app\common\Model;
use function GuzzleHttp\Promise\task;
use service\DateService;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\facade\Hook;
/**
@ -364,6 +367,20 @@ class Task extends CommonModel
return $result;
}
public function batchAssignTask($taskCodes, $executorCode)
{
if ($taskCodes) {
try {
foreach ($taskCodes as $taskCode) {
$this->assignTask($taskCode, $executorCode);
}
} catch (\Exception $e) {
return error(201, $e->getMessage());
}
}
return true;
}
/**
* @param $taskCode
* @param $comment

View File

@ -32,7 +32,7 @@ class ProjectMember extends BasicApi
$list = $this->model->_list($where, 'is_owner desc');
if ($list['list']) {
foreach ($list['list'] as &$item) {
$member = Member::where(['code' => $item['member_code']])->field('id,name,avatar,code,email')->find();
$member = Member::where(['code' => $item['member_code']])->field('name,avatar,code,email')->find();
!$member && $member = [];
$member['is_owner'] = $item['is_owner'];
$item = $member;

View File

@ -210,6 +210,25 @@ class Task extends BasicApi
$this->error("操作失败,请稍候再试!");
}
/**
* 批量
* 指派任务
* @param Request $request
*/
public function batchAssignTask(Request $request)
{
$taskCodes = $request::param('taskCodes');
$executorCode = $request::param('executorCode');
if ($taskCodes) {
$result = $this->model->batchAssignTask(json_decode($taskCodes), $executorCode);
if (isError($result)) {
$this->error($result['msg'], $result['errno']);
}
}
$this->success();
}
/**
* 排序
* @param Request $request