!93 【重构】Vue3 管理后台:[流程管理 -> 待办流程][流程管理 -> 我的流程] 使用 Element Plus 原生实现

Merge pull request !93 from Chika/dev
This commit is contained in:
芋道源码 2023-04-07 00:12:58 +00:00 committed by Gitee
commit 8f2acea7a5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 339 additions and 226 deletions

View File

@ -317,6 +317,42 @@ const remainingRouter: AppRouteRecordRaw[] = [
title: '查看 OA 请假', title: '查看 OA 请假',
activeMenu: 'bpm/oa/leave/detail' activeMenu: 'bpm/oa/leave/detail'
} }
},
{
path: '/bpm/task/done',
component: () => import('@/views/bpm/task/done/index.vue'),
name: 'TaskDone',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '已办任务',
activeMenu: 'bpm/task/done/index'
}
},
{
path: '/bpm/task/todo',
component: () => import('@/views/bpm/task/todo/index.vue'),
name: 'TaskTodo',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '代办任务',
activeMenu: 'bpm/task/todo/index'
}
},
{
path: '/bpm/processInstance',
component: () => import('@/views/bpm/processInstance/index.vue'),
name: 'processInstance',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '流程办理',
activeMenu: 'bpm/processInstance/index'
}
} }
] ]
}, },

View File

@ -24,9 +24,6 @@ declare module '@vue/runtime-core' {
DocAlert: typeof import('./../components/DocAlert/index.vue')['default'] DocAlert: typeof import('./../components/DocAlert/index.vue')['default']
Echart: typeof import('./../components/Echart/src/Echart.vue')['default'] Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
Editor: typeof import('./../components/Editor/src/Editor.vue')['default'] Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge'] ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
@ -56,34 +53,25 @@ declare module '@vue/runtime-core' {
ElForm: typeof import('element-plus/es')['ElForm'] ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon'] ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage']
ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElLink: typeof import('element-plus/es')['ElLink'] ElLink: typeof import('element-plus/es')['ElLink']
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover'] ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect'] ElSelect: typeof import('element-plus/es')['ElSelect']
ElSkeleton: typeof import('element-plus/es')['ElSkeleton'] ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
ElSpace: typeof import('element-plus/es')['ElSpace']
ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable'] ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTableV2: typeof import('element-plus/es')['ElTableV2']
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline'] ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree']
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
ElUpload: typeof import('element-plus/es')['ElUpload'] ElUpload: typeof import('element-plus/es')['ElUpload']
Error: typeof import('./../components/Error/src/Error.vue')['default'] Error: typeof import('./../components/Error/src/Error.vue')['default']
FlowCondition: typeof import('./../components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue')['default'] FlowCondition: typeof import('./../components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue')['default']

View File

@ -1,64 +1,215 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 列表 --> <!-- 搜索工作栏 -->
<XTable @register="registerTable"> <el-form
<template #toolbar_buttons> class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="流程名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入流程名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="所属流程" prop="processDefinitionId">
<el-input
v-model="queryParams.processDefinitionId"
placeholder="请输入流程定义的编号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="流程分类" prop="category">
<el-select v-model="queryParams.category" placeholder="请选择" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_MODEL_CATEGORY)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="结果" prop="result">
<el-select v-model="queryParams.result" placeholder="请选择" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="提交时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-form>
<el-col>
<el-row>
<el-col>
<!-- 操作新增 --> <!-- 操作新增 -->
<XButton <el-button
type="primary" type="primary"
preIcon="ep:zoom-in"
title="发起流程"
v-hasPermi="['bpm:process-instance:query']" v-hasPermi="['bpm:process-instance:query']"
@click="handleCreate" @click="handleCreate"
/> >发起流程</el-button
>
</el-col>
</el-row>
</el-col>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="流程编号" align="center" prop="id" width="300px" />
<el-table-column label="流程名称" align="center" prop="name" />
<el-table-column label="流程分类" align="center" prop="category">
<template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
</template> </template>
<!-- 流程分类 --> </el-table-column>
<template #category_default="{ row }"> <el-table-column label="当前审批任务" align="center" prop="tasks">
<DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> <template #default="scope">
</template> <el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
<!-- 当前审批任务 -->
<template #tasks_default="{ row }">
<el-button v-for="task in row.tasks" :key="task.id" link>
<span>{{ task.name }}</span> <span>{{ task.name }}</span>
</el-button> </el-button>
</template> </template>
<!-- 操作 --> </el-table-column>
<template #actionbtns_default="{ row }"> <el-table-column label="状态" prop="status">
<XTextButton <template #default="scope">
preIcon="ep:view" <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
:title="t('action.detail')"
v-hasPermi="['bpm:process-instance:cancel']"
@click="handleDetail(row)"
/>
<XTextButton
preIcon="ep:delete"
title="取消"
v-if="row.result === 1"
v-hasPermi="['bpm:process-instance:query']"
@click="handleCancel(row)"
/>
</template> </template>
</XTable> </el-table-column>
<el-table-column label="结果" prop="result">
<template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.result" />
</template>
</el-table-column>
<el-table-column
label="提交时间"
align="center"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column
label="结束时间"
align="center"
prop="endTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
v-hasPermi="['bpm:process-instance:cancel']"
@click="handleDetail(scope.row)"
>详情</el-button
>
<el-button
link
type="primary"
v-if="scope.row.result === 1"
v-hasPermi="['bpm:process-instance:query']"
@click="handleCancel(scope.row)"
>取消</el-button
>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// import // import
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
// import // import
import * as ProcessInstanceApi from '@/api/bpm/processInstance' import * as ProcessInstanceApi from '@/api/bpm/processInstance'
import { allSchemas } from './process.data' // import { allSchemas } from './process.data'
import { dateFormatter } from '@/utils/formatTime'
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: '',
processDefinitionId: undefined,
category: undefined,
status: undefined,
result: undefined,
createTime: []
})
const router = useRouter() // const router = useRouter() //
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const queryFormRef = ref() //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ProcessInstanceApi.getMyProcessInstancePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
// ========== ========== // ========== ==========
const [registerTable, { reload }] = useXTable({ // const [reload] = useXTable({
allSchemas: allSchemas, // allSchemas: allSchemas,
getListApi: ProcessInstanceApi.getMyProcessInstancePage // getListApi: ProcessInstanceApi.getMyProcessInstancePage
}) // })
/** 发起流程操作 **/ /** 发起流程操作 **/
const handleCreate = () => { const handleCreate = () => {
@ -87,7 +238,11 @@ const handleCancel = (row) => {
}).then(async ({ value }) => { }).then(async ({ value }) => {
await ProcessInstanceApi.cancelProcessInstance(row.id, value) await ProcessInstanceApi.cancelProcessInstance(row.id, value)
message.success('取消成功') message.success('取消成功')
reload() // reload()
}) })
} }
/** 初始化 **/
onMounted(() => {
getList()
})
</script> </script>

View File

@ -1,94 +0,0 @@
import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// CrudSchema
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: null,
primaryTitle: '编号',
action: true,
actionWidth: '200px',
columns: [
{
title: '编号',
field: 'id',
table: {
width: 320
}
},
{
title: '流程名',
field: 'name',
isSearch: true
},
{
title: '所属流程',
field: 'processDefinitionId',
isSearch: true,
isTable: false
},
{
title: '流程分类',
field: 'category',
dictType: DICT_TYPE.BPM_MODEL_CATEGORY,
dictClass: 'number',
isSearch: true,
table: {
slots: {
default: 'category_default'
}
}
},
{
title: '当前审批任务',
field: 'tasks',
table: {
width: 140,
slots: {
default: 'tasks_default'
}
}
},
{
title: t('common.status'),
field: 'status',
dictType: DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS,
dictClass: 'number',
isSearch: true
},
{
title: '结果',
field: 'result',
dictType: DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT,
dictClass: 'number',
isSearch: true
},
{
title: '提交时间',
field: 'createTime',
formatter: 'formatDate',
table: {
width: 180
},
isForm: false,
isSearch: true,
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
},
{
title: '结束时间',
field: 'endTime',
formatter: 'formatDate',
table: {
width: 180
},
isForm: false
}
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)

View File

@ -1,31 +1,113 @@
<template> <template>
<ContentWrap> <ContentWrap>
<XTable @register="registerTable"> <!-- 搜索工作栏 -->
<template #suspensionState_default="{ row }"> <el-form
<el-tag type="success" v-if="row.suspensionState === 1">激活</el-tag> class="-mb-15px"
<el-tag type="warning" v-if="row.suspensionState === 2">挂起</el-tag> :model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="任务名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入任务名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="任务编号" align="center" prop="id" width="300px" />
<el-table-column label="任务名称" align="center" prop="name" />
<el-table-column label="所属流程" align="center" prop="processInstance.name" />
<el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="任务状态" prop="suspensionState">
<template #default="scope">
<el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
<el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
</template> </template>
<template #actionbtns_default="{ row }"> </el-table-column>
<!-- 操作: 审批进度 --> <el-table-column label="操作" align="center">
<XTextButton preIcon="ep:edit-pen" title="审批进度" @click="handleAudit(row)" /> <template #default="scope">
<el-button link type="primary" @click="handleAudit(scope.row)">审批进度</el-button>
</template> </template>
</XTable> </el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
</template> </template>
<script setup lang="ts"> <script setup lang="tsx">
// import // import
import { allSchemas } from './todo.data'
import * as TaskApi from '@/api/bpm/task' import * as TaskApi from '@/api/bpm/task'
import { dateFormatter } from '@/utils/formatTime'
const { push } = useRouter() // const { push } = useRouter() //
const loading = ref(true) //
const [registerTable] = useXTable({ const total = ref(0) //
allSchemas: allSchemas, const list = ref([]) //
topActionSlots: false, const queryParams = reactive({
getListApi: TaskApi.getTodoTaskPage pageNo: 1,
pageSize: 10,
name: '',
createTime: []
}) })
const queryFormRef = ref() //
/** 查询任务列表 */
const getList = async () => {
loading.value = true
try {
const data = await TaskApi.getTodoTaskPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
// //
const handleAudit = (row) => { const handleAudit = (row) => {
push({ push({
@ -35,4 +117,8 @@ const handleAudit = (row) => {
} }
}) })
} }
/** 初始化 **/
onMounted(() => {
getList()
})
</script> </script>

View File

@ -1,58 +0,0 @@
import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// crudSchemas
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: null,
action: true,
searchSpan: 8,
columns: [
{
title: '任务编号',
field: 'id',
table: {
width: 320
}
},
{
title: '任务名称',
field: 'name',
isSearch: true
},
{
title: '所属流程',
field: 'processInstance.name'
},
{
title: '流程发起人',
field: 'processInstance.startUserNickname'
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
table: {
width: 180
},
isSearch: true,
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
},
{
title: '任务状态',
field: 'suspensionState',
table: {
slots: {
default: 'suspensionState_default'
}
}
}
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)