Skip to content

Commit 501a1c2

Browse files
committed
BPM:新增流程分类表,替代现有的 bpm_category 数据字典
1 parent a0f157c commit 501a1c2

File tree

10 files changed

+457
-83
lines changed

10 files changed

+457
-83
lines changed

src/api/bpm/category/index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import request from '@/config/axios'
2+
3+
// BPM 流程分类 VO
4+
export interface CategoryVO {
5+
id: number // 分类编号
6+
name: string // 分类名
7+
code: string // 分类标志
8+
status: number // 分类状态
9+
sort: number // 分类排序
10+
}
11+
12+
// BPM 流程分类 API
13+
export const CategoryApi = {
14+
// 查询流程分类分页
15+
getCategoryPage: async (params: any) => {
16+
return await request.get({ url: `/bpm/category/page`, params })
17+
},
18+
19+
// 查询流程分类列表
20+
getCategorySimpleList: async () => {
21+
return await request.get({ url: `/bpm/category/simple-list` })
22+
},
23+
24+
// 查询流程分类详情
25+
getCategory: async (id: number) => {
26+
return await request.get({ url: `/bpm/category/get?id=` + id })
27+
},
28+
29+
// 新增流程分类
30+
createCategory: async (data: CategoryVO) => {
31+
return await request.post({ url: `/bpm/category/create`, data })
32+
},
33+
34+
// 修改流程分类
35+
updateCategory: async (data: CategoryVO) => {
36+
return await request.put({ url: `/bpm/category/update`, data })
37+
},
38+
39+
// 删除流程分类
40+
deleteCategory: async (id: number) => {
41+
return await request.delete({ url: `/bpm/category/delete?id=` + id })
42+
}
43+
}

src/router/modules/remaining.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,6 @@ const remainingRouter: AppRouteRecordRaw[] = [
278278
activeMenu: '/bpm/manager/model'
279279
}
280280
},
281-
{
282-
path: '/process-instance/create',
283-
component: () => import('@/views/bpm/processInstance/create/index.vue'),
284-
name: 'BpmProcessInstanceCreate',
285-
meta: {
286-
noCache: true,
287-
hidden: true,
288-
canTo: true,
289-
title: '发起流程',
290-
activeMenu: 'bpm/processInstance/create'
291-
}
292-
},
293281
{
294282
path: '/process-instance/detail',
295283
component: () => import('@/views/bpm/processInstance/detail/index.vue'),

src/utils/dict.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,10 @@ export enum DICT_TYPE {
136136
INFRA_FILE_STORAGE = 'infra_file_storage',
137137

138138
// ========== BPM 模块 ==========
139-
BPM_MODEL_CATEGORY = 'bpm_model_category',
140139
BPM_MODEL_FORM_TYPE = 'bpm_model_form_type',
141140
BPM_TASK_CANDIDATE_STRATEGY = 'bpm_task_candidate_strategy',
142141
BPM_PROCESS_INSTANCE_STATUS = 'bpm_process_instance_status',
143-
BPM_PROCESS_INSTANCE_RESULT = 'bpm_process_instance_result',
142+
BPM_PROCESS_INSTANCE_RESULT = 'bpm_process_instance_result', // TODO @芋艿:改名
144143
BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type',
145144

146145
// ========== PAY 模块 ==========
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<template>
2+
<Dialog :title="dialogTitle" v-model="dialogVisible">
3+
<el-form
4+
ref="formRef"
5+
:model="formData"
6+
:rules="formRules"
7+
label-width="100px"
8+
v-loading="formLoading"
9+
>
10+
<el-form-item label="分类名" prop="name">
11+
<el-input v-model="formData.name" placeholder="请输入分类名" />
12+
</el-form-item>
13+
<el-form-item label="分类标志" prop="code">
14+
<el-input v-model="formData.code" placeholder="请输入分类标志" />
15+
</el-form-item>
16+
<el-form-item label="分类状态" prop="status">
17+
<el-radio-group v-model="formData.status">
18+
<el-radio
19+
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
20+
:key="dict.value"
21+
:label="dict.value"
22+
>
23+
{{ dict.label }}
24+
</el-radio>
25+
</el-radio-group>
26+
</el-form-item>
27+
<el-form-item label="分类排序" prop="sort">
28+
<el-input-number
29+
v-model="formData.sort"
30+
placeholder="请输入分类排序"
31+
class="!w-1/1"
32+
:precision="0"
33+
/>
34+
</el-form-item>
35+
</el-form>
36+
<template #footer>
37+
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
38+
<el-button @click="dialogVisible = false">取 消</el-button>
39+
</template>
40+
</Dialog>
41+
</template>
42+
<script setup lang="ts">
43+
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
44+
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
45+
46+
/** BPM 流程分类 表单 */
47+
defineOptions({ name: 'CategoryForm' })
48+
49+
const { t } = useI18n() // 国际化
50+
const message = useMessage() // 消息弹窗
51+
52+
const dialogVisible = ref(false) // 弹窗的是否展示
53+
const dialogTitle = ref('') // 弹窗的标题
54+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
55+
const formType = ref('') // 表单的类型:create - 新增;update - 修改
56+
const formData = ref({
57+
id: undefined,
58+
name: undefined,
59+
code: undefined,
60+
status: undefined,
61+
sort: undefined
62+
})
63+
const formRules = reactive({
64+
name: [{ required: true, message: '分类名不能为空', trigger: 'blur' }],
65+
code: [{ required: true, message: '分类标志不能为空', trigger: 'blur' }],
66+
status: [{ required: true, message: '分类状态不能为空', trigger: 'blur' }],
67+
sort: [{ required: true, message: '分类排序不能为空', trigger: 'blur' }]
68+
})
69+
const formRef = ref() // 表单 Ref
70+
71+
/** 打开弹窗 */
72+
const open = async (type: string, id?: number) => {
73+
dialogVisible.value = true
74+
dialogTitle.value = t('action.' + type)
75+
formType.value = type
76+
resetForm()
77+
// 修改时,设置数据
78+
if (id) {
79+
formLoading.value = true
80+
try {
81+
formData.value = await CategoryApi.getCategory(id)
82+
} finally {
83+
formLoading.value = false
84+
}
85+
}
86+
}
87+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
88+
89+
/** 提交表单 */
90+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
91+
const submitForm = async () => {
92+
// 校验表单
93+
await formRef.value.validate()
94+
// 提交请求
95+
formLoading.value = true
96+
try {
97+
const data = formData.value as unknown as CategoryVO
98+
if (formType.value === 'create') {
99+
await CategoryApi.createCategory(data)
100+
message.success(t('common.createSuccess'))
101+
} else {
102+
await CategoryApi.updateCategory(data)
103+
message.success(t('common.updateSuccess'))
104+
}
105+
dialogVisible.value = false
106+
// 发送操作成功的事件
107+
emit('success')
108+
} finally {
109+
formLoading.value = false
110+
}
111+
}
112+
113+
/** 重置表单 */
114+
const resetForm = () => {
115+
formData.value = {
116+
id: undefined,
117+
name: undefined,
118+
code: undefined,
119+
status: undefined,
120+
sort: undefined
121+
}
122+
formRef.value?.resetFields()
123+
}
124+
</script>

src/views/bpm/category/index.vue

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<template>
2+
<ContentWrap>
3+
<!-- 搜索工作栏 -->
4+
<el-form
5+
class="-mb-15px"
6+
:model="queryParams"
7+
ref="queryFormRef"
8+
:inline="true"
9+
label-width="68px"
10+
>
11+
<el-form-item label="分类名" prop="name">
12+
<el-input
13+
v-model="queryParams.name"
14+
placeholder="请输入分类名"
15+
clearable
16+
@keyup.enter="handleQuery"
17+
class="!w-240px"
18+
/>
19+
</el-form-item>
20+
<el-form-item label="分类标志" prop="code">
21+
<el-input
22+
v-model="queryParams.code"
23+
placeholder="请输入分类标志"
24+
clearable
25+
@keyup.enter="handleQuery"
26+
class="!w-240px"
27+
/>
28+
</el-form-item>
29+
<el-form-item label="分类状态" prop="status">
30+
<el-select
31+
v-model="queryParams.status"
32+
placeholder="请选择分类状态"
33+
clearable
34+
class="!w-240px"
35+
>
36+
<el-option
37+
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
38+
:key="dict.value"
39+
:label="dict.label"
40+
:value="dict.value"
41+
/>
42+
</el-select>
43+
</el-form-item>
44+
<el-form-item label="创建时间" prop="createTime">
45+
<el-date-picker
46+
v-model="queryParams.createTime"
47+
value-format="YYYY-MM-DD HH:mm:ss"
48+
type="daterange"
49+
start-placeholder="开始日期"
50+
end-placeholder="结束日期"
51+
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
52+
class="!w-240px"
53+
/>
54+
</el-form-item>
55+
<el-form-item>
56+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
57+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
58+
<el-button
59+
type="primary"
60+
plain
61+
@click="openForm('create')"
62+
v-hasPermi="['bpm:category:create']"
63+
>
64+
<Icon icon="ep:plus" class="mr-5px" /> 新增
65+
</el-button>
66+
</el-form-item>
67+
</el-form>
68+
</ContentWrap>
69+
70+
<!-- 列表 -->
71+
<ContentWrap>
72+
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
73+
<el-table-column label="分类编号" align="center" prop="id" />
74+
<el-table-column label="分类名" align="center" prop="name" />
75+
<el-table-column label="分类标志" align="center" prop="code" />
76+
<el-table-column label="分类描述" align="center" prop="description" />
77+
<el-table-column label="分类状态" align="center" prop="status">
78+
<template #default="scope">
79+
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
80+
</template>
81+
</el-table-column>
82+
<el-table-column label="分类排序" align="center" prop="sort" />
83+
<el-table-column
84+
label="创建时间"
85+
align="center"
86+
prop="createTime"
87+
:formatter="dateFormatter"
88+
width="180px"
89+
/>
90+
<el-table-column label="操作" align="center">
91+
<template #default="scope">
92+
<el-button
93+
link
94+
type="primary"
95+
@click="openForm('update', scope.row.id)"
96+
v-hasPermi="['bpm:category:update']"
97+
>
98+
编辑
99+
</el-button>
100+
<el-button
101+
link
102+
type="danger"
103+
@click="handleDelete(scope.row.id)"
104+
v-hasPermi="['bpm:category:delete']"
105+
>
106+
删除
107+
</el-button>
108+
</template>
109+
</el-table-column>
110+
</el-table>
111+
<!-- 分页 -->
112+
<Pagination
113+
:total="total"
114+
v-model:page="queryParams.pageNo"
115+
v-model:limit="queryParams.pageSize"
116+
@pagination="getList"
117+
/>
118+
</ContentWrap>
119+
120+
<!-- 表单弹窗:添加/修改 -->
121+
<CategoryForm ref="formRef" @success="getList" />
122+
</template>
123+
124+
<script setup lang="ts">
125+
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
126+
import { dateFormatter } from '@/utils/formatTime'
127+
import download from '@/utils/download'
128+
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
129+
import CategoryForm from './CategoryForm.vue'
130+
131+
/** BPM 流程分类 列表 */
132+
defineOptions({ name: 'BpmCategory' })
133+
134+
const message = useMessage() // 消息弹窗
135+
const { t } = useI18n() // 国际化
136+
137+
const loading = ref(true) // 列表的加载中
138+
const list = ref<CategoryVO[]>([]) // 列表的数据
139+
const total = ref(0) // 列表的总页数
140+
const queryParams = reactive({
141+
pageNo: 1,
142+
pageSize: 10,
143+
name: undefined,
144+
code: undefined,
145+
status: undefined,
146+
createTime: []
147+
})
148+
const queryFormRef = ref() // 搜索的表单
149+
const exportLoading = ref(false) // 导出的加载中
150+
151+
/** 查询列表 */
152+
const getList = async () => {
153+
loading.value = true
154+
try {
155+
const data = await CategoryApi.getCategoryPage(queryParams)
156+
list.value = data.list
157+
total.value = data.total
158+
} finally {
159+
loading.value = false
160+
}
161+
}
162+
163+
/** 搜索按钮操作 */
164+
const handleQuery = () => {
165+
queryParams.pageNo = 1
166+
getList()
167+
}
168+
169+
/** 重置按钮操作 */
170+
const resetQuery = () => {
171+
queryFormRef.value.resetFields()
172+
handleQuery()
173+
}
174+
175+
/** 添加/修改操作 */
176+
const formRef = ref()
177+
const openForm = (type: string, id?: number) => {
178+
formRef.value.open(type, id)
179+
}
180+
181+
/** 删除按钮操作 */
182+
const handleDelete = async (id: number) => {
183+
try {
184+
// 删除的二次确认
185+
await message.delConfirm()
186+
// 发起删除
187+
await CategoryApi.deleteCategory(id)
188+
message.success(t('common.delSuccess'))
189+
// 刷新列表
190+
await getList()
191+
} catch {}
192+
}
193+
194+
/** 初始化 **/
195+
onMounted(() => {
196+
getList()
197+
})
198+
</script>

0 commit comments

Comments
 (0)