IndexPage.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 #status="{ row }">
  14. <el-tag size="small" :type="statusList[row.status].color">{{ statusList[row.status].text }}</el-tag>
  15. </template>
  16. <template #actions="{ row }">
  17. <m-button type="primary" text @click="onProcess(row)">审批进度</m-button>
  18. <slot name="actions" :row="row"></slot>
  19. </template>
  20. </m-table>
  21. <ApprovalProgress ref="approvalProgressRefs"></ApprovalProgress>
  22. </div>
  23. </template>
  24. <script>
  25. import {
  26. getApprovalList
  27. } from '@/api/approval'
  28. import ApprovalProgress from './ApprovalProgress'
  29. export default {
  30. name: 'IndexPage',
  31. components: {
  32. ApprovalProgress
  33. },
  34. props: {
  35. dataType: {
  36. type: Number,
  37. default: 0
  38. }
  39. },
  40. data () {
  41. return {
  42. statusList: [
  43. { text: '处理中', color: 'default' },
  44. { text: '审批通过', color: 'success' },
  45. { text: '审批拒绝', color: 'danger' },
  46. { text: '异常结束', color: 'warning' }
  47. ],
  48. searchItems: [
  49. {
  50. label: '名称',
  51. prop: 'title',
  52. type: 'input',
  53. options: {
  54. placeholder: '请输入名称'
  55. }
  56. }
  57. ],
  58. searchValues: {
  59. title: null
  60. },
  61. headers: [
  62. { label: '审批功能名称', prop: 'title' },
  63. { label: '发起人', prop: 'createUserName' },
  64. { label: '发起时间', prop: 'createDate' },
  65. { label: '审核状态', prop: 'status', align: 'center' },
  66. { label: '工作流版本号', prop: 'version' },
  67. { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
  68. ],
  69. items: [],
  70. total: 0,
  71. pageInfo: {
  72. current: 1,
  73. size: 10
  74. },
  75. loading: false
  76. }
  77. },
  78. created () {
  79. this.onInit()
  80. },
  81. methods: {
  82. async onInit () {
  83. this.loading = true
  84. try {
  85. const { data } = await getApprovalList({
  86. dataType: this.dataType,
  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. onProcess ({ workFlowInstanceId }) {
  106. this.$refs.approvalProgressRefs.open(workFlowInstanceId)
  107. },
  108. async onDetails (item) {
  109. this.$refs.approvalDetailsRefs.open(item)
  110. },
  111. onSearch () {
  112. this.pageInfo.current = 1
  113. this.onInit()
  114. },
  115. onPageChange (index) {
  116. this.pageInfo.current = index
  117. this.onInit()
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. /* 自定义样式 */
  124. </style>