taskSubmit.vue 3.7 KB

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