index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="pa-3 white">
  3. <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  4. <m-table
  5. v-loading="loading"
  6. :items="items"
  7. :headers="headers"
  8. :page-size="pageInfo.size"
  9. :page-current="pageInfo.current"
  10. :total="total"
  11. @page-change="onPageChange"
  12. >
  13. <template #opType="{ row }">
  14. <el-tag size="small" :type="statusList[row.opType].color">{{ statusList[row.opType].text }}</el-tag>
  15. </template>
  16. <template #actions="{ row }">
  17. <m-button type="primary" text @click="onDetails(row)">审批进度</m-button>
  18. <template v-if="row.opType === 1">
  19. <m-button type="primary" class="mr-2" text @click="onApproval(row.workFlowInstanceId)">通过审核</m-button>
  20. <m-button type="danger" text @click="onApprovalReject(row)">拒绝通过</m-button>
  21. </template>
  22. </template>
  23. </m-table>
  24. <ApprovalProgress ref="approvalProgressRefs"></ApprovalProgress>
  25. <ApprovalReject ref="approvalRejectRefs" @refresh="onInit"></ApprovalReject>
  26. </div>
  27. </template>
  28. <script>
  29. import {
  30. getApprovalList,
  31. getApprovalProgress,
  32. setApproval
  33. } from '@/api/approval'
  34. import ApprovalProgress from './approvalProgress.vue'
  35. import ApprovalReject from './approvalReject.vue'
  36. export default {
  37. name: 'ApprovalPage',
  38. components: {
  39. ApprovalProgress,
  40. ApprovalReject
  41. },
  42. data () {
  43. return {
  44. statusList: [
  45. { text: '我发起的 ', color: 'default' },
  46. { text: '待我审批 ', color: 'warning' },
  47. { text: '我已审批 ', color: 'success' }
  48. ],
  49. searchItems: [
  50. {
  51. label: '名称',
  52. prop: 'name',
  53. type: 'input',
  54. options: {
  55. placeholder: '请输入名称'
  56. }
  57. }
  58. ],
  59. searchValues: {
  60. name: null
  61. },
  62. headers: [
  63. { label: '名称', prop: 'title' },
  64. { label: '发起人', prop: 'createUserName' },
  65. { label: '状态', prop: 'opType', align: 'center' },
  66. { label: '发起时间', prop: 'createDate' },
  67. { label: '版本号', prop: 'version' },
  68. { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
  69. ],
  70. items: [],
  71. total: 0,
  72. pageInfo: {
  73. current: 1,
  74. size: 10
  75. },
  76. loading: false
  77. }
  78. },
  79. created () {
  80. this.onInit()
  81. },
  82. methods: {
  83. async onInit () {
  84. this.loading = true
  85. try {
  86. const { data } = await getApprovalList({
  87. page: {
  88. ...this.pageInfo,
  89. orders: [
  90. { column: 'create_date', asc: false }
  91. ]
  92. },
  93. entity: {
  94. ...this.searchValues
  95. }
  96. })
  97. this.items = data.records
  98. this.total = data.total || 0
  99. } catch (error) {
  100. this.$message.error(error)
  101. } finally {
  102. this.loading = false
  103. }
  104. },
  105. async onDetails ({ workFlowInstanceId }) {
  106. try {
  107. const { data } = await getApprovalProgress({ workFlowInstanceId })
  108. this.$refs.approvalProgressRefs.open(data)
  109. } catch (error) {
  110. this.$message.error(error)
  111. }
  112. },
  113. onApprovalReject (item) {
  114. this.$refs.approvalRejectRefs.open(item)
  115. },
  116. async onApproval (workFlowInstanceId, status) {
  117. try {
  118. await setApproval({
  119. workFlowInstanceId: workFlowInstanceId,
  120. status: 1
  121. })
  122. this.$message.success(status ? '审批通过' : '拒绝成功')
  123. } catch (error) {
  124. this.$message.error(error)
  125. }
  126. },
  127. onSearch () {
  128. this.pageInfo.current = 1
  129. this.onInit()
  130. },
  131. onPageChange (index) {
  132. this.pageInfo.current = index
  133. this.onInit()
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. /* 自定义样式 */
  140. </style>