submit.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: 'blur'
  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, rejectTask} from '@/api/bpm/task';
  40. import storageApi from '@/api/warehouseManagement';
  41. // 流程实例的详情页,可用于审批
  42. export default {
  43. name: '',
  44. props: {
  45. businessId: {
  46. default: ''
  47. },
  48. taskId: {
  49. default: ''
  50. },
  51. id: {
  52. default: ''
  53. },
  54. taskDefinitionKey: {
  55. default: ''
  56. }
  57. },
  58. data() {
  59. return {
  60. statusOption: [
  61. {
  62. label: '盘盈',
  63. value: '2',
  64. numKey: 'surplusQuantity'
  65. },
  66. {
  67. label: '丢失',
  68. value: '3',
  69. numKey: 'loseQuantity'
  70. },
  71. {
  72. label: '破损',
  73. value: '4',
  74. numKey: 'wornQuantity'
  75. }
  76. ],
  77. form: {
  78. reason: ''
  79. },
  80. userOptions: []
  81. };
  82. },
  83. methods: {
  84. async handleAudit(status) {
  85. await this._approveTaskWithVariables(status);
  86. },
  87. getTableValue() {
  88. return new Promise((resolve) => {
  89. this.$emit('getTableValue', async (data) => {
  90. resolve(await data);
  91. });
  92. });
  93. },
  94. async _approveTaskWithVariables(status) {
  95. if (this.taskDefinitionKey == 'Activity_1l4tn01') {
  96. // 驳回(主管审核)
  97. if (!status) {
  98. const data = await storageApi.notProfitLoss({
  99. id: this.businessId,
  100. reason: this.form.reason,
  101. taskId: this.taskId
  102. });
  103. if (data.data.code != '-1') {
  104. this.$emit('handleAudit', {
  105. status,
  106. title: '驳回'
  107. });
  108. }
  109. return;
  110. }
  111. } else if (this.taskDefinitionKey == 'Activity_1ftg2hu') {
  112. // 通过(仓管审核)
  113. if (!!status) {
  114. console.log('通过了!!!!');
  115. let infoData = await this.getTableValue();
  116. let params = infoData.info[0].planDetailVOList.map((item) => {
  117. let filterArr = this.statusOption.filter(
  118. (ite) => ite.value == item.status
  119. )[0];
  120. console.log(filterArr.numKey);
  121. return {
  122. id: this.businessId,
  123. isAdd: filterArr.numKey == 'surplusQuantity' ? true : false,
  124. packingNo: item.packageNo,
  125. quantity: item[filterArr.numKey]
  126. };
  127. });
  128. try {
  129. await storageApi.addSubtractStockPacking(params);
  130. } catch (error) {
  131. this.$message.error('保存失败');
  132. return;
  133. }
  134. }
  135. }
  136. let variables = {
  137. pass: !!status
  138. };
  139. let API = !!status ? approveTaskWithVariables : rejectTask;
  140. API({
  141. id: this.taskId,
  142. reason: this.form.reason,
  143. variables
  144. }).then((res) => {
  145. if (res.data.code != '-1') {
  146. this.$emit('handleAudit', {
  147. status,
  148. title: status === 0 ? '驳回' : ''
  149. });
  150. }
  151. });
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss"></style>