submit.vue 3.6 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. <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. @click="handleAudit(1)"
  26. >通过
  27. </el-button>
  28. <el-button
  29. icon="el-icon-circle-close"
  30. type="danger"
  31. size="mini"
  32. @click="handleAudit(0)"
  33. >驳回
  34. </el-button>
  35. </div>
  36. </el-col>
  37. </template>
  38. <script>
  39. import { approveTaskWithVariables } from '@/api/bpm/task';
  40. import storageApi from '@/api/warehouseManagement';
  41. export default {
  42. data() {
  43. return {
  44. form: {}
  45. };
  46. },
  47. props: {
  48. businessId: {
  49. default: ''
  50. },
  51. taskId: {
  52. default: ''
  53. },
  54. id: {
  55. default: ''
  56. },
  57. taskDefinitionKey: {
  58. default: ''
  59. }
  60. },
  61. methods: {
  62. handleAudit(status) {
  63. if (!this.form.reason && status == 1) {
  64. this.$message.warning(`请填写审批意见!`);
  65. return;
  66. }
  67. this._approveTaskWithVariables(status);
  68. },
  69. async _approveTaskWithVariables(status) {
  70. console.log(status);
  71. console.log(this.taskDefinitionKey);
  72. // return
  73. if (status == 1) {
  74. if (this.taskDefinitionKey === 'storage') {
  75. const res = await storageApi.allot({ applyId: this.businessId });
  76. if (res.data.code != '-1') {
  77. const params = {
  78. id: this.taskId,
  79. reason: this.form.reason,
  80. variables: { pass: true }
  81. };
  82. const data = await approveTaskWithVariables(params);
  83. if (data.data.code != '-1') {
  84. this.$emit('handleAudit', {
  85. status,
  86. title: '通过'
  87. });
  88. }
  89. }
  90. } else {
  91. const params = {
  92. id: this.taskId,
  93. reason: this.form.reason,
  94. variables: { pass: true }
  95. };
  96. const data = await approveTaskWithVariables(params);
  97. if (data.data.code != '-1') {
  98. this.$emit('handleAudit', {
  99. status,
  100. title: '通过'
  101. });
  102. }
  103. }
  104. } else {
  105. // 调拨出库 storage
  106. if (this.taskDefinitionKey === 'outbound' || this.taskDefinitionKey === 'storage') {
  107. const data = await storageApi.notAllotPass({
  108. id: this.businessId,
  109. reason: this.form.reason,
  110. taskId: this.taskId
  111. });
  112. if (data.data.code != '-1') {
  113. this.$emit('handleAudit', {
  114. status,
  115. title: '驳回'
  116. });
  117. }
  118. } else {
  119. const params = {
  120. id: this.taskId,
  121. reason: this.form.reason,
  122. variables: { pass: false }
  123. };
  124. const data = await approveTaskWithVariables(params);
  125. if (data.data.code != '-1') {
  126. this.$emit('handleAudit', {
  127. status,
  128. title: '驳回'
  129. });
  130. }
  131. }
  132. }
  133. }
  134. }
  135. };
  136. </script>