taskSubmit.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 class="btnList">
  11. <u-button style="width: 45%;margin-bottom: 10rpx;" :loading='loading' type="success" text="通过"
  12. @click="handleAudit(1)">
  13. </u-button>
  14. <u-button style="width: 45%;" :loading='loading' type="error" text="驳回" @click="rejectTask(0)"></u-button>
  15. </view>
  16. <view class="btnConcel">
  17. <u-button @click="showAction = true">更多</u-button>
  18. </view>
  19. <u-action-sheet :actions="actionList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="更多操作" :show="showAction" @close="showAction = false" @select="selectActionClick"></u-action-sheet>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. approveTaskWithVariables,
  25. rejectTask,
  26. cancelTask
  27. } from '@/api/wt/index.js'
  28. export default {
  29. name: 'taskSubmit',
  30. props: {
  31. businessId: {
  32. default: ''
  33. },
  34. taskId: {
  35. default: ''
  36. },
  37. id: {
  38. default: ''
  39. },
  40. taskDefinitionKey: {
  41. default: ''
  42. }
  43. },
  44. data() {
  45. return {
  46. showAction: false,
  47. loading: false,
  48. actionList: [{
  49. name: '作废',
  50. fontSize: '28',
  51. color: '#ffaa7f'
  52. }],
  53. form: {
  54. technicianId: '',
  55. reason: '',
  56. },
  57. rules: {
  58. reason: {
  59. type: 'string',
  60. required: true,
  61. message: '请输入审批建议',
  62. trigger: 'blur'
  63. }
  64. }
  65. }
  66. },
  67. mounted() {
  68. this.$refs.uForm.setRules(this.rules)
  69. },
  70. methods: {
  71. selectActionClick(item) {
  72. console.log('selectActionClick', item)
  73. if (item.name == '作废') {
  74. uni.showModal({
  75. title: '提示',
  76. content: '是否确认作废?',
  77. success: (res) => {
  78. if (res.confirm) {
  79. this.loading = true
  80. cancelTask({
  81. taskId: this.taskId,
  82. id: this.id,
  83. reason: this.form.reason,
  84. businessId: this.businessId,
  85. }).then(() => {
  86. if (res.code != '-1') {
  87. this.loading = false
  88. this.$emit('handleAudit', {
  89. title: '作废'
  90. });
  91. }
  92. }).catch(() => {
  93. this.loading = false
  94. this.$message.error("流程作废失败");
  95. });
  96. } else if (res.cancel) {
  97. console.log('用户点击取消');
  98. }
  99. }
  100. });
  101. }
  102. },
  103. async handleAudit(status) {
  104. if (!!status) await this.$refs.uForm.validate()
  105. this.loading = true
  106. await this._approveTaskWithVariables(status);
  107. },
  108. async _approveTaskWithVariables(status) {
  109. let variables = {
  110. pass: !!status
  111. };
  112. let res = await approveTaskWithVariables({
  113. id: this.taskId,
  114. reason: this.form.reason,
  115. variables
  116. })
  117. if (res.code != '-1') {
  118. this.$emit('handleAudit', {
  119. status,
  120. title: status === 0 ? '驳回' : ''
  121. });
  122. }
  123. this.loading = false
  124. },
  125. async rejectTask(status) {
  126. let variables = {
  127. pass: !!status
  128. };
  129. let res = await rejectTask({
  130. id: this.taskId,
  131. reason: this.form.reason,
  132. variables
  133. })
  134. if (res.code != '-1') {
  135. this.$emit('handleAudit', {
  136. status,
  137. title: status === 0 ? '驳回' : ''
  138. });
  139. }
  140. this.loading = false
  141. },
  142. getTableValue() {
  143. return new Promise((resolve, reject) => {
  144. this.$emit('getTableValue', async (data) => {
  145. resolve(await data);
  146. });
  147. });
  148. }
  149. }
  150. }
  151. </script>
  152. <style>
  153. .btnList {
  154. display: flex;
  155. }
  156. </style>