feat: bpm views

pull/33/head
xingyu 2023-08-23 14:14:39 +08:00
parent 3622c099e9
commit 3ad5511aa8
20 changed files with 349 additions and 94 deletions

View File

@ -0,0 +1,5 @@
import { defHttp } from '@/utils/http/axios'
export function getActivityList(params) {
return defHttp.get({ url: '/bpm/activity/list', params })
}

View File

@ -1,11 +1,5 @@
import type { AxiosProgressEvent } from 'axios'
import type { UploadApiResult } from '@/api/base/model/uploadModel'
import { useGlobSetting } from '@/hooks/setting'
import type { UploadFileParams } from '@/types/axios'
import { defHttp } from '@/utils/http/axios' import { defHttp } from '@/utils/http/axios'
const { apiUrl = '' } = useGlobSetting()
export interface ProcessDefinitionVO { export interface ProcessDefinitionVO {
id: string id: string
version: number version: number
@ -43,7 +37,11 @@ export function updateModel(data: ModelVO) {
} }
// 任务状态修改 // 任务状态修改
export function updateModelState(data) { export function updateModelState(id: number, state: number) {
const data = {
id,
state,
}
return defHttp.put({ url: '/bpm/model/update-state', data }) return defHttp.put({ url: '/bpm/model/update-state', data })
} }
@ -59,12 +57,6 @@ export function deployModel(id: number) {
return defHttp.post({ url: `/bpm/model/deploy?id=${id}` }) return defHttp.post({ url: `/bpm/model/deploy?id=${id}` })
} }
export function importModel(params: UploadFileParams, onUploadProgress: (progressEvent: AxiosProgressEvent) => void) { export function importModel(data) {
return defHttp.uploadFile<UploadApiResult>( return defHttp.post({ url: '/bpm/model/import', data })
{
url: `${apiUrl}/bpm/model/import`,
onUploadProgress,
},
params,
)
} }

View File

@ -32,3 +32,8 @@ export function getTaskListByProcessInstanceId(processInstanceId) {
url: `/bpm/task/list-by-process-instance-id?processInstanceId=${processInstanceId}`, url: `/bpm/task/list-by-process-instance-id?processInstanceId=${processInstanceId}`,
}) })
} }
// 导出任务
export async function exportTask(params) {
return await defHttp.download({ url: '/bpm/task/export', params })
}

View File

@ -1,39 +0,0 @@
export interface FormVO {
id: number
name: string
conf: string
fields: string[]
status: number
remark: string
createTime: string
}
export interface TaskProcessVO {
id: string
name: string
startUserId: number
startUserNickname: string
processDefinitionId: string
}
export interface TaskTodoVO {
id: string
name: string
claimTime: string
createTime: string
suspensionState: number
processInstance: TaskProcessVO
}
export interface TaskDoneVO {
id: string
name: string
claimTime: string
createTime: string
endTime: string
durationInMillis: number
suspensionState: number
result: number
reason: string
processInstance: TaskProcessVO
}

View File

@ -88,7 +88,7 @@ export function createActionColumn(handleRemove: Function): BasicColumn {
const actions: ActionItem[] = [ const actions: ActionItem[] = [
{ {
label: t('component.upload.del'), label: t('component.upload.del'),
color: 'error', danger: true,
onClick: handleRemove.bind(null, record), onClick: handleRemove.bind(null, record),
}, },
] ]
@ -132,7 +132,7 @@ export function createPreviewActionColumn({ handleRemove, handleDownload }: { ha
const actions: ActionItem[] = [ const actions: ActionItem[] = [
{ {
label: t('component.upload.del'), label: t('component.upload.del'),
color: 'error', danger: true,
onClick: handleRemove.bind(null, record), onClick: handleRemove.bind(null, record),
}, },
{ {

View File

@ -1,4 +1,4 @@
import type { FormSchema } from '@/components/Form/index' import type { FormSchema } from '@/components/Form'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n() const { t } = useI18n()

View File

@ -1,6 +1,6 @@
import type { BasicColumn, FormSchema } from '@/components/Table' import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table' import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
@ -43,13 +43,4 @@ export const searchFormSchema: FormSchema[] = [
component: 'Input', component: 'Input',
colProps: { span: 8 }, colProps: { span: 8 },
}, },
{
label: '状态',
field: 'status',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
},
colProps: { span: 8 },
},
] ]

View File

@ -67,7 +67,7 @@ async function handleDelete(record: Recordable) {
{ icon: IconEnum.VIEW, label: t('action.detail'), auth: 'bpm:form:query', onClick: openDetail.bind(null, record) }, { icon: IconEnum.VIEW, label: t('action.detail'), auth: 'bpm:form:query', onClick: openDetail.bind(null, record) },
{ {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
color: 'error', danger: true,
label: t('action.delete'), label: t('action.delete'),
auth: 'bpm:form:delete', auth: 'bpm:form:delete',
popConfirm: { popConfirm: {

View File

@ -126,7 +126,7 @@ export const formSchema: FormSchema[] = [
{ {
label: '状态', label: '状态',
field: 'status', field: 'status',
component: 'Select', component: 'RadioGroup',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS), options: getDictOptions(DICT_TYPE.COMMON_STATUS),
}, },

View File

@ -59,7 +59,7 @@ async function handleDelete(record: Recordable) {
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'bpm:user-group:update', onClick: handleEdit.bind(null, record) }, { icon: IconEnum.EDIT, label: t('action.edit'), auth: 'bpm:user-group:update', onClick: handleEdit.bind(null, record) },
{ {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
color: 'error', danger: true,
label: t('action.delete'), label: t('action.delete'),
auth: 'bpm:user-group:delete', auth: 'bpm:user-group:delete',
popConfirm: { popConfirm: {

View File

@ -0,0 +1,78 @@
<script lang="ts" setup>
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import type { FormSchema } from '@/components/Form'
import { BasicForm, useForm } from '@/components/Form'
import { BasicModal, useModalInner } from '@/components/Modal'
import { importModel } from '@/api/bpm/model'
defineOptions({ name: 'ModelImportForm' })
const emit = defineEmits(['success', 'register'])
const formSchema: FormSchema[] = [
{
label: '流程标识',
field: 'key',
component: 'Input',
required: true,
},
{
label: '流程名称',
field: 'name',
component: 'Input',
required: true,
},
{
label: '流程描述',
field: 'description',
component: 'Input',
},
{
label: '流程文件',
field: 'bpmnFile',
component: 'FileUpload',
componentProps: {
maxCount: 1,
fileType: 'file',
},
},
]
const { t } = useI18n()
const { createMessage } = useMessage()
const [registerForm, { resetFields, validate }] = useForm({
labelWidth: 120,
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: { span: 23 },
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
resetFields()
setModalProps({ confirmLoading: false })
})
async function handleSubmit() {
try {
const values = await validate()
setModalProps({ confirmLoading: true })
console.info(values)
await importModel(values)
closeModal()
emit('success')
createMessage.success(t('common.saveSuccessText'))
}
finally {
setModalProps({ confirmLoading: false })
}
}
</script>
<template>
<BasicModal v-bind="$attrs" title="导入流程" @register="registerModal" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>

View File

@ -7,7 +7,7 @@ import { BasicForm, useForm } from '@/components/Form'
import { BasicModal, useModalInner } from '@/components/Modal' import { BasicModal, useModalInner } from '@/components/Modal'
import { createModel, getModel, updateModel } from '@/api/bpm/model' import { createModel, getModel, updateModel } from '@/api/bpm/model'
defineOptions({ name: 'BpmModelModal' }) defineOptions({ name: 'ModelForm' })
const emit = defineEmits(['success', 'register']) const emit = defineEmits(['success', 'register'])
const { t } = useI18n() const { t } = useI18n()

View File

@ -1,16 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'
import ModelModal from './ModelModal.vue' import ModelModal from './ModelModal.vue'
import ModelImportModal from './ModelImportModal.vue'
import { columns, searchFormSchema } from './model.data' import { columns, searchFormSchema } from './model.data'
import { useGo } from '@/hooks/web/usePage' import { useGo } from '@/hooks/web/usePage'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage' import { useMessage } from '@/hooks/web/useMessage'
import { useModal } from '@/components/Modal' import { useModal } from '@/components/Modal'
import { IconEnum } from '@/enums/appEnum' import { IconEnum } from '@/enums/appEnum'
import { BasicUpload } from '@/components/Upload'
import { BasicTable, TableAction, useTable } from '@/components/Table' import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteModel, deployModel, getModelPage, importModel } from '@/api/bpm/model' import { deleteModel, deployModel, getModelPage } from '@/api/bpm/model'
import { getAccessToken, getTenantId } from '@/utils/auth'
// import { getAccessToken, getTenantId } from '@/utils/auth'
defineOptions({ name: 'BpmModel' }) defineOptions({ name: 'BpmModel' })
@ -18,11 +18,12 @@ const go = useGo()
const { t } = useI18n() const { t } = useI18n()
const { createMessage } = useMessage() const { createMessage } = useMessage()
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
const [registerImportModal, { openModal: openImportModal }] = useModal()
const uploadParams = ref({ // const uploadParams = ref({
'Authorization': `Bearer ${getAccessToken()}`, // 'Authorization': `Bearer ${getAccessToken()}`,
'tenant-id': getTenantId(), // 'tenant-id': getTenantId(),
}) // })
const [registerTable, { reload }] = useTable({ const [registerTable, { reload }] = useTable({
title: '流程模型图列表', title: '流程模型图列表',
@ -83,7 +84,10 @@ async function handleDelete(record: Recordable) {
<a-button v-auth="['bpm:model:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> <a-button v-auth="['bpm:model:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }} {{ t('action.create') }}
</a-button> </a-button>
<BasicUpload <a-button v-auth="['bpm:model:import']" type="primary" :pre-icon="IconEnum.UPLOAD" @click="openImportModal">
{{ t('action.import') }}
</a-button>
<!-- <BasicUpload
:max-size="20" :max-size="20"
:max-number="1" :max-number="1"
:empty-hide-preview="true" :empty-hide-preview="true"
@ -92,7 +96,7 @@ async function handleDelete(record: Recordable) {
class="my-5" class="my-5"
:accept="['.bpmn', '.xml']" :accept="['.bpmn', '.xml']"
@change="reload" @change="reload"
/> /> -->
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
@ -119,7 +123,7 @@ async function handleDelete(record: Recordable) {
}, },
{ {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
color: 'error', danger: true,
label: t('action.delete'), label: t('action.delete'),
auth: 'bpm:model:delete', auth: 'bpm:model:delete',
popConfirm: { popConfirm: {
@ -134,5 +138,6 @@ async function handleDelete(record: Recordable) {
</template> </template>
</BasicTable> </BasicTable>
<ModelModal @register="registerModal" @success="reload()" /> <ModelModal @register="registerModal" @success="reload()" />
<ModelImportModal @register="registerImportModal" @success="reload()" />
</div> </div>
</template> </template>

View File

@ -1,3 +1,42 @@
<script lang="ts" setup>
import { onMounted } from 'vue'
import { formSchema } from './leave.data'
import { BasicForm, useForm } from '@/components/Form'
import { PageWrapper } from '@/components/Page'
import { createLeave } from '@/api/bpm/leave'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
defineOptions({ name: 'LeaveCreate' })
const { t } = useI18n()
const { createMessage } = useMessage()
const [registerForm, { resetFields, validate }] = useForm({
labelWidth: 140,
baseColProps: { span: 24 },
schemas: formSchema,
showResetButton: false,
submitButtonOptions: { text: t('common.saveText') },
actionColOptions: { span: 23 },
})
async function handleSubmit() {
try {
const values = await validate()
await createLeave(values)
}
finally {
createMessage.success(t('common.saveSuccessText'))
}
}
onMounted(() => {
resetFields()
})
</script>
<template> <template>
123 <PageWrapper>
<BasicForm class="mt-10 w-200 h-120" @register="registerForm" @submit="handleSubmit" />
</PageWrapper>
</template> </template>

View File

@ -1,3 +1,40 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { descSchema } from './leave.data'
import { Description, useDescription } from '@/components/Description'
import { PageWrapper } from '@/components/Page'
import { getLeave } from '@/api/bpm/leave'
import { propTypes } from '@/utils/propTypes'
defineOptions({ name: 'InfraJobModal' })
const props = defineProps({
id: propTypes.number.def(undefined),
})
const { query } = useRoute()
const datas = ref()
const [registerDesc] = useDescription({
schema: descSchema,
data: datas,
})
async function getInfo() {
const queryId = query.id as unknown as number // URL id
const res = await getLeave(props.id || queryId)
datas.value = res
}
/** 初始化 **/
onMounted(async () => {
await getInfo()
})
</script>
<template> <template>
123 <PageWrapper>
<Description :column="1" @register="registerDesc" />
</PageWrapper>
</template> </template>

View File

@ -1,14 +1,20 @@
<script lang="ts" setup> <script lang="ts" setup>
import { columns, searchFormSchema } from './leave.data' import { columns, searchFormSchema } from './leave.data'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { BasicTable, useTable } from '@/components/Table' import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { getLeavePage } from '@/api/bpm/leave' import { getLeavePage } from '@/api/bpm/leave'
import { useGo } from '@/hooks/web/usePage'
import { useMessage } from '@/hooks/web/useMessage'
import { cancelProcessInstance } from '@/api/bpm/processInstance'
defineOptions({ name: 'BpmLeave' }) defineOptions({ name: 'BpmLeave' })
const { t } = useI18n() const { t } = useI18n()
const go = useGo()
const { createMessage } = useMessage()
const [registerTable] = useTable({ const [registerTable, { reload }] = useTable({
title: '请假列表', title: '请假列表',
api: getLeavePage, api: getLeavePage,
columns, columns,
@ -16,16 +22,83 @@ const [registerTable] = useTable({
useSearchForm: true, useSearchForm: true,
showTableSetting: true, showTableSetting: true,
actionColumn: { actionColumn: {
width: 140, width: 160,
title: t('common.action'), title: t('common.action'),
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
}, },
}) })
/** 添加操作 */
function handleCreate() {
go({ name: 'OALeaveCreate' })
}
/** 详情操作 */
function handleDetail(row) {
go({
name: 'OALeaveDetail',
query: {
id: row.id,
},
})
}
/** 取消请假操作 */
async function cancelLeave(row) {
// //
// const { value } = await ElMessageBox.prompt('', '', {
// confirmButtonText: t('common.ok'),
// cancelButtonText: t('common.cancel'),
// inputPattern: /^[\s\S]*.*\S[\s\S]*$/, //
// inputErrorMessage: '',
// })
const value = ''
//
await cancelProcessInstance(row.id, value)
createMessage.success(t('common.delSuccessText'))
reload()
}
/** 审批进度 */
function handleProcessDetail(row) {
go({
name: 'BpmProcessInstanceDetail',
query: {
id: row.processInstanceId,
},
})
}
</script> </script>
<template> <template>
<div> <div>
<BasicTable @register="registerTable" /> <BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
发起请假
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.SEARCH, label: t('action.detail'), auth: 'bpm:oa-leave:query', onClick: handleDetail.bind(null, record) },
{ icon: IconEnum.LOG, label: '进度', auth: 'bpm:oa-leave:query', onClick: handleProcessDetail.bind(null, record) },
{
icon: IconEnum.DELETE,
danger: true,
label: t('action.cancel'),
auth: 'bpm:oa-leave:create',
ifShow: () => {
return record.result === 1
},
onClick: cancelLeave.bind(null, record),
},
]"
/>
</template>
</template>
</BasicTable>
</div> </div>
</template> </template>

View File

@ -1,3 +1,4 @@
import type { DescItem } from '@/components/Description'
import type { BasicColumn, FormSchema } from '@/components/Table' import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table' import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE, getDictOptions } from '@/utils/dict'
@ -47,7 +48,7 @@ export const columns: BasicColumn[] = [
}, },
{ {
title: '申请时间', title: '申请时间',
dataIndex: 'applyTime', dataIndex: 'createTime',
width: 180, width: 180,
customRender: ({ text }) => { customRender: ({ text }) => {
return useRender.renderDate(text) return useRender.renderDate(text)
@ -58,7 +59,7 @@ export const columns: BasicColumn[] = [
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: '请假类型', label: '请假类型',
field: 'status', field: 'type',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE), options: getDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE),
@ -73,7 +74,7 @@ export const searchFormSchema: FormSchema[] = [
}, },
{ {
label: '结果', label: '结果',
field: 'status', field: 'result',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT), options: getDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT),
@ -87,3 +88,71 @@ export const searchFormSchema: FormSchema[] = [
colProps: { span: 8 }, colProps: { span: 8 },
}, },
] ]
export const formSchema: FormSchema[] = [
{
label: '请假类型',
field: 'type',
required: true,
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE),
},
},
{
label: '开始时间',
field: 'startTime',
required: true,
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
},
},
{
label: '结束时间',
field: 'endTime',
required: true,
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
},
},
{
label: '原因',
field: 'reason',
required: true,
component: 'Input',
},
]
export const descSchema: DescItem[] = [
{
label: '请假类型',
field: 'merchantOrderId',
render: (curVal) => {
return useRender.renderTag(curVal)
},
},
{
label: '开始时间',
field: 'startTime',
render: (curVal) => {
return useRender.renderDate(curVal, 'YYYY-MM-DD')
},
},
{
label: '结束时间',
field: 'endTime',
render: (curVal) => {
return useRender.renderDate(curVal, 'YYYY-MM-DD')
},
},
{
label: '原因',
field: 'reason',
},
]

View File

@ -1,3 +1,3 @@
<template> <template>
123 <div>123</div>
</template> </template>

View File

@ -1,3 +1,3 @@
<template> <template>
123 <div>123</div>
</template> </template>

View File

@ -65,7 +65,7 @@ async function handleCancel(record: Recordable) {
}, },
{ {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
color: 'error', danger: true,
label: t('action.cancel'), label: t('action.cancel'),
ifShow: record.result === 1, ifShow: record.result === 1,
auth: 'bpm:process-instance:cancel', auth: 'bpm:process-instance:cancel',