|
|
@@ -47,12 +47,18 @@
|
|
|
</el-row>
|
|
|
<el-divider>条件选择</el-divider>
|
|
|
<el-row :gutter="20">
|
|
|
- <!-- <el-col :span="8">
|
|
|
- <el-form-item label="借用天数大于" prop="condition.days">
|
|
|
- <el-input-number v-model="form.condition.days" :min="1" controls-position="right" style="width: 100px" />
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="最少借用天数" prop="condition.min_days">
|
|
|
+ <el-input-number v-model="form.condition.min_days" :min="1" controls-position="right" style="width: 100px" />
|
|
|
<span style="margin-left: 8px">天</span>
|
|
|
</el-form-item>
|
|
|
- </el-col> -->
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="最多借用天数" prop="condition.max_days">
|
|
|
+ <el-input-number v-model="form.condition.max_days" :min="1" controls-position="right" style="width: 100px" />
|
|
|
+ <span style="margin-left: 8px">天</span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="用户角色" prop="condition.roles">
|
|
|
<el-checkbox-group v-model="form.condition.roles">
|
|
|
@@ -78,17 +84,17 @@
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="借用类型" prop="condition.borrow_types">
|
|
|
<el-checkbox-group v-model="form.condition.borrow_types" :disabled="props.mode === 'view'">
|
|
|
- <el-checkbox label="常规借用" value="0"></el-checkbox>
|
|
|
- <el-checkbox label="课堂借用" value="1"></el-checkbox>
|
|
|
- <el-checkbox label="特殊借用" value="2"></el-checkbox>
|
|
|
+ <el-checkbox :label="'0'">常规借用</el-checkbox>
|
|
|
+ <el-checkbox :label="'1'">课堂借用</el-checkbox>
|
|
|
+ <el-checkbox :label="'2'">特殊借用</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="借用方式" prop="condition.team_type">
|
|
|
<el-checkbox-group v-model="form.condition.team_type" :disabled="props.mode === 'view'">
|
|
|
- <el-checkbox label="个人借用" value="0"></el-checkbox>
|
|
|
- <el-checkbox label="团队借用" value="1"></el-checkbox>
|
|
|
+ <el-checkbox :label="'0'">个人借用</el-checkbox>
|
|
|
+ <el-checkbox :label="'1'">团队借用</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -127,8 +133,8 @@
|
|
|
<el-option label="学院领导" value="学院领导" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <!-- <el-form-item
|
|
|
- v-if="role.name === '学院领导'"
|
|
|
+ <el-form-item
|
|
|
+ v-if="role.name === '学院领导审批'||role.name === '学院领导'"
|
|
|
:label="'领导姓名'"
|
|
|
:label-position="'left'"
|
|
|
label-width="100px"
|
|
|
@@ -147,7 +153,7 @@
|
|
|
:value="user.id"
|
|
|
/>
|
|
|
</el-select>
|
|
|
- </el-form-item> -->
|
|
|
+ </el-form-item>
|
|
|
<el-form-item
|
|
|
:label="'通过条件'"
|
|
|
:label-position="'left'"
|
|
|
@@ -273,7 +279,8 @@ const form = reactive({
|
|
|
description: '',
|
|
|
is_active: true,
|
|
|
condition: {
|
|
|
- days: 1,
|
|
|
+ min_days: 1,
|
|
|
+ max_days: null as number | null,
|
|
|
roles: [],
|
|
|
equipment: [],
|
|
|
borrow_types: [],
|
|
|
@@ -287,7 +294,20 @@ const rules = reactive({
|
|
|
workflow_type: [{ required: true, message: '请选择流程类型', trigger: 'change' }],
|
|
|
description: [{ required: true, message: '请输入流程描述', trigger: 'blur' }],
|
|
|
is_active:[{ required: true, message: '请输选择是否启用', trigger: 'blur' }],
|
|
|
- 'condition.days': [{ required: true, message: '请输入借用天数', trigger: 'change' }],
|
|
|
+ 'condition.min_days': [{ required: true, message: '请输入最少借用天数', trigger: 'change' }],
|
|
|
+ 'condition.max_days': [{
|
|
|
+ required: false,
|
|
|
+ validator: (_rule: any, value: number | null, callback: (err?: Error) => void) => {
|
|
|
+ const min = form.condition.min_days;
|
|
|
+ if (value == null || value === undefined || value === ('' as any)) {
|
|
|
+ return callback();
|
|
|
+ }
|
|
|
+ if (typeof value === 'number' && typeof min === 'number' && value < min) {
|
|
|
+ return callback(new Error('最多借用天数不能小于最少借用天数'));
|
|
|
+ }
|
|
|
+ return callback();
|
|
|
+ }, trigger: 'change'
|
|
|
+ }],
|
|
|
'condition.roles': [{ required: true, message: '请选择用户角色', trigger: 'change' }],
|
|
|
'condition.equipment': [{ required: false, message: '请选择设备标签', trigger: 'change' }],
|
|
|
'condition.borrow_types': [{ required: true, message: '请选择借用类型', trigger: 'change' }],
|
|
|
@@ -318,7 +338,7 @@ watch(
|
|
|
() => props.editData,
|
|
|
async (val) => {
|
|
|
// eslint-disable-next-line no-console
|
|
|
- console.error("编辑时获取到的值val:", val);
|
|
|
+ console.log("编辑时获取到的值val:", val);
|
|
|
if (val) {
|
|
|
// Object.assign(form, JSON.parse(JSON.stringify(val)));
|
|
|
const cloned = JSON.parse(JSON.stringify(val));
|
|
|
@@ -330,22 +350,26 @@ watch(
|
|
|
|
|
|
const tc = cloned.trigger_conditions || {};
|
|
|
form.condition = {
|
|
|
- days: 1,
|
|
|
+ min_days: cloned.duration_rules?.[0]?.min_days,
|
|
|
+ max_days: cloned.duration_rules?.[0]?.max_days,
|
|
|
roles: tc.user_types || [],
|
|
|
equipment: Array.isArray(tc.equipment_categories) ? tc.equipment_categories[0] : '',
|
|
|
- borrow_types: tc.borrow_types || [],
|
|
|
- team_type: tc.team_type || [],
|
|
|
+ borrow_types: Array.isArray(cloned.duration_rules?.[0]?.borrow_types)
|
|
|
+ ? cloned.duration_rules[0].borrow_types.map((x: any) => String(x))
|
|
|
+ : [],
|
|
|
+ team_type: Array.isArray(tc.team_type) ? tc.team_type.map((x: any) => String(x)) : [],
|
|
|
};
|
|
|
|
|
|
// 获取工作流步骤信息
|
|
|
const workflowSteps = await firstapi.GetInfo(cloned.id);
|
|
|
+ console.log("workflowSteps",workflowSteps)
|
|
|
if (workflowSteps && workflowSteps.data) {
|
|
|
editId.value = workflowSteps.data[0].id;
|
|
|
form.steps = workflowSteps.data.map((step: any) => ({
|
|
|
roles: [{
|
|
|
name: step.step_name || '',
|
|
|
passType: String(step.step_type ?? '1'),
|
|
|
- leaderId:step.leaderId||null,
|
|
|
+ leaderId:step.app_approver_names.join(",")||null,
|
|
|
}],
|
|
|
}));
|
|
|
} else {
|
|
|
@@ -359,7 +383,7 @@ watch(
|
|
|
form.workflow_type = "0";
|
|
|
form.description = '';
|
|
|
form.is_active = true;
|
|
|
- form.condition = { days: 1, roles: [], equipment: [], borrow_types: [],team_type:[] };
|
|
|
+ form.condition = { min_days: 1, max_days: null, roles: [], equipment: [], borrow_types: [],team_type:[] };
|
|
|
form.steps = [defaultStep()];
|
|
|
}
|
|
|
generateStepRules();
|
|
|
@@ -420,10 +444,13 @@ async function onSave() {
|
|
|
description: form.description,
|
|
|
is_active: typeof form.is_active === 'boolean' ? form.is_active : true,
|
|
|
trigger_conditions: {
|
|
|
+ min_days: form.condition?.min_days,
|
|
|
+ max_days: form.condition?.max_days,
|
|
|
equipment_categories: form.condition?.equipment ? [form.condition.equipment] : ['贵重设备'],
|
|
|
borrow_types: form.condition?.borrow_types?.length ? form.condition.borrow_types : ['0', '1', '2'],
|
|
|
team_type: form.condition?.team_type?.length ? form.condition.team_type : ['0', '1'],
|
|
|
user_types: form.condition?.roles?.length ? form.condition.roles:['student', 'teacher'],
|
|
|
+ require_approval:true
|
|
|
},
|
|
|
};
|
|
|
|