Commit 8c9cbdb6 authored by Cai Wei's avatar Cai Wei

feat(*): 除尘器总览连调

parent b631dafc
......@@ -273,9 +273,8 @@ const submitForm = () => {
// 发送数据到父组件处理保存逻辑
emit('save', submitData);
emit('update:modelValue', false);
// emit('update:modelValue', false);
} else {
console.error('Form validation failed');
return false;
}
});
......
......@@ -49,11 +49,11 @@
size="small"
border
>
<el-table-column prop="compartPositionRow" label="排" width="180">
<template #default="{ row }">
<span>{{row.compartPositionRow}}</span>
<el-table-column prop="compartPositionRow" label="排" width="180">
<template #default="{ row }">
<span>{{ row.compartPositionRow }}</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column prop="compartPositionColumnNum" label="仓数量">
<template #default="{ row }">
<el-input-number
......@@ -72,7 +72,11 @@
<template #footer>
<span class="dialog-footer">
<el-button @click="$emit('update:modelValue', false)">取消</el-button>
<el-button type="primary" @click="handleConfirm" :disabled="distributionDiff > 0">
<el-button
type="primary"
@click="handleConfirm"
:disabled="distributionDiff > 0"
>
确认
</el-button>
</span>
......@@ -87,15 +91,15 @@ const props = defineProps({
modelValue: Boolean,
data: {
type: Object,
default: () => {}
}
default: () => {},
},
});
const emit = defineEmits(["update:modelValue", "confirm"]);
const roomForm = ref({
totalRooms: 0,
rows: 0
rows: 0,
});
const distributionData = ref([]);
......@@ -104,13 +108,13 @@ const initializeState = () => {
if (props.data.deviceNo) {
const { compartNum, compartRowNum, compartHealthList } = props.data;
roomForm.value.totalRooms = compartNum || 0;
roomForm.value.rows = compartRowNum || 0
roomForm.value.rows = compartRowNum || 0;
if (compartHealthList && compartHealthList.length > 0) {
roomForm.value.rows = compartHealthList.length;
distributionData.value = compartHealthList.map((row, index) => ({
compartPositionRow: index + 1,
compartPositionColumnNum: row.length
compartPositionColumnNum: row.length,
}));
} else {
roomForm.value.rows = 0;
......@@ -119,11 +123,15 @@ const initializeState = () => {
}
};
watch(() => props.data, (newVal) => {
if (newVal) {
initializeState();
}
}, { immediate: true });
watch(
() => props.data,
(newVal) => {
if (newVal) {
initializeState();
}
},
{ immediate: true }
);
const distributionDiff = computed(() => {
const total = distributionData.value.reduce(
......@@ -135,21 +143,18 @@ const distributionDiff = computed(() => {
const handleRowsChange = (value) => {
const total = roomForm.value.totalRooms;
console.log('total', total, value);
if (!total || !value) return;
// 计算每行的基础数量(向下取整)和余数
const baseValue = Math.floor(total / value);
const remainder = total % value;
console.log(baseValue, remainder)
// 生成分布数据
distributionData.value = Array.from({ length: value }, (_, index) => {
return {
compartPositionRow: index + 1,
compartPositionColumnNum: index < remainder ? baseValue + 1 : baseValue
compartPositionRow: index + 1,
compartPositionColumnNum: index < remainder ? baseValue + 1 : baseValue,
};
});
console.log
};
const handleDistributionChange = () => {
......@@ -160,10 +165,10 @@ const handleConfirm = () => {
if (distributionDiff.value <= 0) {
const { deviceNo, compartNum } = props.data;
emit("confirm", {
compartNum,
dusterNo: deviceNo,
compartRowNum: roomForm.value.rows,
detailList: distributionData.value
compartNum,
dusterNo: deviceNo,
compartRowNum: roomForm.value.rows,
detailList: distributionData.value,
});
// emit("update:modelValue", false);
}
......@@ -216,4 +221,4 @@ const handleConfirm = () => {
:deep(.distribution-table .el-table--border .el-table__cell) {
border-right: 1px solid #ebeef5 !important;
}
</style>
\ No newline at end of file
</style>
......@@ -156,7 +156,6 @@ const validateValveCount = computed(() => {
const initializeState = () => {
if (props.modelValue) {
console.log(props.data);
valveForm.value.total = props.data.valveNum;
getAllocation({
customerId: props.data.customerId,
......@@ -177,10 +176,8 @@ const initializeState = () => {
const getAllocation = (params) => {
getValveAllocation(params).then(res => {
console.log(res, res.data.valveList);
if (res.code === 1 && res.data.valveList.length > 0) {
statusData.value = res.data.valveList;
console.log(statusData.value);
valveForm.value.compartNo = statusData.value[0].compartNo;
valveForm.value.valveNum = statusData.value[0].valveNum;
valveForm.value.bagNum = statusData.value[0].bagNum;
......@@ -237,7 +234,6 @@ const handleAverageDistribute = () => {
const handleSave = () => {
// 验证是否超出限制
const validation = validateValveCount.value;
console.log(valveForm.value.valveNum);
if (!validation.valid) {
errorMessage.value = validation.message;
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment