|
@@ -41,12 +41,21 @@
|
|
|
</template>
|
|
|
</t-select-input>
|
|
|
</div>
|
|
|
+ <div v-if="isHvacValvePen" class="form-item px-12" style="margin-top: -12px">
|
|
|
+ <label style="width: 50px">{{$t('阀门')}}</label>
|
|
|
+ <t-select
|
|
|
+ v-model="data.pen.hvacValveType"
|
|
|
+ :options="valveTypeList"
|
|
|
+ :placeholder="$t('请选择阀门类型')"
|
|
|
+ @change="handleValveChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
<div v-if="data.pen.hvacDeviceInfo" class="form-item px-12" style="margin-top: -12px">
|
|
|
<label style="width: 50px">{{$t('设备')}}</label>
|
|
|
<t-cascader
|
|
|
v-model="data.pen.hvacDeviceInfo.id"
|
|
|
:keys="{ value: 'id' }"
|
|
|
- :options="deviceList"
|
|
|
+ :options="currentDeviceList"
|
|
|
:placeholder="$t('请选择设备')"
|
|
|
filterable
|
|
|
clearable
|
|
@@ -1319,10 +1328,11 @@ import { s8 } from '@/services/random';
|
|
|
import { EllipsisIcon, LinkIcon, LinkUnlinkIcon, ChevronDownIcon, FormatVerticalAlignLeftIcon, FormatHorizontalAlignCenterIcon, FormatVerticalAlignCenterIcon, FormatVerticalAlignRightIcon, FormatHorizontalAlignTopIcon, FormatHorizontalAlignBottomIcon } from 'tdesign-icons-vue-next';
|
|
|
import { getToken } from '@le5le/auth-token';
|
|
|
import { getImgUrl } from '@/services/utils';
|
|
|
-import { DeviceItem } from '@/types';
|
|
|
+import { DeviceItem, DeviceGroupTree } from '@/types';
|
|
|
+import { DeviceType, ValveType, valveTypeList } from '..';
|
|
|
|
|
|
interface Props {
|
|
|
- deviceList: DeviceItem[];
|
|
|
+ deviceList: DeviceGroupTree[];
|
|
|
}
|
|
|
|
|
|
const props = defineProps<Props>();
|
|
@@ -1576,10 +1586,86 @@ const changeValue = (prop: string) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const isHvacValvePen = computed(() => {
|
|
|
+ return data.pen.hvacValveType !== undefined;
|
|
|
+})
|
|
|
+
|
|
|
+const currentDeviceList = computed(() => {
|
|
|
+ if (!isHvacValvePen.value) {
|
|
|
+ return props.deviceList;
|
|
|
+ }
|
|
|
+
|
|
|
+ const valveType = data.pen.hvacValveType as number | string;
|
|
|
+
|
|
|
+ // 根据阀门类型确定目标设备类型
|
|
|
+ let deviceTypes: DeviceType[] = [];
|
|
|
+
|
|
|
+ switch (valveType) {
|
|
|
+ case ValveType.冷冻侧阀:
|
|
|
+ case ValveType.冷却侧阀:
|
|
|
+ deviceTypes = [DeviceType.冷水主机];
|
|
|
+ break;
|
|
|
+ case ValveType.进口阀:
|
|
|
+ case ValveType.出口阀:
|
|
|
+ deviceTypes = [DeviceType.冷却塔];
|
|
|
+ break;
|
|
|
+ case ValveType.旁通阀:
|
|
|
+ deviceTypes = [DeviceType.控制柜];
|
|
|
+ break;
|
|
|
+ case '': // 空字符串返回三种类型
|
|
|
+ deviceTypes = [DeviceType.冷水主机, DeviceType.冷却塔, DeviceType.控制柜];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return []; // 未知类型返回空列表
|
|
|
+ }
|
|
|
+
|
|
|
+ return filterDeviceGroups(props.deviceList, deviceTypes);
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 过滤设备组树,移除不包含指定类型设备的分组
|
|
|
+ * @param deviceGroups 原始设备组树
|
|
|
+ * @param deviceTypes 需要保留的设备类型列表
|
|
|
+ * @returns 过滤后的设备组树
|
|
|
+ */
|
|
|
+const filterDeviceGroups = (deviceGroups: DeviceGroupTree[], deviceTypes: DeviceType[]) => {
|
|
|
+ return deviceGroups
|
|
|
+ .map(group => ({
|
|
|
+ ...group,
|
|
|
+ children: group.children
|
|
|
+ .map(child => ({
|
|
|
+ ...child,
|
|
|
+ children: child.children.filter(device =>
|
|
|
+ deviceTypes.includes(device.deviceType)
|
|
|
+ )
|
|
|
+ }))
|
|
|
+ .filter(child => child.children.length > 0) // 过滤空的二级分组
|
|
|
+ }))
|
|
|
+ .filter(group => group.children.length > 0); // 过滤空的一级分组
|
|
|
+}
|
|
|
+
|
|
|
+const handleValveChange = () => {
|
|
|
+ data.pen.hvacDeviceInfo = {};
|
|
|
+}
|
|
|
+
|
|
|
const handleDeviceChange = (value: CascaderValue<DeviceItem>, context: CascaderChangeContext<DeviceItem>) => {
|
|
|
if (context.node) {
|
|
|
data.pen.description = context.node.label
|
|
|
Object.assign(data.pen.hvacDeviceInfo, context.node.data)
|
|
|
+
|
|
|
+ if (isHvacValvePen.value) {
|
|
|
+ switch (context.node.data.deviceType) {
|
|
|
+ case DeviceType.冷水主机:
|
|
|
+ data.pen.hvacValveType = ValveType.冷冻侧阀;
|
|
|
+ break;
|
|
|
+ case DeviceType.冷却塔:
|
|
|
+ data.pen.hvacValveType = ValveType.进口阀;
|
|
|
+ break;
|
|
|
+ case DeviceType.控制柜:
|
|
|
+ data.pen.hvacValveType = ValveType.旁通阀;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
data.pen.hvacDeviceInfo = {}
|
|
|
}
|