index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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="dict in getIntDictOptions(DICT_TYPE.BPM_MODEL_CATEGORY)"
  39. :key="dict.value"
  40. :label="dict.label"
  41. :value="dict.value"
  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="category">
  91. <template #default="scope">
  92. <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="当前审批任务" align="center" prop="tasks">
  96. <template #default="scope">
  97. <el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
  98. <span>{{ task.name }}</span>
  99. </el-button>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="流程" prop="status">
  103. <template #default="scope">
  104. <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. label="提交时间"
  109. align="center"
  110. prop="startTime"
  111. width="180"
  112. :formatter="dateFormatter"
  113. />
  114. <el-table-column
  115. label="结束时间"
  116. align="center"
  117. prop="endTime"
  118. width="180"
  119. :formatter="dateFormatter"
  120. />
  121. <el-table-column label="操作" align="center">
  122. <template #default="scope">
  123. <el-button
  124. link
  125. type="primary"
  126. v-hasPermi="['bpm:process-instance:cancel']"
  127. @click="handleDetail(scope.row)"
  128. >
  129. 详情
  130. </el-button>
  131. <el-button
  132. link
  133. type="primary"
  134. v-if="scope.row.status === 1"
  135. v-hasPermi="['bpm:process-instance:query']"
  136. @click="handleCancel(scope.row)"
  137. >
  138. 取消
  139. </el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <!-- 分页 -->
  144. <Pagination
  145. :total="total"
  146. v-model:page="queryParams.pageNo"
  147. v-model:limit="queryParams.pageSize"
  148. @pagination="getList"
  149. />
  150. </ContentWrap>
  151. </template>
  152. <script lang="ts" setup>
  153. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  154. import { dateFormatter } from '@/utils/formatTime'
  155. import { ElMessageBox } from 'element-plus'
  156. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  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. /** 查询列表 */
  175. const getList = async () => {
  176. loading.value = true
  177. try {
  178. const data = await ProcessInstanceApi.getMyProcessInstancePage(queryParams)
  179. list.value = data.list
  180. total.value = data.total
  181. } finally {
  182. loading.value = false
  183. }
  184. }
  185. /** 搜索按钮操作 */
  186. const handleQuery = () => {
  187. queryParams.pageNo = 1
  188. getList()
  189. }
  190. /** 重置按钮操作 */
  191. const resetQuery = () => {
  192. queryFormRef.value.resetFields()
  193. handleQuery()
  194. }
  195. /** 发起流程操作 **/
  196. const handleCreate = () => {
  197. router.push({
  198. name: 'BpmProcessInstanceCreate'
  199. })
  200. }
  201. /** 查看详情 */
  202. const handleDetail = (row) => {
  203. router.push({
  204. name: 'BpmProcessInstanceDetail',
  205. query: {
  206. id: row.id
  207. }
  208. })
  209. }
  210. /** 取消按钮操作 */
  211. const handleCancel = async (row) => {
  212. // 二次确认
  213. const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
  214. confirmButtonText: t('common.ok'),
  215. cancelButtonText: t('common.cancel'),
  216. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  217. inputErrorMessage: '取消原因不能为空'
  218. })
  219. // 发起取消
  220. await ProcessInstanceApi.cancelProcessInstance(row.id, value)
  221. message.success('取消成功')
  222. // 刷新列表
  223. await getList()
  224. }
  225. /** 激活时 **/
  226. onActivated(() => {
  227. getList()
  228. })
  229. /** 初始化 **/
  230. onMounted(() => {
  231. getList()
  232. })
  233. </script>