index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <doc-alert title="工作流手册" url="https://doc.iocoder.cn/bpm/" />
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="流程名称" prop="name">
  13. <el-input
  14. v-model="queryParams.name"
  15. placeholder="请输入流程名称"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="所属流程" prop="processDefinitionId">
  22. <el-input
  23. v-model="queryParams.processDefinitionId"
  24. placeholder="请输入流程定义的编号"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="流程分类" prop="category">
  31. <el-select
  32. v-model="queryParams.category"
  33. placeholder="请选择流程分类"
  34. clearable
  35. class="!w-240px"
  36. >
  37. <el-option
  38. v-for="category in categoryList"
  39. :key="category.code"
  40. :label="category.name"
  41. :value="category.code"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="流程状态" prop="status">
  46. <el-select
  47. v-model="queryParams.status"
  48. placeholder="请选择流程状态"
  49. clearable
  50. class="!w-240px"
  51. >
  52. <el-option
  53. v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS)"
  54. :key="dict.value"
  55. :label="dict.label"
  56. :value="dict.value"
  57. />
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label="提交时间" prop="createTime">
  61. <el-date-picker
  62. v-model="queryParams.createTime"
  63. value-format="YYYY-MM-DD HH:mm:ss"
  64. type="daterange"
  65. start-placeholder="开始日期"
  66. end-placeholder="结束日期"
  67. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  68. class="!w-240px"
  69. />
  70. </el-form-item>
  71. <el-form-item>
  72. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  73. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  74. <el-button
  75. type="primary"
  76. plain
  77. v-hasPermi="['bpm:process-instance:query']"
  78. @click="handleCreate()"
  79. >
  80. <Icon icon="ep:plus" class="mr-5px" /> 发起流程
  81. </el-button>
  82. </el-form-item>
  83. </el-form>
  84. </ContentWrap>
  85. <!-- 列表 -->
  86. <ContentWrap>
  87. <el-table v-loading="loading" :data="list">
  88. <el-table-column label="流程编号" align="center" prop="id" width="300px" />
  89. <el-table-column label="流程名称" align="center" prop="name" />
  90. <el-table-column label="流程分类" align="center" prop="categoryName" />
  91. <el-table-column label="当前审批任务" align="center" prop="tasks">
  92. <template #default="scope">
  93. <el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
  94. <span>{{ task.name }}</span>
  95. </el-button>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="流程" prop="status">
  99. <template #default="scope">
  100. <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. label="提交时间"
  105. align="center"
  106. prop="startTime"
  107. width="180"
  108. :formatter="dateFormatter"
  109. />
  110. <el-table-column
  111. label="结束时间"
  112. align="center"
  113. prop="endTime"
  114. width="180"
  115. :formatter="dateFormatter"
  116. />
  117. <el-table-column label="操作" align="center">
  118. <template #default="scope">
  119. <el-button
  120. link
  121. type="primary"
  122. v-hasPermi="['bpm:process-instance:cancel']"
  123. @click="handleDetail(scope.row)"
  124. >
  125. 详情
  126. </el-button>
  127. <el-button
  128. link
  129. type="primary"
  130. v-if="scope.row.status === 1"
  131. v-hasPermi="['bpm:process-instance:query']"
  132. @click="handleCancel(scope.row)"
  133. >
  134. 取消
  135. </el-button>
  136. <el-button link type="primary" v-else @click="handleCreate(scope.row.id)">
  137. 重新发起
  138. </el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <!-- 分页 -->
  143. <Pagination
  144. :total="total"
  145. v-model:page="queryParams.pageNo"
  146. v-model:limit="queryParams.pageSize"
  147. @pagination="getList"
  148. />
  149. </ContentWrap>
  150. </template>
  151. <script lang="ts" setup>
  152. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  153. import { dateFormatter } from '@/utils/formatTime'
  154. import { ElMessageBox } from 'element-plus'
  155. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  156. import { CategoryApi } from '@/api/bpm/category'
  157. defineOptions({ name: 'BpmProcessInstance' })
  158. const router = useRouter() // 路由
  159. const message = useMessage() // 消息弹窗
  160. const { t } = useI18n() // 国际化
  161. const loading = ref(true) // 列表的加载中
  162. const total = ref(0) // 列表的总页数
  163. const list = ref([]) // 列表的数据
  164. const queryParams = reactive({
  165. pageNo: 1,
  166. pageSize: 10,
  167. name: '',
  168. processDefinitionId: undefined,
  169. category: undefined,
  170. status: undefined,
  171. createTime: []
  172. })
  173. const queryFormRef = ref() // 搜索的表单
  174. const categoryList = ref([]) // 流程分类列表
  175. /** 查询列表 */
  176. const getList = async () => {
  177. loading.value = true
  178. try {
  179. const data = await ProcessInstanceApi.getMyProcessInstancePage(queryParams)
  180. list.value = data.list
  181. total.value = data.total
  182. } finally {
  183. loading.value = false
  184. }
  185. }
  186. /** 搜索按钮操作 */
  187. const handleQuery = () => {
  188. queryParams.pageNo = 1
  189. getList()
  190. }
  191. /** 重置按钮操作 */
  192. const resetQuery = () => {
  193. queryFormRef.value.resetFields()
  194. handleQuery()
  195. }
  196. /** 发起流程操作 **/
  197. const handleCreate = (id) => {
  198. router.push({
  199. name: 'BpmProcessInstanceCreate',
  200. query: { processInstanceId: id }
  201. })
  202. }
  203. /** 查看详情 */
  204. const handleDetail = (row) => {
  205. router.push({
  206. name: 'BpmProcessInstanceDetail',
  207. query: {
  208. id: row.id
  209. }
  210. })
  211. }
  212. /** 取消按钮操作 */
  213. const handleCancel = async (row) => {
  214. // 二次确认
  215. const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
  216. confirmButtonText: t('common.ok'),
  217. cancelButtonText: t('common.cancel'),
  218. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  219. inputErrorMessage: '取消原因不能为空'
  220. })
  221. // 发起取消
  222. await ProcessInstanceApi.cancelProcessInstance(row.id, value)
  223. message.success('取消成功')
  224. // 刷新列表
  225. await getList()
  226. }
  227. /** 激活时 **/
  228. onActivated(() => {
  229. getList()
  230. })
  231. /** 初始化 **/
  232. onMounted(async () => {
  233. await getList()
  234. categoryList.value = await CategoryApi.getCategorySimpleList()
  235. })
  236. </script>