no message
This commit is contained in:
parent
56a352a9d2
commit
114b792300
@ -170,6 +170,19 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"project_flow_item": [ // 工作流
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"project_id": 2,
|
||||||
|
"flow_id": 3,
|
||||||
|
"name": "待处理",
|
||||||
|
"status": "start",
|
||||||
|
"turns": [9,10,11,12],
|
||||||
|
"userids": [],
|
||||||
|
"sort": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
"task_num": 9,
|
"task_num": 9,
|
||||||
"task_complete": 0,
|
"task_complete": 0,
|
||||||
"task_percent": 0,
|
"task_percent": 0,
|
||||||
@ -186,7 +199,8 @@ class ProjectController extends AbstractController
|
|||||||
//
|
//
|
||||||
$project = Project::userProject($project_id);
|
$project = Project::userProject($project_id);
|
||||||
$data = array_merge($project->toArray(), $project->getTaskStatistics($user->userid), [
|
$data = array_merge($project->toArray(), $project->getTaskStatistics($user->userid), [
|
||||||
'project_user' => $project->projectUser
|
'project_user' => $project->projectUser,
|
||||||
|
'project_flow_item' => $project->projectFlowItem
|
||||||
]);
|
]);
|
||||||
//
|
//
|
||||||
return Base::retSuccess('success', $data);
|
return Base::retSuccess('success', $data);
|
||||||
@ -1408,6 +1422,49 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retSuccess('删除成功', ['id' => $task->id]);
|
return Base::retSuccess('删除成功', ['id' => $task->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} api/project/task/flow 29. 任务工作流信息
|
||||||
|
*
|
||||||
|
* @apiDescription 需要token身份
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiGroup project
|
||||||
|
* @apiName task__flow
|
||||||
|
*
|
||||||
|
* @apiParam {Number} task_id 任务ID
|
||||||
|
*
|
||||||
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
|
* @apiSuccess {Object} data 返回数据
|
||||||
|
*/
|
||||||
|
public function task__flow()
|
||||||
|
{
|
||||||
|
User::auth();
|
||||||
|
//
|
||||||
|
$task_id = intval(Request::input('task_id'));
|
||||||
|
//
|
||||||
|
$projectTask = ProjectTask::select(['id', 'flow_item_id', 'flow_item_name', 'project_id'])->find($task_id);
|
||||||
|
if (empty($projectTask)) {
|
||||||
|
return Base::retError('任务不存在', [ 'task_id' => $task_id ], -4002);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$projectFlowItem = [];
|
||||||
|
$turnBuilder = ProjectFlowItem::select(['id', 'name']);
|
||||||
|
if ($projectTask->flow_item_id) {
|
||||||
|
$projectFlowItem = ProjectFlowItem::select(['id', 'name', 'turns'])->find($projectTask->flow_item_id);
|
||||||
|
}
|
||||||
|
if (empty($projectFlowItem)) {
|
||||||
|
$data = [
|
||||||
|
'id' => 0,
|
||||||
|
'name' => '',
|
||||||
|
'turns' => $turnBuilder->whereProjectId($projectTask->project_id)->get()
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$data = $projectFlowItem->toArray();
|
||||||
|
$data['turns'] = $turnBuilder->whereIn('id', $data['turns'])->get();
|
||||||
|
}
|
||||||
|
return Base::retSuccess('success', $data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/project/flow/list 29. 工作流列表
|
* @api {get} api/project/flow/list 29. 工作流列表
|
||||||
*
|
*
|
||||||
@ -1459,6 +1516,9 @@ class ProjectController extends AbstractController
|
|||||||
if (!is_array($flows)) {
|
if (!is_array($flows)) {
|
||||||
return Base::retError('参数错误');
|
return Base::retError('参数错误');
|
||||||
}
|
}
|
||||||
|
if (count($flows) > 10) {
|
||||||
|
return Base::retError('流程状态最多不能超过10个');
|
||||||
|
}
|
||||||
//
|
//
|
||||||
$project = Project::userProject($project_id, true, true);
|
$project = Project::userProject($project_id, true, true);
|
||||||
//
|
//
|
||||||
@ -1512,7 +1572,11 @@ class ProjectController extends AbstractController
|
|||||||
if (!$hasEnd) {
|
if (!$hasEnd) {
|
||||||
throw new ApiException('至少需要1个结束状态');
|
throw new ApiException('至少需要1个结束状态');
|
||||||
}
|
}
|
||||||
ProjectFlowItem::whereFlowId($projectFlow->id)->whereNotIn('id', $ids)->delete();
|
ProjectFlowItem::whereFlowId($projectFlow->id)->whereNotIn('id', $ids)->chunk(100, function($list) {
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$item->deleteFlowItem();
|
||||||
|
}
|
||||||
|
});
|
||||||
//
|
//
|
||||||
$projectFlow = ProjectFlow::with(['projectFlowItem'])->whereProjectId($project->id)->find($projectFlow->id);
|
$projectFlow = ProjectFlow::with(['projectFlowItem'])->whereProjectId($project->id)->find($projectFlow->id);
|
||||||
$itemIds = $projectFlow->projectFlowItem->pluck('id')->toArray();
|
$itemIds = $projectFlow->projectFlowItem->pluck('id')->toArray();
|
||||||
@ -1559,8 +1623,11 @@ class ProjectController extends AbstractController
|
|||||||
$project = Project::userProject($project_id, true, true);
|
$project = Project::userProject($project_id, true, true);
|
||||||
//
|
//
|
||||||
return AbstractModel::transaction(function() use ($project) {
|
return AbstractModel::transaction(function() use ($project) {
|
||||||
ProjectFlow::whereProjectId($project->id)->delete();
|
ProjectFlow::whereProjectId($project->id)->chunk(100, function($list) {
|
||||||
ProjectFlowItem::whereProjectId($project->id)->delete();
|
foreach ($list as $item) {
|
||||||
|
$item->deleteFlow();
|
||||||
|
}
|
||||||
|
});
|
||||||
return Base::retSuccess('删除成功');
|
return Base::retSuccess('删除成功');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -34,60 +34,18 @@ class ProjectFlow extends AbstractModel
|
|||||||
return $this->hasMany(ProjectFlowItem::class, 'flow_id', 'id')->orderBy('sort');
|
return $this->hasMany(ProjectFlowItem::class, 'flow_id', 'id')->orderBy('sort');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addFlow()
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function deleteFlow()
|
||||||
{
|
{
|
||||||
AbstractModel::transaction(function() {
|
return AbstractModel::transaction(function() {
|
||||||
$projectFlow = ProjectFlow::whereProjectId($project->id)->first();
|
ProjectFlowItem::whereProjectId($this->project_id)->chunk(100, function($list) {
|
||||||
if (empty($projectFlow)) {
|
foreach ($list as $item) {
|
||||||
$projectFlow = ProjectFlow::createInstance([
|
$item->deleteFlowItem();
|
||||||
'project_id' => $project->id,
|
|
||||||
'name' => 'Default'
|
|
||||||
]);
|
|
||||||
if (!$projectFlow->save()) {
|
|
||||||
return Base::retError('工作流创建失败');
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
//
|
return $this->delete();
|
||||||
$ids = [];
|
|
||||||
$idc = [];
|
|
||||||
$hasStart = false;
|
|
||||||
$hasEnd = false;
|
|
||||||
foreach ($flows as $item) {
|
|
||||||
$id = intval($item['id']);
|
|
||||||
$turns = Base::arrayRetainInt($item['turns'] ?: [], true);
|
|
||||||
$userids = Base::arrayRetainInt($item['userids'] ?: [], true);
|
|
||||||
$flow = ProjectFlowItem::updateInsert([
|
|
||||||
'id' => $id,
|
|
||||||
'project_id' => $project->id,
|
|
||||||
'flow_id' => $projectFlow->id,
|
|
||||||
], [
|
|
||||||
'name' => trim($item['name']),
|
|
||||||
'status' => trim($item['status']),
|
|
||||||
'sort' => intval($item['sort']),
|
|
||||||
'turns' => $turns,
|
|
||||||
'userids' => $userids,
|
|
||||||
]);
|
|
||||||
if ($flow) {
|
|
||||||
$ids[] = $flow->id;
|
|
||||||
if ($flow->id != $id) {
|
|
||||||
$idc[$id] = $flow->id;
|
|
||||||
}
|
|
||||||
if ($flow->status == 'start') {
|
|
||||||
$hasStart = true;
|
|
||||||
}
|
|
||||||
if ($flow->status == 'end') {
|
|
||||||
$hasEnd = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$hasStart) {
|
|
||||||
return Base::retError('至少需要1个开始状态');
|
|
||||||
}
|
|
||||||
if (!$hasEnd) {
|
|
||||||
return Base::retError('至少需要1个结束状态');
|
|
||||||
}
|
|
||||||
ProjectFlowItem::whereFlowId($projectFlow->id)->whereNotIn('id', $ids)->delete();
|
|
||||||
});
|
});
|
||||||
return Base::retSuccess("success");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,11 @@ use App\Module\Base;
|
|||||||
*/
|
*/
|
||||||
class ProjectFlowItem extends AbstractModel
|
class ProjectFlowItem extends AbstractModel
|
||||||
{
|
{
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return array
|
* @return array
|
||||||
@ -57,4 +62,16 @@ class ProjectFlowItem extends AbstractModel
|
|||||||
}
|
}
|
||||||
return Base::json2array($value);
|
return Base::json2array($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public function deleteFlowItem()
|
||||||
|
{
|
||||||
|
ProjectTask::whereFlowItemId($this->id)->update([
|
||||||
|
'flow_item_id' => 0,
|
||||||
|
'flow_item_name' => "",
|
||||||
|
]);
|
||||||
|
return $this->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ use Request;
|
|||||||
* @property int|null $column_id 列表ID
|
* @property int|null $column_id 列表ID
|
||||||
* @property int|null $dialog_id 聊天会话ID
|
* @property int|null $dialog_id 聊天会话ID
|
||||||
* @property int|null $flow_item_id 工作流状态ID
|
* @property int|null $flow_item_id 工作流状态ID
|
||||||
|
* @property string|null $flow_item_name 工作流状态名称
|
||||||
* @property string|null $name 标题
|
* @property string|null $name 标题
|
||||||
* @property string|null $color 颜色
|
* @property string|null $color 颜色
|
||||||
* @property string|null $desc 描述
|
* @property string|null $desc 描述
|
||||||
@ -74,6 +75,7 @@ use Request;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDialogId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDialogId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereEndAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereEndAt($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereFlowItemId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereFlowItemId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereFlowItemName($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereName($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereName($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask wherePColor($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask wherePColor($value)
|
||||||
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class ProjectTasksAddFlowItemId extends Migration
|
class ProjectTasksAddFlowItemIdFlowItemName extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@ -16,6 +16,7 @@ class ProjectTasksAddFlowItemId extends Migration
|
|||||||
Schema::table('project_tasks', function (Blueprint $table) {
|
Schema::table('project_tasks', function (Blueprint $table) {
|
||||||
if (!Schema::hasColumn('project_tasks', 'flow_item_id')) {
|
if (!Schema::hasColumn('project_tasks', 'flow_item_id')) {
|
||||||
$table->bigInteger('flow_item_id')->nullable()->default(0)->after('dialog_id')->comment('工作流状态ID');
|
$table->bigInteger('flow_item_id')->nullable()->default(0)->after('dialog_id')->comment('工作流状态ID');
|
||||||
|
$table->string('flow_item_name', 50)->nullable()->default('')->after('flow_item_id')->comment('工作流状态名称');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -29,6 +30,7 @@ class ProjectTasksAddFlowItemId extends Migration
|
|||||||
{
|
{
|
||||||
Schema::table('project_tasks', function (Blueprint $table) {
|
Schema::table('project_tasks', function (Blueprint $table) {
|
||||||
$table->dropColumn("flow_item_id");
|
$table->dropColumn("flow_item_id");
|
||||||
|
$table->dropColumn("flow_item_name");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
3
resources/assets/js/store/actions.js
vendored
3
resources/assets/js/store/actions.js
vendored
@ -524,6 +524,9 @@ export default {
|
|||||||
if (typeof data.project_user === "undefined") {
|
if (typeof data.project_user === "undefined") {
|
||||||
data.project_user = []
|
data.project_user = []
|
||||||
}
|
}
|
||||||
|
if (typeof data.project_flow_item === "undefined") {
|
||||||
|
data.project_flow_item = []
|
||||||
|
}
|
||||||
state.cacheProjects.push(data);
|
state.cacheProjects.push(data);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user