newFile.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  2. import { getTreeByGroup } from '@/api/classifyManage';
  3. import { tableHeader } from '../common';
  4. export default (await import('vue')).defineComponent({
  5. components: {
  6. pickOrder,
  7. selectUpload,
  8. selectTree,
  9. AssetsDialog,
  10. WareHouseDailog,
  11. upload,
  12. detailSelect,
  13. // TurnToAsset,
  14. outputType,
  15. eom
  16. },
  17. data() {
  18. return {
  19. llList: [],
  20. codeList: [],
  21. materialType,
  22. warehousingType,
  23. outputSceneState,
  24. emergencyState,
  25. saveLoading: false,
  26. title: '',
  27. tableData2: [],
  28. uploadList: [],
  29. fromUserList: [], //人员数组
  30. warehousingMaterialList: [],
  31. activeName: 'a',
  32. treeList: [],
  33. staffList: [],
  34. formData: {
  35. extInfo: {
  36. assetType: '', //物品类型
  37. deptCode: '', //部门code
  38. deptName: '', //部门名称
  39. verifyDeptCode: '', //审核部门编码
  40. verifyDeptName: '', //审核部门名称
  41. deliveryName: '', //送货人名称
  42. deliveryPhone: '', //送货人电话
  43. documentSource: '', //销售订单
  44. urgent: '', //紧急状态
  45. supplierId: '', //供应商ID
  46. supplierName: '', //供应商名称
  47. createUserName: '', //创建人名字
  48. contentImage: [] //图片数组
  49. },
  50. fromUser: '', //送货人
  51. bizType: '', //物品类型
  52. verifyId: '', //审核人Id
  53. verifyName: '', //审核人名称
  54. createUserId: '',
  55. remark: ''
  56. },
  57. rules: {
  58. // 'extInfo.assetType': {
  59. // required: true,
  60. // message: '请选择出库产品类型',
  61. // trigger: 'change'
  62. // },
  63. bizType: {
  64. required: true,
  65. message: '请选择出库场景',
  66. trigger: 'change'
  67. },
  68. fromUser: {
  69. required: true,
  70. message: '请选择领料人',
  71. trigger: 'change'
  72. }
  73. },
  74. options: [],
  75. loading: false,
  76. onSelectTableDataVal: []
  77. };
  78. },
  79. computed: {
  80. tableHeader() {
  81. return tableHeader(this.formData.extInfo.assetType);
  82. },
  83. // 条码信息
  84. materialCodeReqList() {
  85. console.log(
  86. '===',
  87. this.warehousingMaterialList
  88. .map((i) => i.warehouseLedgerDetails || [])
  89. .flat()
  90. );
  91. return this.warehousingMaterialList
  92. .map((i) => i.warehouseLedgerDetails || [])
  93. .flat();
  94. }
  95. },
  96. created() {
  97. this.initData();
  98. },
  99. methods: {
  100. eomSuccess(row) {
  101. this.formData.documentSource = row.orderNo;
  102. console.log(row);
  103. this.onSelectTableData(row.tableData, 1);
  104. this.$forceUpdate();
  105. },
  106. pickOrderRow(row) {
  107. row.tableData = [];
  108. this.formData.documentSource = row.code;
  109. for (const key in row.orderInfoList) {
  110. if (row.orderInfoList[key].bomDetailDTOS.length != 0) {
  111. for (const i in row.orderInfoList[key].bomDetailDTOS) {
  112. row.tableData.push({
  113. ...row.orderInfoList[key].bomDetailDTOS[i],
  114. code: row.orderInfoList[key].bomDetailDTOS[i].categoryCode,
  115. name: row.orderInfoList[key].bomDetailDTOS[i].categoryName,
  116. modelType: row.orderInfoList[key].bomDetailDTOS[i].model,
  117. id: row.orderInfoList[key].bomDetailDTOS[i].categoryId
  118. });
  119. }
  120. }
  121. if (row.orderInfoList[key].instanceList.length != 0) {
  122. for (const j in row.orderInfoList[key].instanceList) {
  123. row.tableData.push({
  124. ...row.orderInfoList[key].instanceList[j],
  125. code: row.orderInfoList[key].instanceList[j].categoryCode,
  126. name: row.orderInfoList[key].instanceList[j].categoryName,
  127. modelType: row.orderInfoList[key].instanceList[j].model,
  128. id: row.orderInfoList[key].instanceList[j].categoryId
  129. });
  130. }
  131. }
  132. }
  133. const uniqueItems = [];
  134. const uniqueIds = new Set();
  135. row.tableData.forEach((item) => {
  136. if (!uniqueIds.has(item.code)) {
  137. uniqueIds.add(item.code);
  138. uniqueItems.push(item);
  139. }
  140. });
  141. row.tableData = uniqueItems;
  142. console.log(row);
  143. this.onSelectTableData(row.tableData, 1);
  144. this.$forceUpdate();
  145. },
  146. handleEom() {
  147. this.$refs.eomRef.open();
  148. },
  149. handlePickorder() {
  150. this.$refs.pickOrderRef.open();
  151. },
  152. async handleDocumentSourceChange() {
  153. if (!this.formData.documentSource) {
  154. if (this.formData.bizType == 4) {
  155. this.warehousingMaterialList = [];
  156. }
  157. return;
  158. }
  159. if (
  160. !(this.formData.extInfo.assetType == 7 && this.formData.bizType == 4)
  161. ) {
  162. return;
  163. }
  164. const loading = this.$loading({ fullscreen: true });
  165. const res = await getSparePartsInfo({
  166. code: this.formData.documentSource
  167. });
  168. if (res?.success && res.data.length) {
  169. const curMap = {
  170. assetId: 'classificationId',
  171. assetCode: 'informationCode', //编码
  172. assetName: 'informationName', //名称
  173. materialId: 'classificationId',
  174. materialName: 'informationName',
  175. batchNo: '', //批次号
  176. unit: 'measuringUnit', //单位
  177. minPackUnit: 'packingUnit' //最小包装单位
  178. };
  179. res.data.forEach((item) => {
  180. let obj = {};
  181. for (const key in curMap) {
  182. obj[key] = curMap[key] ? item[curMap[key]] : '';
  183. }
  184. obj.curId =
  185. obj.assetCode +
  186. (obj.measurementUnit || '') +
  187. (obj.minPackUnit || '') +
  188. (obj.unit || '');
  189. console.log(obj.curId);
  190. const index = this.warehousingMaterialList.findIndex(
  191. (i) => i.curId === obj.curId
  192. );
  193. if (index === -1) {
  194. Object.assign(obj, item);
  195. obj.sparePartsNum = item.num;
  196. this.warehousingMaterialList.push(obj);
  197. } else {
  198. this.warehousingMaterialList[index].sparePartsNum = item.num;
  199. }
  200. });
  201. }
  202. loading.close();
  203. },
  204. // 备品备件来源单号
  205. async remoteMethod(code) {
  206. // if (code !== '') {
  207. // this.loading = true
  208. const res = await getDocumentSource({ code });
  209. if (res?.success) {
  210. this.options = res.data;
  211. }
  212. // this.loading = false
  213. // } else {
  214. // this.options = []
  215. // }
  216. },
  217. rowClass({ row, column, rowIndex, columnIndex }) {
  218. if (rowIndex === 1) {
  219. return {
  220. display: 'none',
  221. background: '#EEEEEE',
  222. border: 'none'
  223. };
  224. }
  225. return { background: '#EEEEEE', border: 'none' };
  226. },
  227. // 部门 点击事件
  228. async auditorDeptClick(data) {
  229. console.log(data);
  230. this.formData.extInfo.verifyDeptCode = data?.id;
  231. this.formData.extInfo.verifyDeptName = data?.name;
  232. this.formData.verifyId = '';
  233. this.formData.verifyName = '';
  234. this.$refs.formName.validateField('verifyDeptName');
  235. if (data) {
  236. this.getStaffList(data);
  237. }
  238. },
  239. async getStaffList(data) {
  240. let res = await warehouseDefinition.getUserPage({
  241. groupId: data.id,
  242. size: 9999,
  243. page: 1
  244. });
  245. this.staffList = res.list;
  246. },
  247. // // 转资产
  248. // turnToAssets (row) {
  249. // this.$refs.turnToAssetRef
  250. // .open(row.transferCurVal)
  251. // .then(({ code, name }) => {
  252. // row.transferType = name
  253. // row.materialId = code
  254. // row.materialName = name.split('/').pop()
  255. // row.transferType = name
  256. // this.$set(row, 'transferCurVal', code)
  257. // })
  258. // },
  259. handleSetting(row) {
  260. this.$refs.detailSelectRef
  261. .open(row, row.warehouseLedgerDetails || [])
  262. .then((res) => {
  263. console.log(res);
  264. console.log(row);
  265. this.$set(
  266. row,
  267. 'warehouseLedgerDetails',
  268. (res || []).map((item) => {
  269. delete item.updateTime;
  270. delete item.createTime;
  271. this.$set(item, 'isTransferAsset', false);
  272. item.isUnpack = row.isUnpack;
  273. return item;
  274. })
  275. );
  276. this.$set(row, 'outInNum', res.length);
  277. this.$set(row, 'minPackUnit', res[0].minPackUnit);
  278. this.$set(
  279. row,
  280. 'selfSum',
  281. row.warehouseLedgerDetails.reduce((sum, pre) => {
  282. if (row.isUnpack) {
  283. return ++sum;
  284. }
  285. return sum + pre.measurementUnit;
  286. }, 0)
  287. );
  288. });
  289. },
  290. // 仓库编辑
  291. handleWareHouse(row) {
  292. this.$refs.wareHouseDailogRef.open(row);
  293. },
  294. // 出库操作
  295. listEdit(row) {
  296. this.$set(row, 'isSave', false);
  297. },
  298. //出库明细删除
  299. listDel(row, index) {
  300. this.warehousingMaterialList.splice(index, 1);
  301. if (this.warehousingMaterialList.length == 0) {
  302. this.formData.documentSource = '';
  303. }
  304. },
  305. // 出库明细生成条码信息
  306. async createMaterialCode(row) {
  307. let arr = [];
  308. const res = await getAssetNum({
  309. assetCode: row.assetCode,
  310. num: row.outInNum || 1
  311. });
  312. if (res?.success) {
  313. delete row.createTime;
  314. arr = Array.from(new Array(res.data.length), (val, idx) => ({
  315. ...row,
  316. num: res.data[idx],
  317. bizStatus: 2,
  318. isTransferAsset: false
  319. }));
  320. }
  321. return arr;
  322. },
  323. handleSave() {
  324. this.$refs.formName.validate(async (valid) => {
  325. if (valid) {
  326. if (!this.warehousingMaterialList?.length) {
  327. return this.$message.error('请添加出库明细!');
  328. } else if (
  329. this.warehousingMaterialList.some(
  330. (item) => !item.warehouseLedgerDetails?.length
  331. )
  332. ) {
  333. return this.$message.error('请完善出库明细数据!');
  334. }
  335. console.log('qqqq===>', this.warehousingMaterialList);
  336. let arr = this.warehousingMaterialList.map((item) => {
  337. return {
  338. batchNo: item.batchNo,
  339. categoryId: item.id,
  340. count: item.outInNum,
  341. num: item.outInNum,
  342. minPackingCount: item.selfSum,
  343. packingCount: item.outInNum,
  344. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  345. ...item
  346. };
  347. });
  348. arr.forEach((item) => {
  349. delete item.id;
  350. delete item.warehouseLedgerDetails;
  351. if (item.outInDetailRecordAddPOList.length > 0) {
  352. let list = item.outInDetailRecordAddPOList.map((it) => {
  353. return {
  354. positionId: it.positionId,
  355. code: it.sourceBizNo,
  356. dateType: it.dateType,
  357. dateValue: it.dateValue,
  358. minUnit: it.minUnit,
  359. batchNo: it.sourceBatchNo,
  360. position: it.pathName,
  361. // minPositionId: it.cargoSpaceId,
  362. minPositionId: it.minPositionId,
  363. name: it.name,
  364. pathIds: it.pathIds,
  365. unit: it.unit,
  366. packageNo: it.num
  367. // num: it.minPackingCount
  368. };
  369. });
  370. item.outInDetailRecordAddPOList = list;
  371. }
  372. });
  373. let obj = { ...this.formData, type: 2 };
  374. for (const key in arr) {
  375. arr[key].count = arr[key].outInNum;
  376. }
  377. obj.outInDetailAddPOList = arr;
  378. this.saveLoading = true;
  379. // console.log('明细', this.warehousingMaterialList);
  380. // const categoryLevelId = this.$refs.assetsDialogRef.materialType;
  381. // let newObj = {
  382. // inOutAddPO: {
  383. // ...this.formData,
  384. // ...this.formData.extInfo,
  385. // bizStatus: 2
  386. // },
  387. // warehouseLedgerInfos: this.handelArr(
  388. // this.warehousingMaterialList,
  389. // categoryLevelId
  390. // )
  391. // };
  392. // delete newObj.inOutAddPO.extInfo;
  393. console.log('2222', obj);
  394. // const res = await outin.save(obj);
  395. // if (res.code == 0) {
  396. // this.$message.success('保存成功!');
  397. // }
  398. // this.saveLoading = false;
  399. // this.$router.push('/warehouseManagement/outgoingManagement');
  400. // if (res?.success) {
  401. // this.$message.success('保存成功!');
  402. // this.$router.go(-1);
  403. // }
  404. }
  405. });
  406. },
  407. handelArr(arr, id) {
  408. for (const key in arr) {
  409. arr[key].inLedgerId = arr[key].id;
  410. arr[key].categoryLevelId = id;
  411. for (const k in arr[key].warehouseLedgerDetails) {
  412. arr[key].warehouseLedgerDetails[k].ledgerDetailId =
  413. arr[key].warehouseLedgerDetails[k].id;
  414. arr[key].warehouseLedgerDetails[k].inDetailId = arr[key].inLedgerId;
  415. arr[key].warehouseLedgerDetails[k].isTransferAsset = arr[key]
  416. .warehouseLedgerDetails[k].isTransferAsset
  417. ? 1
  418. : 0;
  419. arr[key].warehouseLedgerDetails[k].bizStatus = 2;
  420. }
  421. }
  422. return arr;
  423. // let newArr = arr.map((item) => {
  424. // return { ...item, ledgerId: item.id };
  425. // });
  426. // newArr.map((item) => {
  427. // item.warehouseLedgerDetails.map((ite) => {
  428. // return { ...ite, ledgerDetailId: ite.id, ledgerId: item.id };
  429. // });
  430. // });
  431. // return newArr;
  432. },
  433. //添加明细
  434. onSelectTableData(val, e) {
  435. // if (e == 1) {
  436. // this.llList = val;
  437. // } else {
  438. // this.llList = [];
  439. // }
  440. // .concat(this.llList)
  441. // if (this.warehousingMaterialList.length != 0) {
  442. // val = this.warehousingMaterialList.concat(val);
  443. // }
  444. this.onSelectTableDataVal = val;
  445. this.warehousingMaterialList = val.map((next) => {
  446. delete next.updateTime;
  447. delete next.createTime;
  448. return {
  449. ...next,
  450. realInventoryAmount: 0,
  451. // cargoSpaceCode: '', //货位编码
  452. // cargoSpaceId: '', //货位id
  453. // shelfId: '', //货架id
  454. // shelfCode: '', //货架名称
  455. // areaId: '', //库区id
  456. // areaName: '', //库区名称
  457. // warehouseId: '', //仓库id
  458. // warehouseName: '', //仓库名称
  459. assetType: this.formData.extInfo.assetType,
  460. outInNum: '',
  461. assetCode: next.code,
  462. assetName: next.name,
  463. bizStatus: 2,
  464. contactCode: next.contactCode
  465. };
  466. });
  467. console.log('sasasasa===>>>', this.warehousingMaterialList);
  468. },
  469. codeListValue(val) {
  470. console.log(val);
  471. this.formData.extInfo.assetType = val.id;
  472. this.$forceUpdate();
  473. this.title = val?.name;
  474. this.selectEquiType = val?.id;
  475. console.log(this.title);
  476. },
  477. async initData() {
  478. const { data } = await getTreeByGroup({ type: 1 });
  479. this.codeList = data;
  480. const res = await warehouseDefinition.tree();
  481. this.treeList = this.$util.toTreeData({
  482. data: res,
  483. idField: 'id',
  484. parentIdField: 'parentId'
  485. });
  486. let res22 = await warehouseDefinition.getUserPage({
  487. size: -1,
  488. page: 1
  489. });
  490. this.fromUserList = res22.list;
  491. // /
  492. // const res111 = await warehouseDefinition.list();
  493. // this.warehouseList = res111.list;
  494. const info = JSON.parse(localStorage.getItem('info'));
  495. let obj = res.find((item) => item.id === info.deptId);
  496. this.formData.extInfo.deptName = obj.name;
  497. this.formData.extInfo.deptCode = obj.id;
  498. this.formData.extInfo.createUserName = info.name;
  499. this.formData.createUserId = info.id;
  500. },
  501. addStock() {
  502. if (!this.title) return this.$message.error('请选择出库产品类型');
  503. if (!this.formData.bizType && this.formData.bizType !== 0)
  504. return this.$message.error('请选择出库场景');
  505. if (this.formData.bizType == 4 && !this.formData.documentSource) {
  506. return this.$message.error('请选择来源单据');
  507. }
  508. this.$refs.assetsDialogRef.open();
  509. },
  510. handleChange(data) {
  511. this.title = data?.dictValue;
  512. if (this.formData.bizType == 4) {
  513. this.formData.documentSource = '';
  514. }
  515. },
  516. handleChanges(code) {
  517. const data = this.codeList.find((item) => item.dictCode == code);
  518. this.title = data?.dictValue;
  519. this.selectEquiType = data?.dictCode;
  520. if (this.formData.bizType == 4) {
  521. this.formData.documentSource = '';
  522. }
  523. },
  524. handleBizSceneChange() {
  525. if (this.formData.extInfo.assetType == 7) {
  526. this.formData.extInfo.documentSource = '';
  527. }
  528. },
  529. getSupplier() {
  530. return new Promise((resolve, reject) => {
  531. supplier.list({ page: 1, size: 999 }).then((res) => {
  532. if (res.success) {
  533. resolve(res);
  534. }
  535. });
  536. });
  537. },
  538. upload(data) {
  539. this.formData.contentImage = data;
  540. this.$refs.formName.validateField('contentImage');
  541. },
  542. deptClick(data) {
  543. this.formData.deptName = data?.name;
  544. this.formData.deptCode = data?.code;
  545. }
  546. }
  547. });