submit.vue 3.7 KB

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