|
|
@@ -744,39 +744,70 @@ export default {
|
|
|
});
|
|
|
|
|
|
// 遍历过滤后的设备列表,根据val的顺序构建层级结构
|
|
|
- filteredEquipment.forEach(item => {
|
|
|
+ filteredEquipment.forEach((item, index) => {
|
|
|
// 根据val的顺序构建值数组
|
|
|
const values = [];
|
|
|
+ let path = []; // 用于构建唯一键的路径
|
|
|
|
|
|
val.forEach(level => {
|
|
|
switch (level) {
|
|
|
case 'center':
|
|
|
if (item.maintenanceCenter) {
|
|
|
- values.push({ value: item.maintenanceCenter, label: item.maintenanceCenter });
|
|
|
+ path.push(`center-${item.maintenanceCenter}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.maintenanceCenter,
|
|
|
+ originalValue: item.maintenanceCenter
|
|
|
+ });
|
|
|
}
|
|
|
break;
|
|
|
case 'station':
|
|
|
if (item.station) {
|
|
|
- values.push({ value: item.station, label: item.station });
|
|
|
+ path.push(`station-${item.station}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.station,
|
|
|
+ originalValue: item.station
|
|
|
+ });
|
|
|
}
|
|
|
break;
|
|
|
case 'brand':
|
|
|
if (item.brand) {
|
|
|
- values.push({ value: item.brand, label: item.brand });
|
|
|
+ path.push(`brand-${item.brand}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.brand,
|
|
|
+ originalValue: item.brand
|
|
|
+ });
|
|
|
}
|
|
|
break;
|
|
|
case 'model':
|
|
|
if (item.model) {
|
|
|
- values.push({ value: item.model, label: item.model });
|
|
|
+ path.push(`model-${item.model}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.model,
|
|
|
+ originalValue: item.model
|
|
|
+ });
|
|
|
}
|
|
|
break;
|
|
|
case 'area':
|
|
|
// area表示同时选择center和station两个层级
|
|
|
if (item.maintenanceCenter) {
|
|
|
- values.push({ value: item.maintenanceCenter, label: item.maintenanceCenter });
|
|
|
+ path.push(`center-${item.maintenanceCenter}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.maintenanceCenter,
|
|
|
+ originalValue: item.maintenanceCenter
|
|
|
+ });
|
|
|
}
|
|
|
if (item.station) {
|
|
|
- values.push({ value: item.station, label: item.station });
|
|
|
+ path.push(`station-${item.station}`);
|
|
|
+ values.push({
|
|
|
+ value: path.join('-'),
|
|
|
+ label: item.station,
|
|
|
+ originalValue: item.station
|
|
|
+ });
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -785,9 +816,12 @@ export default {
|
|
|
// 添加设备编号作为最终层级
|
|
|
// 显示为equipmentCode,但值为equipmentId
|
|
|
if (item.equipmentCode && item.equipmentId) {
|
|
|
+ path.push(`equipment-${item.equipmentId}-${index}`);
|
|
|
values.push({
|
|
|
- value: item.equipmentId, // 值为equipmentId
|
|
|
- label: item.equipmentCode // 显示为equipmentCode
|
|
|
+ value: path.join('-'), // 使用唯一键
|
|
|
+ label: item.equipmentCode, // 显示为equipmentCode
|
|
|
+ originalValue: item.equipmentId, // 保存原始设备ID
|
|
|
+ equipmentId: item.equipmentId // 保存设备ID
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -824,7 +858,9 @@ export default {
|
|
|
currentLevel[key] = {
|
|
|
value: value.value,
|
|
|
label: value.label,
|
|
|
- children: {}
|
|
|
+ children: {},
|
|
|
+ originalValue: value.originalValue, // 保存原始值
|
|
|
+ equipmentId: value.equipmentId // 保存设备ID(如果是设备节点)
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -838,11 +874,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // 生成唯一键值
|
|
|
- generateKey(values, index) {
|
|
|
- return values.slice(0, index + 1).map(v => v.value).join('-');
|
|
|
- },
|
|
|
-
|
|
|
// 将层级结构转换为级联选择器需要的格式
|
|
|
convertToCascaderOptions(optionsMap) {
|
|
|
const result = [];
|
|
|
@@ -850,7 +881,9 @@ export default {
|
|
|
Object.values(optionsMap).forEach((item, index) => {
|
|
|
const option = {
|
|
|
value: item.value,
|
|
|
- label: item.label
|
|
|
+ label: item.label,
|
|
|
+ originalValue: item.originalValue, // 保存原始值
|
|
|
+ equipmentId: item.equipmentId // 保存设备ID(如果是设备节点)
|
|
|
};
|
|
|
|
|
|
// 添加isFirst标记(仅第一个选项)
|
|
|
@@ -897,7 +930,7 @@ export default {
|
|
|
const models = {};
|
|
|
|
|
|
// 遍历设备列表,构建层级结构
|
|
|
- equipmentList.forEach(item => {
|
|
|
+ equipmentList.forEach((item, index) => {
|
|
|
const center = item.maintenanceCenter;
|
|
|
const station = item.station;
|
|
|
const brand = item.brand;
|
|
|
@@ -905,69 +938,83 @@ export default {
|
|
|
const equipmentCode = item.equipmentCode;
|
|
|
const equipmentId = item.equipmentId; // 获取设备ID
|
|
|
|
|
|
+ // 为每个层级生成唯一值,避免重复
|
|
|
+ const centerKey = center ? `center-${center}` : null;
|
|
|
+ const stationKey = center && station ? `station-${center}-${station}` : null;
|
|
|
+ const brandKey = center && station && brand ? `brand-${center}-${station}-${brand}` : null;
|
|
|
+ const modelKey = center && station && brand && model ? `model-${center}-${station}-${brand}-${model}` : null;
|
|
|
+
|
|
|
// 维保中心层级
|
|
|
- if (center && !centers[center]) {
|
|
|
- centers[center] = {
|
|
|
- value: center,
|
|
|
+ if (center && !centers[centerKey]) {
|
|
|
+ centers[centerKey] = {
|
|
|
+ value: centerKey,
|
|
|
label: center,
|
|
|
- children: []
|
|
|
+ children: [],
|
|
|
+ originalValue: center // 保存原始值
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 场站层级
|
|
|
- if (center && station && !stations[`${center}-${station}`]) {
|
|
|
- stations[`${center}-${station}`] = {
|
|
|
- value: station,
|
|
|
+ if (center && station && !stations[stationKey]) {
|
|
|
+ stations[stationKey] = {
|
|
|
+ value: stationKey,
|
|
|
label: station,
|
|
|
- children: []
|
|
|
+ children: [],
|
|
|
+ originalValue: station // 保存原始值
|
|
|
};
|
|
|
|
|
|
// 将场站添加到对应的维保中心下
|
|
|
- if (centers[center] && !centers[center].children.some(child => child.value === station)) {
|
|
|
- centers[center].children.push(stations[`${center}-${station}`]);
|
|
|
+ if (centers[centerKey] && !centers[centerKey].children.some(child => child.value === stationKey)) {
|
|
|
+ centers[centerKey].children.push(stations[stationKey]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 品牌层级
|
|
|
- if (center && station && brand && !brands[`${center}-${station}-${brand}`]) {
|
|
|
- brands[`${center}-${station}-${brand}`] = {
|
|
|
- value: brand,
|
|
|
+ if (center && station && brand && !brands[brandKey]) {
|
|
|
+ brands[brandKey] = {
|
|
|
+ value: brandKey,
|
|
|
label: brand,
|
|
|
- children: []
|
|
|
+ children: [],
|
|
|
+ originalValue: brand // 保存原始值
|
|
|
};
|
|
|
|
|
|
// 将品牌添加到对应的场站下
|
|
|
- if (stations[`${center}-${station}`] && !stations[`${center}-${station}`].children.some(child => child.value === brand)) {
|
|
|
- stations[`${center}-${station}`].children.push(brands[`${center}-${station}-${brand}`]);
|
|
|
+ if (stations[stationKey] && !stations[stationKey].children.some(child => child.value === brandKey)) {
|
|
|
+ stations[stationKey].children.push(brands[brandKey]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 机型层级
|
|
|
- if (center && station && brand && model && !models[`${center}-${station}-${brand}-${model}`]) {
|
|
|
- models[`${center}-${station}-${brand}-${model}`] = {
|
|
|
- value: model,
|
|
|
+ if (center && station && brand && model && !models[modelKey]) {
|
|
|
+ models[modelKey] = {
|
|
|
+ value: modelKey,
|
|
|
label: model,
|
|
|
- children: []
|
|
|
+ children: [],
|
|
|
+ originalValue: model // 保存原始值
|
|
|
};
|
|
|
|
|
|
// 将机型添加到对应的品牌下
|
|
|
- if (brands[`${center}-${station}-${brand}`] && !brands[`${center}-${station}-${brand}`].children.some(child => child.value === model)) {
|
|
|
- brands[`${center}-${station}-${brand}`].children.push(models[`${center}-${station}-${brand}-${model}`]);
|
|
|
+ if (brands[brandKey] && !brands[brandKey].children.some(child => child.value === modelKey)) {
|
|
|
+ brands[brandKey].children.push(models[modelKey]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 风机编号层级(最终层级)
|
|
|
// 显示为equipmentCode,但值为equipmentId
|
|
|
if (center && station && brand && model && equipmentCode && equipmentId) {
|
|
|
+ // 为设备节点生成唯一值,结合所有层级信息和索引确保唯一性
|
|
|
+ const equipmentKey = `equipment-${center}-${station}-${brand}-${model}-${equipmentId}-${index}`;
|
|
|
+
|
|
|
const equipmentOption = {
|
|
|
- value: equipmentId, // 值为equipmentId
|
|
|
+ value: equipmentKey, // 使用唯一键作为值
|
|
|
label: equipmentCode, // 显示为equipmentCode
|
|
|
- equipmentId: equipmentId // 保存设备ID
|
|
|
+ equipmentId: equipmentId, // 保存设备ID
|
|
|
+ originalValue: equipmentId // 保存原始设备ID
|
|
|
};
|
|
|
|
|
|
// 将风机编号添加到对应的机型下
|
|
|
- if (models[`${center}-${station}-${brand}-${model}`] && !models[`${center}-${station}-${brand}-${model}`].children.some(child => child.value === equipmentId)) {
|
|
|
- models[`${center}-${station}-${brand}-${model}`].children.push(equipmentOption);
|
|
|
+ if (models[modelKey] && !models[modelKey].children.some(child => child.value === equipmentKey)) {
|
|
|
+ models[modelKey].children.push(equipmentOption);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -1396,7 +1443,10 @@ export default {
|
|
|
const filteredChildren = this.filterOptionsByKeyword(option.children, keyword);
|
|
|
if (filteredChildren.length > 0) {
|
|
|
// 如果子项中有匹配的,添加当前选项并更新子项
|
|
|
- const newOption = { ...option, children: filteredChildren };
|
|
|
+ const newOption = {
|
|
|
+ ...option,
|
|
|
+ children: filteredChildren
|
|
|
+ };
|
|
|
filtered.push(newOption);
|
|
|
}
|
|
|
}
|
|
|
@@ -1409,8 +1459,14 @@ export default {
|
|
|
handleEquipmentTreeCheck(data, checkedInfo) {
|
|
|
// 保存选中的节点信息
|
|
|
this.selectedEquipmentNodes = checkedInfo.checkedNodes;
|
|
|
- // 同时更新selectedEquipment数组以保持与原逻辑兼容
|
|
|
- this.selectedEquipment = checkedInfo.checkedKeys;
|
|
|
+
|
|
|
+ // 提取实际的设备ID用于selectedEquipment数组
|
|
|
+ const actualEquipmentIds = checkedInfo.checkedNodes
|
|
|
+ .filter(node => node.originalValue && (!node.children || node.children.length === 0)) // 只选择叶子节点(设备节点)
|
|
|
+ .map(node => node.originalValue);
|
|
|
+
|
|
|
+ // 更新selectedEquipment数组以保持与原逻辑兼容
|
|
|
+ this.selectedEquipment = actualEquipmentIds;
|
|
|
|
|
|
// 自动更新查询参数中的设备ID
|
|
|
this.updateEquipmentQueryParams();
|
|
|
@@ -1418,8 +1474,10 @@ export default {
|
|
|
|
|
|
// 更新设备查询参数
|
|
|
updateEquipmentQueryParams() {
|
|
|
- // 提取选中节点的值(设备ID)
|
|
|
- const selectedIds = this.selectedEquipmentNodes.map(node => node.value);
|
|
|
+ // 提取选中节点的实际设备ID(叶子节点)
|
|
|
+ const selectedIds = this.selectedEquipmentNodes
|
|
|
+ .filter(node => node.originalValue && (!node.children || node.children.length === 0)) // 只选择叶子节点(设备节点)
|
|
|
+ .map(node => node.originalValue);
|
|
|
|
|
|
// 将设备ID用逗号拼接成字符串存储到this.queryParams.devices
|
|
|
this.queryParams.devices = selectedIds.length > 0 ? selectedIds.join(',') : null;
|