taskSubmit.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="">
  3. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
  4. labelWidth='140rpx'>
  5. <u-form-item label="审批建议" prop="reason" required>
  6. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  7. v-model="form.reason"></u--textarea>
  8. </u-form-item>
  9. </u--form>
  10. <view>
  11. <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
  12. text="通过" @click="handleAudit(1)">
  13. </u-button>
  14. <u-button style="width: 100%;margin-bottom: 10rpx;" :loading='loading' type="error" icon="close" text="驳回"
  15. @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
  16. <u-button style="width: 100%;margin-bottom: 10rpx;" :loading='loading' type="info" icon="close" text="作废"
  17. @click="handleCancel()"></u-button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. approveTaskWithVariables,
  24. rejectTask,
  25. cancelTask,
  26. } from '@/api/wt/index.js'
  27. export default {
  28. name: 'taskSubmit',
  29. props: {
  30. businessId: {
  31. default: ''
  32. },
  33. taskId: {
  34. default: ''
  35. },
  36. id: {
  37. default: ''
  38. },
  39. taskDefinitionKey: {
  40. default: ''
  41. }
  42. },
  43. data() {
  44. return {
  45. loading: false,
  46. form: {
  47. technicianId: '',
  48. reason: '',
  49. },
  50. rules: {
  51. reason: {
  52. type: 'string',
  53. required: true,
  54. message: '请输入审批建议',
  55. trigger: 'blur'
  56. }
  57. }
  58. }
  59. },
  60. mounted() {
  61. this.$refs.uForm.setRules(this.rules)
  62. },
  63. methods: {
  64. async handleAudit(status) {
  65. if (!!status) await this.$refs.uForm.validate()
  66. this.loading = true
  67. await this._approveTaskWithVariables(status);
  68. },
  69. async _approveTaskWithVariables(status) {
  70. let variables = {
  71. pass: !!status
  72. };
  73. const requestApi = status == 1 ? approveTaskWithVariables : rejectTask
  74. // console.log('variables~~~', variables)
  75. try {
  76. let res = await requestApi({
  77. id: this.taskId,
  78. reason: this.form.reason,
  79. variables
  80. })
  81. // console.log('res~~~', res)
  82. this.loading = false
  83. if (res.code != '-1') {
  84. this.$emit('handleAudit', {
  85. status,
  86. title: status === 0 ? '驳回' : ''
  87. });
  88. }
  89. } catch (error) {
  90. console.log('error~~~', error)
  91. this.loading = false
  92. }
  93. },
  94. handleCancel() {
  95. uni.showModal({
  96. title: '提示',
  97. content: '是否确认作废?',
  98. success: (res) => {
  99. if (res.confirm) {
  100. this.loading = true
  101. cancelTask({
  102. taskId: this.taskId,
  103. id: this.id,
  104. reason: this.form.reason,
  105. businessId: this.businessId,
  106. }).then(() => {
  107. if (res.code != '-1') {
  108. this.loading = false
  109. this.$emit('handleAudit', {
  110. title: '作废'
  111. });
  112. }
  113. }).catch(() => {
  114. this.loading = false
  115. this.$message.error("流程作废失败");
  116. });
  117. } else if (res.cancel) {
  118. console.log('用户点击取消');
  119. }
  120. }
  121. });
  122. },
  123. getTableValue() {
  124. return new Promise((resolve, reject) => {
  125. this.$emit('getTableValue', async (data) => {
  126. resolve(await data);
  127. });
  128. });
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. </style>