|
@@ -284,7 +284,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import pickingList from '@/views/produce/components/picking/pickingList.vue';
|
|
|
|
|
|
|
+ import pickingList from '@/views/produce/components/picking/newPickingList.vue';
|
|
|
import { workorderList, getCode } from '@/api/produce/workOrder';
|
|
import { workorderList, getCode } from '@/api/produce/workOrder';
|
|
|
import produceOrder from './produceOrder.vue';
|
|
import produceOrder from './produceOrder.vue';
|
|
|
|
|
|
|
@@ -339,6 +339,7 @@
|
|
|
const param = { ids, taskId };
|
|
const param = { ids, taskId };
|
|
|
|
|
|
|
|
workorderList(param).then((res) => {
|
|
workorderList(param).then((res) => {
|
|
|
|
|
+ console.log(res, 'resres');
|
|
|
this.workList = res.map((item) => {
|
|
this.workList = res.map((item) => {
|
|
|
// 处理 pickList 并统一 warehouse 字段
|
|
// 处理 pickList 并统一 warehouse 字段
|
|
|
const pickList = item.bomDetailDTOS.map((it) => {
|
|
const pickList = item.bomDetailDTOS.map((it) => {
|
|
@@ -381,14 +382,54 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
allSelection(id, list) {
|
|
allSelection(id, list) {
|
|
|
|
|
+ // this.workList.forEach((e) => {
|
|
|
|
|
+ // if (e.id == id) {
|
|
|
|
|
+ // e.pickList = list;
|
|
|
|
|
+ // this.$forceUpdate();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ console.log(id, list);
|
|
|
|
|
+ list.forEach((item) => {
|
|
|
|
|
+ item.code = item.categoryCode;
|
|
|
|
|
+ item.name = item.categoryName;
|
|
|
|
|
+ item.modelType = item.modelType ? item.modelType : item.categoryModel;
|
|
|
|
|
+ item.measuringUnit = item.measuringUnit
|
|
|
|
|
+ ? item.measuringUnit
|
|
|
|
|
+ : item.measureUnit;
|
|
|
|
|
+ item.unit = item.unit ? item.unit : item.measureUnit;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
this.workList.forEach((e) => {
|
|
this.workList.forEach((e) => {
|
|
|
if (e.id == id) {
|
|
if (e.id == id) {
|
|
|
- e.pickList = list;
|
|
|
|
|
|
|
+ const newData = [];
|
|
|
|
|
+ if (list.length != 0) {
|
|
|
|
|
+ list.forEach((it) => {
|
|
|
|
|
+ newData.push(this.deepCopy(it));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // e.pickList = list;
|
|
|
|
|
+ e.pickList = newData;
|
|
|
this.$forceUpdate();
|
|
this.$forceUpdate();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ deepCopy(obj, hash = new WeakMap()) {
|
|
|
|
|
+ if (obj === null) return null;
|
|
|
|
|
+ if (obj instanceof Date) return new Date(obj);
|
|
|
|
|
+ if (obj instanceof RegExp) return new RegExp(obj);
|
|
|
|
|
+ if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
|
|
|
|
|
+ if (hash.has(obj)) return hash.get(obj);
|
|
|
|
|
+
|
|
|
|
|
+ const result = Array.isArray(obj) ? [] : {};
|
|
|
|
|
+ hash.set(obj, result);
|
|
|
|
|
+
|
|
|
|
|
+ return Object.keys(obj).reduce((acc, key) => {
|
|
|
|
|
+ acc[key] = this.deepCopy(obj[key], hash);
|
|
|
|
|
+ return acc;
|
|
|
|
|
+ }, result);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
save() {
|
|
save() {
|
|
|
if (this.workList.length > 0) {
|
|
if (this.workList.length > 0) {
|
|
|
let bol;
|
|
let bol;
|
|
@@ -473,48 +514,104 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
workSelect(ids, taskId) {
|
|
workSelect(ids, taskId) {
|
|
|
|
|
+ console.log(ids, taskId, 'ids, taskId');
|
|
|
this.getList(ids, taskId);
|
|
this.getList(ids, taskId);
|
|
|
|
|
|
|
|
this.orderShow = false;
|
|
this.orderShow = false;
|
|
|
},
|
|
},
|
|
|
changeWarehouse(item, index) {},
|
|
changeWarehouse(item, index) {},
|
|
|
|
|
+
|
|
|
changeInput(item, index, idx) {
|
|
changeInput(item, index, idx) {
|
|
|
- if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
|
|
|
|
|
- this.$set(
|
|
|
|
|
- this.workList[idx].pickList[index],
|
|
|
|
|
- 'demandQuantity',
|
|
|
|
|
- Number(item.availableCountBase)
|
|
|
|
|
- );
|
|
|
|
|
- const idsList = [];
|
|
|
|
|
- item.warehouseList.forEach((it) => {
|
|
|
|
|
- idsList.push(it.id);
|
|
|
|
|
- });
|
|
|
|
|
- this.$set(
|
|
|
|
|
- this.workList[idx].pickList[index],
|
|
|
|
|
- 'warehouseIdList',
|
|
|
|
|
- idsList
|
|
|
|
|
- );
|
|
|
|
|
- } else if (!Number(item.demandQuantity)) {
|
|
|
|
|
- this.$set(this.workList[idx].pickList[index], 'warehouseIdList', []);
|
|
|
|
|
- } else {
|
|
|
|
|
- const idsList = [];
|
|
|
|
|
- let totalNum = 0;
|
|
|
|
|
- for (let i = 0; i < item.warehouseList.length; i++) {
|
|
|
|
|
- totalNum += Number(item.warehouseList[i].availableCountBase);
|
|
|
|
|
- if (Number(item.demandQuantity) > totalNum) {
|
|
|
|
|
- idsList.push(item.warehouseList[i].id);
|
|
|
|
|
- } else {
|
|
|
|
|
- idsList.push(item.warehouseList[i].id);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const pickItem = this.workList[idx].pickList[index];
|
|
|
|
|
+
|
|
|
|
|
+ let value = String(item.demandQuantity ?? '');
|
|
|
|
|
+
|
|
|
|
|
+ value = value.replace(/[^\d.]/g, '');
|
|
|
|
|
+
|
|
|
|
|
+ value = value
|
|
|
|
|
+ .replace(/\.{2,}/g, '.')
|
|
|
|
|
+ .replace('.', '$#$')
|
|
|
|
|
+ .replace(/\./g, '')
|
|
|
|
|
+ .replace('$#$', '.');
|
|
|
|
|
+
|
|
|
|
|
+ if (value.includes('.')) {
|
|
|
|
|
+ const [intPart, decPart] = value.split('.');
|
|
|
|
|
+ value = `${intPart}.${decPart.slice(0, 4)}`;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.$set(pickItem, 'demandQuantity', value);
|
|
|
|
|
+
|
|
|
|
|
+ const demandQty = Number(value);
|
|
|
|
|
+ const maxQty = item.warehouseList.reduce((sum, cur) => {
|
|
|
|
|
+ return sum + Number(cur.availableCountBase || 0);
|
|
|
|
|
+ }, 0);
|
|
|
|
|
+
|
|
|
|
|
+ if (!demandQty) {
|
|
|
|
|
+ this.$set(pickItem, 'warehouseIdList', []);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (demandQty >= maxQty) {
|
|
|
|
|
+ this.$set(pickItem, 'demandQuantity', maxQty);
|
|
|
|
|
+
|
|
|
this.$set(
|
|
this.$set(
|
|
|
- this.workList[0].pickList[index],
|
|
|
|
|
|
|
+ pickItem,
|
|
|
'warehouseIdList',
|
|
'warehouseIdList',
|
|
|
- idsList
|
|
|
|
|
|
|
+ item.warehouseList.map((w) => w.warehouse_id)
|
|
|
);
|
|
);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let total = 0;
|
|
|
|
|
+ const idsList = [];
|
|
|
|
|
+
|
|
|
|
|
+ for (const w of item.warehouseList) {
|
|
|
|
|
+ total += Number(w.availableCountBase) || 0;
|
|
|
|
|
+ idsList.push(w.warehouse_id);
|
|
|
|
|
+
|
|
|
|
|
+ if (total >= demandQty) break;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ this.$set(pickItem, 'warehouseIdList', idsList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // changeInput(item, index, idx) {
|
|
|
|
|
+ // if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.workList[idx].pickList[index],
|
|
|
|
|
+ // 'demandQuantity',
|
|
|
|
|
+ // Number(item.availableCountBase)
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const idsList = [];
|
|
|
|
|
+ // item.warehouseList.forEach((it) => {
|
|
|
|
|
+ // idsList.push(it.id);
|
|
|
|
|
+ // });
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.workList[idx].pickList[index],
|
|
|
|
|
+ // 'warehouseIdList',
|
|
|
|
|
+ // idsList
|
|
|
|
|
+ // );
|
|
|
|
|
+ // } else if (!Number(item.demandQuantity)) {
|
|
|
|
|
+ // this.$set(this.workList[idx].pickList[index], 'warehouseIdList', []);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // const idsList = [];
|
|
|
|
|
+ // let totalNum = 0;
|
|
|
|
|
+ // for (let i = 0; i < item.warehouseList.length; i++) {
|
|
|
|
|
+ // totalNum += Number(item.warehouseList[i].availableCountBase);
|
|
|
|
|
+ // if (Number(item.demandQuantity) > totalNum) {
|
|
|
|
|
+ // idsList.push(item.warehouseList[i].id);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // idsList.push(item.warehouseList[i].id);
|
|
|
|
|
+ // break;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.$set(
|
|
|
|
|
+ // this.workList[0].pickList[index],
|
|
|
|
|
+ // 'warehouseIdList',
|
|
|
|
|
+ // idsList
|
|
|
|
|
+ // );
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
created() {
|