123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <doc-alert title="工作流手册" url="https://doc.iocoder.cn/bpm/" />
- <ContentWrap>
- <!-- 搜索工作栏 -->
- <el-form
- 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
- class="!w-240px"
- >
- <el-option
- v-for="category in categoryList"
- :key="category.code"
- :label="category.name"
- :value="category.code"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="流程状态" prop="status">
- <el-select
- v-model="queryParams.status"
- placeholder="请选择流程状态"
- clearable
- class="!w-240px"
- >
- <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="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-button
- type="primary"
- plain
- v-hasPermi="['bpm:process-instance:query']"
- @click="handleCreate()"
- >
- <Icon icon="ep:plus" 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="categoryName" />
- <el-table-column label="当前审批任务" align="center" prop="tasks">
- <template #default="scope">
- <el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
- <span>{{ task.name }}</span>
- </el-button>
- </template>
- </el-table-column>
- <el-table-column label="流程" prop="status">
- <template #default="scope">
- <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
- </template>
- </el-table-column>
- <el-table-column
- label="提交时间"
- align="center"
- prop="startTime"
- 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.status === 1"
- v-hasPermi="['bpm:process-instance:query']"
- @click="handleCancel(scope.row)"
- >
- 取消
- </el-button>
- <el-button link type="primary" v-else @click="handleCreate(scope.row.id)">
- 重新发起
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <Pagination
- :total="total"
- v-model:page="queryParams.pageNo"
- v-model:limit="queryParams.pageSize"
- @pagination="getList"
- />
- </ContentWrap>
- </template>
- <script lang="ts" setup>
- import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
- import { dateFormatter } from '@/utils/formatTime'
- import { ElMessageBox } from 'element-plus'
- import * as ProcessInstanceApi from '@/api/bpm/processInstance'
- import { CategoryApi } from '@/api/bpm/category'
- defineOptions({ name: 'BpmProcessInstance' })
- const router = useRouter() // 路由
- const message = useMessage() // 消息弹窗
- const { t } = useI18n() // 国际化
- 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,
- createTime: []
- })
- const queryFormRef = ref() // 搜索的表单
- const categoryList = 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 handleCreate = (id) => {
- router.push({
- name: 'BpmProcessInstanceCreate',
- query: { processInstanceId: id }
- })
- }
- /** 查看详情 */
- const handleDetail = (row) => {
- router.push({
- name: 'BpmProcessInstanceDetail',
- query: {
- id: row.id
- }
- })
- }
- /** 取消按钮操作 */
- const handleCancel = async (row) => {
- // 二次确认
- const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
- confirmButtonText: t('common.ok'),
- cancelButtonText: t('common.cancel'),
- inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
- inputErrorMessage: '取消原因不能为空'
- })
- // 发起取消
- await ProcessInstanceApi.cancelProcessInstance(row.id, value)
- message.success('取消成功')
- // 刷新列表
- await getList()
- }
- /** 激活时 **/
- onActivated(() => {
- getList()
- })
- /** 初始化 **/
- onMounted(async () => {
- await getList()
- categoryList.value = await CategoryApi.getCategorySimpleList()
- })
- </script>
|