submit.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <!--流程标识: bom_release 医药bom审批-->
  3. <el-col :span="16" :offset="6">
  4. <el-form label-width="100px" ref="formRef" :model="form">
  5. <el-form-item
  6. label="审批建议"
  7. style="margin-bottom: 20px"
  8. :rules="{
  9. required: true,
  10. message: '请选择',
  11. trigger: 'change'
  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, rejectTask} from '@/api/bpm/task';
  41. import { jsBomNotPass, batchUpdate } from '@/api/bpm/components/bomApprover';
  42. // 流程实例的详情页,可用于审批
  43. export default {
  44. name: '',
  45. components: {},
  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. form: {
  63. reason: ''
  64. }
  65. };
  66. },
  67. created() {},
  68. methods: {
  69. async handleAudit(status) {
  70. this._approveTaskWithVariables(status);
  71. },
  72. async _approveTaskWithVariables(status) {
  73. if (status == 1) {
  74. if (
  75. this.taskDefinitionKey == 'Activity_021lrxj' ||
  76. this.taskDefinitionKey == 'Activity_1q7btlc'
  77. ) {
  78. let LL = await this.getTableValue();
  79. let bol = LL.every((m) => m.supplierId);
  80. if (!bol) {
  81. this.$message.error('请选择供应商!');
  82. return;
  83. }
  84. }
  85. let API = !!status ? approveTaskWithVariables : rejectTask;
  86. API({
  87. businessId: this.businessId,
  88. id: this.taskId,
  89. reason: this.form.reason,
  90. variables: { pass: true }
  91. }).then((res) => {
  92. if (res.data.code != '-1') {
  93. this.updateDate();
  94. this.$emit('handleAudit', {
  95. status,
  96. title: ''
  97. });
  98. }
  99. });
  100. } else if (status == 0) {
  101. jsBomNotPass({
  102. businessId: this.businessId,
  103. id: this.taskId,
  104. reason: this.form.reason
  105. }).then((res) => {
  106. if (res.data.code != '-1') {
  107. this.$emit('handleAudit', {
  108. status,
  109. title: '驳回'
  110. });
  111. }
  112. });
  113. }
  114. },
  115. /**
  116. * 更新日期数据
  117. *
  118. * @returns {Promise<void>}
  119. */
  120. async updateDate() {
  121. let LL = await this.getTableValue();
  122. if (this.taskDefinitionKey == 'Activity_0uypakw') {
  123. let _LL = LL.map((m) => {
  124. return {
  125. id: m.id,
  126. materielDesignation: m.materielDesignation
  127. };
  128. });
  129. if (_LL.length > 0) {
  130. batchUpdate(_LL).then(() => {});
  131. }
  132. } else {
  133. let _LL = LL.map((m) => {
  134. return {
  135. id: m.id,
  136. supplierId: m.supplierId
  137. };
  138. });
  139. if (_LL.length > 0) {
  140. batchUpdate(_LL).then(() => {});
  141. }
  142. }
  143. },
  144. getTableValue() {
  145. return new Promise((resolve, reject) => {
  146. this.$emit('getTableValue', async (data) => {
  147. resolve(await data);
  148. });
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss"></style>