submit.vue 3.2 KB

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