submit.vue 4.2 KB

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