submit.vue 7.2 KB

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