From d21d683289a91812fad7730961af7d8c0fe520d8 Mon Sep 17 00:00:00 2001 From: haha Date: Tue, 10 Jun 2025 16:17:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B2=99=E7=9B=98=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hasor/dataway/config/DatawayUtils.java | 344 ++++++++++ yanzhu-ui-vue3/package.json | 3 +- yanzhu-ui-vue3/src/api/bim/bim.js | 8 + .../src/assets/icons/svg/pitMonitor.svg | 1 + yanzhu-ui-vue3/src/assets/icons/svg/power.svg | 2 + .../src/assets/icons/svg/towerMonitor.svg | 3 + .../src/assets/icons/svg/videoMonitor.svg | 4 + yanzhu-ui-vue3/src/assets/styles/index.scss | 8 +- yanzhu-ui-vue3/src/router/index.js | 18 +- yanzhu-ui-vue3/src/utils/request.js | 246 ++++--- .../views/bim/bimSetting/ModelFloorTree.vue | 646 +++++++++--------- .../src/views/bim/bimSetting/index.vue | 544 ++++++++------- .../src/views/bim/sandTableSetting/index.vue | 326 +++++++++ 13 files changed, 1481 insertions(+), 672 deletions(-) create mode 100644 yanzhu-modules/yanzhu-manage/src/main/java/net/hasor/dataway/config/DatawayUtils.java create mode 100644 yanzhu-ui-vue3/src/assets/icons/svg/pitMonitor.svg create mode 100644 yanzhu-ui-vue3/src/assets/icons/svg/power.svg create mode 100644 yanzhu-ui-vue3/src/assets/icons/svg/towerMonitor.svg create mode 100644 yanzhu-ui-vue3/src/assets/icons/svg/videoMonitor.svg create mode 100644 yanzhu-ui-vue3/src/views/bim/sandTableSetting/index.vue diff --git a/yanzhu-modules/yanzhu-manage/src/main/java/net/hasor/dataway/config/DatawayUtils.java b/yanzhu-modules/yanzhu-manage/src/main/java/net/hasor/dataway/config/DatawayUtils.java new file mode 100644 index 00000000..1dd70ca0 --- /dev/null +++ b/yanzhu-modules/yanzhu-manage/src/main/java/net/hasor/dataway/config/DatawayUtils.java @@ -0,0 +1,344 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package net.hasor.dataway.config; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Random; +import java.util.function.Supplier; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import net.hasor.core.spi.SpiTrigger; +import net.hasor.dataql.DataQueryException; +import net.hasor.dataql.QueryResult; +import net.hasor.dataql.domain.DataModel; +import net.hasor.dataql.runtime.ThrowRuntimeException; +import net.hasor.dataway.dal.ApiStatusEnum; +import net.hasor.dataway.dal.FieldDef; +import net.hasor.dataway.dal.QueryCondition; +import net.hasor.dataway.spi.ApiInfo; +import net.hasor.dataway.spi.SerializationChainSpi; +import net.hasor.utils.StringUtils; +import net.hasor.utils.io.IOUtils; +import net.hasor.web.Invoker; + +public class DatawayUtils { + private static final ThreadLocal localRequestTime = ThreadLocal.withInitial(System::currentTimeMillis); + public static final Supplier> STATUS_UPDATE_TO_EDITOR = () -> new HashMap() { + { + this.put(FieldDef.STATUS, String.valueOf(ApiStatusEnum.Editor.typeNum())); + this.put(FieldDef.GMT_TIME, String.valueOf(System.currentTimeMillis())); + } + }; + public static final Supplier> STATUS_UPDATE_TO_PUBLISHED = () -> new HashMap() { + { + this.put(FieldDef.STATUS, String.valueOf(ApiStatusEnum.Published.typeNum())); + this.put(FieldDef.GMT_TIME, String.valueOf(System.currentTimeMillis())); + } + }; + public static final Supplier> STATUS_UPDATE_TO_CHANGES = () -> new HashMap() { + { + this.put(FieldDef.STATUS, String.valueOf(ApiStatusEnum.Changes.typeNum())); + this.put(FieldDef.GMT_TIME, String.valueOf(System.currentTimeMillis())); + } + }; + public static final Supplier> STATUS_UPDATE_TO_DISABLE = () -> new HashMap() { + { + this.put(FieldDef.STATUS, String.valueOf(ApiStatusEnum.Disable.typeNum())); + this.put(FieldDef.GMT_TIME, String.valueOf(System.currentTimeMillis())); + } + }; + public static final Supplier> STATUS_UPDATE_TO_DELETE = () -> new HashMap() { + { + this.put(FieldDef.STATUS, String.valueOf(ApiStatusEnum.Delete.typeNum())); + this.put(FieldDef.GMT_TIME, String.valueOf(System.currentTimeMillis())); + } + }; + + public DatawayUtils() { + } + + public static String getDwContextPath(Invoker invoker, String defaultPath) { + String contextPath = invoker.getHttpRequest().getContextPath(); + String contextPathProxy2 = invoker.getHttpRequest().getHeader("DW_CONTEXT_PATH_PROXY"); + String contextPathProxy = StringUtils.isNotBlank(defaultPath) ? defaultPath : contextPathProxy2; + if (StringUtils.isBlank(contextPathProxy)) { + if (StringUtils.isBlank(contextPath)) { + contextPath = "/"; + } + + if (contextPath.endsWith("/")) { + contextPath = contextPath.substring(0, contextPath.length() - 1); + } + } else { + contextPath = contextPathProxy; + } + + return contextPath; + } + + public static String evalCodeValueForSQL(String strCodeValue, Map strRequestBody) { + StringBuilder paramKeyBuilder = new StringBuilder(""); + StringBuilder callKeyBuilder = new StringBuilder(""); + + for(String key : strRequestBody.keySet()) { + paramKeyBuilder.append("`" + key + "`,"); + callKeyBuilder.append("${" + key + "},"); + } + + if (paramKeyBuilder.length() > 0) { + paramKeyBuilder.deleteCharAt(paramKeyBuilder.length() - 1); + callKeyBuilder.deleteCharAt(callKeyBuilder.length() - 1); + } + + strCodeValue = "var tempCall = @@sql(" + paramKeyBuilder.toString() + ")<%" + strCodeValue + "%>;\n"; + strCodeValue = strCodeValue + "return tempCall(" + callKeyBuilder.toString() + ");"; + return strCodeValue; + } + + public static long resetLocalTime() { + long currentTimeMillis = System.currentTimeMillis(); + localRequestTime.remove(); + localRequestTime.set(currentTimeMillis); + return currentTimeMillis; + } + + public static long currentLostTime() { + return System.currentTimeMillis() - (Long)localRequestTime.get(); + } + + public static boolean isResultStructure(Map optionMap) { + return optionMap == null ? true : (Boolean)optionMap.getOrDefault("resultStructure", true); + } + + public static String wrapParameterName(Map optionMap) { + if (optionMap == null) { + return null; + } else { + boolean wrapAllParameters = (Boolean)optionMap.getOrDefault("wrapAllParameters", false); + if (wrapAllParameters) { + String wrapParameterName = (String)optionMap.getOrDefault("wrapParameterName", "root"); + return StringUtils.isBlank(wrapParameterName) ? null : wrapParameterName.trim(); + } else { + return null; + } + } + } + + public static Result queryResultToResultWithSpecialValue(Map optionMap, final QueryResult queryResult, Object specialValue) { + final Object resultValue; + if (specialValue instanceof DataModel) { + resultValue = ((DataModel)specialValue).unwrap(); + } else { + resultValue = specialValue; + } + + if (!isResultStructure(optionMap)) { + return Result.of(resultValue); + } else { + Map resultData = new LinkedHashMap() { + { + this.put("success", true); + this.put("message", "OK"); + this.put("code", queryResult.getCode()); + this.put("location", (Object)null); + this.put("lifeCycleTime", DatawayUtils.currentLostTime()); + this.put("executionTime", queryResult.executionTime()); + this.put("value", resultValue); + } + }; + return Result.of(doResponseFormat(optionMap, resultData)); + } + } + + public static Result exceptionToResult(Throwable e) { + return e instanceof ThrowRuntimeException ? exceptionToResultWithSpecialValue((Map)null, e, ((ThrowRuntimeException)e).getResult().unwrap()) : exceptionToResultWithSpecialValue((Map)null, e, e.getMessage()); + } + + public static Result exceptionToResultWithSpecialValue(Map optionMap, Throwable e, Object specialValue) { + if (!isResultStructure(optionMap) && specialValue != null) { + return Result.of(specialValue); + } else { + Map resultData = new LinkedHashMap(); + resultData.put("success", false); + resultData.put("message", e.getLocalizedMessage()); + resultData.put("value", specialValue); + resultData.put("lifeCycleTime", currentLostTime()); + if (e instanceof ThrowRuntimeException) { + resultData.put("location", ((ThrowRuntimeException)e).getLocation().toString()); + resultData.put("code", ((ThrowRuntimeException)e).getThrowCode()); + resultData.put("executionTime", ((ThrowRuntimeException)e).getExecutionTime()); + } else if (e instanceof DataQueryException) { + resultData.put("location", ((DataQueryException)e).getLocation().toString()); + resultData.put("code", 500); + resultData.put("executionTime", -1); + } else { + resultData.put("location", "Unknown"); + resultData.put("code", 500); + resultData.put("executionTime", -1); + } + + return Result.of(doResponseFormat(optionMap, resultData)); + } + } + + private static Object doResponseFormat(Map optionMap, Map resultData) { + if (optionMap != null && optionMap.containsKey("responseFormat")) { + Object responseFormat = optionMap.get("responseFormat"); + Map finalResult = new LinkedHashMap(); + LinkedHashMap jsonObject = (LinkedHashMap)JSONObject.parseObject(responseFormat.toString(), LinkedHashMap.class); + + for(Object key : jsonObject.keySet()) { + Object value = jsonObject.get(key); + if (value == null) { + finalResult.put(key.toString(), (Object)null); + } else { + switch (value.toString()) { + case "@resultStatus": + finalResult.put(key.toString(), resultData.get("success")); + break; + case "@resultMessage": + finalResult.put(key.toString(), resultData.get("message")); + break; + case "@codeLocation": + finalResult.put(key.toString(), resultData.get("location")); + break; + case "@resultCode": + finalResult.put(key.toString(), resultData.get("code")); + break; + case "@timeLifeCycle": + finalResult.put(key.toString(), resultData.get("lifeCycleTime")); + break; + case "@timeExecution": + finalResult.put(key.toString(), resultData.get("executionTime")); + break; + case "@resultData": + finalResult.put(key.toString(), resultData.get("value")); + break; + default: + finalResult.put(key.toString(), value); + } + } + } + + return finalResult; + } else { + return resultData; + } + } + + public static Object responseData(SpiTrigger spiTrigger, ApiInfo apiInfo, String contentType, Invoker invoker, Object objectMap) throws IOException { + HttpServletRequest httpRequest = invoker.getHttpRequest(); + HttpServletResponse httpResponse = invoker.getHttpResponse(); + if (!httpResponse.isCommitted()) { + Object resultData = spiTrigger.chainSpi(SerializationChainSpi.class, (listener, lastResult) -> listener.doSerialization(apiInfo, invoker, lastResult), objectMap); + String contentDisposition = null; + long contentLength = -1L; + if (resultData instanceof SerializationChainSpi.SerializationInfo) { + contentType = ((SerializationChainSpi.SerializationInfo)resultData).getContentType(); + contentDisposition = ((SerializationChainSpi.SerializationInfo)resultData).getContentDisposition(); + contentLength = ((SerializationChainSpi.SerializationInfo)resultData).getContentLength(); + resultData = ((SerializationChainSpi.SerializationInfo)resultData).getData(); + } + + if (resultData instanceof String) { + setUIContextType(httpRequest, httpResponse, "text"); + String characterEncoding = httpResponse.getCharacterEncoding(); + characterEncoding="UTF-8"; + responseString(httpResponse, contentType, characterEncoding, (String)resultData); + } else if (resultData instanceof byte[]) { + setUIContextType(httpRequest, httpResponse, "bytes"); + byte[] bodyByte = (byte[])resultData; + responseBytes(httpResponse, contentType, contentDisposition, (long)bodyByte.length, new ByteArrayInputStream(bodyByte)); + } else if (resultData instanceof InputStream) { + setUIContextType(httpRequest, httpResponse, "bytes"); + responseBytes(httpResponse, contentType, contentDisposition, contentLength, (InputStream)resultData); + } else { + setUIContextType(httpRequest, httpResponse, "json"); + String characterEncoding = httpResponse.getCharacterEncoding(); + characterEncoding="UTF-8"; + String body = JSON.toJSONString(resultData, new SerializerFeature[]{SerializerFeature.WriteMapNullValue}); + responseString(httpResponse, contentType, characterEncoding, body); + } + } + + return objectMap; + } + + private static void setUIContextType(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String responseContextType) { + if ("true".equalsIgnoreCase(httpRequest.getHeader("X-InterfaceUI-Info"))) { + httpResponse.setHeader("X-InterfaceUI-ContextType", responseContextType); + } + + } + + private static void responseBytes(HttpServletResponse httpResponse, String contentType, String contentDisposition, long contentLength, InputStream bodyInputStream) throws IOException { + httpResponse.setContentType(contentType); + if (StringUtils.isNotBlank(contentDisposition)) { + httpResponse.setHeader("Content-Disposition", contentDisposition); + } + + if (contentLength > 0L) { + if (contentLength > 2147483647L) { + httpResponse.setContentLengthLong(contentLength); + } else { + httpResponse.setContentLength((int)contentLength); + } + } + + try (ServletOutputStream output = httpResponse.getOutputStream()) { + IOUtils.copy(bodyInputStream, output); + output.flush(); + } + + } + + private static void responseString(HttpServletResponse httpResponse, String contentType, String characterEncoding, String contentBody) throws IOException { + if (StringUtils.isNotBlank(characterEncoding)) { + contentType = contentType + ";charset=" + characterEncoding; + } + + if (StringUtils.isNotBlank(contentType)) { + httpResponse.setContentType(contentType); + } + + try (PrintWriter writer = httpResponse.getWriter()) { + writer.write(contentBody); + writer.flush(); + } + + } + + public static String generateID() { + long timeMillis = System.currentTimeMillis(); + int nextInt = (new Random(timeMillis)).nextInt(); + String s = Integer.toString(nextInt, 24); + if (s.length() > 4) { + s = s.substring(0, 4); + } else { + s = StringUtils.rightPad(s, 4, "0"); + } + + return Long.toString(timeMillis, 24) + s; + } + + public static Map conditionByApiId(final String apiId) { + return new HashMap() { + { + this.put(QueryCondition.ApiId, apiId); + } + }; + } +} diff --git a/yanzhu-ui-vue3/package.json b/yanzhu-ui-vue3/package.json index 4c7940a5..1f40d7f1 100644 --- a/yanzhu-ui-vue3/package.json +++ b/yanzhu-ui-vue3/package.json @@ -10,7 +10,7 @@ "dev:prod": "vite --mode production", "build:prod": "vite build && npm run pkg", "build:stage": "vite build --mode staging", - "pkg":"node make.cjs", + "pkg": "node make.cjs", "preview": "vite preview" }, "repository": { @@ -48,6 +48,7 @@ "@vitejs/plugin-vue": "5.0.5", "@vitejs/plugin-vue-jsx": "^4.1.2", "less": "^4.3.0", + "mitt": "^3.0.1", "sass": "1.77.5", "unplugin-auto-import": "0.17.6", "unplugin-vue-components": "^28.5.0", diff --git a/yanzhu-ui-vue3/src/api/bim/bim.js b/yanzhu-ui-vue3/src/api/bim/bim.js index 5e285f05..c31354f5 100644 --- a/yanzhu-ui-vue3/src/api/bim/bim.js +++ b/yanzhu-ui-vue3/src/api/bim/bim.js @@ -61,3 +61,11 @@ export function viewpointDeleteById(data) { params: data, }); } + +export function devicePositionGet(data) { + return request({ + url: "/manage/api/bim/devicePosition/get", + method: "get", + params: data, + }); +} diff --git a/yanzhu-ui-vue3/src/assets/icons/svg/pitMonitor.svg b/yanzhu-ui-vue3/src/assets/icons/svg/pitMonitor.svg new file mode 100644 index 00000000..e72ff1c2 --- /dev/null +++ b/yanzhu-ui-vue3/src/assets/icons/svg/pitMonitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/assets/icons/svg/power.svg b/yanzhu-ui-vue3/src/assets/icons/svg/power.svg new file mode 100644 index 00000000..fbf095fc --- /dev/null +++ b/yanzhu-ui-vue3/src/assets/icons/svg/power.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/assets/icons/svg/towerMonitor.svg b/yanzhu-ui-vue3/src/assets/icons/svg/towerMonitor.svg new file mode 100644 index 00000000..3c372688 --- /dev/null +++ b/yanzhu-ui-vue3/src/assets/icons/svg/towerMonitor.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/assets/icons/svg/videoMonitor.svg b/yanzhu-ui-vue3/src/assets/icons/svg/videoMonitor.svg new file mode 100644 index 00000000..ca11e6c7 --- /dev/null +++ b/yanzhu-ui-vue3/src/assets/icons/svg/videoMonitor.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/assets/styles/index.scss b/yanzhu-ui-vue3/src/assets/styles/index.scss index eefebeb0..524d0dee 100644 --- a/yanzhu-ui-vue3/src/assets/styles/index.scss +++ b/yanzhu-ui-vue3/src/assets/styles/index.scss @@ -195,4 +195,10 @@ aside { overflow: hidden !important; } } -} \ No newline at end of file +} + +body.is-sapi { + .app-main { + height: calc(100vh - 84px); + } +} \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/router/index.js b/yanzhu-ui-vue3/src/router/index.js index 2fc0f900..8a9e9c80 100644 --- a/yanzhu-ui-vue3/src/router/index.js +++ b/yanzhu-ui-vue3/src/router/index.js @@ -1,6 +1,8 @@ import { createWebHashHistory, createRouter } from 'vue-router' /* Layout */ import Layout from '@/layout' +import mitt from 'mitt'; +const emitter = mitt(); /** * Note: 路由配置项 @@ -238,16 +240,14 @@ export const dynamicRoutes = [ } ] -const router = createRouter({ +export const router = createRouter({ history: createWebHashHistory(), - routes: constantRoutes, - scrollBehavior(to, from, savedPosition) { - if (savedPosition) { - return savedPosition - } else { - return { top: 0 } - } - }, + routes: [...constantRoutes, ...dynamicRoutes] +}) + +router.afterEach((to, from) => { + emitter.emit('routeChanged', { to, from }); }); +export { emitter }; export default router; \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/utils/request.js b/yanzhu-ui-vue3/src/utils/request.js index 410ec95c..8b345737 100644 --- a/yanzhu-ui-vue3/src/utils/request.js +++ b/yanzhu-ui-vue3/src/utils/request.js @@ -1,108 +1,147 @@ -import axios from 'axios' -import { ElNotification , ElMessageBox, ElMessage, ElLoading } from 'element-plus' -import { getToken } from '@/utils/auth' -import errorCode from '@/utils/errorCode' -import { tansParams, blobValidate } from '@/utils/ruoyi' -import cache from '@/plugins/cache' -import { saveAs } from 'file-saver' -import useUserStore from '@/store/modules/user' +import axios from "axios"; +import { + ElNotification, + ElMessageBox, + ElMessage, + ElLoading, +} from "element-plus"; +import { getToken } from "@/utils/auth"; +import errorCode from "@/utils/errorCode"; +import { tansParams, blobValidate } from "@/utils/ruoyi"; +import cache from "@/plugins/cache"; +import { saveAs } from "file-saver"; +import useUserStore from "@/store/modules/user"; let downloadLoadingInstance; // 是否显示重新登录 export let isRelogin = { show: false }; -axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' +axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8"; // 创建axios实例 const service = axios.create({ // axios中请求配置有baseURL选项,表示请求URL公共部分 baseURL: import.meta.env.VITE_APP_BASE_API, // 超时 - timeout: 60000 -}) + timeout: 60000, +}); // request拦截器 -service.interceptors.request.use(config => { - // 是否需要设置 token - const isToken = (config.headers || {}).isToken === false - // 是否需要防止数据重复提交 - const isRepeatSubmit = (config.headers || {}).repeatSubmit === false - if (getToken() && !isToken) { - config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - } - // get请求映射params参数 - if (config.method === 'get' && config.params) { - let url = config.url + '?' + tansParams(config.params); - url = url.slice(0, -1); - config.params = {}; - config.url = url; - } - if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { - const requestObj = { - url: config.url, - data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, - time: new Date().getTime() +service.interceptors.request.use( + (config) => { + // 是否需要设置 token + const isToken = (config.headers || {}).isToken === false; + // 是否需要防止数据重复提交 + const isRepeatSubmit = (config.headers || {}).repeatSubmit === false; + if (getToken() && !isToken) { + config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 } - const sessionObj = cache.session.getJSON('sessionObj') - if (sessionObj === undefined || sessionObj === null || sessionObj === '') { - cache.session.setJSON('sessionObj', requestObj) - } else { - const s_url = sessionObj.url; // 请求地址 - const s_data = sessionObj.data; // 请求数据 - const s_time = sessionObj.time; // 请求时间 - const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 - if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { - const message = '数据正在处理,请勿重复提交'; - console.warn(`[${s_url}]: ` + message) - return Promise.reject(new Error(message)) + config.headers["Content-Type"] = "application/json;charset=UTF-8"; + // get请求映射params参数 + if (config.method === "get" && config.params) { + let url = config.url + "?" + tansParams(config.params); + url = url.slice(0, -1); + config.params = {}; + config.url = url; + } + if ( + !isRepeatSubmit && + (config.method === "post" || config.method === "put") + ) { + const requestObj = { + url: config.url, + data: + typeof config.data === "object" + ? JSON.stringify(config.data) + : config.data, + time: new Date().getTime(), + }; + const sessionObj = cache.session.getJSON("sessionObj"); + if ( + sessionObj === undefined || + sessionObj === null || + sessionObj === "" + ) { + cache.session.setJSON("sessionObj", requestObj); } else { - cache.session.setJSON('sessionObj', requestObj) + const s_url = sessionObj.url; // 请求地址 + const s_data = sessionObj.data; // 请求数据 + const s_time = sessionObj.time; // 请求时间 + const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 + if ( + s_data === requestObj.data && + requestObj.time - s_time < interval && + s_url === requestObj.url + ) { + const message = "数据正在处理,请勿重复提交"; + console.warn(`[${s_url}]: ` + message); + return Promise.reject(new Error(message)); + } else { + cache.session.setJSON("sessionObj", requestObj); + } } } + return config; + }, + (error) => { + console.log(error); + Promise.reject(error); } - return config -}, error => { - console.log(error) - Promise.reject(error) -}) +); // 响应拦截器 -service.interceptors.response.use(res => { +service.interceptors.response.use( + (res) => { // 未设置状态码则默认成功状态 const code = res.data.code || 200; // 获取错误信息 - const msg = errorCode[code] || res.data.msg || errorCode['default'] + const msg = errorCode[code] || res.data.msg || errorCode["default"]; // 二进制数据则直接返回 - if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { - return res.data + if ( + res.request.responseType === "blob" || + res.request.responseType === "arraybuffer" + ) { + return res.data; } if (code === 401) { if (!isRelogin.show) { isRelogin.show = true; - ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => { - isRelogin.show = false; - useUserStore().logOut().then(() => { - location.href = '#/index'; + ElMessageBox.confirm( + "登录状态已过期,您可以继续留在该页面,或者重新登录", + "系统提示", + { + confirmButtonText: "重新登录", + cancelButtonText: "取消", + type: "warning", + } + ) + .then(() => { + isRelogin.show = false; + useUserStore() + .logOut() + .then(() => { + location.href = "#/index"; + }); }) - }).catch(() => { - isRelogin.show = false; - }); - } - return Promise.reject('无效的会话,或者会话已过期,请重新登录。') + .catch(() => { + isRelogin.show = false; + }); + } + return Promise.reject("无效的会话,或者会话已过期,请重新登录。"); } else if (code === 500) { - ElMessage({ message: msg, type: 'error' }) - return Promise.reject(new Error(msg)) + ElMessage({ message: msg, type: "error" }); + return Promise.reject(new Error(msg)); } else if (code === 601) { - ElMessage({ message: msg, type: 'warning' }) - return Promise.reject(new Error(msg)) + ElMessage({ message: msg, type: "warning" }); + return Promise.reject(new Error(msg)); } else if (code !== 200) { - ElNotification.error({ title: msg }) - return Promise.reject('error') + ElNotification.error({ title: msg }); + return Promise.reject("error"); } else { - return Promise.resolve(res.data) + return Promise.resolve(res.data); } }, - error => { - console.log('err' + error) + (error) => { + console.log("err" + error); let { message } = error; if (message == "Network Error") { message = "后端接口连接异常"; @@ -111,36 +150,47 @@ service.interceptors.response.use(res => { } else if (message.includes("Request failed with status code")) { message = "系统接口" + message.substr(message.length - 3) + "异常"; } - ElMessage({ message: message, type: 'error', duration: 5 * 1000 }) - return Promise.reject(error) + ElMessage({ message: message, type: "error", duration: 5 * 1000 }); + return Promise.reject(error); } -) +); // 通用下载方法 export function download(url, params, filename, config) { - downloadLoadingInstance = ElLoading.service({ text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)", }) - return service.post(url, params, { - transformRequest: [(params) => { return tansParams(params) }], - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - responseType: 'blob', - ...config - }).then(async (data) => { - const isBlob = blobValidate(data); - if (isBlob) { - const blob = new Blob([data]) - saveAs(blob, filename) - } else { - const resText = await data.text(); - const rspObj = JSON.parse(resText); - const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] - ElMessage.error(errMsg); - } - downloadLoadingInstance.close(); - }).catch((r) => { - console.error(r) - ElMessage.error('下载文件出现错误,请联系管理员!') - downloadLoadingInstance.close(); - }) + downloadLoadingInstance = ElLoading.service({ + text: "正在下载数据,请稍候", + background: "rgba(0, 0, 0, 0.7)", + }); + return service + .post(url, params, { + transformRequest: [ + (params) => { + return tansParams(params); + }, + ], + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + responseType: "blob", + ...config, + }) + .then(async (data) => { + const isBlob = blobValidate(data); + if (isBlob) { + const blob = new Blob([data]); + saveAs(blob, filename); + } else { + const resText = await data.text(); + const rspObj = JSON.parse(resText); + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode["default"]; + ElMessage.error(errMsg); + } + downloadLoadingInstance.close(); + }) + .catch((r) => { + console.error(r); + ElMessage.error("下载文件出现错误,请联系管理员!"); + downloadLoadingInstance.close(); + }); } -export default service +export default service; diff --git a/yanzhu-ui-vue3/src/views/bim/bimSetting/ModelFloorTree.vue b/yanzhu-ui-vue3/src/views/bim/bimSetting/ModelFloorTree.vue index 80e1684b..f92d70b4 100644 --- a/yanzhu-ui-vue3/src/views/bim/bimSetting/ModelFloorTree.vue +++ b/yanzhu-ui-vue3/src/views/bim/bimSetting/ModelFloorTree.vue @@ -1,15 +1,15 @@ \ No newline at end of file + diff --git a/yanzhu-ui-vue3/src/views/bim/bimSetting/index.vue b/yanzhu-ui-vue3/src/views/bim/bimSetting/index.vue index 3bb59c35..e9c84683 100644 --- a/yanzhu-ui-vue3/src/views/bim/bimSetting/index.vue +++ b/yanzhu-ui-vue3/src/views/bim/bimSetting/index.vue @@ -1,275 +1,315 @@ \ No newline at end of file + diff --git a/yanzhu-ui-vue3/src/views/bim/sandTableSetting/index.vue b/yanzhu-ui-vue3/src/views/bim/sandTableSetting/index.vue new file mode 100644 index 00000000..92ced92e --- /dev/null +++ b/yanzhu-ui-vue3/src/views/bim/sandTableSetting/index.vue @@ -0,0 +1,326 @@ + + + + +