diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 7b7dc391..5a040249 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -1618,6 +1618,14 @@ class ProjectController extends AbstractController $id = intval($item['id']); $turns = Base::arrayRetainInt($item['turns'] ?: [], true); $userids = Base::arrayRetainInt($item['userids'] ?: [], true); + $usertype = trim($item['usertype']); + $userlimit = intval($item['userlimit']); + if ($usertype == 'replace' && empty($userids)) { + throw new ApiException("状态[{$item['name']}]设置错误,设置流转模式时必须填写状态负责人"); + } + if ($userlimit && empty($userids)) { + throw new ApiException("状态[{$item['name']}]设置错误,设置限制负责人时必须填写状态负责人"); + } $flow = ProjectFlowItem::updateInsert([ 'id' => $id, 'project_id' => $project->id, @@ -1628,7 +1636,8 @@ class ProjectController extends AbstractController 'sort' => intval($item['sort']), 'turns' => $turns, 'userids' => $userids, - 'usertype' => $item['usertype'], + 'usertype' => trim($item['usertype']), + 'userlimit' => $userlimit, ]); if ($flow) { $ids[] = $flow->id; diff --git a/app/Models/ProjectFlowItem.php b/app/Models/ProjectFlowItem.php index 9d358710..267f24e0 100644 --- a/app/Models/ProjectFlowItem.php +++ b/app/Models/ProjectFlowItem.php @@ -15,6 +15,7 @@ use App\Module\Base; * @property array $turns 可流转 * @property array $userids 自动负责人ID * @property string|null $usertype 流转模式 + * @property int|null $userlimit 限制负责人 * @property int|null $sort 排序 * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at @@ -32,6 +33,7 @@ use App\Module\Base; * @method static \Illuminate\Database\Eloquent\Builder|ProjectFlowItem whereTurns($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectFlowItem whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectFlowItem whereUserids($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectFlowItem whereUserlimit($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectFlowItem whereUsertype($value) * @mixin \Eloquent */ diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 8d9ec0c0..0ecedb3c 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -508,8 +508,19 @@ class ProjectTask extends AbstractModel if ($this->flow_item_id) { // 判断符合流转 $currentFlowItem = ProjectFlowItem::find($this->flow_item_id); - if ($currentFlowItem && !in_array($currentFlowItem->id, $newFlowItem->turns)) { - throw new ApiException("当前状态[{$currentFlowItem->name}]不可流转到[{$newFlowItem->name}]"); + if ($currentFlowItem) { + if (!in_array($currentFlowItem->id, $newFlowItem->turns)) { + throw new ApiException("当前状态[{$currentFlowItem->name}]不可流转到[{$newFlowItem->name}]"); + } + if ($currentFlowItem->userlimit) { + if (!in_array(User::userid(), $currentFlowItem->userids)) { + try { + Project::userProject($this->project_id, true, true); + } catch (Exception) { + throw new ApiException("当前状态[{$currentFlowItem->name}]仅限状态负责人或项目负责人修改"); + } + } + } } } if ($newFlowItem->status == 'end') { diff --git a/database/migrations/2022_01_08_171816_create_project_flow_items_table.php b/database/migrations/2022_01_08_171816_create_project_flow_items_table.php index a681a290..bb327d14 100644 --- a/database/migrations/2022_01_08_171816_create_project_flow_items_table.php +++ b/database/migrations/2022_01_08_171816_create_project_flow_items_table.php @@ -20,7 +20,7 @@ class CreateProjectFlowItemsTable extends Migration $table->string('name', 50)->nullable()->default('')->comment('名称'); $table->string('status', 20)->nullable()->default('')->comment('状态'); $table->string('turns')->nullable()->default('')->comment('可流转'); - $table->string('userids')->nullable()->default('')->comment('自动负责人ID'); + $table->string('userids')->nullable()->default('')->comment('状态负责人ID'); $table->integer('sort')->nullable()->comment('排序'); $table->timestamps(); }); diff --git a/database/migrations/2022_01_12_153411_project_flow_items_add_userlimit.php b/database/migrations/2022_01_12_153411_project_flow_items_add_userlimit.php new file mode 100644 index 00000000..4d1f16ac --- /dev/null +++ b/database/migrations/2022_01_12_153411_project_flow_items_add_userlimit.php @@ -0,0 +1,34 @@ +tinyInteger('userlimit')->nullable()->default(0)->after('usertype')->comment('限制负责人'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('project_flow_items', function (Blueprint $table) { + $table->dropColumn("userlimit"); + }); + } +} diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue index aaa13c15..0e3f20e8 100644 --- a/resources/assets/js/pages/manage/components/ProjectList.vue +++ b/resources/assets/js/pages/manage/components/ProjectList.vue @@ -405,7 +405,7 @@ + :size="1280"> diff --git a/resources/assets/js/pages/manage/components/ProjectWorkflow.vue b/resources/assets/js/pages/manage/components/ProjectWorkflow.vue index 82fd9ee3..1abe0b5a 100644 --- a/resources/assets/js/pages/manage/components/ProjectWorkflow.vue +++ b/resources/assets/js/pages/manage/components/ProjectWorkflow.vue @@ -89,7 +89,7 @@
- {{$L('自动负责人')}} + {{$L('状态负责人')}}
@@ -136,22 +136,27 @@ - +
- - + + {{$L('添加模式')}} {{$L('流转模式')}} -
{{$L('流转到此流程时改变负责人,原本的负责人移至协助人员。')}}
-
{{$L('流转到此流程时添加负责人。')}}
+
{{$L('流转到此状态时改变任务负责人为状态负责人,原本的任务负责人移至协助人员。')}}
+
{{$L('流转到此状态时添加状态负责人至任务负责人。')}}
+
+ + +
{{$L('在此状态的任务仅状态负责人可以修改状态。')}}
+
{{$L('任务负责人和项目管理员都可以修改状态。')}}
@@ -267,6 +272,7 @@ export default { "turns": [-10, -11, -12, -13], "userids": [], "usertype": 'add', + "userlimit": 0, }, { "id": -11, @@ -275,6 +281,7 @@ export default { "turns": [-10, -11, -12, -13], "userids": [], "usertype": 'add', + "userlimit": 0, }, { "id": -12, @@ -283,6 +290,7 @@ export default { "turns": [-10, -11, -12, -13], "userids": [], "usertype": 'add', + "userlimit": 0, }, { "id": -13, @@ -291,6 +299,7 @@ export default { "turns": [-10, -11, -12, -13], "userids": [], "usertype": 'add', + "userlimit": 0, } ] }) @@ -343,6 +352,7 @@ export default { this.$set(this.userData, 'name', item.name); this.$set(this.userData, 'userids', item.userids); this.$set(this.userData, 'usertype', item.usertype); + this.$set(this.userData, 'userlimit', item.userlimit); this.userShow = true; break; @@ -363,6 +373,7 @@ export default { if (item) { this.$set(item, 'userids', this.userData.userids) this.$set(item, 'usertype', this.userData.usertype) + this.$set(item, 'userlimit', this.userData.userlimit) } }) }, @@ -409,6 +420,7 @@ export default { turns, userids: [], usertype: 'add', + userlimit: 0, }) data.project_flow_item.some(item => { item.turns.push(id) diff --git a/resources/assets/sass/pages/common.scss b/resources/assets/sass/pages/common.scss index 9c16a587..256c40c6 100755 --- a/resources/assets/sass/pages/common.scss +++ b/resources/assets/sass/pages/common.scss @@ -2,6 +2,8 @@ body { overflow: hidden; .form-tip { color: #999999; + line-height: 22px; + padding: 5px 0; } .ivu-input, .ivu-select-selection { diff --git a/resources/assets/sass/pages/components/project-workflow.scss b/resources/assets/sass/pages/components/project-workflow.scss index 041ac17b..c7b835e5 100644 --- a/resources/assets/sass/pages/components/project-workflow.scss +++ b/resources/assets/sass/pages/components/project-workflow.scss @@ -106,7 +106,7 @@ .taskflow-config { display: flex; - max-height: 580px; + max-height: 800px; .taskflow-config-table { display: flex;