Commit 8823c0f278c0f8ca35469df53a3527d482ae630b
Merge branch 'ft' into 'main_dev'
fix(src/api): 修改url传组织id,过滤其他组织 See merge request yunteng/thingskit-view!125
Showing
5 changed files
with
88 additions
and
27 deletions
@@ -16,7 +16,7 @@ import { PaginationResult } from '/#/external/axios'; | @@ -16,7 +16,7 @@ import { PaginationResult } from '/#/external/axios'; | ||
16 | DEVICE_ATTR_LIST = '/device/attributes', | 16 | DEVICE_ATTR_LIST = '/device/attributes', |
17 | GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find/can_use_interfaces', | 17 | GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find/can_use_interfaces', |
18 | //ft | 18 | //ft |
19 | - GET_PUBLIC_INTERFACE_DETAIL = '/data_view_interface/get_interface_details' | 19 | + GET_PUBLIC_INTERFACE_DETAIL = '/data_view_interface/get_interface_details' |
20 | } | 20 | } |
21 | 21 | ||
22 | export const getPublicInterface = async (params: Record<'page' | 'pageSize', number>) => { | 22 | export const getPublicInterface = async (params: Record<'page' | 'pageSize', number>) => { |
@@ -26,9 +26,10 @@ export const getPublicInterface = async (params: Record<'page' | 'pageSize', num | @@ -26,9 +26,10 @@ export const getPublicInterface = async (params: Record<'page' | 'pageSize', num | ||
26 | }) | 26 | }) |
27 | } | 27 | } |
28 | 28 | ||
29 | -export const getOrgList = async () => { | 29 | +export const getOrgList = async (params:object) => { |
30 | return defHttp.get({ | 30 | return defHttp.get({ |
31 | - url: Api.ORG_LISt | 31 | + url: Api.ORG_LISt, |
32 | + params | ||
32 | }) | 33 | }) |
33 | } | 34 | } |
34 | 35 |
@@ -74,10 +74,15 @@ props.chartConfig.option = { | @@ -74,10 +74,15 @@ props.chartConfig.option = { | ||
74 | //地图点击返回 | 74 | //地图点击返回 |
75 | const watchAdcode = async () => { | 75 | const watchAdcode = async () => { |
76 | if (props.chartConfig.option.drillingIn) { | 76 | if (props.chartConfig.option.drillingIn) { |
77 | - let saveAdcode: any = saveLevelStr.parentInfo.adcode | ||
78 | - saveLevelStr.level = saveLevelStr.parentInfo.level | 77 | + //如果是从右边配置里设置的,比如点击四川省,然后点击返回 |
78 | + const savePopParent = saveHistoryParent.value.pop() | ||
79 | + let saveAdcode: any = savePopParent?.adcode | ||
80 | + saveLevelStr.level = savePopParent?.level as string | ||
81 | + if (!savePopParent) { | ||
82 | + saveAdcode = getParentAdcode(props.chartConfig.option.mapRegion.adcode) | ||
83 | + saveLevelStr.level = (regionMapParentArea as any)[props.chartConfig.option.mapRegion.saveSelect.levelStr] | ||
84 | + } | ||
79 | if (saveAdcode === 0) { | 85 | if (saveAdcode === 0) { |
80 | - // | ||
81 | saveAdcode = 'china' | 86 | saveAdcode = 'china' |
82 | saveLevelStr.level = 'COUNTRY' | 87 | saveLevelStr.level = 'COUNTRY' |
83 | } | 88 | } |
@@ -110,9 +115,11 @@ const handleMap3DClick = async (params: any) => { | @@ -110,9 +115,11 @@ const handleMap3DClick = async (params: any) => { | ||
110 | const adcode = item.properties.adcode | 115 | const adcode = item.properties.adcode |
111 | props.chartConfig.option.mapRegion.adcode = adcode | 116 | props.chartConfig.option.mapRegion.adcode = adcode |
112 | saveLevelStr.level = level | 117 | saveLevelStr.level = level |
113 | - saveLevelStr.parentInfo.adcode = item.properties.parent.adcode //保存上一级的地区编码 | ||
114 | - saveLevelStr.parentInfo.level = (regionMapParentArea as any)[level] //保存上一级的行政级别 | ||
115 | handleDataPoint(adcode) | 118 | handleDataPoint(adcode) |
119 | + saveHistoryParent.value.push({ | ||
120 | + adcode: item.properties.parent.adcode, | ||
121 | + level: (regionMapParentArea as any)[level] | ||
122 | + }) | ||
116 | } | 123 | } |
117 | }) | 124 | }) |
118 | } | 125 | } |
@@ -123,14 +130,18 @@ const saveGeojson: any = ref({}) // 保存geojson | @@ -123,14 +130,18 @@ const saveGeojson: any = ref({}) // 保存geojson | ||
123 | const chinaDefaultRegionId = ref(100000) //如果是china则adcode为100000 | 130 | const chinaDefaultRegionId = ref(100000) //如果是china则adcode为100000 |
124 | 131 | ||
125 | const saveLevelStr = reactive({ | 132 | const saveLevelStr = reactive({ |
126 | - // 保存行政级别和上一级的adcode和level | ||
127 | - level: '', | ||
128 | - parentInfo: { | ||
129 | - adcode: 0, | ||
130 | - level: '' | ||
131 | - } | 133 | + // 地区级别 |
134 | + level: '' | ||
132 | }) | 135 | }) |
133 | 136 | ||
137 | +//父级地区编码和级别接口 | ||
138 | +interface HistoryParentType { | ||
139 | + adcode: number | ||
140 | + level: string | ||
141 | +} | ||
142 | + | ||
143 | +const saveHistoryParent = ref<HistoryParentType[]>([]) | ||
144 | + | ||
134 | //动态注册地图 | 145 | //动态注册地图 |
135 | const getGeojson = (regionId: any) => { | 146 | const getGeojson = (regionId: any) => { |
136 | try { | 147 | try { |
@@ -158,6 +169,18 @@ const getGeojson = (regionId: any) => { | @@ -158,6 +169,18 @@ const getGeojson = (regionId: any) => { | ||
158 | } | 169 | } |
159 | } | 170 | } |
160 | 171 | ||
172 | + | ||
173 | +//传adcode 获取上级 | ||
174 | +const getParentAdcode = (adcode: number) => { | ||
175 | + let adcodeNum = 100000 | ||
176 | + saveGeojson.value?.features.forEach((item: any) => { | ||
177 | + if (item.properties.adcode === adcode) { | ||
178 | + adcodeNum = item.properties.parent.adcode | ||
179 | + } | ||
180 | + }) | ||
181 | + return adcodeNum | ||
182 | +} | ||
183 | + | ||
161 | watch( | 184 | watch( |
162 | () => w.value, | 185 | () => w.value, |
163 | (value: number) => { | 186 | (value: number) => { |
@@ -107,10 +107,15 @@ props.chartConfig.option = { | @@ -107,10 +107,15 @@ props.chartConfig.option = { | ||
107 | //地图点击返回 adcode=100000,名字必须是china | 107 | //地图点击返回 adcode=100000,名字必须是china |
108 | const watchAdcode = async () => { | 108 | const watchAdcode = async () => { |
109 | if (props.chartConfig.option.drillingIn) { | 109 | if (props.chartConfig.option.drillingIn) { |
110 | - let saveAdcode: any = saveLevelStr.parentInfo.adcode | ||
111 | - saveLevelStr.level = saveLevelStr.parentInfo.level | 110 | + //如果是从右边配置里设置的,比如点击四川省,然后点击返回 |
111 | + const savePopParent = saveHistoryParent.value.pop() | ||
112 | + let saveAdcode: any = savePopParent?.adcode | ||
113 | + saveLevelStr.level = savePopParent?.level as string | ||
114 | + if (!savePopParent) { | ||
115 | + saveAdcode = getParentAdcode(props.chartConfig.option.mapRegion.adcode) | ||
116 | + saveLevelStr.level = (regionMapParentArea as any)[props.chartConfig.option.mapRegion.saveSelect.levelStr] | ||
117 | + } | ||
112 | if (saveAdcode === 0) { | 118 | if (saveAdcode === 0) { |
113 | - // | ||
114 | saveAdcode = 'china' | 119 | saveAdcode = 'china' |
115 | saveLevelStr.level = 'COUNTRY' | 120 | saveLevelStr.level = 'COUNTRY' |
116 | } | 121 | } |
@@ -132,14 +137,18 @@ const saveGeojson: any = ref({}) // 保存geojson | @@ -132,14 +137,18 @@ const saveGeojson: any = ref({}) // 保存geojson | ||
132 | const chinaDefaultRegionId = ref(100000) //如果是china则adcode为100000 | 137 | const chinaDefaultRegionId = ref(100000) //如果是china则adcode为100000 |
133 | 138 | ||
134 | const saveLevelStr = reactive({ | 139 | const saveLevelStr = reactive({ |
135 | - // 保存行政级别和上一级的adcode和level | ||
136 | - level: '', | ||
137 | - parentInfo: { | ||
138 | - adcode: 0, | ||
139 | - level: '' | ||
140 | - } | 140 | + // 地区级别 |
141 | + level: '' | ||
141 | }) | 142 | }) |
142 | 143 | ||
144 | +//父级地区编码和级别接口 | ||
145 | +interface HistoryParentType { | ||
146 | + adcode: number | ||
147 | + level: string | ||
148 | +} | ||
149 | + | ||
150 | +const saveHistoryParent = ref<HistoryParentType[]>([]) | ||
151 | + | ||
143 | //动态注册地图 | 152 | //动态注册地图 |
144 | const getGeojson = async (regionId: any) => { | 153 | const getGeojson = async (regionId: any) => { |
145 | try { | 154 | try { |
@@ -281,6 +290,17 @@ const regionMapParentArea = { | @@ -281,6 +290,17 @@ const regionMapParentArea = { | ||
281 | [areaEnum.TOWN]: areaEnum.COUNTY //镇的上一级 县或者区 | 290 | [areaEnum.TOWN]: areaEnum.COUNTY //镇的上一级 县或者区 |
282 | } | 291 | } |
283 | 292 | ||
293 | +//传adcode 获取上级 | ||
294 | +const getParentAdcode = (adcode: number) => { | ||
295 | + let adcodeNum = 100000 | ||
296 | + saveGeojson.value?.features.forEach((item: any) => { | ||
297 | + if (item.properties.adcode === adcode) { | ||
298 | + adcodeNum = item.properties.parent.adcode | ||
299 | + } | ||
300 | + }) | ||
301 | + return adcodeNum | ||
302 | +} | ||
303 | + | ||
284 | //地图点击下钻 | 304 | //地图点击下钻 |
285 | const handleVChartClick = async (params: any) => { | 305 | const handleVChartClick = async (params: any) => { |
286 | if (props.chartConfig.option.drillingIn) { | 306 | if (props.chartConfig.option.drillingIn) { |
@@ -291,9 +311,11 @@ const handleVChartClick = async (params: any) => { | @@ -291,9 +311,11 @@ const handleVChartClick = async (params: any) => { | ||
291 | const adcode = item.properties.adcode | 311 | const adcode = item.properties.adcode |
292 | props.chartConfig.option.mapRegion.adcode = adcode | 312 | props.chartConfig.option.mapRegion.adcode = adcode |
293 | saveLevelStr.level = level | 313 | saveLevelStr.level = level |
294 | - saveLevelStr.parentInfo.adcode = item.properties.parent.adcode //保存上一级的地区编码 | ||
295 | - saveLevelStr.parentInfo.level = (regionMapParentArea as any)[level] //保存上一级的行政级别 | ||
296 | handleDataPoint(adcode) | 314 | handleDataPoint(adcode) |
315 | + saveHistoryParent.value.push({ | ||
316 | + adcode: item.properties.parent.adcode, | ||
317 | + level: (regionMapParentArea as any)[level] | ||
318 | + }) | ||
297 | } | 319 | } |
298 | }) | 320 | }) |
299 | } | 321 | } |
1 | -import { excludeParseEventKeyList, excludeParseEventValueList } from "@/enums/eventEnum" | 1 | +import { excludeParseEventKeyList, excludeParseEventValueList } from '@/enums/eventEnum' |
2 | 2 | ||
3 | const tryRunFunction = (v: string) => { | 3 | const tryRunFunction = (v: string) => { |
4 | try { | 4 | try { |
@@ -30,3 +30,11 @@ export const JSONParse = (data: string) => { | @@ -30,3 +30,11 @@ export const JSONParse = (data: string) => { | ||
30 | return v | 30 | return v |
31 | }) | 31 | }) |
32 | } | 32 | } |
33 | + | ||
34 | +//解析web url 参数 | ||
35 | +export const parseWebUrl = (str = window.location.search) => { | ||
36 | + const reg = /([^?&=]+)=([^&]+)/g | ||
37 | + const params = {} as any | ||
38 | + str.replace(reg, (_, k, v) => (params[k] = v)) | ||
39 | + return params | ||
40 | +} |
@@ -8,6 +8,7 @@ import { computed, onMounted, reactive, Ref, ref, unref } from "vue" | @@ -8,6 +8,7 @@ import { computed, onMounted, reactive, Ref, ref, unref } from "vue" | ||
8 | import { DictEnum } from '@/enums/external/dictEnum' | 8 | import { DictEnum } from '@/enums/external/dictEnum' |
9 | import { SelectTimeAggregationFieldEnum, SelectTimeAggregationValueTypw } from "../SelectTImeAggregation" | 9 | import { SelectTimeAggregationFieldEnum, SelectTimeAggregationValueTypw } from "../SelectTImeAggregation" |
10 | import { isArray } from "@/utils" | 10 | import { isArray } from "@/utils" |
11 | +import { parseWebUrl } from "@/utils/external/utils" | ||
11 | 12 | ||
12 | const GROUP_SEPARATOR = ',' | 13 | const GROUP_SEPARATOR = ',' |
13 | 14 | ||
@@ -102,9 +103,15 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | @@ -102,9 +103,15 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | ||
102 | }, {} as BuiltInVariableRecord) | 103 | }, {} as BuiltInVariableRecord) |
103 | } | 104 | } |
104 | 105 | ||
106 | + | ||
107 | + | ||
105 | const getOrgOption = async () => { | 108 | const getOrgOption = async () => { |
109 | + if( !window.location.href ) return | ||
110 | + const { organizationId } = parseWebUrl(window.location.href) | ||
111 | + if( !organizationId) return | ||
106 | if (!validIsExist(BuiltInVariable.ORGANIZATION_ID)) return | 112 | if (!validIsExist(BuiltInVariable.ORGANIZATION_ID)) return |
107 | - optionsSet[BuiltInVariable.ORGANIZATION_ID] = await getOrgList() | 113 | + optionsSet[BuiltInVariable.ORGANIZATION_ID] = await getOrgList({organizationId}) |
114 | + console.log(optionsSet[BuiltInVariable.ORGANIZATION_ID]) | ||
108 | } | 115 | } |
109 | 116 | ||
110 | const getDeviceProfileOption = async () => { | 117 | const getDeviceProfileOption = async () => { |