submit.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. <ApprovalOpinion ref="approvalOpinion" v-model="form.reason" />
  14. </el-form-item>
  15. </el-form>
  16. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  17. <el-button
  18. icon="el-icon-edit-outline"
  19. type="success"
  20. size="mini"
  21. v-click-once
  22. @click="$refs.approvalOpinion.validate(1) && handleAudit(1)"
  23. >通过
  24. </el-button>
  25. <el-button
  26. icon="el-icon-circle-close"
  27. type="danger"
  28. size="mini"
  29. v-click-once
  30. @click="$refs.approvalOpinion.validate(0) && handleAudit(0)"
  31. v-if="!['starter'].includes(taskDefinitionKey)"
  32. >驳回
  33. </el-button>
  34. <el-dropdown @command="(command) => handleCommand(command)" style="margin-left: 30px;">
  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="cancel">作废</el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. </div>
  43. </el-col>
  44. </template>
  45. <script>
  46. import { UpdateInformation, cancel } from '@/api/bpm/components/purchasingManage/purchaseNeedManage';
  47. import {approveTaskWithVariables, rejectTask,cancelTask} from '@/api/bpm/task';
  48. // 流程实例的详情页,可用于审批
  49. export default {
  50. name: '',
  51. components: {
  52. // Parser
  53. },
  54. props: {
  55. businessId: {
  56. default: ''
  57. },
  58. taskId: {
  59. default: ''
  60. },
  61. id: {
  62. default: ''
  63. },
  64. taskDefinitionKey: {
  65. default: ''
  66. }
  67. },
  68. data() {
  69. return {
  70. form: {
  71. reason: '同意'
  72. }
  73. };
  74. },
  75. created() {},
  76. methods: {
  77. /** 处理转办审批人 */
  78. handleUpdateAssignee() {
  79. this.$emit('handleUpdateAssignee');
  80. },
  81. /** 退回 */
  82. handleBackList() {
  83. this.$emit('handleBackList');
  84. },
  85. async handleAudit(status) {
  86. //发起人
  87. if (this.taskDefinitionKey === 'starter') {
  88. let arr = await this.getTableValue();
  89. if (!arr) {
  90. return;
  91. }
  92. let data = await UpdateInformation(arr);
  93. if (data.code != '0') {
  94. return;
  95. }
  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. }).then(() => {
  132. cancelTask({
  133. taskId: this.taskId,
  134. id: this.id,
  135. reason: this.form.reason,
  136. businessId: this.businessId,
  137. }).then(() => {
  138. this.$emit('handleClose');
  139. }).catch(() => {
  140. this.$message.error("流程作废失败");
  141. });
  142. }).catch(() => {});
  143. }
  144. },
  145. }
  146. };
  147. </script>
  148. <style lang="scss"></style>