index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. </template>
  137. </el-table-column>
  138. </el-table>
  139. <!-- 分页 -->
  140. <Pagination
  141. :total="total"
  142. v-model:page="queryParams.pageNo"
  143. v-model:limit="queryParams.pageSize"
  144. @pagination="getList"
  145. />
  146. </ContentWrap>
  147. </template>
  148. <script lang="ts" setup>
  149. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  150. import { dateFormatter } from '@/utils/formatTime'
  151. import { ElMessageBox } from 'element-plus'
  152. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  153. import { CategoryApi } from '@/api/bpm/category'
  154. defineOptions({ name: 'BpmProcessInstance' })
  155. const router = useRouter() // 路由
  156. const message = useMessage() // 消息弹窗
  157. const { t } = useI18n() // 国际化
  158. const loading = ref(true) // 列表的加载中
  159. const total = ref(0) // 列表的总页数
  160. const list = ref([]) // 列表的数据
  161. const queryParams = reactive({
  162. pageNo: 1,
  163. pageSize: 10,
  164. name: '',
  165. processDefinitionId: undefined,
  166. category: undefined,
  167. status: undefined,
  168. createTime: []
  169. })
  170. const queryFormRef = ref() // 搜索的表单
  171. const categoryList = ref([]) // 流程分类列表
  172. /** 查询列表 */
  173. const getList = async () => {
  174. loading.value = true
  175. try {
  176. const data = await ProcessInstanceApi.getMyProcessInstancePage(queryParams)
  177. list.value = data.list
  178. total.value = data.total
  179. } finally {
  180. loading.value = false
  181. }
  182. }
  183. /** 搜索按钮操作 */
  184. const handleQuery = () => {
  185. queryParams.pageNo = 1
  186. getList()
  187. }
  188. /** 重置按钮操作 */
  189. const resetQuery = () => {
  190. queryFormRef.value.resetFields()
  191. handleQuery()
  192. }
  193. /** 发起流程操作 **/
  194. const handleCreate = () => {
  195. router.push({
  196. name: 'BpmProcessInstanceCreate'
  197. })
  198. }
  199. /** 查看详情 */
  200. const handleDetail = (row) => {
  201. router.push({
  202. name: 'BpmProcessInstanceDetail',
  203. query: {
  204. id: row.id
  205. }
  206. })
  207. }
  208. /** 取消按钮操作 */
  209. const handleCancel = async (row) => {
  210. // 二次确认
  211. const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
  212. confirmButtonText: t('common.ok'),
  213. cancelButtonText: t('common.cancel'),
  214. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  215. inputErrorMessage: '取消原因不能为空'
  216. })
  217. // 发起取消
  218. await ProcessInstanceApi.cancelProcessInstance(row.id, value)
  219. message.success('取消成功')
  220. // 刷新列表
  221. await getList()
  222. }
  223. /** 激活时 **/
  224. onActivated(() => {
  225. getList()
  226. })
  227. /** 初始化 **/
  228. onMounted(async () => {
  229. await getList()
  230. categoryList.value = await CategoryApi.getCategorySimpleList()
  231. })
  232. </script>