submit.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. 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. </div>
  38. </el-col>
  39. </template>
  40. <script>
  41. import { approveTaskWithVariables } from '@/api/bpm/task';
  42. import storageApi from '@/api/warehouseManagement';
  43. // 流程实例的详情页,可用于审批
  44. export default {
  45. name: '',
  46. props: {
  47. businessId: {
  48. default: ''
  49. },
  50. taskId: {
  51. default: ''
  52. },
  53. id: {
  54. default: ''
  55. },
  56. taskDefinitionKey: {
  57. default: ''
  58. }
  59. },
  60. data() {
  61. return {
  62. statusOption: [
  63. {
  64. label: '盘盈',
  65. value: '2',
  66. numKey: 'surplusQuantity'
  67. },
  68. {
  69. label: '丢失',
  70. value: '3',
  71. numKey: 'loseQuantity'
  72. },
  73. {
  74. label: '破损',
  75. value: '4',
  76. numKey: 'wornQuantity'
  77. }
  78. ],
  79. form: {
  80. reason: '同意'
  81. },
  82. userOptions: []
  83. };
  84. },
  85. methods: {
  86. async handleAudit(status) {
  87. await this._approveTaskWithVariables(status);
  88. },
  89. getTableValue() {
  90. return new Promise((resolve) => {
  91. this.$emit('getTableValue', async (data) => {
  92. resolve(await data);
  93. });
  94. });
  95. },
  96. async _approveTaskWithVariables(status) {
  97. if (!status) {
  98. // 报损报溢所有节点驳回后都恢复为可编辑、可重新提交。
  99. const data = await storageApi.notProfitLoss({
  100. id: this.businessId,
  101. reason: this.form.reason,
  102. taskId: this.taskId
  103. });
  104. if (data.data.code != '-1') {
  105. this.$emit('handleAudit', {
  106. status,
  107. title: '驳回'
  108. });
  109. }
  110. return;
  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. categoryId: item.categoryId,
  127. batchNo: item.batchNo,
  128. systemBatchNo: item.systemBatchNo
  129. };
  130. });
  131. console.log('params~~~', params);
  132. try {
  133. const result = await storageApi.addSubtractStockPacking(params);
  134. if (result && result.code !== 0 && result.code !== '0') {
  135. throw new Error(result.message || '库存调整失败');
  136. }
  137. } catch (error) {
  138. this.$message.error('保存失败');
  139. return;
  140. }
  141. }
  142. }
  143. let variables = {
  144. pass: !!status
  145. };
  146. approveTaskWithVariables({
  147. id: this.taskId,
  148. reason: this.form.reason,
  149. variables
  150. }).then((res) => {
  151. if (res.data.code != '-1') {
  152. this.$emit('handleAudit', {
  153. status,
  154. title: status === 0 ? '驳回' : ''
  155. });
  156. }
  157. });
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss"></style>