| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572 |
- import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
- import { getTreeByGroup } from '@/api/classifyManage';
- import { tableHeader } from '../common';
- export default (await import('vue')).defineComponent({
- components: {
- pickOrder,
- selectUpload,
- selectTree,
- AssetsDialog,
- WareHouseDailog,
- upload,
- detailSelect,
- // TurnToAsset,
- outputType,
- eom
- },
- data() {
- return {
- llList: [],
- codeList: [],
- materialType,
- warehousingType,
- outputSceneState,
- emergencyState,
- saveLoading: false,
- title: '',
- tableData2: [],
- uploadList: [],
- fromUserList: [], //人员数组
- warehousingMaterialList: [],
- activeName: 'a',
- treeList: [],
- staffList: [],
- formData: {
- extInfo: {
- assetType: '', //物品类型
- deptCode: '', //部门code
- deptName: '', //部门名称
- verifyDeptCode: '', //审核部门编码
- verifyDeptName: '', //审核部门名称
- deliveryName: '', //送货人名称
- deliveryPhone: '', //送货人电话
- documentSource: '', //销售订单
- urgent: '', //紧急状态
- supplierId: '', //供应商ID
- supplierName: '', //供应商名称
- createUserName: '', //创建人名字
- contentImage: [] //图片数组
- },
- fromUser: '', //送货人
- bizType: '', //物品类型
- verifyId: '', //审核人Id
- verifyName: '', //审核人名称
- createUserId: '',
- remark: ''
- },
- rules: {
- // 'extInfo.assetType': {
- // required: true,
- // message: '请选择出库产品类型',
- // trigger: 'change'
- // },
- bizType: {
- required: true,
- message: '请选择出库场景',
- trigger: 'change'
- },
- fromUser: {
- required: true,
- message: '请选择领料人',
- trigger: 'change'
- }
- },
- options: [],
- loading: false,
- onSelectTableDataVal: []
- };
- },
- computed: {
- tableHeader() {
- return tableHeader(this.formData.extInfo.assetType);
- },
- // 条码信息
- materialCodeReqList() {
- console.log(
- '===',
- this.warehousingMaterialList
- .map((i) => i.warehouseLedgerDetails || [])
- .flat()
- );
- return this.warehousingMaterialList
- .map((i) => i.warehouseLedgerDetails || [])
- .flat();
- }
- },
- created() {
- this.initData();
- },
- methods: {
- eomSuccess(row) {
- this.formData.documentSource = row.orderNo;
- console.log(row);
- this.onSelectTableData(row.tableData, 1);
- this.$forceUpdate();
- },
- pickOrderRow(row) {
- row.tableData = [];
- this.formData.documentSource = row.code;
- for (const key in row.orderInfoList) {
- if (row.orderInfoList[key].bomDetailDTOS.length != 0) {
- for (const i in row.orderInfoList[key].bomDetailDTOS) {
- row.tableData.push({
- ...row.orderInfoList[key].bomDetailDTOS[i],
- code: row.orderInfoList[key].bomDetailDTOS[i].categoryCode,
- name: row.orderInfoList[key].bomDetailDTOS[i].categoryName,
- modelType: row.orderInfoList[key].bomDetailDTOS[i].model,
- id: row.orderInfoList[key].bomDetailDTOS[i].categoryId
- });
- }
- }
- if (row.orderInfoList[key].instanceList.length != 0) {
- for (const j in row.orderInfoList[key].instanceList) {
- row.tableData.push({
- ...row.orderInfoList[key].instanceList[j],
- code: row.orderInfoList[key].instanceList[j].categoryCode,
- name: row.orderInfoList[key].instanceList[j].categoryName,
- modelType: row.orderInfoList[key].instanceList[j].model,
- id: row.orderInfoList[key].instanceList[j].categoryId
- });
- }
- }
- }
- const uniqueItems = [];
- const uniqueIds = new Set();
- row.tableData.forEach((item) => {
- if (!uniqueIds.has(item.code)) {
- uniqueIds.add(item.code);
- uniqueItems.push(item);
- }
- });
- row.tableData = uniqueItems;
- console.log(row);
- this.onSelectTableData(row.tableData, 1);
- this.$forceUpdate();
- },
- handleEom() {
- this.$refs.eomRef.open();
- },
- handlePickorder() {
- this.$refs.pickOrderRef.open();
- },
- async handleDocumentSourceChange() {
- if (!this.formData.documentSource) {
- if (this.formData.bizType == 4) {
- this.warehousingMaterialList = [];
- }
- return;
- }
- if (
- !(this.formData.extInfo.assetType == 7 && this.formData.bizType == 4)
- ) {
- return;
- }
- const loading = this.$loading({ fullscreen: true });
- const res = await getSparePartsInfo({
- code: this.formData.documentSource
- });
- if (res?.success && res.data.length) {
- const curMap = {
- assetId: 'classificationId',
- assetCode: 'informationCode', //编码
- assetName: 'informationName', //名称
- materialId: 'classificationId',
- materialName: 'informationName',
- batchNo: '', //批次号
- unit: 'measuringUnit', //单位
- minPackUnit: 'packingUnit' //最小包装单位
- };
- res.data.forEach((item) => {
- let obj = {};
- for (const key in curMap) {
- obj[key] = curMap[key] ? item[curMap[key]] : '';
- }
- obj.curId =
- obj.assetCode +
- (obj.measurementUnit || '') +
- (obj.minPackUnit || '') +
- (obj.unit || '');
- console.log(obj.curId);
- const index = this.warehousingMaterialList.findIndex(
- (i) => i.curId === obj.curId
- );
- if (index === -1) {
- Object.assign(obj, item);
- obj.sparePartsNum = item.num;
- this.warehousingMaterialList.push(obj);
- } else {
- this.warehousingMaterialList[index].sparePartsNum = item.num;
- }
- });
- }
- loading.close();
- },
- // 备品备件来源单号
- async remoteMethod(code) {
- // if (code !== '') {
- // this.loading = true
- const res = await getDocumentSource({ code });
- if (res?.success) {
- this.options = res.data;
- }
- // this.loading = false
- // } else {
- // this.options = []
- // }
- },
- rowClass({ row, column, rowIndex, columnIndex }) {
- if (rowIndex === 1) {
- return {
- display: 'none',
- background: '#EEEEEE',
- border: 'none'
- };
- }
- return { background: '#EEEEEE', border: 'none' };
- },
- // 部门 点击事件
- async auditorDeptClick(data) {
- console.log(data);
- this.formData.extInfo.verifyDeptCode = data?.id;
- this.formData.extInfo.verifyDeptName = data?.name;
- this.formData.verifyId = '';
- this.formData.verifyName = '';
- this.$refs.formName.validateField('verifyDeptName');
- if (data) {
- this.getStaffList(data);
- }
- },
- async getStaffList(data) {
- let res = await warehouseDefinition.getUserPage({
- groupId: data.id,
- size: 9999,
- page: 1
- });
- this.staffList = res.list;
- },
- // // 转资产
- // turnToAssets (row) {
- // this.$refs.turnToAssetRef
- // .open(row.transferCurVal)
- // .then(({ code, name }) => {
- // row.transferType = name
- // row.materialId = code
- // row.materialName = name.split('/').pop()
- // row.transferType = name
- // this.$set(row, 'transferCurVal', code)
- // })
- // },
- handleSetting(row) {
- this.$refs.detailSelectRef
- .open(row, row.warehouseLedgerDetails || [])
- .then((res) => {
- console.log(res);
- console.log(row);
- this.$set(
- row,
- 'warehouseLedgerDetails',
- (res || []).map((item) => {
- delete item.updateTime;
- delete item.createTime;
- this.$set(item, 'isTransferAsset', false);
- item.isUnpack = row.isUnpack;
- return item;
- })
- );
- this.$set(row, 'outInNum', res.length);
- this.$set(row, 'minPackUnit', res[0].minPackUnit);
- this.$set(
- row,
- 'selfSum',
- row.warehouseLedgerDetails.reduce((sum, pre) => {
- if (row.isUnpack) {
- return ++sum;
- }
- return sum + pre.measurementUnit;
- }, 0)
- );
- });
- },
- // 仓库编辑
- handleWareHouse(row) {
- this.$refs.wareHouseDailogRef.open(row);
- },
- // 出库操作
- listEdit(row) {
- this.$set(row, 'isSave', false);
- },
- //出库明细删除
- listDel(row, index) {
- this.warehousingMaterialList.splice(index, 1);
- if (this.warehousingMaterialList.length == 0) {
- this.formData.documentSource = '';
- }
- },
- // 出库明细生成条码信息
- async createMaterialCode(row) {
- let arr = [];
- const res = await getAssetNum({
- assetCode: row.assetCode,
- num: row.outInNum || 1
- });
- if (res?.success) {
- delete row.createTime;
- arr = Array.from(new Array(res.data.length), (val, idx) => ({
- ...row,
- num: res.data[idx],
- bizStatus: 2,
- isTransferAsset: false
- }));
- }
- return arr;
- },
- handleSave() {
- this.$refs.formName.validate(async (valid) => {
- if (valid) {
- if (!this.warehousingMaterialList?.length) {
- return this.$message.error('请添加出库明细!');
- } else if (
- this.warehousingMaterialList.some(
- (item) => !item.warehouseLedgerDetails?.length
- )
- ) {
- return this.$message.error('请完善出库明细数据!');
- }
- console.log('qqqq===>', this.warehousingMaterialList);
- let arr = this.warehousingMaterialList.map((item) => {
- return {
- batchNo: item.batchNo,
- categoryId: item.id,
- count: item.outInNum,
- num: item.outInNum,
- minPackingCount: item.selfSum,
- packingCount: item.outInNum,
- outInDetailRecordAddPOList: item.warehouseLedgerDetails,
- ...item
- };
- });
- arr.forEach((item) => {
- delete item.id;
- delete item.warehouseLedgerDetails;
- if (item.outInDetailRecordAddPOList.length > 0) {
- let list = item.outInDetailRecordAddPOList.map((it) => {
- return {
- positionId: it.positionId,
- code: it.sourceBizNo,
- dateType: it.dateType,
- dateValue: it.dateValue,
- minUnit: it.minUnit,
- batchNo: it.sourceBatchNo,
- position: it.pathName,
- // minPositionId: it.cargoSpaceId,
- minPositionId: it.minPositionId,
- name: it.name,
- pathIds: it.pathIds,
- unit: it.unit,
- packageNo: it.num
- // num: it.minPackingCount
- };
- });
- item.outInDetailRecordAddPOList = list;
- }
- });
- let obj = { ...this.formData, type: 2 };
- for (const key in arr) {
- arr[key].count = arr[key].outInNum;
- }
- obj.outInDetailAddPOList = arr;
- this.saveLoading = true;
- // console.log('明细', this.warehousingMaterialList);
- // const categoryLevelId = this.$refs.assetsDialogRef.materialType;
- // let newObj = {
- // inOutAddPO: {
- // ...this.formData,
- // ...this.formData.extInfo,
- // bizStatus: 2
- // },
- // warehouseLedgerInfos: this.handelArr(
- // this.warehousingMaterialList,
- // categoryLevelId
- // )
- // };
- // delete newObj.inOutAddPO.extInfo;
- console.log('2222', obj);
- // const res = await outin.save(obj);
- // if (res.code == 0) {
- // this.$message.success('保存成功!');
- // }
- // this.saveLoading = false;
- // this.$router.push('/warehouseManagement/outgoingManagement');
- // if (res?.success) {
- // this.$message.success('保存成功!');
- // this.$router.go(-1);
- // }
- }
- });
- },
- handelArr(arr, id) {
- for (const key in arr) {
- arr[key].inLedgerId = arr[key].id;
- arr[key].categoryLevelId = id;
- for (const k in arr[key].warehouseLedgerDetails) {
- arr[key].warehouseLedgerDetails[k].ledgerDetailId =
- arr[key].warehouseLedgerDetails[k].id;
- arr[key].warehouseLedgerDetails[k].inDetailId = arr[key].inLedgerId;
- arr[key].warehouseLedgerDetails[k].isTransferAsset = arr[key]
- .warehouseLedgerDetails[k].isTransferAsset
- ? 1
- : 0;
- arr[key].warehouseLedgerDetails[k].bizStatus = 2;
- }
- }
- return arr;
- // let newArr = arr.map((item) => {
- // return { ...item, ledgerId: item.id };
- // });
- // newArr.map((item) => {
- // item.warehouseLedgerDetails.map((ite) => {
- // return { ...ite, ledgerDetailId: ite.id, ledgerId: item.id };
- // });
- // });
- // return newArr;
- },
- //添加明细
- onSelectTableData(val, e) {
- // if (e == 1) {
- // this.llList = val;
- // } else {
- // this.llList = [];
- // }
- // .concat(this.llList)
- // if (this.warehousingMaterialList.length != 0) {
- // val = this.warehousingMaterialList.concat(val);
- // }
- this.onSelectTableDataVal = val;
- this.warehousingMaterialList = val.map((next) => {
- delete next.updateTime;
- delete next.createTime;
- return {
- ...next,
- realInventoryAmount: 0,
- // cargoSpaceCode: '', //货位编码
- // cargoSpaceId: '', //货位id
- // shelfId: '', //货架id
- // shelfCode: '', //货架名称
- // areaId: '', //库区id
- // areaName: '', //库区名称
- // warehouseId: '', //仓库id
- // warehouseName: '', //仓库名称
- assetType: this.formData.extInfo.assetType,
- outInNum: '',
- assetCode: next.code,
- assetName: next.name,
- bizStatus: 2,
- contactCode: next.contactCode
- };
- });
- console.log('sasasasa===>>>', this.warehousingMaterialList);
- },
- codeListValue(val) {
- console.log(val);
- this.formData.extInfo.assetType = val.id;
- this.$forceUpdate();
- this.title = val?.name;
- this.selectEquiType = val?.id;
- console.log(this.title);
- },
- async initData() {
- const { data } = await getTreeByGroup({ type: 1 });
- this.codeList = data;
- const res = await warehouseDefinition.tree();
- this.treeList = this.$util.toTreeData({
- data: res,
- idField: 'id',
- parentIdField: 'parentId'
- });
- let res22 = await warehouseDefinition.getUserPage({
- size: -1,
- page: 1
- });
- this.fromUserList = res22.list;
- // /
- // const res111 = await warehouseDefinition.list();
- // this.warehouseList = res111.list;
- const info = JSON.parse(localStorage.getItem('info'));
- let obj = res.find((item) => item.id === info.deptId);
- this.formData.extInfo.deptName = obj.name;
- this.formData.extInfo.deptCode = obj.id;
- this.formData.extInfo.createUserName = info.name;
- this.formData.createUserId = info.id;
- },
- addStock() {
- if (!this.title) return this.$message.error('请选择出库产品类型');
- if (!this.formData.bizType && this.formData.bizType !== 0)
- return this.$message.error('请选择出库场景');
- if (this.formData.bizType == 4 && !this.formData.documentSource) {
- return this.$message.error('请选择来源单据');
- }
- this.$refs.assetsDialogRef.open();
- },
- handleChange(data) {
- this.title = data?.dictValue;
- if (this.formData.bizType == 4) {
- this.formData.documentSource = '';
- }
- },
- handleChanges(code) {
- const data = this.codeList.find((item) => item.dictCode == code);
- this.title = data?.dictValue;
- this.selectEquiType = data?.dictCode;
- if (this.formData.bizType == 4) {
- this.formData.documentSource = '';
- }
- },
- handleBizSceneChange() {
- if (this.formData.extInfo.assetType == 7) {
- this.formData.extInfo.documentSource = '';
- }
- },
- getSupplier() {
- return new Promise((resolve, reject) => {
- supplier.list({ page: 1, size: 999 }).then((res) => {
- if (res.success) {
- resolve(res);
- }
- });
- });
- },
- upload(data) {
- this.formData.contentImage = data;
- this.$refs.formName.validateField('contentImage');
- },
- deptClick(data) {
- this.formData.deptName = data?.name;
- this.formData.deptCode = data?.code;
- }
- }
- });
|