submit.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. prop="reason"
  7. style="margin-bottom: 20px"
  8. :rules="{
  9. required: true,
  10. message: '请输入',
  11. trigger: 'blur'
  12. }"
  13. >
  14. <el-input
  15. type="textarea"
  16. v-model="form.reason"
  17. placeholder="请输入审批建议"
  18. />
  19. </el-form-item>
  20. </el-form>
  21. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  22. <el-button
  23. icon="el-icon-edit-outline"
  24. type="success"
  25. size="mini"
  26. @click="handleAudit(1)"
  27. >通过
  28. </el-button>
  29. <el-button
  30. icon="el-icon-circle-close"
  31. type="danger"
  32. size="mini"
  33. @click="handleAudit(0)"
  34. >驳回
  35. </el-button>
  36. </div>
  37. </el-col>
  38. </template>
  39. <script>
  40. import { approveTaskWithVariables } from '@/api/bpm/task';
  41. import storageApi from '@/api/warehouseManagement';
  42. // 流程实例的详情页,可用于审批
  43. export default {
  44. name: '',
  45. props: {
  46. businessId: {
  47. default: ''
  48. },
  49. taskId: {
  50. default: ''
  51. },
  52. id: {
  53. default: ''
  54. },
  55. taskDefinitionKey: {
  56. default: ''
  57. }
  58. },
  59. data() {
  60. return {
  61. statusOption: [
  62. {
  63. label: '盘盈',
  64. value: '2',
  65. numKey: 'surplusQuantity'
  66. },
  67. {
  68. label: '丢失',
  69. value: '3',
  70. numKey: 'loseQuantity'
  71. },
  72. {
  73. label: '破损',
  74. value: '4',
  75. numKey: 'wornQuantity'
  76. }
  77. ],
  78. form: {
  79. reason: ''
  80. },
  81. userOptions: []
  82. };
  83. },
  84. methods: {
  85. async handleAudit(status) {
  86. await this._approveTaskWithVariables(status);
  87. },
  88. getTableValue() {
  89. return new Promise((resolve) => {
  90. this.$emit('getTableValue', async (data) => {
  91. resolve(await data);
  92. });
  93. });
  94. },
  95. async _approveTaskWithVariables(status) {
  96. if (this.taskDefinitionKey == 'Activity_1l4tn01') {
  97. // 驳回(主管审核)
  98. if (!status) {
  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. }
  112. } else if (this.taskDefinitionKey == 'Activity_1ftg2hu') {
  113. // 通过(仓管审核)
  114. if (!!status) {
  115. console.log('通过了!!!!');
  116. let infoData = await this.getTableValue();
  117. let params = infoData.info[0].planDetailVOList.map((item) => {
  118. let filterArr = this.statusOption.filter(
  119. (ite) => ite.value == item.status
  120. )[0];
  121. console.log(filterArr.numKey);
  122. return {
  123. id: this.businessId,
  124. isAdd: filterArr.numKey == 'surplusQuantity' ? true : false,
  125. packingNo: item.packageNo,
  126. quantity: item[filterArr.numKey]
  127. };
  128. });
  129. try {
  130. await storageApi.addSubtractStockPacking(params);
  131. } catch (error) {
  132. this.$message.error('保存失败');
  133. return;
  134. }
  135. }
  136. }
  137. let variables = {
  138. pass: !!status
  139. };
  140. approveTaskWithVariables({
  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>