submit.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. >驳回
  32. </el-button>
  33. <el-dropdown
  34. @command="(command) => handleCommand(command)"
  35. style="margin-left: 30px"
  36. >
  37. <span class="el-dropdown-link">
  38. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  39. </span>
  40. <el-dropdown-menu slot="dropdown">
  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 { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
  49. export default {
  50. name: '',
  51. props: {
  52. businessId: {
  53. default: ''
  54. },
  55. taskId: {
  56. default: ''
  57. },
  58. id: {
  59. default: ''
  60. },
  61. taskDefinitionKey: {
  62. default: ''
  63. }
  64. },
  65. data() {
  66. return {
  67. visible: false,
  68. form: {
  69. reason: '同意'
  70. },
  71. };
  72. },
  73. created() {},
  74. methods: {
  75. async handleAudit(status) {
  76. await this._approveTaskWithVariables(status);
  77. },
  78. //更多
  79. handleCommand(command) {
  80. if (command === 'cancel') {
  81. this.$confirm('是否确认作废?', {
  82. type: 'warning',
  83. cancelButtonText: '取消',
  84. confirmButtonText: '确定'
  85. })
  86. .then(() => {
  87. cancelTask({
  88. id: this.id,
  89. taskId: this.taskId,
  90. reason: this.form.reason,
  91. businessId: this.businessId
  92. })
  93. .then(() => {
  94. this.$emit('handleClose');
  95. })
  96. .catch(() => {
  97. this.$message.error('流程作废失败');
  98. });
  99. })
  100. .catch(() => {});
  101. }
  102. },
  103. async _approveTaskWithVariables(status) {
  104. let variables = {
  105. pass: !!status
  106. };
  107. let API = !!status ? approveTaskWithVariables : rejectTask;
  108. API({
  109. id: this.taskId,
  110. reason: this.form.reason,
  111. variables
  112. }).then((res) => {
  113. if (res.data.code != '-1') {
  114. this.$emit('handleAudit', {
  115. status,
  116. title: status === 0 ? '驳回' : ''
  117. });
  118. }
  119. });
  120. }
  121. }
  122. };
  123. </script>
  124. <style lang="scss"></style>