feat: bpm api

This commit is contained in:
xingyu 2022-07-28 12:18:38 +08:00
parent 88fc7ed39b
commit ee6317e906
20 changed files with 827 additions and 15 deletions

View File

@ -0,0 +1,48 @@
import { useAxios } from '@/hooks/web/useAxios'
import { FormVO } from './types'
const request = useAxios()
// 创建工作流的表单定义
export const createFormApi = async (data: FormVO) => {
return await request.post({
url: '/bpm/form/create',
data: data
})
}
// 更新工作流的表单定义
export const updateFormApi = async (data: FormVO) => {
return await request.put({
url: '/bpm/form/update',
data: data
})
}
// 删除工作流的表单定义
export const deleteFormApi = async (id: number) => {
return await request.delete({
url: '/bpm/form/delete?id=' + id
})
}
// 获得工作流的表单定义
export const getFormApi = async (id: number) => {
return await request.get({
url: '/bpm/form/get?id=' + id
})
}
// 获得工作流的表单定义分页
export const getFormPageApi = async (params) => {
return await request.get({
url: '/bpm/form/page',
params
})
}
// 获得动态表单的精简列表
export const getSimpleFormsApi = async () => {
return await request.get({
url: '/bpm/form/list-all-simple'
})
}

View File

@ -0,0 +1,9 @@
export type FormVO = {
id: number
name: string
conf: string
fields: string[]
status: number
remark: string
createTime: string
}

View File

@ -0,0 +1,18 @@
import { useAxios } from '@/hooks/web/useAxios'
import { LeaveVO } from './types'
const request = useAxios()
// 创建请假申请
export const createLeaveApi = async (data: LeaveVO) => {
return await request.post({ url: '/bpm/oa/leave/create', data: data })
}
// 获得请假申请
export const getLeaveApi = async (id: number) => {
return await request.get({ url: '/bpm/oa/leave/get?id=' + id })
}
// 获得请假申请分页
export const getLeavePageApi = async (params) => {
return await request.get({ url: '/bpm/oa/leave/page', params })
}

View File

@ -0,0 +1,10 @@
export type LeaveVO = {
id: number
result: number
type: number
reason: string
processInstanceId: string
startTime: string
endTime: string
createTime: string
}

View File

@ -0,0 +1,36 @@
import { useAxios } from '@/hooks/web/useAxios'
import { ModelVO } from './types'
const request = useAxios()
export const getModelPage = async (params) => {
return await request.get({ url: '/bpm/model/page', params })
}
export const getModel = async (id: number) => {
return await request.get({ url: '/bpm/model/get?id=' + id })
}
export const updateModel = async (data: ModelVO) => {
return await request.put({ url: '/bpm/model/update', data: data })
}
// 任务状态修改
export const updateModelState = async (id: number, state: string) => {
const data = {
id: id,
state: state
}
return await request.put({ url: '/bpm/model/update-state', data: data })
}
export const createModel = async (data: ModelVO) => {
return await request.post({ url: '/bpm/model/create', data: data })
}
export const deleteModel = async (id: number) => {
return await request.delete({ url: '/bpm/model/delete?id=' + id })
}
export const deployModel = async (id: number) => {
return await request.post({ url: '/bpm/model/deploy?id=' + id })
}

View File

@ -0,0 +1,15 @@
export type ModelVO = {
id: number
formName: string
key: string
name: string
description: string
category: string
formType: number
formId: number
formCustomCreatePath: string
formCustomViewPath: string
status: number
remark: string
createTime: string
}

View File

@ -0,0 +1,23 @@
import { useAxios } from '@/hooks/web/useAxios'
import { ProcessInstanceVO } from './types'
const request = useAxios()
export const getMyProcessInstancePage = async (params) => {
return await request.get({ url: '/bpm/process-instance/my-page', params })
}
export const createProcessInstance = async (data: ProcessInstanceVO) => {
return await request.post({ url: '/bpm/process-instance/create', data: data })
}
export const cancelProcessInstance = async (id: number, reason: string) => {
const data = {
id: id,
reason: reason
}
return await request.delete({ url: '/bpm/process-instance/cancel', data: data })
}
export const getProcessInstance = async (id: number) => {
return await request.get({ url: '/bpm/process-instance/get?id=' + id })
}

View File

@ -0,0 +1,18 @@
export type task = {
id: string
name: string
}
export type ProcessInstanceVO = {
id: number
name: string
processDefinitionId: string
category: string
result: number
tasks: task[]
fields: string[]
status: number
remark: string
businessKey: string
createTime: string
endTime: string
}

View File

@ -0,0 +1,36 @@
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
export const getTodoTaskPage = async (params) => {
return await request.get({ url: '/bpm/task/todo-page', params })
}
export const getDoneTaskPage = async (params) => {
return await request.get({ url: '/bpm/task/done-page', params })
}
export const completeTask = async (data) => {
return await request.put({ url: '/bpm/task/complete', data: data })
}
export const approveTask = async (data) => {
return await request.put({ url: '/bpm/task/approve', data: data })
}
export const rejectTask = async (data) => {
return await request.put({ url: '/bpm/task/reject', data: data })
}
export const backTask = async (data) => {
return await request.put({ url: '/bpm/task/back', data: data })
}
export const updateTaskAssignee = async (data) => {
return await request.put({ url: '/bpm/task/update-assignee', data: data })
}
export const getTaskListByProcessInstanceId = async (processInstanceId) => {
return await request.get({
url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId
})
}

View File

@ -0,0 +1,9 @@
export type FormVO = {
id: number
name: string
conf: string
fields: string[]
status: number
remark: string
createTime: string
}

View File

@ -0,0 +1,21 @@
import { useAxios } from '@/hooks/web/useAxios'
import { TaskAssignVO } from './types'
const request = useAxios()
export const getTaskAssignRuleList = async (params) => {
return await request.get({ url: '/bpm/task-assign-rule/list', params })
}
export const createTaskAssignRule = async (data: TaskAssignVO) => {
return await request.post({
url: '/bpm/task-assign-rule/create',
data: data
})
}
export const updateTaskAssignRule = async (data: TaskAssignVO) => {
return await request.put({
url: '/bpm/task-assign-rule/update',
data: data
})
}

View File

@ -0,0 +1,9 @@
export type TaskAssignVO = {
id: number
modelId: string
processDefinitionId: string
taskDefinitionKey: string
taskDefinitionName: string
options: string[]
type: number
}

View File

@ -0,0 +1,39 @@
import { useAxios } from '@/hooks/web/useAxios'
import { UserGroupVO } from './types'
const request = useAxios()
// 创建用户组
export const createUserGroupApi = async (data: UserGroupVO) => {
return await request.post({
url: '/bpm/user-group/create',
data: data
})
}
// 更新用户组
export const updateUserGroupApi = async (data: UserGroupVO) => {
return await request.put({
url: '/bpm/user-group/update',
data: data
})
}
// 删除用户组
export const deleteUserGroupApi = async (id: number) => {
return await request.delete({ url: '/bpm/user-group/delete?id=' + id })
}
// 获得用户组
export const getUserGroupApi = async (id: number) => {
return await request.get({ url: '/bpm/user-group/get?id=' + id })
}
// 获得用户组分页
export const getUserGroupPageApi = async (params) => {
return await request.get({ url: '/bpm/user-group/page', params })
}
// 获取用户组精简信息列表
export const listSimpleUserGroupsApi = async () => {
return await request.get({ url: '/bpm/user-group/list-all-simple' })
}

View File

@ -0,0 +1,9 @@
export type UserGroupVO = {
id: number
name: string
description: string
memberUserIds: number[]
status: number
remark: string
createTime: string
}

View File

@ -55,3 +55,8 @@ export const updateUserStatusApi = (id: number, status: number) => {
}
return request.put({ url: '/system/user/update-status', data: data })
}
// 获取用户精简信息列表
export const getListSimpleUsersApi = () => {
return request.get({ url: '/system/user/list-all-simple' })
}

View File

@ -1,7 +0,0 @@
<script setup lang="ts"></script>
<template>
<div>index</div>
</template>
<style scoped></style>

View File

@ -0,0 +1,61 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
const { t } = useI18n() // 国际化
// 表单校验
export const rules = reactive({
name: [required]
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
form: {
show: false
},
detail: {
show: false
}
},
{
label: '表单名',
field: 'name',
search: {
show: true
}
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS
},
{
label: '备注',
field: 'remark'
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
}
},
{
label: t('table.action'),
field: 'action',
width: '240px',
form: {
show: false
},
detail: {
show: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)

View File

@ -1,7 +1,169 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { ElMessage } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { FormExpose } from '@/components/Form'
import type { FormVO } from '@/api/bpm/form/types'
import { rules, allSchemas } from './form.data'
import * as FormApi from '@/api/bpm/form'
const { t } = useI18n() //
// ========== ==========
const { register, tableObject, methods } = useTable<FormVO>({
getListApi: FormApi.getFormPageApi,
delListApi: FormApi.deleteFormApi
})
const { getList, setSearchParams, delList } = methods
// ========== CRUD ==========
const actionLoading = ref(false) //
const actionType = ref('') //
const dialogVisible = ref(false) //
const dialogTitle = ref('edit') //
const formRef = ref<FormExpose>() // Ref
//
const setDialogTile = (type: string) => {
dialogTitle.value = t('action.' + type)
actionType.value = type
dialogVisible.value = true
}
//
const handleCreate = () => {
setDialogTile('create')
//
unref(formRef)?.getElFormRef()?.resetFields()
}
//
const handleUpdate = async (row: FormVO) => {
setDialogTile('update')
//
const res = await FormApi.getFormApi(row.id)
unref(formRef)?.setValues(res)
}
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FormVO
if (actionType.value === 'create') {
await FormApi.createFormApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await FormApi.updateFormApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
const handleDelete = (row: FormVO) => {
delList(row.id, false)
}
// ========== ==========
const detailRef = ref() // Ref
//
const handleDetail = async (row: FormVO) => {
//
detailRef.value = row
setDialogTile('detail')
}
// ========== ==========
getList()
</script>
<template>
<div>index</div>
</template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<el-button type="primary" v-hasPermi="['bpm:form:create']" @click="handleCreate">
<Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
</el-button>
</div>
<!-- 列表 -->
<Table
:columns="allSchemas.tableColumns"
:selection="false"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
@register="register"
>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #action="{ row }">
<el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleUpdate(row)">
<Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
</el-button>
<el-button link type="primary" v-hasPermi="['bpm:form:update']" @click="handleDetail(row)">
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
</el-button>
<el-button link type="primary" v-hasPermi="['bpm:form:delete']" @click="handleDelete(row)">
<Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
</el-button>
</template>
</Table>
</ContentWrap>
<style scoped></style>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"
:schema="allSchemas.formSchema"
:rules="rules"
ref="formRef"
/>
<!-- 对话框(详情) -->
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailRef"
>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
</Descriptions>
<!-- 操作按钮 -->
<template #footer>
<el-button
v-if="['create', 'update'].includes(actionType)"
type="primary"
:loading="actionLoading"
@click="submitForm"
>
{{ t('action.save') }}
</el-button>
<el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
</template>
</Dialog>
</template>

View File

@ -0,0 +1,69 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
const { t } = useI18n() // 国际化
// 表单校验
export const rules = reactive({
name: [required]
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
form: {
show: false
},
detail: {
show: false
}
},
{
label: '组名',
field: 'name',
search: {
show: true
}
},
{
label: '成员',
field: 'memberUserIds'
},
{
label: '描述',
field: 'description'
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS
},
{
label: '备注',
field: 'remark'
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
}
},
{
label: t('table.action'),
field: 'action',
width: '240px',
form: {
show: false
},
detail: {
show: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)

View File

@ -1,7 +1,229 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, unref, onMounted } from 'vue'
import dayjs from 'dayjs'
import { ElMessage, ElSelect, ElOption } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { FormExpose } from '@/components/Form'
import type { UserGroupVO } from '@/api/bpm/userGroup/types'
import { rules, allSchemas } from './group.data'
import * as UserGroupApi from '@/api/bpm/userGroup'
import { getListSimpleUsersApi } from '@/api/system/user'
import { UserVO } from '@/api/system/user/types'
const { t } = useI18n() //
// ========== ==========
const { register, tableObject, methods } = useTable<UserGroupVO>({
getListApi: UserGroupApi.getUserGroupPageApi,
delListApi: UserGroupApi.deleteUserGroupApi
})
const { getList, setSearchParams, delList } = methods
// ========== CRUD ==========
const actionLoading = ref(false) //
const actionType = ref('') //
const dialogVisible = ref(false) //
const dialogTitle = ref('edit') //
const formRef = ref<FormExpose>() // Ref
// ========== ==========
const userIds = ref<number[]>([])
const userOptions = ref<UserVO[]>([])
const getUserOptions = async () => {
const res = await getListSimpleUsersApi()
userOptions.value.push(...res)
}
//
const setDialogTile = (type: string) => {
dialogTitle.value = t('action.' + type)
actionType.value = type
dialogVisible.value = true
}
//
const handleCreate = () => {
setDialogTile('create')
userIds.value = []
//
unref(formRef)?.getElFormRef()?.resetFields()
}
//
const handleUpdate = async (row: UserGroupVO) => {
setDialogTile('update')
//
const res = await UserGroupApi.getUserGroupApi(row.id)
userIds.value = res.memberUserIds
unref(formRef)?.setValues(res)
}
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as UserGroupVO
data.memberUserIds = userIds.value
if (actionType.value === 'create') {
await UserGroupApi.createUserGroupApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await UserGroupApi.updateUserGroupApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
const handleDelete = (row: UserGroupVO) => {
delList(row.id, false)
}
//
const getUserNickName = (userId: number) => {
for (const user of userOptions.value) {
if (user.id === userId) return user.nickname
}
return '未知(' + userId + ')'
}
// ========== ==========
const detailRef = ref() // Ref
//
const handleDetail = async (row: UserGroupVO) => {
//
detailRef.value = row
setDialogTile('detail')
}
// ========== ==========
onMounted(async () => {
await getList()
await getUserOptions()
})
</script>
<template>
<div>index</div>
</template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<el-button type="primary" v-hasPermi="['bpm:user-group:create']" @click="handleCreate">
<Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
</el-button>
</div>
<!-- 列表 -->
<Table
:columns="allSchemas.tableColumns"
:selection="false"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
@register="register"
>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #memberUserIds="{ row }">
<span v-for="userId in row.memberUserIds" :key="userId">
{{ getUserNickName(userId) + ' ' }}
</span>
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #action="{ row }">
<el-button
link
type="primary"
v-hasPermi="['bpm:user-group:update']"
@click="handleUpdate(row)"
>
<Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
</el-button>
<el-button
link
type="primary"
v-hasPermi="['bpm:user-group:update']"
@click="handleDetail(row)"
>
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
</el-button>
<el-button
link
type="primary"
v-hasPermi="['bpm:user-group:delete']"
@click="handleDelete(row)"
>
<Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
</el-button>
</template>
</Table>
</ContentWrap>
<style scoped></style>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"
:schema="allSchemas.formSchema"
:rules="rules"
ref="formRef"
>
<template #memberUserIds>
<el-select v-model="userIds" multiple>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</template>
</Form>
<!-- 对话框(详情) -->
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailRef"
>
<template #memberUserIds="{ row }">
<span v-for="userId in row.memberUserIds" :key="userId">
{{ getUserNickName(userId) + ' ' }}
</span>
</template>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
</Descriptions>
<!-- 操作按钮 -->
<template #footer>
<el-button
v-if="['create', 'update'].includes(actionType)"
type="primary"
:loading="actionLoading"
@click="submitForm"
>
{{ t('action.save') }}
</el-button>
<el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
</template>
</Dialog>
</template>