submit.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. v-if="
  27. taskDefinitionKey != 'storemanApprove' ||
  28. (taskDefinitionKey == 'storemanApprove' &&
  29. outInData.verifyStatus == 2)
  30. "
  31. @click="handleAudit(1)"
  32. >通过
  33. </el-button>
  34. <el-button
  35. icon="el-icon-edit-outline"
  36. type="success"
  37. size="mini"
  38. :loading="isSaveLoading"
  39. @click="storemanApprove"
  40. v-if="
  41. ['storemanApprove'].includes(taskDefinitionKey) &&
  42. activeComp == 'outBound' &&
  43. [0, 3].includes(outInData.verifyStatus)
  44. "
  45. >申请出库
  46. </el-button>
  47. <el-button
  48. icon="el-icon-circle-close"
  49. type="danger"
  50. size="mini"
  51. @click="handleAudit(0)"
  52. v-if="
  53. ['deptLeaderApprove', 'storemanApprove'].includes(
  54. taskDefinitionKey
  55. ) && outInData.verifyStatus != 1
  56. "
  57. >驳回
  58. </el-button>
  59. <!-- <el-button
  60. icon="el-icon-circle-close"
  61. type="danger"
  62. size="mini"
  63. @click="handleBackList"
  64. >退回
  65. </el-button> -->
  66. <!-- <el-button
  67. icon="el-icon-circle-close"
  68. type="danger"
  69. size="mini"
  70. @click="handleAudit(0)"
  71. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  72. >不通过
  73. </el-button>
  74. <el-button
  75. icon="el-icon-edit-outline"
  76. type="primary"
  77. size="mini"
  78. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  79. @click="handleUpdateAssignee"
  80. >转办
  81. </el-button> -->
  82. </div>
  83. </el-col>
  84. </template>
  85. <script>
  86. import {
  87. UpdateSendInformation,
  88. getSendSaleOrderrecordDetail,
  89. getWarehouseListByIds,
  90. saleSendProcessCancel,
  91. } from '@/api/bpm/components/saleManage/saleorder';
  92. import { approveTaskWithVariables } from '@/api/bpm/task';
  93. import { getOutInBySourceBizNo } from '@/api/classifyManage';
  94. import outin from '@/api/warehouseManagement/outin';
  95. import { data } from 'ele-admin/lib/ele-pro-table';
  96. // 流程实例的详情页,可用于审批
  97. export default {
  98. name: '',
  99. components: {
  100. // Parser
  101. },
  102. props: {
  103. businessId: {
  104. default: ''
  105. },
  106. taskId: {
  107. default: ''
  108. },
  109. id: {
  110. default: ''
  111. },
  112. taskDefinitionKey: {
  113. default: ''
  114. }
  115. },
  116. data() {
  117. return {
  118. isSaveLoading: false,
  119. form: {
  120. technicianId: '',
  121. reason: ''
  122. },
  123. outInData: { verifyStatus: '' },
  124. activeComp: ''
  125. };
  126. },
  127. async created() {
  128. if (this.taskDefinitionKey == 'storemanApprove') {
  129. let data = await getSendSaleOrderrecordDetail(this.businessId);
  130. try {
  131. console.log(1111, '1111111111');
  132. this.outInData = await getOutInBySourceBizNo(data.docNo);
  133. console.log(this.outInData, '============');
  134. } catch (error) {
  135. console.log(22222222, '22222222222');
  136. this.outInData.verifyStatus = 0;
  137. }
  138. }
  139. console.log('taskDefinitionKey', this.taskDefinitionKey);
  140. console.log('outInData', this.outInData);
  141. },
  142. methods: {
  143. async storemanApprove() {
  144. let res = await this.getTableValue();
  145. let storageData = res.returnStorageData;
  146. console.log(storageData);
  147. // 出库来源storageSource 0-正常 1-外部(外部跳过内部审核流程)
  148. storageData.storageSource = 1;
  149. try {
  150. this.isSaveLoading = true;
  151. await outin.saveNew(storageData);
  152. approveTaskWithVariables({
  153. id: this.taskId,
  154. reason: this.form.reason,
  155. variables: {
  156. pass: true
  157. }
  158. }).then((res) => {
  159. if (res.code != '-1') {
  160. this.$emit('handleAudit', {
  161. status: 1,
  162. title: '出库'
  163. });
  164. }
  165. this.isSaveLoading = false;
  166. });
  167. } catch (error) {
  168. this.isSaveLoading = false;
  169. console.error('保存失败:', error);
  170. }
  171. },
  172. activeCompChange(activeComp) {
  173. this.activeComp = activeComp;
  174. },
  175. /** 处理转办审批人 */
  176. handleUpdateAssignee() {
  177. this.$emit('handleUpdateAssignee');
  178. },
  179. /** 退回 */
  180. handleBackList() {
  181. this.$emit('handleBackList');
  182. },
  183. async handleAudit(status) {
  184. let storemanIds = '';
  185. //发起人补充
  186. if (
  187. this.taskDefinitionKey === 'starter' ||
  188. this.taskDefinitionKey === 'salesmanUploadReceipt'
  189. ) {
  190. let arr = await this.getTableValue();
  191. console.log('arr--------', arr);
  192. if (!arr) {
  193. return;
  194. }
  195. if (
  196. this.taskDefinitionKey === 'salesmanUploadReceipt' &&
  197. arr.replied === 0
  198. ) {
  199. this.$message.error('回执附件不能为空');
  200. return;
  201. }
  202. // console.log(arr)
  203. // return
  204. let data = await UpdateSendInformation(arr);
  205. if (data.code != '0') {
  206. return;
  207. }
  208. }
  209. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  210. let arr = await this.getTableValue();
  211. let ids = arr.form.productList.map((item) => item.warehouseId);
  212. let data = await getWarehouseListByIds(ids || []);
  213. storemanIds = data.map((item) => item.ownerId);
  214. }
  215. this._approveTaskWithVariables(
  216. status,
  217. storemanIds.length > 0
  218. ? Array.from(new Set(storemanIds)).toString()
  219. : ''
  220. );
  221. },
  222. async _approveTaskWithVariables(status, storemanIds) {
  223. let variables = {
  224. pass: !!status
  225. };
  226. if (storemanIds) {
  227. variables['storemanIds'] = storemanIds;
  228. }
  229. approveTaskWithVariables({
  230. id: this.taskId,
  231. reason: this.form.reason,
  232. variables
  233. }).then((res) => {
  234. if (res.data.code != '-1') {
  235. this.$emit('handleAudit', {
  236. status,
  237. title: status === 0 ? '驳回' : ''
  238. });
  239. }
  240. });
  241. },
  242. getTableValue() {
  243. return new Promise((resolve, reject) => {
  244. this.$emit('getTableValue', async (data) => {
  245. resolve(await data);
  246. });
  247. });
  248. },
  249. //更多
  250. handleCommand(command) {
  251. if (command === 'cancel') {
  252. this.$confirm("是否确认作废?", {
  253. type: 'warning',
  254. cancelButtonText: '取消',
  255. confirmButtonText: '确定'
  256. }).then(() => {
  257. saleSendProcessCancel({
  258. id: this.taskId,
  259. reason: this.form.reason,
  260. businessId: this.businessId,
  261. }).then(() => {
  262. this.$emit('handleClose');
  263. }).catch(() => {
  264. this.$message.error("流程作废失败");
  265. });
  266. }).catch(() => {});
  267. }
  268. },
  269. }
  270. };
  271. </script>
  272. <style lang="scss"></style>