index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="pa-3 white">
  3. <m-search class="mb-3" :items="searchItems" v-model="searchValue" @search="search"></m-search>
  4. <m-table
  5. v-loading="loading"
  6. :headers="headers"
  7. :items="items"
  8. :total="total"
  9. @page-change="paginationChange"
  10. @sort-change="onSortChange"
  11. >
  12. <template #card-tools>
  13. <m-button type="orange" size="small" icon="el-icon-plus" @click="onAdd">新增</m-button>
  14. </template>
  15. <template #actions="{ row }">
  16. <m-button type="primary" text @click="getDetails(row, 'workflowEditRefs')">编辑</m-button>
  17. <m-button type="primary" text @click="getDetails(row, 'workflowApprovedRefs')">审批配置</m-button>
  18. <m-button type="danger" text @click="onDelete(row)">删除</m-button>
  19. </template>
  20. </m-table>
  21. <WorkflowEdit ref="workflowEditRefs" @refresh="onInit"></WorkflowEdit>
  22. <WorkflowApproved ref="workflowApprovedRefs"></WorkflowApproved>
  23. </div>
  24. </template>
  25. <script>
  26. import {
  27. getWorkflowList,
  28. getWorkflow,
  29. deleteWorkflow
  30. } from '@/api/workflow'
  31. import WorkflowEdit from './workflowEdit'
  32. import WorkflowApproved from './workflowApproved'
  33. export default {
  34. name: 'WorkFlow',
  35. components: {
  36. WorkflowEdit,
  37. WorkflowApproved
  38. },
  39. data () {
  40. return {
  41. searchItems: [
  42. {
  43. prop: 'name',
  44. label: '名称',
  45. type: 'input',
  46. options: {
  47. placeholder: '请输入工作流名称'
  48. }
  49. },
  50. {
  51. prop: 'status',
  52. label: '状态',
  53. type: 'select',
  54. options: {
  55. placeholder: '请选择状态',
  56. items: [
  57. { label: '启用', value: 0 },
  58. { label: '禁用', value: 1 }
  59. ]
  60. }
  61. }
  62. ],
  63. searchValue: {
  64. name: null,
  65. status: null
  66. },
  67. headers: [
  68. { label: '工作流名称', prop: 'name', sortable: 'custom' },
  69. { label: '功能地址', prop: 'funUrl', sortable: 'custom' },
  70. { label: '状态', prop: 'status', sortable: 'custom' },
  71. { label: '版本', prop: 'version', sortable: 'custom' },
  72. { label: '创建时间', prop: 'createDate', sortable: 'custom' },
  73. { label: '操作', prop: 'actions' }
  74. ],
  75. items: [],
  76. pageInfo: {
  77. size: 10,
  78. current: 1
  79. },
  80. orders: [],
  81. loading: false,
  82. total: 0
  83. }
  84. },
  85. created () {
  86. this.onInit()
  87. },
  88. methods: {
  89. async onInit () {
  90. this.loading = true
  91. try {
  92. const { data } = await getWorkflowList({
  93. page: {
  94. ...this.pageInfo,
  95. orders: this.orders
  96. },
  97. entity: {
  98. ...this.searchValue
  99. }
  100. })
  101. this.items = data.records
  102. this.total = data.total
  103. } catch (error) {
  104. this.$message.error(error)
  105. } finally {
  106. this.loading = false
  107. }
  108. },
  109. onAdd () {
  110. this.$refs.workflowEditRefs.open()
  111. },
  112. search () {
  113. this.pageInfo.current = 1
  114. this.onInit()
  115. },
  116. async getDetails (row, ref) {
  117. this.loading = true
  118. try {
  119. const { data } = await getWorkflow({ workFlowTmplateId: row.workFlowTmplateId })
  120. this.$refs[ref].open(data)
  121. } catch (error) {
  122. this.$message.error(error)
  123. } finally {
  124. this.loading = false
  125. }
  126. },
  127. onDelete (row) {
  128. this.$confirm('确定删除吗?', '提示').then(async () => {
  129. try {
  130. await deleteWorkflow({ workFlowTmplateId: row.workFlowTmplateId })
  131. this.$message.success('删除成功')
  132. this.onInit()
  133. } catch (error) {
  134. this.$message.error(error)
  135. }
  136. }).catch(_ => {})
  137. },
  138. paginationChange (page) {
  139. this.searchValue.page = page
  140. this.search()
  141. },
  142. onSortChange (e) {
  143. console.log(e)
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. </style>