submit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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="qualityInspector"
  7. style="margin-bottom: 20px"
  8. :rules="{
  9. required: true,
  10. message: '请选择',
  11. trigger: 'change'
  12. }"
  13. v-if="taskDefinitionKey == 'QCLeaderApprove'"
  14. >
  15. <el-select
  16. v-model="form.qualityInspector"
  17. clearable
  18. style="width: 100%"
  19. :filterable="true"
  20. >
  21. <el-option
  22. v-for="item in userOptions"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="审批建议" style="margin-bottom: 20px">
  30. <el-input
  31. type="textarea"
  32. v-model="form.reason"
  33. placeholder="请输入审批建议"
  34. />
  35. </el-form-item>
  36. </el-form>
  37. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  38. <el-button
  39. icon="el-icon-edit-outline"
  40. type="success"
  41. size="mini"
  42. v-click-once
  43. @click="handleAudit(1)"
  44. v-if="
  45. !['storeManagerApprove'].includes(taskDefinitionKey) ||
  46. (['storeManagerApprove'].includes(taskDefinitionKey) &&
  47. [2].includes(Number(outInData.flowableStatus)))
  48. "
  49. >通过
  50. </el-button>
  51. <el-button
  52. icon="el-icon-edit-outline"
  53. type="success"
  54. size="mini"
  55. v-click-once
  56. :loading="isSaveLoading"
  57. @click="storeManagerApprove"
  58. v-if="
  59. ['storeManagerApprove'].includes(taskDefinitionKey) &&
  60. activeComp == 'inoutBound' &&
  61. ![1, 2].includes(Number(outInData.flowableStatus))
  62. "
  63. >申请入库
  64. </el-button>
  65. <el-button
  66. icon="el-icon-circle-close"
  67. type="danger"
  68. size="mini"
  69. v-click-once
  70. @click="handleAudit(0)"
  71. v-if="
  72. !['starter', 'qualityInspectionFeedback'].includes(
  73. taskDefinitionKey
  74. ) && ![1, 2].includes(+outInData.flowableStatus)
  75. "
  76. >驳回
  77. </el-button>
  78. <el-dropdown
  79. @command="(command) => handleCommand(command)"
  80. style="margin-left: 30px"
  81. >
  82. <span class="el-dropdown-link"
  83. >更多<i class="el-icon-arrow-down el-icon--right"></i
  84. ></span>
  85. <el-dropdown-menu slot="dropdown">
  86. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  87. </el-dropdown-menu>
  88. </el-dropdown>
  89. <!-- <el-button
  90. icon="el-icon-circle-close"
  91. type="danger"
  92. size="mini"
  93. @click="handleBackList"
  94. >退回
  95. </el-button> -->
  96. <!-- <el-button
  97. icon="el-icon-circle-close"
  98. type="danger"
  99. size="mini"
  100. @click="handleAudit(0)"
  101. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  102. >不通过
  103. </el-button>
  104. <el-button
  105. icon="el-icon-edit-outline"
  106. type="primary"
  107. size="mini"
  108. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  109. @click="handleUpdateAssignee"
  110. >转办
  111. </el-button> -->
  112. <ele-modal
  113. custom-class="ele-dialog-form long-dialog-form"
  114. :centered="true"
  115. v-if="visible"
  116. :visible.sync="visible"
  117. :title="title"
  118. :close-on-click-modal="false"
  119. width="80%"
  120. :modal="false"
  121. @close="cancel"
  122. >
  123. </ele-modal>
  124. </div>
  125. </el-col>
  126. </template>
  127. <script>
  128. import {
  129. UpdateReceiveInformation,
  130. getReceiveSaleOrderrecordDetail,
  131. getReceiveTaskDetail,
  132. cancel
  133. } from '@/api/bpm/components/purchasingManage/purchaseorderreceive';
  134. import { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
  135. import { getWarehouseListByIds } from '@/api/bpm/components/saleManage/saleorder';
  136. import {
  137. getOutInBySourceBizNo,
  138. uploadQualityFile
  139. } from '@/api/classifyManage';
  140. import { listAllUserBind } from '@/api/system/organization';
  141. // import outin from '@/api/warehouseManagement/outin';
  142. import storageApi from '@/api/warehouseManagement';
  143. // 流程实例的详情页,可用于审批
  144. export default {
  145. name: '',
  146. components: {},
  147. props: {
  148. businessId: {
  149. default: ''
  150. },
  151. taskId: {
  152. default: ''
  153. },
  154. id: {
  155. default: ''
  156. },
  157. id: {
  158. default: ''
  159. },
  160. taskDefinitionKey: {
  161. default: ''
  162. },
  163. fromUser: {
  164. default: ''
  165. },
  166. },
  167. data() {
  168. return {
  169. isSaveLoading: false,
  170. form: {
  171. qualityInspector: '',
  172. reason: '同意'
  173. },
  174. outInData: {
  175. flowableStatus: ''
  176. },
  177. visible: false,
  178. userOptions: [],
  179. activeComp: ''
  180. };
  181. },
  182. async created() {
  183. this.userOptions = [];
  184. listAllUserBind().then((data) => {
  185. this.userOptions.push(...data);
  186. });
  187. if (this.taskDefinitionKey == 'storeManagerApprove') {
  188. let data = await getReceiveTaskDetail(this.businessId, this.taskId);
  189. try {
  190. this.outInData = await storageApi.getInfoBySourceBizNoAndWarehouse(
  191. data.receiveNo,
  192. data.productList[0]?.warehouseId
  193. );
  194. console.log('outInData----------', this.outInData);
  195. } catch (error) {}
  196. }
  197. },
  198. mounted() {
  199. console.log('taskDefinitionKey-------------', this.taskDefinitionKey);
  200. },
  201. methods: {
  202. cancel() {
  203. this.visible = false;
  204. },
  205. async storeManagerApprove() {
  206. let res = await this.getTableValue();
  207. let storageData = res.returnStorageData;
  208. console.log('storeManagerApprove', storageData);
  209. // isSkip 0-正常 1-外部(外部跳过内部审核流程)
  210. storageData.isSkip = 1;
  211. storageData.fromUser = this.fromUser;
  212. try {
  213. this.isSaveLoading = true;
  214. await storageApi.storage(storageData);
  215. approveTaskWithVariables({
  216. id: this.taskId,
  217. reason: this.form.reason,
  218. variables: {
  219. pass: true
  220. }
  221. }).then((res) => {
  222. if (res.code != '-1') {
  223. this.$emit('handleAudit', {
  224. status: 1,
  225. title: '入库'
  226. });
  227. }
  228. this.isSaveLoading = false;
  229. });
  230. } catch (error) {
  231. this.isSaveLoading = false;
  232. this.$message.error('保存失败');
  233. }
  234. },
  235. /** 处理转办审批人 */
  236. handleUpdateAssignee() {
  237. this.$emit('handleUpdateAssignee');
  238. },
  239. /** 退回 */
  240. handleBackList() {
  241. this.$emit('handleBackList');
  242. },
  243. activeCompChange(activeComp) {
  244. this.activeComp = activeComp;
  245. },
  246. async handleAudit(status) {
  247. let storemanIds = '';
  248. //发起人补充
  249. if (this.taskDefinitionKey === 'starter') {
  250. let arr = await this.getTableValue();
  251. if (!arr) {
  252. return;
  253. }
  254. let ids = arr.productList.map((item) => item.warehouseId);
  255. let warehouseList = await getWarehouseListByIds(ids || []);
  256. storemanIds = warehouseList.map((item) => item.ownerId);
  257. let data = await UpdateReceiveInformation(arr);
  258. if (data.code != '0') {
  259. return;
  260. }
  261. }
  262. // if (this.taskDefinitionKey === 'deptLeaderApprove') {
  263. // let arr = await this.getTableValue();
  264. // let ids = arr.form.productList.map((item) => item.warehouseId);
  265. // let data = await getWarehouseListByIds(ids || []);
  266. // storemanIds = data.map((item) => item.ownerId);
  267. // }
  268. if (this.taskDefinitionKey === 'QCLeaderApprove' && status) {
  269. if (!this.form.qualityInspector) {
  270. return this.$message.error('请选择质检员!');
  271. }
  272. }
  273. if (this.taskDefinitionKey === 'qualityInspection' && status) {
  274. let arr = await this.getTableValue(); // 是否全部已检
  275. // console.log(arr,'arr')
  276. // return;
  277. if (!arr.isAllChecked) {
  278. return this.$message.error('请完成质检!');
  279. }
  280. }
  281. if (this.taskDefinitionKey === 'qualityInspectionFeedback' && status) {
  282. let arr = await this.getTableValue();
  283. console.log('arr.qualityInspector', arr);
  284. // if (arr.qualityInspector.qualityFile.length == 0) {
  285. // return this.$message.error('请上传回执附件!');
  286. // }
  287. // console.log(arr);
  288. // await uploadQualityFile(arr.qualityInspector);
  289. if (
  290. arr.qualityInspector.qualityFile &&
  291. arr.qualityInspector.qualityFile.length > 0
  292. ) {
  293. await storageApi.uploadQualityFile(arr.qualityInspector);
  294. }
  295. }
  296. await this._approveTaskWithVariables(
  297. status,
  298. storemanIds.length > 0
  299. ? Array.from(new Set(storemanIds)).toString()
  300. : ''
  301. );
  302. },
  303. async _approveTaskWithVariables(status, storemanIds) {
  304. let variables = {
  305. pass: !!status
  306. };
  307. if (storemanIds) {
  308. variables['storemanIds'] = storemanIds;
  309. }
  310. if (this.form.qualityInspector) {
  311. variables['qualityInspector'] = this.form.qualityInspector;
  312. }
  313. let API = !!status ? approveTaskWithVariables : rejectTask;
  314. API({
  315. id: this.taskId,
  316. reason: this.form.reason,
  317. variables
  318. }).then((res) => {
  319. if (res.data.code != '-1') {
  320. this.$emit('handleAudit', {
  321. status,
  322. title: status === 0 ? '驳回' : ''
  323. });
  324. }
  325. });
  326. },
  327. getTableValue() {
  328. return new Promise((resolve, reject) => {
  329. this.$emit('getTableValue', async (data) => {
  330. resolve(await data);
  331. });
  332. });
  333. },
  334. //更多
  335. handleCommand(command) {
  336. if (command === 'cancel') {
  337. this.$confirm('是否确认作废?', {
  338. type: 'warning',
  339. cancelButtonText: '取消',
  340. confirmButtonText: '确定'
  341. })
  342. .then(() => {
  343. cancelTask({
  344. id: this.id,
  345. taskId: this.taskId,
  346. reason: this.form.reason,
  347. businessId: this.businessId
  348. })
  349. .then(() => {
  350. this.$emit('handleClose');
  351. })
  352. .catch(() => {
  353. this.$message.error('流程作废失败');
  354. });
  355. })
  356. .catch(() => {});
  357. }
  358. }
  359. }
  360. };
  361. </script>
  362. <style lang="scss"></style>