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

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

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