submit.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. :loading="isLoading"
  22. v-click-once
  23. @click="$refs.approvalOpinion.validate(1) && handleAudit(1)"
  24. >通过
  25. </el-button>
  26. <el-button
  27. icon="el-icon-circle-close"
  28. type="danger"
  29. size="mini"
  30. :loading="isLoading"
  31. v-click-once
  32. @click="$refs.approvalOpinion.validate(0) && handleAudit(0)"
  33. >驳回
  34. </el-button>
  35. <el-dropdown
  36. @command="(command) => handleCommand(command)"
  37. style="margin-left: 30px"
  38. >
  39. <span class="el-dropdown-link">
  40. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  41. </span>
  42. <el-dropdown-menu slot="dropdown">
  43. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. </div>
  47. </el-col>
  48. </template>
  49. <script>
  50. import {
  51. approveTaskWithVariables,
  52. rejectTask,
  53. cancelTask
  54. } from '@/api/bpm/task';
  55. export default {
  56. name: 'HrContractSubmit',
  57. props: {
  58. businessId: {
  59. default: ''
  60. },
  61. taskId: {
  62. default: ''
  63. },
  64. id: {
  65. default: ''
  66. },
  67. taskDefinitionKey: {
  68. default: ''
  69. }
  70. },
  71. data() {
  72. return {
  73. isLoading: false,
  74. form: {
  75. reason: '同意'
  76. }
  77. };
  78. },
  79. methods: {
  80. async handleAudit(status) {
  81. if (!this.form.reason && !!status) {
  82. this.$message.warning('请填写审批意见');
  83. return;
  84. }
  85. await this._approveTaskWithVariables(status);
  86. },
  87. handleCommand(command) {
  88. if (command === 'cancel') {
  89. this.$confirm('是否确认作废?', {
  90. type: 'warning',
  91. cancelButtonText: '取消',
  92. confirmButtonText: '确定'
  93. })
  94. .then(() => {
  95. cancelTask({
  96. id: this.id,
  97. taskId: this.taskId,
  98. reason: this.form.reason,
  99. businessId: this.businessId
  100. })
  101. .then(() => {
  102. this.$emit('handleClose');
  103. })
  104. .catch(() => {
  105. this.$message.error('流程作废失败');
  106. });
  107. })
  108. .catch(() => {});
  109. }
  110. },
  111. async _approveTaskWithVariables(status) {
  112. const API = !!status ? approveTaskWithVariables : rejectTask;
  113. try {
  114. this.isLoading = true;
  115. const res = await API({
  116. id: this.taskId,
  117. reason: this.form.reason,
  118. variables: {
  119. pass: !!status
  120. }
  121. });
  122. if (res.data.code != '-1') {
  123. this.$emit('handleAudit', {
  124. status,
  125. title: status === 0 ? '驳回' : ''
  126. });
  127. }
  128. } finally {
  129. this.isLoading = false;
  130. }
  131. }
  132. }
  133. };
  134. </script>
  135. <style lang="scss"></style>