index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div v-loading="loading">
  3. <IndexPage ref="indexPageRefs" :dataType="dataType">
  4. <template #actions="{ row }">
  5. <m-button type="danger" text @click="onDetails(row)">审核</m-button>
  6. </template>
  7. </IndexPage>
  8. <ApprovalDetails ref="approvalDetailsRefs" @close="onClose">
  9. <template #approval-btn>
  10. <div>
  11. <m-button type="success" size="small" icon="el-icon-check" class="mr-3" @click="onApproval">通过</m-button>
  12. <el-popover
  13. placement="bottom"
  14. v-model="visible"
  15. width="300"
  16. trigger="click"
  17. >
  18. <el-input v-model="msg" type="textarea" :rows="3" placeholder="请输入拒绝原因"></el-input>
  19. <div class="pt-3 text-right">
  20. <m-button size="mini" @click="visible = false">取消</m-button>
  21. <m-button size="mini" type="orange" @click="onApprovalReject">提交</m-button>
  22. </div>
  23. <template #reference>
  24. <m-button type="danger" size="small" icon="el-icon-close">拒绝</m-button>
  25. </template>
  26. </el-popover>
  27. </div>
  28. </template>
  29. </ApprovalDetails>
  30. </div>
  31. </template>
  32. <script>
  33. import IndexPage from '../components/IndexPage.vue'
  34. import ApprovalDetails from '../components/ApprovalDetails.vue'
  35. import {
  36. setApproval,
  37. getApprovalList
  38. } from '@/api/approval'
  39. export default {
  40. name: 'ApprovalPage',
  41. components: {
  42. IndexPage,
  43. ApprovalDetails
  44. },
  45. data () {
  46. return {
  47. msg: null,
  48. visible: false,
  49. loading: false,
  50. dataType: 3,
  51. itemData: {}
  52. }
  53. },
  54. watch: {
  55. '$route.query.id': {
  56. handler (val) {
  57. if (val) {
  58. this.onGetDetails(val)
  59. }
  60. },
  61. immediate: true
  62. }
  63. },
  64. // created () {
  65. // if (this.$route.query.id) {
  66. // // 获取数据明细
  67. // this.onGetDetails(this.$route.query.id)
  68. // }
  69. // },
  70. methods: {
  71. onClose () {
  72. this.$router.push(this.$route.path)
  73. },
  74. async onGetDetails (workFlowInstanceId) {
  75. this.loading = true
  76. try {
  77. const { data } = await getApprovalList({
  78. dataType: this.dataType,
  79. entity: {
  80. workFlowInstanceId
  81. }
  82. })
  83. if (!data.records.length) {
  84. return
  85. }
  86. // 唤起审核详情
  87. this.onDetails(data.records[0])
  88. } catch (error) {
  89. this.$message.error(error)
  90. } finally {
  91. this.loading = false
  92. }
  93. },
  94. onRefresh () {
  95. this.$refs.approvalDetailsRefs.close()
  96. this.$refs.indexPageRefs.onInit()
  97. },
  98. onDetails (item) {
  99. this.itemData = item
  100. this.msg = null
  101. this.$refs.approvalDetailsRefs.open(item)
  102. },
  103. onApproval () {
  104. this.$confirm('确定审核通过吗?', '提示').then(async _ => {
  105. try {
  106. await setApproval({
  107. workFlowInstanceId: this.itemData.workFlowInstanceId,
  108. status: 1
  109. })
  110. this.$message.success('审核通过')
  111. this.onRefresh()
  112. } catch (error) {
  113. this.$message.error(error)
  114. }
  115. }).catch(_ => {})
  116. },
  117. async onApprovalReject () {
  118. if (!this.msg) {
  119. this.$message.error('请输入拒绝原因')
  120. return
  121. }
  122. try {
  123. await setApproval({
  124. workFlowInstanceId: this.itemData.workFlowInstanceId,
  125. status: 2,
  126. msg: this.msg
  127. })
  128. this.$refs.approvalDetailsRefs.close()
  129. this.$message.success('拒绝成功')
  130. this.onRefresh()
  131. } catch (error) {
  132. this.$message.error(error)
  133. }
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. </style>