更新录入合卷分卷新增内容
This commit is contained in:
@@ -117,8 +117,22 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 原材料选择(仅当该分卷选择了原材料库区时显示) -->
|
||||||
|
<view class="split-field" v-if="item.itemType === 'raw_material'">
|
||||||
|
<text class="field-label-optional">选择原材料</text>
|
||||||
|
<view
|
||||||
|
class="picker-input"
|
||||||
|
@click="showRawMaterialPickerForItem(index)"
|
||||||
|
>
|
||||||
|
<text class="picker-text" :class="{ 'picker-placeholder': !item.rawMaterialName }">
|
||||||
|
{{ item.rawMaterialName || '请选择原材料' }}
|
||||||
|
</text>
|
||||||
|
<text class="picker-arrow">▼</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="split-field">
|
<view class="split-field">
|
||||||
<text class="field-label-optional">毛重 (kg)</text>
|
<text class="field-label-optional">毛重 (吨)</text>
|
||||||
<input
|
<input
|
||||||
v-model="item.grossWeight"
|
v-model="item.grossWeight"
|
||||||
type="digit"
|
type="digit"
|
||||||
@@ -127,7 +141,7 @@
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="split-field">
|
<view class="split-field">
|
||||||
<text class="field-label-optional">净重 (kg)</text>
|
<text class="field-label-optional">净重 (吨)</text>
|
||||||
<input
|
<input
|
||||||
v-model="item.netWeight"
|
v-model="item.netWeight"
|
||||||
type="digit"
|
type="digit"
|
||||||
@@ -217,6 +231,38 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
|
<!-- 原材料选择弹窗 -->
|
||||||
|
<uni-popup ref="rawMaterialPopup" type="bottom">
|
||||||
|
<view class="warehouse-popup">
|
||||||
|
<view class="popup-header">
|
||||||
|
<text class="popup-title">选择原材料</text>
|
||||||
|
<text class="popup-close" @click="closeRawMaterialPickerForItem">✕</text>
|
||||||
|
</view>
|
||||||
|
<view class="popup-search">
|
||||||
|
<input
|
||||||
|
v-model="rawMaterialSearchKeyword"
|
||||||
|
@input="filterRawMaterialsInPicker"
|
||||||
|
placeholder="搜索原材料名称"
|
||||||
|
class="search-input"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<scroll-view class="popup-body" scroll-y>
|
||||||
|
<view
|
||||||
|
class="warehouse-item"
|
||||||
|
v-for="material in filteredRawMaterialsInPicker"
|
||||||
|
:key="material.rawMaterialId"
|
||||||
|
@click="selectRawMaterialFromPicker(material)"
|
||||||
|
>
|
||||||
|
<text class="warehouse-name">{{ material.rawMaterialName }}</text>
|
||||||
|
<text class="warehouse-check" v-if="currentPickerItemIndex !== -1 && splitCoils[currentPickerItemIndex].itemId === material.rawMaterialId">✓</text>
|
||||||
|
</view>
|
||||||
|
<view class="empty-tip" v-if="!filteredRawMaterialsInPicker || filteredRawMaterialsInPicker.length === 0">
|
||||||
|
<text>未找到匹配的原材料</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -225,6 +271,7 @@ import { getGenerateRecord } from '@/api/wms/code.js'
|
|||||||
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
||||||
import { listWarehouse } from '@/api/wms/warehouse.js'
|
import { listWarehouse } from '@/api/wms/warehouse.js'
|
||||||
import { listProduct } from '@/api/wms/product.js'
|
import { listProduct } from '@/api/wms/product.js'
|
||||||
|
import { listRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -244,6 +291,10 @@ export default {
|
|||||||
warehouseKeyword: '',
|
warehouseKeyword: '',
|
||||||
filteredWarehouses: [],
|
filteredWarehouses: [],
|
||||||
showWarehouseList: false,
|
showWarehouseList: false,
|
||||||
|
itemType: '',
|
||||||
|
itemId: undefined,
|
||||||
|
productName: '',
|
||||||
|
rawMaterialName: '',
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: ''
|
netWeight: ''
|
||||||
},
|
},
|
||||||
@@ -256,6 +307,10 @@ export default {
|
|||||||
warehouseKeyword: '',
|
warehouseKeyword: '',
|
||||||
filteredWarehouses: [],
|
filteredWarehouses: [],
|
||||||
showWarehouseList: false,
|
showWarehouseList: false,
|
||||||
|
itemType: '',
|
||||||
|
itemId: undefined,
|
||||||
|
productName: '',
|
||||||
|
rawMaterialName: '',
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: ''
|
netWeight: ''
|
||||||
}
|
}
|
||||||
@@ -266,6 +321,9 @@ export default {
|
|||||||
products: [], // 产品列表
|
products: [], // 产品列表
|
||||||
productSearchKeyword: '',
|
productSearchKeyword: '',
|
||||||
filteredProductsInPicker: [],
|
filteredProductsInPicker: [],
|
||||||
|
rawMaterials: [], // 原材料列表
|
||||||
|
rawMaterialSearchKeyword: '',
|
||||||
|
filteredRawMaterialsInPicker: [],
|
||||||
currentPickerItemIndex: -1,
|
currentPickerItemIndex: -1,
|
||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
@@ -279,10 +337,14 @@ export default {
|
|||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -326,6 +388,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 加载原材料列表
|
||||||
|
async loadRawMaterials() {
|
||||||
|
console.log('开始加载原材料列表...');
|
||||||
|
try {
|
||||||
|
const res = await listRawMaterial({ pageNum: 1, pageSize: 1000 });
|
||||||
|
console.log("原材料返回值", res);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.rawMaterials = res.rows || res.data || [];
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials;
|
||||||
|
console.log('原材料加载成功,数量:', this.rawMaterials.length);
|
||||||
|
} else {
|
||||||
|
console.error('原材料加载失败:', res.msg);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('加载原材料异常:', err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 过滤库区(在选择器中)
|
// 过滤库区(在选择器中)
|
||||||
filterWarehousesInPicker() {
|
filterWarehousesInPicker() {
|
||||||
const keyword = this.warehouseSearchKeyword.trim().toLowerCase();
|
const keyword = this.warehouseSearchKeyword.trim().toLowerCase();
|
||||||
@@ -344,16 +424,23 @@ export default {
|
|||||||
if (this.currentPickerItemIndex === -1) return;
|
if (this.currentPickerItemIndex === -1) return;
|
||||||
|
|
||||||
const item = this.splitCoils[this.currentPickerItemIndex];
|
const item = this.splitCoils[this.currentPickerItemIndex];
|
||||||
item.warehouseId = warehouse.warehouseId;
|
const currentIndex = this.currentPickerItemIndex;
|
||||||
item.warehouseName = warehouse.warehouseName;
|
|
||||||
|
// 使用 $set 确保响应式更新
|
||||||
|
this.$set(item, 'warehouseId', warehouse.warehouseId);
|
||||||
|
this.$set(item, 'warehouseName', warehouse.warehouseName);
|
||||||
|
|
||||||
this.closeWarehousePickerForItem();
|
this.closeWarehousePickerForItem();
|
||||||
|
|
||||||
// 检查是否选择了成品库区
|
// 根据库区ID判断类型:999为成品库,其他为原材料库
|
||||||
if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) {
|
if (warehouse.warehouseId === 999) {
|
||||||
// 加载产品列表
|
// 成品库,显示产品选择器
|
||||||
await this.loadProducts();
|
this.$set(item, 'itemType', 'product');
|
||||||
// 弹出产品选择框
|
this.showProductPickerForItem(currentIndex);
|
||||||
this.showProductPickerForItem(this.currentPickerItemIndex);
|
} else {
|
||||||
|
// 其他库区,显示原材料选择器
|
||||||
|
this.$set(item, 'itemType', 'raw_material');
|
||||||
|
this.showRawMaterialPickerForItem(currentIndex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -413,6 +500,48 @@ export default {
|
|||||||
this.closeProductPickerForItem();
|
this.closeProductPickerForItem();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 显示原材料选择器(为特定分卷)
|
||||||
|
showRawMaterialPickerForItem(index) {
|
||||||
|
this.currentPickerItemIndex = index;
|
||||||
|
this.rawMaterialSearchKeyword = '';
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
this.$refs.rawMaterialPopup.open();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 关闭原材料选择器
|
||||||
|
closeRawMaterialPickerForItem() {
|
||||||
|
this.$refs.rawMaterialPopup.close();
|
||||||
|
this.currentPickerItemIndex = -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 过滤原材料(在选择器中)
|
||||||
|
filterRawMaterialsInPicker() {
|
||||||
|
const keyword = this.rawMaterialSearchKeyword.trim().toLowerCase();
|
||||||
|
if (!keyword) {
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
} else {
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials.filter(material => {
|
||||||
|
const name = (material.rawMaterialName || '').toLowerCase();
|
||||||
|
return name.includes(keyword);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 从选择器中选择原材料
|
||||||
|
selectRawMaterialFromPicker(material) {
|
||||||
|
if (this.currentPickerItemIndex === -1) return;
|
||||||
|
|
||||||
|
const item = this.splitCoils[this.currentPickerItemIndex];
|
||||||
|
item.itemId = material.rawMaterialId;
|
||||||
|
item.itemType = 'raw_material';
|
||||||
|
item.rawMaterialName = material.rawMaterialName; // 保存原材料名称用于显示
|
||||||
|
uni.showToast({
|
||||||
|
title: `分卷 ${this.currentPickerItemIndex + 1} 已选择原材料:${material.rawMaterialName}`,
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.closeRawMaterialPickerForItem();
|
||||||
|
},
|
||||||
|
|
||||||
// 过滤库区(为特定分卷)
|
// 过滤库区(为特定分卷)
|
||||||
filterWarehousesForItem(index) {
|
filterWarehousesForItem(index) {
|
||||||
console.log(`分卷页面过滤库区,分卷${index + 1},关键词:`, this.splitCoils[index].warehouseKeyword);
|
console.log(`分卷页面过滤库区,分卷${index + 1},关键词:`, this.splitCoils[index].warehouseKeyword);
|
||||||
@@ -474,17 +603,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 从选择器中选择库区
|
|
||||||
selectWarehouseFromPicker(warehouse) {
|
|
||||||
if (this.currentPickerItemIndex !== -1) {
|
|
||||||
const item = this.splitCoils[this.currentPickerItemIndex];
|
|
||||||
item.warehouseId = warehouse.warehouseId;
|
|
||||||
item.warehouseName = warehouse.warehouseName;
|
|
||||||
item.warehouseKeyword = warehouse.warehouseName;
|
|
||||||
}
|
|
||||||
this.closeWarehousePickerForItem();
|
|
||||||
},
|
|
||||||
|
|
||||||
// 扫码
|
// 扫码
|
||||||
handleScan() {
|
handleScan() {
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
@@ -594,6 +712,10 @@ export default {
|
|||||||
warehouseKeyword: '',
|
warehouseKeyword: '',
|
||||||
filteredWarehouses: this.warehouses,
|
filteredWarehouses: this.warehouses,
|
||||||
showWarehouseList: false,
|
showWarehouseList: false,
|
||||||
|
itemType: '',
|
||||||
|
itemId: undefined,
|
||||||
|
productName: '',
|
||||||
|
rawMaterialName: '',
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: ''
|
netWeight: ''
|
||||||
});
|
});
|
||||||
@@ -625,6 +747,10 @@ export default {
|
|||||||
warehouseKeyword: '',
|
warehouseKeyword: '',
|
||||||
filteredWarehouses: this.warehouses,
|
filteredWarehouses: this.warehouses,
|
||||||
showWarehouseList: false,
|
showWarehouseList: false,
|
||||||
|
itemType: '',
|
||||||
|
itemId: undefined,
|
||||||
|
productName: '',
|
||||||
|
rawMaterialName: '',
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: ''
|
netWeight: ''
|
||||||
},
|
},
|
||||||
@@ -637,6 +763,10 @@ export default {
|
|||||||
warehouseKeyword: '',
|
warehouseKeyword: '',
|
||||||
filteredWarehouses: this.warehouses,
|
filteredWarehouses: this.warehouses,
|
||||||
showWarehouseList: false,
|
showWarehouseList: false,
|
||||||
|
itemType: '',
|
||||||
|
itemId: undefined,
|
||||||
|
productName: '',
|
||||||
|
rawMaterialName: '',
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: ''
|
netWeight: ''
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,9 +97,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 原材料选择(仅当选择了原材料库区时显示) -->
|
||||||
|
<view class="form-item form-item-optional" v-if="itemType === 'raw_material'">
|
||||||
|
<text class="form-label-optional">选择原材料</text>
|
||||||
|
<view
|
||||||
|
class="picker-input"
|
||||||
|
@click="showRawMaterialPicker()"
|
||||||
|
>
|
||||||
|
<text class="picker-text" :class="{ 'picker-placeholder': !selectedRawMaterialName }">
|
||||||
|
{{ selectedRawMaterialName || '请选择原材料' }}
|
||||||
|
</text>
|
||||||
|
<text class="picker-arrow">▼</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 毛重 -->
|
<!-- 毛重 -->
|
||||||
<view class="form-item form-item-optional">
|
<view class="form-item form-item-optional">
|
||||||
<text class="form-label-optional">毛重 (kg)</text>
|
<text class="form-label-optional">毛重 (吨)</text>
|
||||||
<input
|
<input
|
||||||
v-model="grossWeight"
|
v-model="grossWeight"
|
||||||
type="digit"
|
type="digit"
|
||||||
@@ -110,7 +124,7 @@
|
|||||||
|
|
||||||
<!-- 净重 -->
|
<!-- 净重 -->
|
||||||
<view class="form-item form-item-optional">
|
<view class="form-item form-item-optional">
|
||||||
<text class="form-label-optional">净重 (kg)</text>
|
<text class="form-label-optional">净重 (吨)</text>
|
||||||
<input
|
<input
|
||||||
v-model="netWeight"
|
v-model="netWeight"
|
||||||
type="digit"
|
type="digit"
|
||||||
@@ -202,6 +216,38 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
|
<!-- 原材料选择弹窗 -->
|
||||||
|
<uni-popup ref="rawMaterialPopup" type="bottom">
|
||||||
|
<view class="warehouse-popup">
|
||||||
|
<view class="popup-header">
|
||||||
|
<text class="popup-title">选择原材料</text>
|
||||||
|
<text class="popup-close" @click="closeRawMaterialPicker">✕</text>
|
||||||
|
</view>
|
||||||
|
<view class="popup-search">
|
||||||
|
<input
|
||||||
|
v-model="rawMaterialSearchKeyword"
|
||||||
|
@input="filterRawMaterialsInPicker"
|
||||||
|
placeholder="搜索原材料名称"
|
||||||
|
class="search-input"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<scroll-view class="popup-body" scroll-y>
|
||||||
|
<view
|
||||||
|
class="warehouse-item"
|
||||||
|
v-for="material in filteredRawMaterialsInPicker"
|
||||||
|
:key="material.rawMaterialId"
|
||||||
|
@click="selectRawMaterialFromPicker(material)"
|
||||||
|
>
|
||||||
|
<text class="warehouse-name">{{ material.rawMaterialName }}</text>
|
||||||
|
<text class="warehouse-check" v-if="itemId === material.rawMaterialId">✓</text>
|
||||||
|
</view>
|
||||||
|
<view class="empty-tip" v-if="!filteredRawMaterialsInPicker || filteredRawMaterialsInPicker.length === 0">
|
||||||
|
<text>未找到匹配的原材料</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -210,6 +256,7 @@ import { getGenerateRecord } from '@/api/wms/code.js'
|
|||||||
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
||||||
import { listWarehouse } from '@/api/wms/warehouse.js'
|
import { listWarehouse } from '@/api/wms/warehouse.js'
|
||||||
import { listProduct } from '@/api/wms/product.js'
|
import { listProduct } from '@/api/wms/product.js'
|
||||||
|
import { listRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -228,9 +275,13 @@ export default {
|
|||||||
products: [], // 产品列表
|
products: [], // 产品列表
|
||||||
productSearchKeyword: '',
|
productSearchKeyword: '',
|
||||||
filteredProductsInPicker: [],
|
filteredProductsInPicker: [],
|
||||||
|
rawMaterials: [], // 原材料列表
|
||||||
|
rawMaterialSearchKeyword: '',
|
||||||
|
filteredRawMaterialsInPicker: [],
|
||||||
itemType: '', // 合卷后的物品类型
|
itemType: '', // 合卷后的物品类型
|
||||||
itemId: undefined, // 合卷后的物品ID
|
itemId: undefined, // 合卷后的物品ID
|
||||||
selectedProductName: '', // 已选择的产品名称
|
selectedProductName: '', // 已选择的产品名称
|
||||||
|
selectedRawMaterialName: '', // 已选择的原材料名称
|
||||||
grossWeight: '',
|
grossWeight: '',
|
||||||
netWeight: '',
|
netWeight: '',
|
||||||
loading: false
|
loading: false
|
||||||
@@ -240,10 +291,14 @@ export default {
|
|||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@@ -289,6 +344,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 加载原材料列表
|
||||||
|
async loadRawMaterials() {
|
||||||
|
console.log('开始加载原材料列表...');
|
||||||
|
try {
|
||||||
|
const res = await listRawMaterial({ pageNum: 1, pageSize: 1000 });
|
||||||
|
console.log("原材料返回值", res);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.rawMaterials = res.rows || res.data || [];
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials;
|
||||||
|
console.log('原材料加载成功,数量:', this.rawMaterials.length);
|
||||||
|
} else {
|
||||||
|
console.error('原材料加载失败:', res.msg);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('加载原材料异常:', err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 显示产品选择器
|
// 显示产品选择器
|
||||||
showProductPicker() {
|
showProductPicker() {
|
||||||
this.productSearchKeyword = '';
|
this.productSearchKeyword = '';
|
||||||
@@ -326,6 +399,43 @@ export default {
|
|||||||
this.closeProductPicker();
|
this.closeProductPicker();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 显示原材料选择器
|
||||||
|
showRawMaterialPicker() {
|
||||||
|
this.rawMaterialSearchKeyword = '';
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
this.$refs.rawMaterialPopup.open();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 关闭原材料选择器
|
||||||
|
closeRawMaterialPicker() {
|
||||||
|
this.$refs.rawMaterialPopup.close();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 过滤原材料(在选择器中)
|
||||||
|
filterRawMaterialsInPicker() {
|
||||||
|
const keyword = this.rawMaterialSearchKeyword.trim().toLowerCase();
|
||||||
|
if (!keyword) {
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
} else {
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials.filter(material => {
|
||||||
|
const name = (material.rawMaterialName || '').toLowerCase();
|
||||||
|
return name.includes(keyword);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 从选择器中选择原材料
|
||||||
|
selectRawMaterialFromPicker(material) {
|
||||||
|
this.itemId = material.rawMaterialId;
|
||||||
|
this.itemType = 'raw_material';
|
||||||
|
this.selectedRawMaterialName = material.rawMaterialName;
|
||||||
|
uni.showToast({
|
||||||
|
title: `已选择原材料:${material.rawMaterialName}`,
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.closeRawMaterialPicker();
|
||||||
|
},
|
||||||
|
|
||||||
// 过滤库区
|
// 过滤库区
|
||||||
filterWarehouses() {
|
filterWarehouses() {
|
||||||
console.log('合卷页面过滤库区,关键词:', this.warehouseKeyword);
|
console.log('合卷页面过滤库区,关键词:', this.warehouseKeyword);
|
||||||
@@ -388,14 +498,15 @@ export default {
|
|||||||
this.warehouseKeyword = warehouse.warehouseName;
|
this.warehouseKeyword = warehouse.warehouseName;
|
||||||
this.closeWarehousePicker();
|
this.closeWarehousePicker();
|
||||||
|
|
||||||
// 检查是否选择了成品库区
|
// 根据库区ID判断类型:999为成品库,其他为原材料库
|
||||||
if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) {
|
if (warehouse.warehouseId === 999) {
|
||||||
// 切换为产品类型
|
// 成品库,显示产品选择器
|
||||||
this.itemType = 'product';
|
this.itemType = 'product';
|
||||||
// 加载产品列表
|
|
||||||
await this.loadProducts();
|
|
||||||
// 弹出产品选择框
|
|
||||||
this.showProductPicker();
|
this.showProductPicker();
|
||||||
|
} else {
|
||||||
|
// 其他库区,显示原材料选择器
|
||||||
|
this.itemType = 'raw_material';
|
||||||
|
this.showRawMaterialPicker();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -528,6 +639,7 @@ export default {
|
|||||||
this.itemType = '';
|
this.itemType = '';
|
||||||
this.itemId = undefined;
|
this.itemId = undefined;
|
||||||
this.selectedProductName = '';
|
this.selectedProductName = '';
|
||||||
|
this.selectedRawMaterialName = '';
|
||||||
this.grossWeight = '';
|
this.grossWeight = '';
|
||||||
this.netWeight = '';
|
this.netWeight = '';
|
||||||
this.showWarehouseList = false;
|
this.showWarehouseList = false;
|
||||||
|
|||||||
@@ -114,6 +114,21 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 原材料选择(仅当选择了原材料库区时显示) -->
|
||||||
|
<view class="form-item form-item-optional" v-if="form.itemType === 'raw_material'">
|
||||||
|
<text class="form-label-optional">选择原材料</text>
|
||||||
|
<view
|
||||||
|
class="picker-input"
|
||||||
|
@click="coilDetail.dataType !== 0 && showRawMaterialPicker()"
|
||||||
|
:class="{ 'picker-input-disabled': coilDetail.dataType === 0 }"
|
||||||
|
>
|
||||||
|
<text class="picker-text" :class="{ 'picker-placeholder': !selectedRawMaterialName }">
|
||||||
|
{{ selectedRawMaterialName || '请选择原材料' }}
|
||||||
|
</text>
|
||||||
|
<text class="picker-arrow" v-if="coilDetail.dataType !== 0">▼</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 毛重 -->
|
<!-- 毛重 -->
|
||||||
<view class="form-item form-item-optional">
|
<view class="form-item form-item-optional">
|
||||||
<text class="form-label-optional">毛重 (吨)</text>
|
<text class="form-label-optional">毛重 (吨)</text>
|
||||||
@@ -224,6 +239,38 @@
|
|||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
|
<!-- 原材料选择弹窗 -->
|
||||||
|
<uni-popup ref="rawMaterialPopup" type="bottom">
|
||||||
|
<view class="warehouse-popup">
|
||||||
|
<view class="popup-header">
|
||||||
|
<text class="popup-title">选择原材料</text>
|
||||||
|
<text class="popup-close" @click="closeRawMaterialPicker">✕</text>
|
||||||
|
</view>
|
||||||
|
<view class="popup-search">
|
||||||
|
<input
|
||||||
|
v-model="rawMaterialSearchKeyword"
|
||||||
|
@input="filterRawMaterialsInPicker"
|
||||||
|
placeholder="搜索原材料名称"
|
||||||
|
class="search-input"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<scroll-view scroll-y class="popup-body">
|
||||||
|
<view
|
||||||
|
class="warehouse-item"
|
||||||
|
v-for="material in filteredRawMaterialsInPicker"
|
||||||
|
:key="material.rawMaterialId"
|
||||||
|
@click="selectRawMaterialFromPicker(material)"
|
||||||
|
>
|
||||||
|
<text class="warehouse-name">{{ material.rawMaterialName }}</text>
|
||||||
|
<text class="warehouse-check" v-if="form.itemId === material.rawMaterialId">✓</text>
|
||||||
|
</view>
|
||||||
|
<view class="empty-tip" v-if="!filteredRawMaterialsInPicker || filteredRawMaterialsInPicker.length === 0">
|
||||||
|
<text>未找到匹配的原材料</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
|
|
||||||
<!-- BOM弹窗 -->
|
<!-- BOM弹窗 -->
|
||||||
<uni-popup ref="bomPopup" type="bottom">
|
<uni-popup ref="bomPopup" type="bottom">
|
||||||
<view class="bom-popup">
|
<view class="bom-popup">
|
||||||
@@ -258,7 +305,7 @@
|
|||||||
import { getGenerateRecord } from '@/api/wms/code.js'
|
import { getGenerateRecord } from '@/api/wms/code.js'
|
||||||
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
||||||
import { listWarehouse } from '@/api/wms/warehouse.js'
|
import { listWarehouse } from '@/api/wms/warehouse.js'
|
||||||
import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
import { getRawMaterial, listRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||||
import { listProduct } from '@/api/wms/product.js'
|
import { listProduct } from '@/api/wms/product.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -289,6 +336,10 @@ import { listProduct } from '@/api/wms/product.js'
|
|||||||
productSearchKeyword: '',
|
productSearchKeyword: '',
|
||||||
filteredProductsInPicker: [],
|
filteredProductsInPicker: [],
|
||||||
selectedProductName: '', // 已选择的产品名称
|
selectedProductName: '', // 已选择的产品名称
|
||||||
|
rawMaterials: [], // 原材料列表
|
||||||
|
rawMaterialSearchKeyword: '',
|
||||||
|
filteredRawMaterialsInPicker: [],
|
||||||
|
selectedRawMaterialName: '', // 已选择的原材料名称
|
||||||
loading: false,
|
loading: false,
|
||||||
qrcodeStatus: 1 // 二维码状态:0=历史码,1=当前有效码
|
qrcodeStatus: 1 // 二维码状态:0=历史码,1=当前有效码
|
||||||
}
|
}
|
||||||
@@ -303,10 +354,14 @@ import { listProduct } from '@/api/wms/product.js'
|
|||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadWarehouses();
|
this.loadWarehouses();
|
||||||
|
this.loadProducts();
|
||||||
|
this.loadRawMaterials();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -346,6 +401,24 @@ import { listProduct } from '@/api/wms/product.js'
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 加载原材料列表
|
||||||
|
async loadRawMaterials() {
|
||||||
|
console.log('开始加载原材料列表...');
|
||||||
|
try {
|
||||||
|
const res = await listRawMaterial({ pageNum: 1, pageSize: 1000 });
|
||||||
|
console.log("原材料返回值", res);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.rawMaterials = res.rows || res.data || [];
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials;
|
||||||
|
console.log('原材料加载成功,数量:', this.rawMaterials.length);
|
||||||
|
} else {
|
||||||
|
console.error('原材料加载失败:', res.msg);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('加载原材料异常:', err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 显示产品选择器
|
// 显示产品选择器
|
||||||
showProductPicker() {
|
showProductPicker() {
|
||||||
this.productSearchKeyword = '';
|
this.productSearchKeyword = '';
|
||||||
@@ -384,6 +457,44 @@ import { listProduct } from '@/api/wms/product.js'
|
|||||||
this.closeProductPicker();
|
this.closeProductPicker();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 显示原材料选择器
|
||||||
|
showRawMaterialPicker() {
|
||||||
|
this.rawMaterialSearchKeyword = '';
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
this.$refs.rawMaterialPopup.open();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 关闭原材料选择器
|
||||||
|
closeRawMaterialPicker() {
|
||||||
|
this.$refs.rawMaterialPopup.close();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 过滤原材料(在选择器中)
|
||||||
|
filterRawMaterialsInPicker() {
|
||||||
|
console.log('过滤原材料,关键词:', this.rawMaterialSearchKeyword);
|
||||||
|
const keyword = this.rawMaterialSearchKeyword.trim().toLowerCase();
|
||||||
|
if (!keyword) {
|
||||||
|
this.filteredRawMaterialsInPicker = [...this.rawMaterials];
|
||||||
|
} else {
|
||||||
|
this.filteredRawMaterialsInPicker = this.rawMaterials.filter(material => {
|
||||||
|
const name = (material.rawMaterialName || '').toLowerCase();
|
||||||
|
return name.includes(keyword);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 从选择器中选择原材料
|
||||||
|
selectRawMaterialFromPicker(material) {
|
||||||
|
this.form.itemId = material.rawMaterialId;
|
||||||
|
this.form.itemType = 'raw_material';
|
||||||
|
this.selectedRawMaterialName = material.rawMaterialName;
|
||||||
|
uni.showToast({
|
||||||
|
title: `已选择原材料:${material.rawMaterialName}`,
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.closeRawMaterialPicker();
|
||||||
|
},
|
||||||
|
|
||||||
// 过滤库区
|
// 过滤库区
|
||||||
filterWarehouses() {
|
filterWarehouses() {
|
||||||
console.log('过滤库区,关键词:', this.warehouseKeyword);
|
console.log('过滤库区,关键词:', this.warehouseKeyword);
|
||||||
@@ -444,14 +555,15 @@ import { listProduct } from '@/api/wms/product.js'
|
|||||||
this.currentWarehouseName = warehouse.warehouseName;
|
this.currentWarehouseName = warehouse.warehouseName;
|
||||||
this.closeWarehousePicker();
|
this.closeWarehousePicker();
|
||||||
|
|
||||||
// 检查是否选择了成品库区
|
// 根据库区ID判断类型:999为成品库,其他为原材料库
|
||||||
if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) {
|
if (warehouse.warehouseId === 999) {
|
||||||
// 切换为产品类型
|
// 成品库,显示产品选择器
|
||||||
this.form.itemType = 'product';
|
this.form.itemType = 'product';
|
||||||
// 加载产品列表
|
|
||||||
await this.loadProducts();
|
|
||||||
// 弹出产品选择框
|
|
||||||
this.showProductPicker();
|
this.showProductPicker();
|
||||||
|
} else {
|
||||||
|
// 其他库区,显示原材料选择器
|
||||||
|
this.form.itemType = 'raw_material';
|
||||||
|
this.showRawMaterialPicker();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user