|
|
|
|
@ -197,12 +197,41 @@
|
|
|
|
|
<el-table-column prop="model" label="型号" width="120" />
|
|
|
|
|
<el-table-column prop="specification" label="规格" width="120" />
|
|
|
|
|
<el-table-column prop="wire_disc" label="线盘" width="120" />
|
|
|
|
|
<el-table-column prop="date" label="日期" width="120" />
|
|
|
|
|
<!-- <el-table-column prop="date" label="日期" width="120" /> -->
|
|
|
|
|
<el-table-column prop="total_number" label="总箱数" width="100" />
|
|
|
|
|
<el-table-column prop="warning_number_min" label="最小箱数" width="120" />
|
|
|
|
|
<el-table-column prop="warning_number_max" label="最大箱数" width="120" />
|
|
|
|
|
<el-table-column prop="total_gross_weight" label="总毛重(kg)" width="120" />
|
|
|
|
|
<el-table-column label="最小箱数" width="120">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="scope.row.warning_number_min"
|
|
|
|
|
type="number"
|
|
|
|
|
size="small"
|
|
|
|
|
@input="onWmsValueChange(scope.$index)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="最大箱数" width="120">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="scope.row.warning_number_max"
|
|
|
|
|
type="number"
|
|
|
|
|
size="small"
|
|
|
|
|
@input="onWmsValueChange(scope.$index)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="total_gross_weight" label="总毛重(kg)" width="120" />
|
|
|
|
|
<el-table-column label="操作" width="100" fixed="right">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
size="small"
|
|
|
|
|
:disabled="!wmsModifiedFlags[scope.$index]"
|
|
|
|
|
@click="submitWmsModification(scope.$index)"
|
|
|
|
|
>
|
|
|
|
|
提交修改
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<div class="chart-controls">
|
|
|
|
|
<span class="filter-label">时间范围:</span>
|
|
|
|
|
@ -282,6 +311,8 @@ const salesChartLoading = ref(false)
|
|
|
|
|
const historyChartLoading = ref(false)
|
|
|
|
|
const wmsData = ref([])
|
|
|
|
|
const wmsDataLoading = ref(false)
|
|
|
|
|
const wmsModifiedFlags = ref({})
|
|
|
|
|
const wmsOriginalData = ref({})
|
|
|
|
|
const salesData = ref([])
|
|
|
|
|
const historyData = ref([])
|
|
|
|
|
const hasSalesData = ref(false)
|
|
|
|
|
@ -671,6 +702,7 @@ const fetchWmsData = (model, specification) => {
|
|
|
|
|
console.log('WMS API Response:', data);
|
|
|
|
|
if (data.code === 200 && data.data && data.data.records) {
|
|
|
|
|
wmsData.value = data.data.records;
|
|
|
|
|
recordWmsOriginalData();
|
|
|
|
|
console.log('WMS Data:', wmsData.value);
|
|
|
|
|
} else {
|
|
|
|
|
wmsData.value = [];
|
|
|
|
|
@ -686,6 +718,83 @@ const fetchWmsData = (model, specification) => {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 记录WMS原始数据
|
|
|
|
|
const recordWmsOriginalData = () => {
|
|
|
|
|
wmsOriginalData.value = {};
|
|
|
|
|
wmsModifiedFlags.value = {};
|
|
|
|
|
wmsData.value.forEach((item, index) => {
|
|
|
|
|
const key = `${item.model}_${item.specification}_${item.wire_disc || 'null'}`;
|
|
|
|
|
wmsOriginalData.value[key] = {
|
|
|
|
|
warning_number_min: item.warning_number_min,
|
|
|
|
|
warning_number_max: item.warning_number_max
|
|
|
|
|
};
|
|
|
|
|
wmsModifiedFlags.value[index] = false;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// WMS值变化处理
|
|
|
|
|
const onWmsValueChange = (index) => {
|
|
|
|
|
const item = wmsData.value[index];
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
|
|
|
|
const key = `${item.model}_${item.specification}_${item.wire_disc || 'null'}`;
|
|
|
|
|
const original = wmsOriginalData.value[key];
|
|
|
|
|
|
|
|
|
|
if (original) {
|
|
|
|
|
const isModified = item.warning_number_min !== original.warning_number_min ||
|
|
|
|
|
item.warning_number_max !== original.warning_number_max;
|
|
|
|
|
wmsModifiedFlags.value[index] = isModified;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 提交WMS修改
|
|
|
|
|
const submitWmsModification = async (index) => {
|
|
|
|
|
const item = wmsData.value[index];
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
|
model: item.model,
|
|
|
|
|
specification: item.specification,
|
|
|
|
|
warning_number_min: item.warning_number_min || 0,
|
|
|
|
|
warning_number_max: item.warning_number_max || 300
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (item.wire_disc) {
|
|
|
|
|
params.append('wire_disc', item.wire_disc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const apiUrl = `${API_CONFIG.BASE_URL}/api/wms/warning/upsert?${params.toString()}`;
|
|
|
|
|
console.log('Upsert API URL:', apiUrl);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(apiUrl, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log('Upsert Response:', data);
|
|
|
|
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
const key = `${item.model}_${item.specification}_${item.wire_disc || 'null'}`;
|
|
|
|
|
wmsOriginalData.value[key] = {
|
|
|
|
|
warning_number_min: item.warning_number_min,
|
|
|
|
|
warning_number_max: item.warning_number_max
|
|
|
|
|
};
|
|
|
|
|
wmsModifiedFlags.value[index] = false;
|
|
|
|
|
console.log('WMS修改成功');
|
|
|
|
|
} else {
|
|
|
|
|
console.error('WMS修改失败:', data.message);
|
|
|
|
|
item.warning_number_min = wmsOriginalData.value[key]?.warning_number_min;
|
|
|
|
|
item.warning_number_max = wmsOriginalData.value[key]?.warning_number_max;
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('WMS修改API调用失败:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 初始化销售图表
|
|
|
|
|
const initSalesChart = (retryCount = 0) => {
|
|
|
|
|
if (!hasSalesData.value && !hasHistoryData.value) {
|
|
|
|
|
|