submit.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <el-col :span="16" :offset="6" v-loading="isSaveLoading">
  3. <el-form label-width="100px" ref="formRef" :model="form" :rules="rules">
  4. <el-form-item label="审批意见" prop="reason" style="margin-bottom: 20px">
  5. <ApprovalOpinion ref="approvalOpinion" v-model="form.reason" />
  6. </el-form-item>
  7. </el-form>
  8. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  9. <el-button
  10. icon="el-icon-edit-outline"
  11. type="success"
  12. size="mini"
  13. v-click-once
  14. :loading="isSaveLoading"
  15. @click="$refs.approvalOpinion.validate(1) && handleAudit(1)"
  16. >通过
  17. </el-button>
  18. <el-button
  19. icon="el-icon-circle-close"
  20. type="danger"
  21. size="mini"
  22. v-click-once
  23. :loading="isSaveLoading"
  24. @click="$refs.approvalOpinion.validate(0) && handleAudit(0)"
  25. >驳回
  26. </el-button>
  27. <el-dropdown
  28. @command="(command) => handleCommand(command)"
  29. style="margin-left: 30px"
  30. >
  31. <span class="el-dropdown-link">
  32. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  33. </span>
  34. <el-dropdown-menu slot="dropdown">
  35. <el-dropdown-item command="transfer">转办</el-dropdown-item>
  36. <el-dropdown-item command="back">退回</el-dropdown-item>
  37. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </div>
  41. </el-col>
  42. </template>
  43. <script>
  44. import {
  45. approveTaskWithVariables,
  46. rejectTask,
  47. cancelTask
  48. } from '@/api/bpm/task';
  49. export default {
  50. name: 'ItemPublishApprovalSubmit',
  51. props: {
  52. businessId: {
  53. default: ''
  54. },
  55. businessCode: {
  56. default: ''
  57. },
  58. taskId: {
  59. default: ''
  60. },
  61. id: {
  62. default: ''
  63. },
  64. taskDefinitionKey: {
  65. default: ''
  66. },
  67. fromUser: {
  68. default: ''
  69. },
  70. businessType: {
  71. default: ''
  72. }
  73. },
  74. data() {
  75. return {
  76. form: {
  77. reason: '同意'
  78. },
  79. rules: {
  80. reason: [
  81. {
  82. required: true,
  83. message: '请输入审批建议',
  84. trigger: 'blur'
  85. }
  86. ]
  87. },
  88. isSaveLoading: false
  89. };
  90. },
  91. methods: {
  92. handleAudit(status) {
  93. this.$refs.formRef.validate((valid) => {
  94. if (!valid) {
  95. return;
  96. }
  97. this.approveTask(status);
  98. });
  99. },
  100. async approveTask(status) {
  101. const API = status ? approveTaskWithVariables : rejectTask;
  102. this.isSaveLoading = true;
  103. try {
  104. const res = await API({
  105. id: this.taskId,
  106. reason: this.form.reason,
  107. variables: {
  108. pass: !!status
  109. }
  110. });
  111. if (res.data.code != '-1') {
  112. this.$emit('handleAudit', {
  113. status,
  114. title: status === 0 ? '驳回' : ''
  115. });
  116. }
  117. } finally {
  118. this.isSaveLoading = false;
  119. }
  120. },
  121. handleCommand(command) {
  122. if (command === 'transfer') {
  123. this.$emit('handleUpdateAssignee');
  124. return;
  125. }
  126. if (command === 'back') {
  127. this.$emit('handleBackList');
  128. return;
  129. }
  130. if (command === 'cancel') {
  131. this.cancelTask();
  132. }
  133. },
  134. cancelTask() {
  135. this.$confirm('是否确认作废?', {
  136. type: 'warning',
  137. cancelButtonText: '取消',
  138. confirmButtonText: '确定'
  139. })
  140. .then(() => {
  141. this.isSaveLoading = true;
  142. return cancelTask({
  143. id: this.id,
  144. taskId: this.taskId,
  145. reason: this.form.reason,
  146. businessId: this.businessId
  147. });
  148. })
  149. .then(() => {
  150. this.$emit('handleClose');
  151. })
  152. .catch((error) => {
  153. if (error !== 'cancel') {
  154. this.$message.error('流程作废失败');
  155. }
  156. })
  157. .finally(() => {
  158. this.isSaveLoading = false;
  159. });
  160. }
  161. }
  162. };
  163. </script>
  164. <style lang="scss"></style>