index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div v-loading="loading">
  3. <IndexPage ref="indexPageRefs" :dataType="1">
  4. <template #actions="{ row }">
  5. <m-button type="primary" text @click="onDetails(row)">查看申请单</m-button>
  6. <m-button v-if="row.status === 0" text type="danger" @click="onUrgent(row)">加急</m-button>
  7. </template>
  8. </IndexPage>
  9. <ApprovalDetails ref="approvalDetailsRefs" @close="onClose"></ApprovalDetails>
  10. </div>
  11. </template>
  12. <script>
  13. import IndexPage from '../components/IndexPage.vue'
  14. import ApprovalDetails from '../components/ApprovalDetails.vue'
  15. import {
  16. getApprovalUrge,
  17. getApprovalList
  18. } from '@/api/approval'
  19. export default {
  20. name: 'myOrder',
  21. components: {
  22. IndexPage,
  23. ApprovalDetails
  24. },
  25. data () {
  26. return {
  27. loading: false
  28. }
  29. },
  30. watch: {
  31. '$route.query.id' (val) {
  32. if (val) {
  33. this.onGetDetails(val)
  34. }
  35. }
  36. },
  37. methods: {
  38. onClose () {
  39. this.$router.push(this.$route.path)
  40. },
  41. async onGetDetails (workFlowInstanceId) {
  42. this.loading = true
  43. try {
  44. const { data } = await getApprovalList({
  45. dataType: 1,
  46. entity: {
  47. workFlowInstanceId
  48. }
  49. })
  50. if (!data.records.length) {
  51. return
  52. }
  53. // 唤起审核详情
  54. this.onDetails(data.records[0])
  55. } catch (error) {
  56. this.$message.error(error)
  57. } finally {
  58. this.loading = false
  59. }
  60. },
  61. onDetails (item) {
  62. this.$refs.approvalDetailsRefs.open(item)
  63. },
  64. async onUrgent ({ workFlowInstanceId }) {
  65. try {
  66. await getApprovalUrge({ workFlowInstanceId })
  67. this.$message.success('加急成功')
  68. this.$refs.indexPageRefs.onInit()
  69. } catch (error) {
  70. this.$message.error(error)
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. </style>