diff --git a/src/views/model/heatapiconf/heatSendContent.vue b/src/views/model/heatapiconf/heatSendContent.vue
index 13ab3db..3812b49 100644
--- a/src/views/model/heatapiconf/heatSendContent.vue
+++ b/src/views/model/heatapiconf/heatSendContent.vue
@@ -38,10 +38,10 @@
重置
-
+
-
+
@@ -85,6 +85,7 @@ const loading = ref(false);
const showSearch = ref(true);
const currentPage = ref(1);
const pageSize = ref(10);
+const expandRowKeys = ref([]);
const queryParams = reactive({
deviceUuid: null,
deviceName: null,
@@ -93,29 +94,70 @@ const queryParams = reactive({
});
const router = useRouter()
-
-function solveData(){
- const heatapiContentListData = (router.currentRoute._value.query.heatapiContentListData !== undefined && router.currentRoute._value.query.heatapiContentListData !== null)?router.currentRoute._value.query.heatapiContentListData : null;
- oldData.value = heatapiContentListData;
- if(heatapiContentListData != null){
- heatapiContentList.value = JSON.parse(heatapiContentListData);
- console.log(heatapiContentList.value);
+function solveData() {
+ const heatapiContentListData =
+ router.currentRoute._value.query.heatapiContentListData !== undefined &&
+ router.currentRoute._value.query.heatapiContentListData !== null
+ ? router.currentRoute._value.query.heatapiContentListData
+ : null;
+ if (heatapiContentListData != null) {
+ oldData.value = heatapiContentListData;
+ heatapiContentList.value = JSON.parse(heatapiContentListData);
+ console.log(heatapiContentList.value);
}
}
+onMounted(() => {
+ solveData();
+});
+
function handleQuery() {
// 根据查询参数对 heatapiContentList 进行过滤
- heatapiContentList.value = JSON.parse(oldData.value).filter(item => {
+ const filteredHeatapiContentList = JSON.parse(oldData.value).filter((item) => {
// 根据查询参数进行条件匹配,可以使用正则表达式或其他匹配方式
+
+ // 判断是否匹配到了外层表格的数据
+ let flag = (!queryParams.deviceUuid || item.deviceId?.includes(queryParams.deviceUuid)) &&
+ (!queryParams.deviceName || item.name?.toLowerCase().includes(queryParams.deviceName.toLowerCase()));
+
+ if(!flag){
+ return false;
+ }
+
// 这里以设备编号、设备名称、参数编号和参数名称为例进行示范
- return (
- (!queryParams.deviceUuid || (item.deviceId && item.deviceId.indexOf(queryParams.deviceUuid) !== -1)) &&
- (!queryParams.deviceName || (item.name && item.name.indexOf(queryParams.deviceName) !== -1)) &&
- (!queryParams.paramCode || item.params.some(param => param.paramCode && param.paramCode.indexOf(queryParams.paramCode) !== -1)) &&
- (!queryParams.paramName || item.params.some(param => param.paramName && param.paramName.indexOf(queryParams.paramName) !== -1))
- );
+ const matchedParams = item.params.filter((param) => {
+ return (
+ (!queryParams.paramCode || param.paramCode?.includes(queryParams.paramCode)) &&
+ (!queryParams.paramName || param.paramName?.includes(queryParams.paramName))
+ );
+ });
+
+ // 更新内层表格的数据
+ item.params = matchedParams;
+
+ // 判断是否匹配到了内层表格的数据
+ const hasMatchedParams = matchedParams.length > 0;
+
+ // 根据是否有内层表格的匹配结果进行判断
+ flag = flag && (queryParams.paramCode || queryParams.paramName) ? hasMatchedParams : flag;
+
+ return flag;
});
+
+ // 更新过滤后的数据列表
+ heatapiContentList.value = filteredHeatapiContentList;
+
+ // 展开匹配到的内部表格
+ // 判断是否展开外层表格
+ if (queryParams.paramCode || queryParams.paramName) {
+ expandAllRows();
+ } else {
+ collapseAllRows();
+ }
+
+ // 重置当前页码为第一页
+ currentPage.value = 1;
}
@@ -127,6 +169,7 @@ function resetQuery() {
queryParams.paramName = null,
// 执行查询操作,显示所有数据
heatapiContentList.value = JSON.parse(oldData.value);
+ expandRowKeys.value = [];
}
@@ -145,5 +188,18 @@ const currentPageData = computed(() => {
return heatapiContentList.value.slice(startIndex, endIndex);
});
-solveData();
+// 监听展开行事件,更新展开的行的 key 值
+function handleExpandChange(row, expandedRows) {
+ expandRowKeys.value = expandedRows.map((row) => row.deviceId);
+}
+// 展开所有外层表格行
+function expandAllRows() {
+ expandRowKeys.value = heatapiContentList.value.map((item) => item.deviceId);
+}
+
+// 折叠所有外层表格行
+function collapseAllRows() {
+ expandRowKeys.value = [];
+}
+
diff --git a/src/views/model/heatapiconf/index.vue b/src/views/model/heatapiconf/index.vue
index 197f250..46769d9 100644
--- a/src/views/model/heatapiconf/index.vue
+++ b/src/views/model/heatapiconf/index.vue
@@ -15,13 +15,6 @@
-
@@ -54,7 +47,7 @@
- 新增
+ 新增