submit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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="handleAudit(0)"
  51. v-if="
  52. ['deptLeaderApprove', 'storemanApprove'].includes(
  53. taskDefinitionKey
  54. ) && outInData.verifyStatus != 1
  55. "
  56. >驳回
  57. </el-button>
  58. <!-- <el-button
  59. icon="el-icon-circle-close"
  60. type="danger"
  61. size="mini"
  62. @click="handleBackList"
  63. >退回
  64. </el-button> -->
  65. <!-- <el-button
  66. icon="el-icon-circle-close"
  67. type="danger"
  68. size="mini"
  69. @click="handleAudit(0)"
  70. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  71. >不通过
  72. </el-button>
  73. <el-button
  74. icon="el-icon-edit-outline"
  75. type="primary"
  76. size="mini"
  77. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  78. @click="handleUpdateAssignee"
  79. >转办
  80. </el-button> -->
  81. </div>
  82. </el-col>
  83. </template>
  84. <script>
  85. import {
  86. UpdateSendInformation,
  87. getSendSaleOrderrecordDetail,
  88. getWarehouseListByIds,
  89. saleSendProcessCancel
  90. } from '@/api/bpm/components/saleManage/saleorder';
  91. import {approveTaskWithVariables, rejectTask} from '@/api/bpm/task';
  92. import { getOutInBySourceBizNo } from '@/api/classifyManage';
  93. import outin from '@/api/warehouseManagement/outin';
  94. import { data } from 'ele-admin/lib/ele-pro-table';
  95. import storageApi from '@/api/warehouseManagement';
  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: 0 },
  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. data = await storageApi.getInfoBySourceBizNo(data.docNo);
  133. console.log('data--------------', data);
  134. if (JSON.stringify(data) != '{}') {
  135. this.outInData = data;
  136. }
  137. console.log(this.outInData, '============');
  138. } catch (error) {
  139. console.log(22222222, '22222222222');
  140. this.outInData.verifyStatus = 0;
  141. }
  142. }
  143. console.log('taskDefinitionKey', this.taskDefinitionKey);
  144. console.log('outInData', this.outInData);
  145. },
  146. methods: {
  147. async storemanApprove() {
  148. let res = await this.getTableValue();
  149. let storageData = res.returnStorageData;
  150. console.log(storageData);
  151. // 出库来源isSkip 0-正常 1-外部(外部跳过内部审核流程)
  152. storageData.isSkip = 1;
  153. try {
  154. this.isSaveLoading = true;
  155. await storageApi.outStorage(storageData);
  156. approveTaskWithVariables({
  157. id: this.taskId,
  158. reason: this.form.reason,
  159. variables: {
  160. pass: true
  161. }
  162. }).then((res) => {
  163. if (res.code != '-1') {
  164. this.$emit('handleAudit', {
  165. status: 1,
  166. title: '出库'
  167. });
  168. }
  169. this.isSaveLoading = false;
  170. });
  171. } catch (error) {
  172. this.isSaveLoading = false;
  173. console.error('保存失败:', error);
  174. }
  175. },
  176. activeCompChange(activeComp) {
  177. this.activeComp = activeComp;
  178. },
  179. /** 处理转办审批人 */
  180. handleUpdateAssignee() {
  181. this.$emit('handleUpdateAssignee');
  182. },
  183. /** 退回 */
  184. handleBackList() {
  185. this.$emit('handleBackList');
  186. },
  187. async handleAudit(status) {
  188. let storemanIds = '';
  189. //发起人补充
  190. if (
  191. this.taskDefinitionKey === 'starter' ||
  192. this.taskDefinitionKey === 'salesmanUploadReceipt'
  193. ) {
  194. let arr = await this.getTableValue();
  195. console.log('arr--------', arr);
  196. if (!arr) {
  197. return;
  198. }
  199. if (
  200. this.taskDefinitionKey === 'salesmanUploadReceipt' &&
  201. arr.replied === 0
  202. ) {
  203. this.$message.error('回执附件不能为空');
  204. return;
  205. }
  206. // console.log(arr)
  207. // return
  208. let data = await UpdateSendInformation(arr);
  209. if (data.code != '0') {
  210. return;
  211. }
  212. }
  213. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  214. let arr = await this.getTableValue();
  215. let ids = arr.form.productList.map((item) => item.warehouseId);
  216. let data = await getWarehouseListByIds(ids || []);
  217. storemanIds = data.map((item) => item.ownerId);
  218. }
  219. this._approveTaskWithVariables(
  220. status,
  221. storemanIds.length > 0
  222. ? Array.from(new Set(storemanIds)).toString()
  223. : ''
  224. );
  225. },
  226. async _approveTaskWithVariables(status, storemanIds) {
  227. let variables = {
  228. pass: !!status
  229. };
  230. if (storemanIds) {
  231. variables['storemanIds'] = storemanIds;
  232. }
  233. let API = !!status ? approveTaskWithVariables : rejectTask;
  234. API({
  235. id: this.taskId,
  236. reason: this.form.reason,
  237. variables
  238. }).then((res) => {
  239. if (res.data.code != '-1') {
  240. this.$emit('handleAudit', {
  241. status,
  242. title: status === 0 ? '驳回' : ''
  243. });
  244. }
  245. });
  246. },
  247. getTableValue() {
  248. return new Promise((resolve, reject) => {
  249. this.$emit('getTableValue', async (data) => {
  250. resolve(await data);
  251. });
  252. });
  253. },
  254. //更多
  255. handleCommand(command) {
  256. if (command === 'cancel') {
  257. this.$confirm('是否确认作废?', {
  258. type: 'warning',
  259. cancelButtonText: '取消',
  260. confirmButtonText: '确定'
  261. })
  262. .then(() => {
  263. saleSendProcessCancel({
  264. id: this.taskId,
  265. reason: this.form.reason,
  266. businessId: this.businessId
  267. })
  268. .then(() => {
  269. this.$emit('handleClose');
  270. })
  271. .catch(() => {
  272. this.$message.error('流程作废失败');
  273. });
  274. })
  275. .catch(() => {});
  276. }
  277. }
  278. }
  279. };
  280. </script>
  281. <style lang="scss"></style>