feat: 工作流程状态支持仅限状态负责人修改
This commit is contained in:
parent
f2180b22c7
commit
f80b9cdca5
@ -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;
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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') {
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ProjectFlowItemsAddUserlimit extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('project_flow_items', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('project_flow_items', 'userlimit')) {
|
||||
$table->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");
|
||||
});
|
||||
}
|
||||
}
|
@ -405,7 +405,7 @@
|
||||
<DrawerOverlay
|
||||
v-model="workflowShow"
|
||||
placement="right"
|
||||
:size="1200">
|
||||
:size="1280">
|
||||
<ProjectWorkflow v-if="workflowShow" :project-id="projectId"/>
|
||||
</DrawerOverlay>
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
||||
<EDropdownItem command="user">
|
||||
<div class="item">
|
||||
<Icon type="md-person" />
|
||||
{{$L('自动负责人')}}
|
||||
{{$L('状态负责人')}}
|
||||
</div>
|
||||
</EDropdownItem>
|
||||
<EDropdownItem command="name">
|
||||
@ -136,22 +136,27 @@
|
||||
<Button type="primary" @click="onCreate">{{$L('创建工作流')}}</Button>
|
||||
</div>
|
||||
|
||||
<!--成员管理-->
|
||||
<!--状态负责人-->
|
||||
<Modal
|
||||
v-model="userShow"
|
||||
:title="$L('自动负责人')"
|
||||
:title="`${$L('状态负责人')} (${userData.name})`"
|
||||
:mask-closable="false">
|
||||
<Form :model="userData" label-width="auto" @submit.native.prevent>
|
||||
<FormItem prop="userids" :label="userData.name">
|
||||
<UserInput v-if="userShow" v-model="userData.userids" :project-id="projectId" :multiple-max="5" :placeholder="$L('选择成员')"/>
|
||||
<FormItem prop="userids" :label="$L('状态负责人')">
|
||||
<UserInput v-if="userShow" v-model="userData.userids" :project-id="projectId" :multiple-max="5" :placeholder="$L('选择状态负责人')"/>
|
||||
</FormItem>
|
||||
<FormItem prop="usertype" :label="$L('流转模式')">
|
||||
<RadioGroup v-model="userData.usertype">
|
||||
<Radio label="add">{{$L('添加模式')}}</Radio>
|
||||
<Radio label="replace">{{$L('流转模式')}}</Radio>
|
||||
</RadioGroup>
|
||||
<div v-if="userData.usertype=='replace'" class="form-tip">{{$L('流转到此流程时改变负责人,原本的负责人移至协助人员。')}}</div>
|
||||
<div v-else class="form-tip">{{$L('流转到此流程时添加负责人。')}}</div>
|
||||
<div v-if="userData.usertype=='replace'" class="form-tip">{{$L('流转到此状态时改变任务负责人为状态负责人,原本的任务负责人移至协助人员。')}}</div>
|
||||
<div v-else class="form-tip">{{$L('流转到此状态时添加状态负责人至任务负责人。')}}</div>
|
||||
</FormItem>
|
||||
<FormItem prop="userlimit" :label="$L('限制负责人')">
|
||||
<iSwitch v-model="userData.userlimit" :true-value="1" :false-value="0"/>
|
||||
<div v-if="userData.userlimit===1" class="form-tip">{{$L('在此状态的任务仅状态负责人可以修改状态。')}}</div>
|
||||
<div v-else class="form-tip">{{$L('任务负责人和项目管理员都可以修改状态。')}}</div>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer" class="adaption">
|
||||
@ -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)
|
||||
|
2
resources/assets/sass/pages/common.scss
vendored
2
resources/assets/sass/pages/common.scss
vendored
@ -2,6 +2,8 @@ body {
|
||||
overflow: hidden;
|
||||
.form-tip {
|
||||
color: #999999;
|
||||
line-height: 22px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
.ivu-input,
|
||||
.ivu-select-selection {
|
||||
|
@ -106,7 +106,7 @@
|
||||
|
||||
.taskflow-config {
|
||||
display: flex;
|
||||
max-height: 580px;
|
||||
max-height: 800px;
|
||||
|
||||
.taskflow-config-table {
|
||||
display: flex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user