Skip to content

Commit 5efdd93

Browse files
committed
feat: BPM-更多设置-流程编码
1 parent 22eb2cc commit 5efdd93

File tree

2 files changed

+133
-5
lines changed

2 files changed

+133
-5
lines changed

src/views/bpm/model/form/ExtraSettings.vue

+121-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,132 @@
44
<template #label>
55
<el-text size="large" tag="b">提交人权限</el-text>
66
</template>
7-
<el-checkbox v-model="modelData.allowCancelRunningProcess" label="允许撤销审批中的申请" />
8-
<div class="ml-22px">
9-
<el-text type="info"> 第一个审批节点通过后,提交人仍可撤销申请 </el-text>
7+
<div class="flex flex-col">
8+
<el-checkbox v-model="modelData.allowCancelRunningProcess" label="允许撤销审批中的申请" />
9+
<div class="ml-22px">
10+
<el-text type="info"> 第一个审批节点通过后,提交人仍可撤销申请 </el-text>
11+
</div>
12+
</div>
13+
</el-form-item>
14+
<el-form-item v-if="modelData.processIdRule" class="mb-20px">
15+
<template #label>
16+
<el-text size="large" tag="b">流程编码</el-text>
17+
</template>
18+
<div class="flex flex-col">
19+
<div>
20+
<el-input
21+
v-model="modelData.processIdRule.prefix"
22+
class="w-130px!"
23+
placeholder="前缀"
24+
:disabled="!modelData.processIdRule.enable"
25+
>
26+
<template #prepend>
27+
<el-checkbox v-model="modelData.processIdRule.enable" />
28+
</template>
29+
</el-input>
30+
<el-select
31+
v-model="modelData.processIdRule.infix"
32+
class="w-130px! ml-5px"
33+
placeholder="中缀"
34+
:disabled="!modelData.processIdRule.enable"
35+
>
36+
<el-option
37+
v-for="item in timeOptions"
38+
:key="item.value"
39+
:label="item.label"
40+
:value="item.value"
41+
/>
42+
</el-select>
43+
<el-input
44+
v-model="modelData.processIdRule.postfix"
45+
class="w-80px! ml-5px"
46+
placeholder="后缀"
47+
:disabled="!modelData.processIdRule.enable"
48+
/>
49+
<el-input-number
50+
v-model="modelData.processIdRule.length"
51+
class="w-120px! ml-5px"
52+
:min="5"
53+
:disabled="!modelData.processIdRule.enable"
54+
/>
55+
</div>
56+
<div class="ml-22px" v-if="modelData.processIdRule.enable">
57+
<el-text type="info"> 编码示例:{{ numberExample }} </el-text>
58+
</div>
1059
</div>
1160
</el-form-item>
1261
</el-form>
1362
</template>
1463

1564
<script setup lang="ts">
65+
import dayjs from 'dayjs'
66+
1667
const modelData = defineModel<any>()
68+
69+
const timeOptions = ref([
70+
{
71+
value: 'NULL',
72+
label: ''
73+
},
74+
{
75+
value: 'DAY',
76+
label: '精确到日'
77+
},
78+
{
79+
value: 'HOUR',
80+
label: '精确到时'
81+
},
82+
{
83+
value: 'MINUTE',
84+
label: '精确到分'
85+
},
86+
{
87+
value: 'SECOND',
88+
label: '精确到秒'
89+
}
90+
])
91+
92+
const numberExample = computed(() => {
93+
if (modelData.value.processIdRule.enable) {
94+
let infix = ''
95+
switch (modelData.value.processIdRule.infix) {
96+
case 'DAY':
97+
infix = dayjs().format('YYYYMMDD')
98+
break
99+
case 'HOUR':
100+
infix = dayjs().format('YYYYMMDDHH')
101+
break
102+
case 'MINUTE':
103+
infix = dayjs().format('YYYYMMDDHHmm')
104+
break
105+
case 'SECOND':
106+
infix = dayjs().format('YYYYMMDDHHmmss')
107+
break
108+
default:
109+
break
110+
}
111+
return (
112+
modelData.value.processIdRule.prefix +
113+
infix +
114+
modelData.value.processIdRule.postfix +
115+
'1'.padStart(modelData.value.processIdRule.length - 1, '0')
116+
)
117+
} else {
118+
return ''
119+
}
120+
})
121+
122+
// 兼容以前未配置更多设置的流程
123+
const initData = () => {
124+
if (!modelData.value.processIdRule) {
125+
modelData.value.processIdRule = {
126+
enable: false,
127+
prefix: '',
128+
infix: '',
129+
postfix: '',
130+
length: 5
131+
}
132+
}
133+
}
134+
defineExpose({ initData })
17135
</script>

src/views/bpm/model/form/index.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<ProcessDesign v-if="currentStep === 2" v-model="formData" ref="processDesignRef" />
7171

7272
<!-- 第四步:更多设置 -->
73-
<div v-if="currentStep === 3" class="mx-auto w-700px">
73+
<div v-show="currentStep === 3" class="mx-auto w-700px">
7474
<ExtraSettings v-model="formData" ref="extraSettingsRef" />
7575
</div>
7676
</div>
@@ -103,6 +103,7 @@ const userStore = useUserStoreWithOut()
103103
const basicInfoRef = ref()
104104
const formDesignRef = ref()
105105
const processDesignRef = ref()
106+
const extraSettingsRef = ref()
106107
107108
/** 步骤校验函数 */
108109
const validateBasic = async () => {
@@ -145,7 +146,14 @@ const formData: any = ref({
145146
startUserType: undefined,
146147
startUserIds: [],
147148
managerUserIds: [],
148-
allowCancelRunningProcess: true
149+
allowCancelRunningProcess: true,
150+
processIdRule: {
151+
enable: false,
152+
prefix: '',
153+
infix: '',
154+
postfix: '',
155+
length: 5
156+
}
149157
})
150158
151159
//流程数据
@@ -187,6 +195,8 @@ const initData = async () => {
187195
188196
// 最终,设置 currentStep 切换到第一步
189197
currentStep.value = 0
198+
199+
extraSettingsRef.value.initData()
190200
}
191201
192202
/** 根据类型切换流程数据 */

0 commit comments

Comments
 (0)