submit.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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: '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. v-if="!['storeManagerApprove'].includes(taskDefinitionKey)"
  28. >通过
  29. </el-button>
  30. <el-button
  31. icon="el-icon-edit-outline"
  32. type="success"
  33. size="mini"
  34. @click="open()"
  35. v-if="['storeManagerApprove'].includes(taskDefinitionKey)"
  36. >申请入库
  37. </el-button>
  38. <el-button
  39. icon="el-icon-circle-close"
  40. type="danger"
  41. size="mini"
  42. @click="handleAudit(0)"
  43. v-if="!['starter'].includes(taskDefinitionKey)"
  44. >驳回
  45. </el-button>
  46. <!-- <el-button
  47. icon="el-icon-circle-close"
  48. type="danger"
  49. size="mini"
  50. @click="handleBackList"
  51. >退回
  52. </el-button> -->
  53. <!-- <el-button
  54. icon="el-icon-circle-close"
  55. type="danger"
  56. size="mini"
  57. @click="handleAudit(0)"
  58. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  59. >不通过
  60. </el-button>
  61. <el-button
  62. icon="el-icon-edit-outline"
  63. type="primary"
  64. size="mini"
  65. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  66. @click="handleUpdateAssignee"
  67. >转办
  68. </el-button> -->
  69. <ele-modal
  70. custom-class="ele-dialog-form long-dialog-form"
  71. :centered="true"
  72. v-if="visible"
  73. :visible.sync="visible"
  74. :title="title"
  75. :close-on-click-modal="false"
  76. width="80%"
  77. :modal="false"
  78. @close="cancel"
  79. >
  80. <add ref="add" @cancel="cancel" @handleAudit=handleAudit></add>
  81. </ele-modal>
  82. </div>
  83. </el-col>
  84. </template>
  85. <script>
  86. import { UpdateReceiveInformation } from '@/api/bpm/components/purchasingManage/purchaseorderreceive';
  87. import { approveTaskWithVariables } from '@/api/bpm/task';
  88. // import { listAllUserBind } from '@/api/system/organization';
  89. import { getWarehouseListByIds } from '@/api/bpm/components/saleManage/saleorder';
  90. import add from '@/views/bpm/stockManagement/add.vue';
  91. // 流程实例的详情页,可用于审批
  92. export default {
  93. name: '',
  94. components: {
  95. // Parser
  96. add
  97. },
  98. props: {
  99. businessId: {
  100. default: ''
  101. },
  102. taskId: {
  103. default: ''
  104. },
  105. id: {
  106. default: ''
  107. },
  108. id: {
  109. default: ''
  110. },
  111. taskDefinitionKey: {
  112. default: ''
  113. }
  114. },
  115. data() {
  116. return {
  117. form: {
  118. technicianId: '',
  119. reason: ''
  120. },
  121. visible: false,
  122. userOptions: []
  123. };
  124. },
  125. created() {},
  126. methods: {
  127. cancel() {
  128. this.visible = false;
  129. },
  130. async open() {
  131. if (!this.form.reason) {
  132. this.$message.error('审批意见不能为空');
  133. return;
  134. }
  135. this.visible = true;
  136. let data = await this.getTableValue();
  137. // console.log( this.$refs.add.pickerSuccess())
  138. this.$refs.add.pickerSuccess(data);
  139. },
  140. /** 处理转办审批人 */
  141. handleUpdateAssignee() {
  142. this.$emit('handleUpdateAssignee');
  143. },
  144. /** 退回 */
  145. handleBackList() {
  146. this.$emit('handleBackList');
  147. },
  148. async handleAudit(status) {
  149. let storemanIds = '';
  150. //发起人补充
  151. if (this.taskDefinitionKey === 'starter') {
  152. let arr = await this.getTableValue();
  153. if (!arr) {
  154. return;
  155. }
  156. let data = await UpdateReceiveInformation(arr);
  157. if (data.code != '0') {
  158. return;
  159. }
  160. }
  161. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  162. let arr = await this.getTableValue();
  163. let ids = arr.productList.map((item) => item.warehouseId);
  164. let data = await getWarehouseListByIds(ids || []);
  165. storemanIds = data.map((item) => item.ownerId);
  166. }
  167. this._approveTaskWithVariables(
  168. status,
  169. storemanIds.length > 0
  170. ? Array.from(new Set(storemanIds)).toString()
  171. : ''
  172. );
  173. },
  174. async _approveTaskWithVariables(status, storemanIds) {
  175. let variables = {
  176. pass: !!status
  177. };
  178. if (storemanIds) {
  179. variables['storemanIds'] = storemanIds;
  180. }
  181. approveTaskWithVariables({
  182. id: this.taskId,
  183. reason: this.form.reason,
  184. variables
  185. }).then((res) => {
  186. if (res.data.code != '-1') {
  187. this.$emit('handleAudit', {
  188. status,
  189. title: status === 0 ? '驳回' : ''
  190. });
  191. }
  192. });
  193. },
  194. getTableValue() {
  195. return new Promise((resolve, reject) => {
  196. this.$emit('getTableValue', async (data) => {
  197. resolve(await data);
  198. });
  199. });
  200. }
  201. }
  202. };
  203. </script>
  204. <style lang="scss"></style>