submit.vue 7.6 KB

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