submit.vue 4.4 KB

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