Compare commits
5 Commits
main
...
feature/do
Author | SHA1 | Date | |
---|---|---|---|
2f1f5059d6 | |||
9e9d67dfcd | |||
b986d1b8dd | |||
13d14d0bb6 | |||
ffdf13d156 |
123
.dockerignore
Normal file
123
.dockerignore
Normal file
@ -0,0 +1,123 @@
|
||||
# Node.js
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
.npm
|
||||
.yarn
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Build outputs
|
||||
dist
|
||||
dist-ssr
|
||||
build
|
||||
*.local
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.development
|
||||
.env.test
|
||||
.env.production
|
||||
.env.*.local
|
||||
|
||||
# Editor and IDE
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
.gitattributes
|
||||
|
||||
# Documentation
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE
|
||||
*.md
|
||||
|
||||
# Testing
|
||||
coverage
|
||||
.nyc_output
|
||||
test-results
|
||||
junit.xml
|
||||
|
||||
# Docker related
|
||||
Dockerfile*
|
||||
.dockerignore
|
||||
docker-compose*.yml
|
||||
.docker
|
||||
|
||||
# Scripts (開發用腳本,但保留 docker- 開頭的文件)
|
||||
Scripts/*
|
||||
*.bat
|
||||
*.sh
|
||||
!Scripts/docker-*
|
||||
!Scripts/docker-*.sh
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Temporary files
|
||||
tmp
|
||||
temp
|
||||
.tmp
|
||||
|
||||
# Cache
|
||||
.cache
|
||||
.parcel-cache
|
||||
.vite
|
||||
|
||||
# OS generated files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# ESLint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
7
Docker/svc.front/.dockerignore
Normal file
7
Docker/svc.front/.dockerignore
Normal file
@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
.git
|
||||
.gitignore
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
README.md
|
||||
.vs
|
@ -1,13 +1,13 @@
|
||||
# Project
|
||||
PROJ_NAME=proj_bims_ils-svc
|
||||
PROJ_NAME=proj_bims_empower
|
||||
|
||||
# Network 網路環境
|
||||
NET_TRAEFIK=net-traefik_svc
|
||||
|
||||
# Image: org/name
|
||||
IMAGE_PROJ_NAME=proj_bims_ils
|
||||
IMAGE_PROJ_NAME=proj_bims_empower
|
||||
IMAGE_NAME=empower-front
|
||||
TAG_VERSION=0.1.0
|
||||
TAG_VERSION=0.1.11
|
||||
|
||||
# Remote
|
||||
REMOTE_URL=harbor.mjm-staging.developers-homelab.net
|
||||
|
24
Docker/svc.front/docker-entrypoint.sh
Normal file
24
Docker/svc.front/docker-entrypoint.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# 目標檔案
|
||||
ENV_FILE=/usr/share/nginx/html/env.js
|
||||
|
||||
# 確保目錄存在
|
||||
mkdir -p /usr/share/nginx/html
|
||||
|
||||
# 寫入環境變數
|
||||
cat <<EOF > "$ENV_FILE"
|
||||
window.env = {
|
||||
VITE_API_BASEURL: "${VITE_API_BASEURL:-http://localhost:8080}",
|
||||
VITE_FILE_API_BASEURL: "${VITE_FILE_API_BASEURL:-http://localhost:8081}",
|
||||
VITE_MQTT_BASEURL: "${VITE_MQTT_BASEURL:-ws://localhost:1883}",
|
||||
VITE_APP_TITLE: "${VITE_APP_TITLE:-MyApp}"
|
||||
};
|
||||
EOF
|
||||
|
||||
echo "[Entrypoint] Generated $ENV_FILE:"
|
||||
cat "$ENV_FILE"
|
||||
|
||||
# 執行傳入的 CMD,例如 "nginx -g 'daemon off;'"
|
||||
exec "$@"
|
44
Dockerfile
Normal file
44
Dockerfile
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
# 使用 Node.js 作為基礎映像
|
||||
FROM node:18-slim AS builder
|
||||
|
||||
# git
|
||||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 設定工作目錄
|
||||
WORKDIR /app
|
||||
|
||||
# 複製 package.json 和 package-lock.json (或 yarn.lock) 到工作目錄
|
||||
COPY package*.json ./
|
||||
|
||||
# 安裝依賴
|
||||
RUN npm install --legacy-peer-deps
|
||||
|
||||
# 額外補上 rollup binary (避免 npm optional bug)
|
||||
RUN npm install @rollup/rollup-linux-x64-gnu --force
|
||||
|
||||
# 複製專案原始碼
|
||||
COPY . .
|
||||
|
||||
# 構建前端應用
|
||||
RUN npm run build
|
||||
|
||||
# 使用一個更小的映像來提供靜態文件 (例如 Nginx)
|
||||
FROM nginx:alpine
|
||||
|
||||
# 將構建好的檔案複製到 Nginx 預設目錄
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# (可選) 複製自定義 Nginx 設定檔
|
||||
# COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 複製 entrypoint 腳本 并轉成 LF 及 賦予執行權限
|
||||
COPY Scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN sed -i 's/\r$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh
|
||||
|
||||
# 暴露 Nginx 預設的 80 端口
|
||||
EXPOSE 80
|
||||
|
||||
# 啟動 Nginx
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
20
Scripts/.env
Normal file
20
Scripts/.env
Normal file
@ -0,0 +1,20 @@
|
||||
# Project
|
||||
PROJ_NAME=proj_bims_empower
|
||||
|
||||
# Network 網路環境
|
||||
NET_TRAEFIK=net-traefik_svc
|
||||
|
||||
# Image: org/name
|
||||
IMAGE_PROJ_NAME=proj_bims_empower
|
||||
IMAGE_NAME=empower-front
|
||||
TAG_VERSION=0.1.11
|
||||
|
||||
# Remote
|
||||
REMOTE_URL=harbor.mjm-staging.developers-homelab.net
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Basic 基本配置
|
||||
|
||||
HOST_DOMAIN=ibms.mjmtech.com.tw
|
||||
CUSTOMER_ID=empower1
|
||||
WEB_TITLE=新創賦能
|
40
Scripts/11.build-image.bat
Normal file
40
Scripts/11.build-image.bat
Normal file
@ -0,0 +1,40 @@
|
||||
@echo off
|
||||
cd /d "%~dp0"
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM === 載入 .env 變數(忽略註解與空行) ===
|
||||
for /f "usebackq tokens=1,* delims==" %%a in (".env") do (
|
||||
if "%%a" neq "" (
|
||||
if not "%%a"=="REM" (
|
||||
set "%%a=%%b"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM === 讀取版本 ========================
|
||||
:: 呼叫 version-inc.bat 來更新版本(參數傳遞 inc 或 time)
|
||||
call version-inc.bat time
|
||||
:: 再次讀取 version.txt
|
||||
set /p VERSION=<version.txt
|
||||
REM ====================================
|
||||
|
||||
REM === 檢查變數 ========================
|
||||
echo -----------------------------------
|
||||
echo VERSION=!VERSION!
|
||||
echo IMAGE_PROJ_NAME=!IMAGE_PROJ_NAME!
|
||||
echo IMAGE_NAME=!IMAGE_NAME!
|
||||
echo -----------------------------------
|
||||
echo.
|
||||
|
||||
REM === 流程 ============================
|
||||
|
||||
@REM for /f "usebackq tokens=*" %%i in (`git describe --tags --always`) do (
|
||||
@REM set VERSION=%%i
|
||||
@REM )
|
||||
@REM echo Building version !VERSION!
|
||||
|
||||
:: 0. 移除舊 Image
|
||||
docker rmi !IMAGE_PROJ_NAME!/!IMAGE_NAME!:!VERSION!
|
||||
|
||||
:: 1. 打包 映像檔 ( -f: 文件位置(注:是相對於目錄) -t: 標簽 ..: 上一層作爲根目錄(.: 表示當前當作根目錄))
|
||||
docker build --no-cache -f ../Dockerfile -t !IMAGE_PROJ_NAME!/!IMAGE_NAME!:!VERSION! ../
|
53
Scripts/12.push-image.bat
Normal file
53
Scripts/12.push-image.bat
Normal file
@ -0,0 +1,53 @@
|
||||
@echo off
|
||||
cd /d "%~dp0"
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM === 載入 .env 變數(忽略註解與空行) ===
|
||||
for /f "usebackq tokens=1,* delims==" %%a in (".env") do (
|
||||
if "%%a" neq "" (
|
||||
if not "%%a"=="REM" (
|
||||
set "%%a=%%b"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM === 讀取版本 ========================
|
||||
set /p VERSION=<version.txt
|
||||
REM ====================================
|
||||
|
||||
REM === 檢查變數 ========================
|
||||
echo -----------------------------------
|
||||
echo VERSION=!VERSION!
|
||||
echo IMAGE_PROJ_NAME=!IMAGE_PROJ_NAME!
|
||||
echo IMAGE_NAME=!IMAGE_NAME!
|
||||
echo REMOTE_URL=!REMOTE_URL!
|
||||
echo -----------------------------------
|
||||
echo.
|
||||
|
||||
REM === 設定目標 image tag ==============
|
||||
set "LOCAL_TAG=!IMAGE_PROJ_NAME!/!IMAGE_NAME!:!VERSION!"
|
||||
set "REMOTE_TAG=!REMOTE_URL!/!IMAGE_PROJ_NAME!/!IMAGE_NAME!:!VERSION!"
|
||||
set "REMOTE_TAG_LATEST=!REMOTE_URL!/!IMAGE_PROJ_NAME!/!IMAGE_NAME!:latest"
|
||||
|
||||
REM === 流程 ============================
|
||||
|
||||
:: 1. 登入 遠端倉庫
|
||||
echo.
|
||||
echo Login...
|
||||
docker login !REMOTE_URL!
|
||||
|
||||
:: 2. 標簽 標記映像檔
|
||||
echo.
|
||||
echo Tagging image...
|
||||
docker tag !LOCAL_TAG! !REMOTE_TAG!
|
||||
docker tag !LOCAL_TAG! !REMOTE_TAG_LATEST!
|
||||
|
||||
:: 3. 推送 映像檔
|
||||
echo.
|
||||
echo Pushing image...
|
||||
docker push !REMOTE_TAG!
|
||||
docker push !REMOTE_TAG_LATEST!
|
||||
|
||||
:: 4. 完成
|
||||
echo Done.
|
||||
pause
|
24
Scripts/docker-entrypoint.sh
Normal file
24
Scripts/docker-entrypoint.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# 目標檔案
|
||||
ENV_FILE=/usr/share/nginx/html/env.js
|
||||
|
||||
# 確保目錄存在
|
||||
mkdir -p /usr/share/nginx/html
|
||||
|
||||
# 寫入環境變數
|
||||
cat <<EOF > "$ENV_FILE"
|
||||
window.env = {
|
||||
VITE_API_BASEURL: "${VITE_API_BASEURL:-http://localhost:8080}",
|
||||
VITE_FILE_API_BASEURL: "${VITE_FILE_API_BASEURL:-http://localhost:8081}",
|
||||
VITE_MQTT_BASEURL: "${VITE_MQTT_BASEURL:-ws://localhost:1883}",
|
||||
VITE_APP_TITLE: "${VITE_APP_TITLE:-MyApp}"
|
||||
};
|
||||
EOF
|
||||
|
||||
echo "[Entrypoint] Generated $ENV_FILE:"
|
||||
cat "$ENV_FILE"
|
||||
|
||||
# 執行傳入的 CMD,例如 "nginx -g 'daemon off;'"
|
||||
exec "$@"
|
69
Scripts/version-inc.bat
Normal file
69
Scripts/version-inc.bat
Normal file
@ -0,0 +1,69 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: 檢查輸入參數
|
||||
if "%~1"=="" (
|
||||
echo 使用方式: version-inc.bat [inc ^| time ^| major]
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: 讀版本號(移除前後空白)
|
||||
set /p VERSION=<version.txt
|
||||
for /f "tokens=* delims= " %%v in ("%VERSION%") do set VERSION=%%v
|
||||
echo Current version: %VERSION%
|
||||
|
||||
:: 拆字串(主.次.修訂)
|
||||
for /f "tokens=1,2,3 delims=.-" %%a in ("%VERSION%") do (
|
||||
set MAJOR=%%a
|
||||
set MINOR=%%b
|
||||
set PATCH=%%c
|
||||
)
|
||||
|
||||
:: inc 模式:遞增 patch,不動 minor
|
||||
if /i "%~1"=="inc" (
|
||||
set /a PATCH=!PATCH!+1
|
||||
set VERSION=!MAJOR!.!MINOR!.!PATCH!
|
||||
)
|
||||
|
||||
:: time 模式:遞增 patch,並加上 -time
|
||||
:: time 模式:加上時間戳
|
||||
if /i "%~1"=="time" (
|
||||
set /a PATCH=!PATCH!+1
|
||||
|
||||
rem ---- 抽取數字日期 (YYMMDD) ----
|
||||
set "RAW_DATE=%date%"
|
||||
set "NUM_DATE="
|
||||
for /l %%i in (0,1,19) do (
|
||||
set "ch=!RAW_DATE:~%%i,1!"
|
||||
for %%c in (0 1 2 3 4 5 6 7 8 9) do if "!ch!"=="%%c" set "NUM_DATE=!NUM_DATE!!ch!"
|
||||
)
|
||||
rem 只取最後6位 (YYMMDD)
|
||||
set "YYMMDD=!NUM_DATE:~-6!"
|
||||
|
||||
rem ---- 抽取時間數字 (HHMM) ----
|
||||
set "RAW_TIME=%time%"
|
||||
set "NUM_TIME="
|
||||
for /l %%i in (0,1,19) do (
|
||||
set "ch=!RAW_TIME:~%%i,1!"
|
||||
for %%c in (0 1 2 3 4 5 6 7 8 9) do if "!ch!"=="%%c" set "NUM_TIME=!NUM_TIME!!ch!"
|
||||
)
|
||||
rem 只取前4位 (HHMM)
|
||||
set "HHMM=!NUM_TIME:~0,4!"
|
||||
|
||||
rem ---- 組合完整時間戳 ----
|
||||
set "DT=!YYMMDD!!HHMM!"
|
||||
set VERSION=!MAJOR!.!MINOR!.!PATCH!-!DT!
|
||||
)
|
||||
|
||||
:: major 模式:遞增 major,不動 minor 和 patch
|
||||
if /i "%~1"=="major" (
|
||||
set /a MAJOR=!MAJOR!+1
|
||||
set VERSION=!MAJOR!.!MINOR!.!PATCH!
|
||||
)
|
||||
|
||||
echo New version: %VERSION%
|
||||
|
||||
:: 寫回檔案
|
||||
>version.txt echo %VERSION%
|
||||
|
||||
endlocal
|
1
Scripts/version.txt
Normal file
1
Scripts/version.txt
Normal file
@ -0,0 +1 @@
|
||||
1.0.2-2510091649
|
@ -5,11 +5,12 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.css"
|
||||
rel="stylesheet"
|
||||
href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.css"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>新創賦能</title>
|
||||
<script src="/env.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
|
||||
<!-- <script src="https://code.jquery.com/ui/1.13.3/jquery-ui.js"></script> -->
|
||||
<!-- <script type="text/javascript" src="/requirejs/config.js"></script> -->
|
||||
|
@ -10,12 +10,12 @@ import {
|
||||
DELETE_ACCOUNT_USER_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getAccountUserList = async (search_condition = {}) => {
|
||||
const res = await instance.post(GET_ACCOUNT_USERLIST_API, search_condition);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -27,7 +27,7 @@ export const getAccountRoleList = async (search_condition = {}) => {
|
||||
...search_condition,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -38,7 +38,7 @@ export const getAccountRoleAuthList = async (SelectedRoleId) => {
|
||||
SelectedRoleId,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -47,7 +47,7 @@ export const getAccountRoleAuthList = async (SelectedRoleId) => {
|
||||
export const getAccountRoleAuthPageList = async () => {
|
||||
const res = await instance.post(GET_ACCOUNT_ROLEAUTHPAGELIST_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -60,7 +60,7 @@ export const postAccountRole = async ({ Id, Name, SaveCheckAuth }) => {
|
||||
SaveCheckAuth,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -71,7 +71,7 @@ export const delRole = async (Id) => {
|
||||
Id,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -91,7 +91,7 @@ export const getAccountOneUser = async (Id) => {
|
||||
Id,
|
||||
};
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -128,7 +128,7 @@ export const postAccountUser = async ({
|
||||
}
|
||||
);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -140,7 +140,7 @@ export const changePassword = async ({ Id, Password }) => {
|
||||
Password,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -151,7 +151,7 @@ export const delAccount = async (Id) => {
|
||||
Id,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -23,11 +23,11 @@ import {
|
||||
POST_ALERT_MQTT_REFRESH,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getAlertFormId = async (uuid) => {
|
||||
const res = await instance.post(GET_ALERT_FORMID_API, uuid);
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -45,7 +45,7 @@ export const getAlertLog = async ({
|
||||
isRecovery,
|
||||
device_name_tag,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -55,7 +55,7 @@ export const getAlertLogList = async (building_guid) => {
|
||||
const res = await instance.post(GET_ALERT_LOG_LIST_API, {
|
||||
building_guid,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -64,7 +64,7 @@ export const getAlertLogList = async (building_guid) => {
|
||||
export const postOperationRecord = async (formData) => {
|
||||
const res = await instance.post(POST_OPERATION_RECORD_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -75,7 +75,7 @@ export const getAlertSubList = async (building_guid) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -84,7 +84,7 @@ export const getAlertSubList = async (building_guid) => {
|
||||
export const getAlarmMemberList = async () => {
|
||||
const res = await instance.post(GET_ALERT_MEMBER_LIST_API, {});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -93,7 +93,7 @@ export const getAlarmMemberList = async () => {
|
||||
export const getNoticeList = async (lang) => {
|
||||
const res = await instance.post(GET_NOTICE_LIST_API, { lang });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -102,7 +102,7 @@ export const getNoticeList = async (lang) => {
|
||||
export const postAlertMember = async (data) => {
|
||||
const res = await instance.post(POST_ALERT_MEMBER, data);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -135,7 +135,7 @@ export const getAlarmMember = async (data) => {
|
||||
export const getOutliersList = async (id) => {
|
||||
const res = await instance.post(GET_OUTLIERS_LIST_API, id);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -144,7 +144,7 @@ export const getOutliersList = async (id) => {
|
||||
export const getOutliersDevList = async (id) => {
|
||||
const res = await instance.post(GET_OUTLIERS_DEVLIST_API, id);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -153,7 +153,7 @@ export const getOutliersDevList = async (id) => {
|
||||
export const getOutliersPoints = async (id) => {
|
||||
const res = await instance.post(GET_OUTLIERS_POINTS_API, id);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -162,7 +162,7 @@ export const getOutliersPoints = async (id) => {
|
||||
export const getFactors = async () => {
|
||||
const res = await instance.post(GET_FACTOR_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -171,7 +171,7 @@ export const getFactors = async () => {
|
||||
export const postOutliersSetting = async (data) => {
|
||||
const res = await instance.post(POST_OUTLIERS_SETTING_API, data);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -182,7 +182,7 @@ export const delOutliersSetting = async (Id) => {
|
||||
Id,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -191,7 +191,7 @@ export const delOutliersSetting = async (Id) => {
|
||||
export const getShowAlarm = async () => {
|
||||
const res = await instance.post(GET_SHOW_ALERT_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -200,7 +200,7 @@ export const getShowAlarm = async () => {
|
||||
export const getAlarmScheduleList = async () => {
|
||||
const res = await instance.post(GET_ALERT_SCHEDULE_LIST_API, {});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -209,7 +209,7 @@ export const getAlarmScheduleList = async () => {
|
||||
export const postAlertSchedule = async (data) => {
|
||||
const res = await instance.post(POST_ALERT_SCHEDULE, data);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -231,7 +231,7 @@ export const deleteAlarmSchedule = async (id) => {
|
||||
export const postMQTTRefresh = async () => {
|
||||
const res = await instance.post(POST_ALERT_MQTT_REFRESH);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -28,13 +28,13 @@ import {
|
||||
POST_ASSET_ELEC_SETTING_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
import { object } from "yup";
|
||||
|
||||
export const getAssetMainList = async (building_guid) => {
|
||||
const res = await instance.post(GET_ASSET_MAIN_LIST_API,{building_guid});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -43,7 +43,7 @@ export const getAssetMainList = async (building_guid) => {
|
||||
export const deleteAssetMainItem = async (id) => {
|
||||
const res = await instance.post(DELETE_ASSET_MAIN_LIST_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -57,7 +57,7 @@ export const postAssetMainList = async ({ id, system_key, system_value, building
|
||||
building_guid
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -66,7 +66,7 @@ export const postAssetMainList = async ({ id, system_key, system_value, building
|
||||
export const getAssetSubList = async (id) => {
|
||||
const res = await instance.post(GET_ASSET_SUB_LIST_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -75,7 +75,7 @@ export const getAssetSubList = async (id) => {
|
||||
export const postAssetSubList = async (formData) => {
|
||||
const res = await instance.post(POST_ASSET_SUB_LIST_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -84,7 +84,7 @@ export const postAssetSubList = async (formData) => {
|
||||
export const deleteAssetSubItem = async (id) => {
|
||||
const res = await instance.post(DELETE_ASSET_SUB_LIST_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -95,7 +95,7 @@ export const getAssetList = async (variable_id) => {
|
||||
variable_id: parseInt(variable_id),
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -104,7 +104,7 @@ export const getAssetList = async (variable_id) => {
|
||||
export const getAssetSingle = async (main_id) => {
|
||||
const res = await instance.post(GET_ASSET_SINGLE_API, { main_id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -140,13 +140,13 @@ export const postAssetSingle = async (data) => {
|
||||
}
|
||||
|
||||
const res = await instance.post(POST_ASSET_SINGLE_API, formData);
|
||||
return apihandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
return apiHandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
};
|
||||
|
||||
export const deleteAssetItem = async (main_id) => {
|
||||
const res = await instance.post(DELETE_ASSET_ITEM_API, { main_id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -155,7 +155,7 @@ export const deleteAssetItem = async (main_id) => {
|
||||
export const getAssetFloorList = async (building_guid) => {
|
||||
const res = await instance.post(GET_ASSET_FLOOR_LIST_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -164,7 +164,7 @@ export const getAssetFloorList = async (building_guid) => {
|
||||
export const postAssetFloor = async (formData) => {
|
||||
const res = await instance.post(POST_ASSET_FLOOR_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -173,7 +173,7 @@ export const postAssetFloor = async (formData) => {
|
||||
export const deleteAssetFloor = async (formData) => {
|
||||
const res = await instance.post(DELETE_ASSET_FLOOR_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -185,7 +185,7 @@ export const getAssetIOTList = async (sub_system_tag, points) => {
|
||||
points,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -196,7 +196,7 @@ export const getAssetSubPoint = async (sub_system_tag) => {
|
||||
sub_system_tag,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -205,7 +205,7 @@ export const getAssetSubPoint = async (sub_system_tag) => {
|
||||
export const getIOTSchema = async (variable_id) => {
|
||||
const res = await instance.post(GET_ASSET_IOT_SCHEMA_API, { variable_id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -218,7 +218,7 @@ export const postIOTSchema = async ({ name, variable_id, points }) => {
|
||||
points,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -227,7 +227,7 @@ export const postIOTSchema = async ({ name, variable_id, points }) => {
|
||||
export const getDeviceItem = async (variable_id) => {
|
||||
const res = await instance.post(GET_ASSET_DEVICE_ITEM_API, { variable_id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -252,7 +252,7 @@ export const postDeviceItem = async ({
|
||||
is_link,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -261,7 +261,7 @@ export const postDeviceItem = async ({
|
||||
export const deleteDeviceItem = async (id) => {
|
||||
const res = await instance.post(DELETE_ASSET_DEVICE_ITEM_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -270,7 +270,7 @@ export const deleteDeviceItem = async (id) => {
|
||||
export const getDepartmentList = async () => {
|
||||
const res = await instance.post(GET_ASSET_DEPARTMENT_API, {});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -282,7 +282,7 @@ export const postDepartmentList = async ({ name, id }) => {
|
||||
id,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -291,7 +291,7 @@ export const postDepartmentList = async ({ name, id }) => {
|
||||
export const deleteDepartmentItem = async (id) => {
|
||||
const res = await instance.post(DELETE_ASSET_DEPARTMENT_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -300,7 +300,7 @@ export const deleteDepartmentItem = async (id) => {
|
||||
export const getElecTypeList = async () => {
|
||||
const res = await instance.post(GET_ASSET_ELECTYPE_API, {});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -312,7 +312,7 @@ export const postElecTypeList = async ({ name, id }) => {
|
||||
id,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -321,7 +321,7 @@ export const postElecTypeList = async ({ name, id }) => {
|
||||
export const deleteElecTypeItem = async (id) => {
|
||||
const res = await instance.post(DELETE_ASSET_ELECTYPE_API, { id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -330,7 +330,7 @@ export const deleteElecTypeItem = async (id) => {
|
||||
export const postAssetElecSetting = async (formData) => {
|
||||
const res = await instance.post(POST_ASSET_ELEC_SETTING_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -7,12 +7,12 @@ import {
|
||||
GET_ALL_DEVICE_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getBuildings = async () => {
|
||||
const res = await instance.post(GET_BUILDING_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -24,7 +24,7 @@ export const postBuildings = async ({ full_name, building_guid }) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -33,7 +33,7 @@ export const postBuildings = async ({ full_name, building_guid }) => {
|
||||
export const deleteBuildings = async (building_guid) => {
|
||||
const res = await instance.post(DELETE_BUILDING_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -43,7 +43,7 @@ export const getAuth = async (lang) => {
|
||||
const res = await instance.post(GET_AUTHPAGE_API, {
|
||||
lang,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -51,7 +51,7 @@ export const getAuth = async (lang) => {
|
||||
|
||||
export const getAllSysSidebar = async (building_guid) => {
|
||||
const res = await instance.post(GET_SUBAUTHPAGE_API, {building_guid});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -62,7 +62,7 @@ export const getSysSidebar = async (building_tag) => {
|
||||
building_tag,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -71,7 +71,7 @@ export const getSysSidebar = async (building_tag) => {
|
||||
export const getAllDevice = async () => {
|
||||
const res = await instance.post(GET_ALL_DEVICE_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -83,7 +83,7 @@ export const ackSingleAlarm = async (uuid) => {
|
||||
'<obj is="obix:AckAlarmIn"><str name="ackUser" val="obix" /></obj>'
|
||||
);
|
||||
console.log("acked", res);
|
||||
return apihandler(res.code, res, {
|
||||
return apiHandler(res.code, res, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -13,14 +13,14 @@ import {
|
||||
GET_DASHBOARD_ALARMOPERATION_INFO_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getDashboardInit = async (page_type = "SR") => {
|
||||
const res = await instance.post(GET_DASHBOARD_INIT_API, {
|
||||
page_type, // SR:戰情室;PS:生產設定
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -31,7 +31,7 @@ export const getDashboardDevice = async ({ option }) => {
|
||||
option: parseInt(option),
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -40,7 +40,7 @@ export const getDashboardDevice = async ({ option }) => {
|
||||
export const getDashboardProductCompletion = async () => {
|
||||
const res = await instance.post(GET_DASHBOARD_PRODUCT_COMPLETE_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -49,7 +49,7 @@ export const getDashboardProductCompletion = async () => {
|
||||
export const getDashboardEnergy = async () => {
|
||||
const res = await instance.post(GET_DASHBOARD_ENERGY_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -60,7 +60,7 @@ export const getDashboardFormulaRoom = async ({ timeInterval, typeOption }) => {
|
||||
timeInterval,
|
||||
typeOption,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -79,7 +79,7 @@ export const getDashboardTemp = async ({
|
||||
option
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -103,7 +103,7 @@ export const postDashboardProductTarget = async ({ date, type, data }) => {
|
||||
},
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -117,7 +117,7 @@ export const getDashboardProductTarget = async ({ date, type }) => {
|
||||
},
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -129,7 +129,7 @@ export const getDashboardProductRecord = async ({ start_time, end_time }) => {
|
||||
end_time,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -140,7 +140,7 @@ export const getEnergyInfo = async (building_guid) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -157,7 +157,7 @@ export const getEnergyCost = async ({
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -168,7 +168,7 @@ export const getAlarmOperationInfo = async (building_guid) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -18,13 +18,13 @@ import {
|
||||
POST_TIME_ELEC_API,
|
||||
} from "./api";
|
||||
import instance, { fileInstance } from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
import downloadExcel from "@/util/downloadExcel";
|
||||
|
||||
export const getRealTimeData = async () => {
|
||||
const res = await instance.post(GET_REALTIME_DATA_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -33,7 +33,7 @@ export const getRealTimeData = async () => {
|
||||
export const getElecUseMonth = async () => {
|
||||
const res = await instance.post(GET_ELEC_MONTH_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -42,7 +42,7 @@ export const getElecUseMonth = async () => {
|
||||
export const getElecUseofDay = async () => {
|
||||
const res = await instance.post(GET_ELEC_DAY_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -59,7 +59,7 @@ export const getRealTimeDist = async ({
|
||||
floor_guid_list,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -76,7 +76,7 @@ export const getElecUseDay = async ({
|
||||
floor_guid_list,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -95,7 +95,7 @@ export const getTaipower = async ({
|
||||
floor_guid_list,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -104,7 +104,7 @@ export const getTaipower = async ({
|
||||
export const getSideBar = async (system_type) => {
|
||||
const res = await instance.post(GET_SIDEBAR_API, { system_type });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -113,7 +113,7 @@ export const getSideBar = async (system_type) => {
|
||||
export const getEnergySearch = async (type) => {
|
||||
const res = await instance.post(GET_SEARCH_API, { type });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -136,7 +136,7 @@ export const getReport = async ({
|
||||
type,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -163,7 +163,7 @@ export const getExcel = async ({
|
||||
{ responseType: "blob" }
|
||||
);
|
||||
|
||||
return apihandler(
|
||||
return apiHandler(
|
||||
res.code,
|
||||
res,
|
||||
{
|
||||
@ -177,7 +177,7 @@ export const getExcel = async ({
|
||||
export const getDemand = async (building_guid) => {
|
||||
const res = await instance.post(GET_DEMAND_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -198,7 +198,7 @@ export const postEditDemand = async ({
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -207,7 +207,7 @@ export const postEditDemand = async ({
|
||||
export const getCarbonValue = async (building_guid) => {
|
||||
const res = await instance.post(GET_CARBON_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -224,7 +224,7 @@ export const postEditCarbonValue = async ({
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -233,7 +233,7 @@ export const postEditCarbonValue = async ({
|
||||
export const getRealTimeDemand = async (building_guid) => {
|
||||
const res = await instance.post(GET_REALTIME_DEMAND_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -242,7 +242,7 @@ export const getRealTimeDemand = async (building_guid) => {
|
||||
export const getTimeElec = async (building_guid) => {
|
||||
const res = await instance.post(GET_TIME_ELEC_API, { building_guid });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -255,7 +255,7 @@ export const postTimeElec = async ({ sheet, cost, building_guid }) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -1,11 +1,11 @@
|
||||
import instance from "@/util/request";
|
||||
import { GET_FORGETOKEN_API, GET_FORGEURN_API } from "./api";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getUrn = async () => {
|
||||
const res = await instance.post(GET_FORGEURN_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -1,5 +1,8 @@
|
||||
// graph
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;
|
||||
|
||||
export const GET_GRAPH_SIDEBAR_API = `/GraphManage/GraphManageTreeList`;
|
||||
|
||||
export const UPDATE_GRAPH_SIDEBAR_API = `/GraphManage/EditGraphManageTree`;
|
||||
|
@ -11,12 +11,12 @@ import {
|
||||
UPDATE_GRAPH_TABLE_API
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apiHandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getSideBar = async () => {
|
||||
const res = await instance.post(GET_GRAPH_SIDEBAR_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -25,7 +25,7 @@ export const getSideBar = async () => {
|
||||
export const addSideBarTreeName = async ({ parent_id, name }) => {
|
||||
const res = await instance.post(POST_GRAPH_SIDEBAR_API, { parent_id, name });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -34,7 +34,7 @@ export const addSideBarTreeName = async ({ parent_id, name }) => {
|
||||
export const updateSideBarTreeName = async ({ id, name }) => {
|
||||
const res = await instance.post(UPDATE_GRAPH_SIDEBAR_API, { id, name });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -43,7 +43,7 @@ export const updateSideBarTreeName = async ({ id, name }) => {
|
||||
export const removeSideBarTreeName = async (id) => {
|
||||
const res = await instance.post(REMOVE_GRAPH_SIDEBAR_API, { id });
|
||||
|
||||
return apihandler(
|
||||
return apiHandler(
|
||||
res.code,
|
||||
{ isSuccess: true },
|
||||
{
|
||||
@ -58,7 +58,7 @@ export const removeSideBarTreeName = async (id) => {
|
||||
export const getGraphData = async (id) => {
|
||||
const res = await instance.post(GET_GRAPH_TABLE_API, { layer_id: id });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -68,7 +68,7 @@ export const getGraphData = async (id) => {
|
||||
export const getGraphAddParamOption = async () => {
|
||||
const res = await instance.post(GET_GRAPH_PARAM_OPTION_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -78,7 +78,7 @@ export const getGraphAddParamOption = async () => {
|
||||
export const addGraphTableData = async (formData) => {
|
||||
const res = await instance.post(POST_GRAPH_TABLE_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -88,7 +88,7 @@ export const addGraphTableData = async (formData) => {
|
||||
export const delGraphData = async (id, hard_delete = false, recover_delete = false) => {
|
||||
const res = await instance.post(DELETE_GRAPH_TABLE_API, { id, hard_delete, recover_delete });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -99,7 +99,7 @@ export const delGraphData = async (id, hard_delete = false, recover_delete = fal
|
||||
export const addGraphTableDataWithoutSubSys = async (formData) => {
|
||||
const res = await instance.post(POST_GRAPH_TABLE_API_2, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -109,7 +109,7 @@ export const addGraphTableDataWithoutSubSys = async (formData) => {
|
||||
export const editGraphTableDataWithoutSubSys = async (formData) => {
|
||||
const res = await instance.post(UPDATE_GRAPH_TABLE_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
|
@ -1,5 +1,9 @@
|
||||
// history
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;
|
||||
|
||||
export const GET_HISTORY_SIDEBAR_API = `/api/History/GetDeviceInfo`;
|
||||
export const GET_HISTORY_POINT_API = `/api/History/GetAllDevPoi`;
|
||||
export const GET_HISTORY_DATA_API = `/api/History/GetHistoryData`;
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
GET_HISTORY_EXPORT_API,
|
||||
} from "./api";
|
||||
import instance, { fileInstance } from "@/util/request";
|
||||
import apihandler from "@/util/apiHandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
import downloadExcel from "@/util/downloadExcel";
|
||||
|
||||
export const getHistorySideBar = async ({
|
||||
@ -25,7 +25,7 @@ export const getHistorySideBar = async ({
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -36,7 +36,7 @@ export const getHistoryPoints = async (Device_list) => {
|
||||
Device_list,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -74,7 +74,7 @@ export const getHistoryData = async ({
|
||||
table_type: parseInt(table_type),
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -116,7 +116,7 @@ export const getHistoryExportData = async ({
|
||||
{ responseType: "blob" }
|
||||
);
|
||||
|
||||
return apihandler(
|
||||
return apiHandler(
|
||||
res.code,
|
||||
res,
|
||||
{
|
||||
@ -130,7 +130,7 @@ export const getHistoryExportData = async ({
|
||||
export const getHistoryFavorite = async () => {
|
||||
const res = await instance.post(GET_HISTORY_FAVORITE_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -147,7 +147,7 @@ export const addHistoryFavorite = async (value) => {
|
||||
Type: parseInt(value.Type),
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -158,7 +158,7 @@ export const deleteHistoryFavorite = async (favorite_guid) => {
|
||||
favorite_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -170,7 +170,7 @@ export const editHistoryFavorite = async ({ favorite_guid, favorite_name }) => {
|
||||
favorite_name,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { POST_LOGIN } from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export async function Login({ account, password }) {
|
||||
const res = await instance.post(POST_LOGIN, {
|
||||
@ -19,7 +19,7 @@ export async function Login({ account, password }) {
|
||||
}`;
|
||||
}
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
DELETE_OPERATION_COMPANY_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const getOperationRecord = async ({
|
||||
@ -34,7 +34,7 @@ export const getOperationRecord = async ({
|
||||
typeof sub_system_tag === "string" ? [sub_system_tag] : sub_system_tag,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -53,7 +53,7 @@ export const getOperationExportRecord = async ({
|
||||
.format("YYYY-MM-DDTHH:mm:ss"),
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -64,7 +64,7 @@ export const getOperationCompanyList = async () => {
|
||||
sub_system_tag: [],
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -84,7 +84,7 @@ export const getOperationDeviceList = async ({
|
||||
device_area_tag,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -95,7 +95,7 @@ export const getOperationEditRecord = async (formId) => {
|
||||
formId,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -104,7 +104,7 @@ export const getOperationEditRecord = async (formId) => {
|
||||
export const postOperationRecord = async (formData) => {
|
||||
const res = await instance.post(POST_OPERATION_RECORD_API, formData);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -112,7 +112,7 @@ export const postOperationRecord = async (formData) => {
|
||||
|
||||
export const getOperationFormId = async () => {
|
||||
const res = await instance.post(GET_OPERATION_FORMID_API, {});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -120,7 +120,7 @@ export const getOperationFormId = async () => {
|
||||
|
||||
export const deleteOperationRecord = async (id) => {
|
||||
const res = await instance.post(DELETE_OPERATION_RECORD_API, { id });
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -147,7 +147,7 @@ export const postOperationCompany = async ({
|
||||
tax_id_number,
|
||||
remark,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -175,7 +175,7 @@ export const updateOperationCompany = async ({
|
||||
tax_id_number,
|
||||
remark,
|
||||
});
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -183,7 +183,7 @@ export const updateOperationCompany = async ({
|
||||
|
||||
export const deleteOperationCompany = async (id) => {
|
||||
const res = await instance.post(DELETE_OPERATION_COMPANY_API, { id });
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
import {
|
||||
POST_SETTING_POINT_API,
|
||||
GET_SETTING_TYPE_API,
|
||||
@ -17,7 +17,7 @@ export const postProductSettingPoint = async (type, devices) => {
|
||||
],
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -27,7 +27,7 @@ export const postProductSettingPoint = async (type, devices) => {
|
||||
export const getProductSettingType = async () => {
|
||||
const res = await instance.post(GET_SETTING_TYPE_API);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
@ -37,7 +37,7 @@ export const getProductSettingType = async () => {
|
||||
export const postProductSettingType = async (data) => {
|
||||
const res = await instance.post(POST_SETTING_TYPE_API, data);
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
isSuccess: false,
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
POST_SET_SAMBA_DIRECTORY,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
/**
|
||||
* 開關 RTSP
|
||||
@ -12,7 +12,7 @@ import apihandler from "@/util/apihandler";
|
||||
*/
|
||||
export const setRtspEnable = async ({ main_id, enable }) => {
|
||||
const res = await instance.post(POST_SET_RTSP_ENABLE, { main_id, enable });
|
||||
return apihandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
return apiHandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
};
|
||||
|
||||
/**
|
||||
@ -25,5 +25,5 @@ export const setSambaDirectory = async ({ main_id, directory }) => {
|
||||
main_id,
|
||||
directory,
|
||||
});
|
||||
return apihandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
return apiHandler(res.code, res.data, { msg: res.msg, code: res.code });
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
POST_MQTT_TOPIC_STOP_API,
|
||||
} from "./api";
|
||||
import instance from "@/util/request";
|
||||
import apihandler from "@/util/apihandler";
|
||||
import apiHandler from "@/util/apiHandler";
|
||||
|
||||
export const getSystemFloors = async (building_tag, sub_system_tag) => {
|
||||
const res = await instance.post(GET_SYSTEM_FLOOR_LIST_API, {
|
||||
@ -15,7 +15,7 @@ export const getSystemFloors = async (building_tag, sub_system_tag) => {
|
||||
sub_system_tag,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -26,7 +26,7 @@ export const getSystemDevices = async ({ building_guid }) => {
|
||||
building_guid,
|
||||
});
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -34,7 +34,7 @@ export const getSystemDevices = async ({ building_guid }) => {
|
||||
|
||||
export const getSystemRealTime = async (device_list) => {
|
||||
const res = await instance.post(GET_SYSTEM_REALTIME_API, { device_list });
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -42,7 +42,7 @@ export const getSystemRealTime = async (device_list) => {
|
||||
|
||||
export const getSystemConfig = async (building_guid) => {
|
||||
const res = await instance.post(GET_SYSTEM_CONFIG_API, { building_guid });
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -51,7 +51,7 @@ export const getSystemConfig = async (building_guid) => {
|
||||
export const postMqttTopic = async ({ iotTag, Topic }) => {
|
||||
const res = await instance.post(POST_MQTT_TOPIC_API, { iotTag, Topic });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
@ -60,7 +60,7 @@ export const postMqttTopic = async ({ iotTag, Topic }) => {
|
||||
export const postMqttTopicStop = async ({ iotTag, Topic }) => {
|
||||
const res = await instance.post(POST_MQTT_TOPIC_STOP_API, { iotTag, Topic });
|
||||
|
||||
return apihandler(res.code, res.data, {
|
||||
return apiHandler(res.code, res.data, {
|
||||
msg: res.msg,
|
||||
code: res.code,
|
||||
});
|
||||
|
@ -202,7 +202,7 @@ watch(
|
||||
class="flex flex-col justify-center w-3 mx-2 relative"
|
||||
@click="() => sort(column.key)"
|
||||
>
|
||||
<font-awesome-icon
|
||||
<!-- <font-awesome-icon
|
||||
:icon="['fas', 'sort-up']"
|
||||
:class="
|
||||
twMerge(
|
||||
@ -221,30 +221,19 @@ watch(
|
||||
)
|
||||
"
|
||||
size="lg"
|
||||
/>
|
||||
/> -->
|
||||
</div>
|
||||
<div class="ml-2 relative" v-if="column.filter">
|
||||
<font-awesome-icon
|
||||
:icon="['fas', 'filter']"
|
||||
:class="
|
||||
twMerge(
|
||||
filterColumn[column.key] ||
|
||||
selectedFilterItem[column.key].length > 0
|
||||
? 'text-success'
|
||||
: ''
|
||||
)
|
||||
"
|
||||
@click="() => toggleFilterModal(column.key)"
|
||||
/>
|
||||
|
||||
<div class="fixed z-50" v-if="filterColumn[column.key]">
|
||||
<div class="card min-w-max bg-body shadow-xl px-10 py-5">
|
||||
<label
|
||||
class="input input-bordered bg-transparent rounded-lg flex items-center px-2 mb-4 border-success focus-within:border-success"
|
||||
>
|
||||
<font-awesome-icon
|
||||
<!-- <font-awesome-icon
|
||||
:icon="['fas', 'search']"
|
||||
class="w-6 h-6 mr-2 text-success"
|
||||
/>
|
||||
/> -->
|
||||
<input
|
||||
type="text"
|
||||
:placeholder="t('operation.enter_text')"
|
||||
|
@ -1,7 +1,10 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const forgeDom = ref(null);
|
||||
let viewer = null;
|
||||
|
@ -164,7 +164,10 @@ const initForge = async () => {
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const viewer = await initViewer(forgeDom.value)
|
||||
const filePath = `${FILE_BASEURL}/upload/forge/0.svf`;
|
||||
await loadModel(viewer, filePath)
|
||||
|
@ -1,4 +1,8 @@
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;;
|
||||
|
||||
export const POST_LOGIN = `${BASEURL}/api/Login/`;
|
||||
export const GET_AUTHPAGE_API = `${BASEURL}/api/GetUsrFroList`;
|
||||
export const GET_SUBAUTHPAGE_API = `${BASEURL}/api/Device/GetMainSub`;
|
||||
|
@ -1,4 +1,8 @@
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;;
|
||||
|
||||
export const GET_FORGETOKEN_API = `${BASEURL}/api/forge/oauth/token`;
|
||||
|
||||
export const GET_FORGEURN_API = `${BASEURL}/api/Device/GetBuild`;
|
||||
|
@ -4,13 +4,14 @@ const moveModal = (elmnt) => {
|
||||
pos2 = 0,
|
||||
pos3 = 0,
|
||||
pos4 = 0;
|
||||
document.body.addEventListener("mousedown", dragMouseDown, {
|
||||
elmnt.addEventListener("mousedown", dragMouseDown, {
|
||||
passive: false,
|
||||
});
|
||||
|
||||
function dragMouseDown(e) {
|
||||
console.log("dragMouseDown", e);
|
||||
e = e || window.event;
|
||||
if (e.button !== 0) return;
|
||||
e.preventDefault();
|
||||
// get the mouse cursor position at startup:
|
||||
pos3 = e.clientX;
|
||||
|
Binary file not shown.
@ -5,7 +5,10 @@ import System from "@/views/system/System.vue";
|
||||
import SystemFloor from "@/views/system/SystemFloor.vue";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(import.meta.env.BASE_URL),
|
||||
// 本地開發 BASE_URL
|
||||
// history: createWebHashHistory(import.meta.env.BASE_URL),
|
||||
// docker 部屬 BASE_URL (兩者視部屬方式擇一保留)
|
||||
history: createWebHashHistory(window.env?.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: "/login",
|
||||
|
@ -11,9 +11,10 @@ const useHeatmapBarStore = defineStore("heatmap", () => {
|
||||
|
||||
const getConfig = async () => {
|
||||
const api =
|
||||
import.meta.env.MODE === "production"
|
||||
? "/dist/config.json"
|
||||
: "/config.json";
|
||||
// 本地開發 MODE
|
||||
// import.meta.env.MODE === "production"
|
||||
// docker 部屬 MODE (兩者視部屬方式擇一保留)
|
||||
window.env?.MODE === "production" ? "/dist/config.json" : "/config.json";
|
||||
const res = await axios.get(api);
|
||||
console.log(res);
|
||||
allHeatMaps.value = res.data.heatmap;
|
||||
|
@ -1,4 +1,4 @@
|
||||
const apihandler = (code, successData, errorData, cb = null) => {
|
||||
const apiHandler = (code, successData, errorData, cb = null) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (code === "0000") {
|
||||
cb && cb(successData);
|
||||
@ -8,4 +8,4 @@ const apihandler = (code, successData, errorData, cb = null) => {
|
||||
});
|
||||
};
|
||||
|
||||
export default apihandler;
|
||||
export default apiHandler;
|
||||
|
@ -1,4 +1,7 @@
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;;
|
||||
|
||||
export default function downloadExcel(res) {
|
||||
let disposition = res.headers.get("Content-Disposition");
|
||||
|
@ -1,6 +1,9 @@
|
||||
import useGetCookie from "@/hooks/useGetCookie";
|
||||
import axios from "axios";
|
||||
const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// 本地開發 BASEURL
|
||||
// const BASEURL = import.meta.env.VITE_API_BASEURL;
|
||||
// docker 部屬 BASEURL (兩者視部屬方式擇一保留)
|
||||
const BASEURL = window.env?.VITE_API_BASEURL;;
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: BASEURL,
|
||||
|
@ -10,7 +10,10 @@ import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const { openToast, cancelToastOpen } = inject("app_toast");
|
||||
const { companyOptions, departmentList, floors } = inject("asset_modal_options");
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { searchParams, changeParams } = useSearchParam();
|
||||
|
||||
const totalCoordinates = ref({});
|
||||
|
@ -10,7 +10,10 @@ import useUserInfoStore from "@/stores/useUserInfoStore";
|
||||
import dayjs from "dayjs";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { searchParams, changeParams } = useSearchParam();
|
||||
const { updateLeftFields, formErrorMsg, formState } = inject(
|
||||
"asset_table_modal_form"
|
||||
|
@ -4,7 +4,10 @@ import { ref, computed, inject, watch, onMounted } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import Menu from "@/components/customUI/Menu.vue";
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { formState } = inject("asset_table_modal_form");
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -7,7 +7,10 @@ import { twMerge } from "tailwind-merge";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { totalCoordinates } = inject("asset_table_data");
|
||||
const { floors } = inject("asset_modal_options");
|
||||
const { updateRightFields, formErrorMsg, formState } = inject(
|
||||
|
@ -1,13 +1,5 @@
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
defineProps,
|
||||
watch,
|
||||
inject,
|
||||
nextTick,
|
||||
onMounted,
|
||||
toRaw,
|
||||
} from "vue";
|
||||
import { ref, defineProps, watch, inject, onMounted } from "vue";
|
||||
import dayjs from "dayjs";
|
||||
import { postOperationRecord } from "@/apis/alert";
|
||||
import * as yup from "yup";
|
||||
@ -15,7 +7,10 @@ import "yup-phone-lite";
|
||||
import useFormErrorMessage from "@/hooks/useFormErrorMessage";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const props = defineProps({
|
||||
editRecord: Object,
|
||||
@ -93,28 +88,6 @@ const updateFileList = (files) => {
|
||||
formState.value.lorf = files;
|
||||
};
|
||||
|
||||
// ---------------------- 告警影片儲存位置:顯示 API 的 video_url ----------------------
|
||||
// 重要:你的 <Input name="videoLocation" :value="..."> 會從 value[name] 取值
|
||||
// 所以我們把 videoLocation 寫成 { videoLocation: string } 的物件
|
||||
const videoLocation = ref({ videoLocation: "" });
|
||||
const showTooltip = ref(false);
|
||||
|
||||
async function copyToClipboard() {
|
||||
const text = videoLocation.value.videoLocation || "";
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
// 觸發 tooltip 動畫
|
||||
showTooltip.value = false;
|
||||
await nextTick();
|
||||
showTooltip.value = true;
|
||||
setTimeout(() => {
|
||||
showTooltip.value = false;
|
||||
}, 1500);
|
||||
} catch (err) {
|
||||
console.error("複製失敗:", err);
|
||||
}
|
||||
}
|
||||
|
||||
const onOk = async () => {
|
||||
const formData = new FormData(form.value);
|
||||
formData.delete("oriFile");
|
||||
@ -177,14 +150,12 @@ const onCancel = () => {
|
||||
description: "",
|
||||
lorf: [],
|
||||
};
|
||||
// 重置顯示用的影片路徑
|
||||
videoLocation.value.videoLocation = "";
|
||||
handleErrorReset();
|
||||
updateEditRecord?.(null);
|
||||
alert_action_item.close();
|
||||
};
|
||||
|
||||
// 同步 props.editRecord -> formState / 日期 / 維修項目 / 影片網址
|
||||
// 同步 props.editRecord -> formState / 日期 / 維修項目
|
||||
watch(
|
||||
() => props.editRecord,
|
||||
(newVal) => {
|
||||
@ -203,10 +174,6 @@ watch(
|
||||
formState.value.fix_do = value ?? "";
|
||||
}
|
||||
}
|
||||
// 取 API 回傳的影片位址(與 device_number 同來源物件)
|
||||
videoLocation.value.videoLocation =
|
||||
newVal?.video_url ?? newVal?.videoUrl ?? newVal?.video_path ?? "";
|
||||
debugLog("derived videoLocation", videoLocation.value.videoLocation);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
@ -258,16 +225,8 @@ watch(
|
||||
name="work_type"
|
||||
Attribute="title"
|
||||
:options="[
|
||||
{
|
||||
key: 1,
|
||||
value: 1,
|
||||
title: $t('alert.maintenance'),
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
value: 2,
|
||||
title: $t('alert.repair'),
|
||||
},
|
||||
{ key: 1, value: 1, title: $t('alert.maintenance') },
|
||||
{ key: 2, value: 2, title: $t('alert.repair') },
|
||||
]"
|
||||
:required="true"
|
||||
:disabled="true"
|
||||
@ -276,8 +235,8 @@ watch(
|
||||
</Select>
|
||||
<Input class="my-2" :value="formState" name="fix_do" :required="true">
|
||||
<template #topLeft>{{ $t("alert.repair_item") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">
|
||||
{{ formErrorMsg.fix_do }}
|
||||
</span>
|
||||
</template>
|
||||
@ -290,11 +249,11 @@ watch(
|
||||
:disabled="true"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.repair_item_code") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">
|
||||
{{ formErrorMsg.fix_do_code }}
|
||||
</span></template
|
||||
>
|
||||
</span>
|
||||
</template>
|
||||
</Input>
|
||||
<Select
|
||||
:value="formState"
|
||||
@ -306,27 +265,19 @@ watch(
|
||||
:required="true"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.responsible_vendor") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">
|
||||
{{ formErrorMsg.fix_firm }}
|
||||
</span></template
|
||||
>
|
||||
</span>
|
||||
</template>
|
||||
</Select>
|
||||
<RadioGroup
|
||||
class="my-2"
|
||||
name="status"
|
||||
:value="formState"
|
||||
:items="[
|
||||
{
|
||||
key: 0,
|
||||
value: 0,
|
||||
title: $t('alert.not_completed'),
|
||||
},
|
||||
{
|
||||
key: 1,
|
||||
value: 1,
|
||||
title: $t('alert.completed'),
|
||||
},
|
||||
{ key: 0, value: 0, title: $t('alert.not_completed') },
|
||||
{ key: 1, value: 1, title: $t('alert.completed') },
|
||||
]"
|
||||
:required="true"
|
||||
>
|
||||
@ -342,11 +293,11 @@ watch(
|
||||
:required="true"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.worker_id") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">
|
||||
{{ formErrorMsg.work_person_id }}
|
||||
</span></template
|
||||
>
|
||||
</span>
|
||||
</template>
|
||||
</Select>
|
||||
|
||||
<!-- 注意事項 -->
|
||||
@ -354,45 +305,11 @@ watch(
|
||||
<template #topLeft>{{ $t("alert.notice") }}</template>
|
||||
</Textarea>
|
||||
|
||||
<!-- 告警影片儲存位置-->
|
||||
<div class="my-4 w-full">
|
||||
<label class="text-lg">
|
||||
{{ $t("alert.video_storage_location") }}
|
||||
</label>
|
||||
<div class="flex items-center gap-3">
|
||||
<Input
|
||||
class="flex-1"
|
||||
name="videoLocation"
|
||||
:value="videoLocation"
|
||||
readonly
|
||||
/>
|
||||
<div class="relative inline-flex items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
@click.stop="copyToClipboard"
|
||||
>
|
||||
{{ $t("alert.copy") }}
|
||||
</button>
|
||||
|
||||
<transition name="fade">
|
||||
<span
|
||||
v-if="showTooltip"
|
||||
class="absolute left-full ml-4 top-1/2 -translate-y-1/2 text-white text-xs px-2 py-1 bg-gray-800 rounded shadow whitespace-nowrap"
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
>
|
||||
{{ $t("alert.copied") }}
|
||||
</span>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 結果描述 -->
|
||||
<Textarea :value="formState" name="description" class="w-full my-2">
|
||||
<template #topLeft>{{ $t("alert.result_description") }}</template>
|
||||
</Textarea>
|
||||
|
||||
<Upload
|
||||
class="my-2"
|
||||
name="oriFile"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { inject, defineProps, watch, ref, provide } from "vue";
|
||||
import { inject, defineProps, watch, ref } from "vue";
|
||||
import useSearchParam from "@/hooks/useSearchParam";
|
||||
import useFormErrorMessage from "@/hooks/useFormErrorMessage";
|
||||
import AlertNoticesTable from "./AlertNoticesTable.vue";
|
||||
@ -9,7 +9,7 @@ import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const { openToast } = inject("app_toast");
|
||||
const { timesList, noticeList } = inject("notify_table");
|
||||
const { searchParams, changeParams } = useSearchParam();
|
||||
const { searchParams } = useSearchParam();
|
||||
|
||||
const props = defineProps({
|
||||
openModal: Function,
|
||||
@ -19,8 +19,8 @@ const props = defineProps({
|
||||
OptionsData: Object,
|
||||
});
|
||||
|
||||
const form = ref(null);
|
||||
const formState = ref({
|
||||
// ---- 初始表單狀態(統一使用此物件重置) ----
|
||||
const initialFormState = () => ({
|
||||
id: 0,
|
||||
device_number: "",
|
||||
device_name_tag: searchParams.value?.subSys_id,
|
||||
@ -28,7 +28,7 @@ const formState = ref({
|
||||
enable: 0,
|
||||
factor: 1,
|
||||
alarm_value: "",
|
||||
delay: 0,
|
||||
delay: null,
|
||||
highLimit: null,
|
||||
lowLimit: null,
|
||||
highDelay: null,
|
||||
@ -36,20 +36,35 @@ const formState = ref({
|
||||
notices: [],
|
||||
});
|
||||
|
||||
let scheme = yup.object({
|
||||
const form = ref(null);
|
||||
const formState = ref(initialFormState());
|
||||
|
||||
/** 將數字欄位統一做「可空值」轉換:空字串/undefined/null -> null,其餘轉 number */
|
||||
const numNullable = () =>
|
||||
yup
|
||||
.number()
|
||||
.transform((value, originalValue) =>
|
||||
originalValue === "" || originalValue === undefined || originalValue === null
|
||||
? null
|
||||
: value
|
||||
)
|
||||
.nullable();
|
||||
|
||||
// ---- 驗證規則:上下限/延遲一律非必填 ----
|
||||
const scheme = yup.object({
|
||||
device_number: yup.string().required(t("button.required")),
|
||||
points: yup.string().required(t("button.required")),
|
||||
factor: yup.number().nullable(),
|
||||
enable: yup.number().required(),
|
||||
highLimit: yup.number().nullable(),
|
||||
lowLimit: yup.number().nullable(),
|
||||
highDelay: yup.number().nullable(),
|
||||
lowDelay: yup.number().nullable(),
|
||||
factor: numNullable(),
|
||||
enable: numNullable().required(),
|
||||
delay: numNullable(),
|
||||
highLimit: numNullable(),
|
||||
lowLimit: numNullable(),
|
||||
highDelay: numNullable(),
|
||||
lowDelay: numNullable(),
|
||||
// alarm_value 如不需驗證可不放 schema;若要限制型別可在此補上
|
||||
});
|
||||
|
||||
const { formErrorMsg, handleSubmit, handleErrorReset } = useFormErrorMessage(
|
||||
scheme.value
|
||||
);
|
||||
const { formErrorMsg, handleSubmit, handleErrorReset } = useFormErrorMessage(scheme);
|
||||
|
||||
const SaveCheckAuth = ref([]);
|
||||
const factorNum = ref(1);
|
||||
@ -58,15 +73,30 @@ watch(
|
||||
() => props.editRecord,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
// 將不存在或空字串的數字欄位正規化為 null,避免編輯時被當作「必填」
|
||||
const normalize = (v) =>
|
||||
v === "" || v === undefined ? null : v;
|
||||
|
||||
formState.value = {
|
||||
...initialFormState(),
|
||||
...newValue,
|
||||
delay: normalize(newValue.delay),
|
||||
highLimit: normalize(newValue.highLimit),
|
||||
lowLimit: normalize(newValue.lowLimit),
|
||||
highDelay: normalize(newValue.highDelay),
|
||||
lowDelay: normalize(newValue.lowDelay),
|
||||
};
|
||||
console.log('formState.value',formState.value);
|
||||
|
||||
SaveCheckAuth.value = newValue.notices ? [...newValue.notices] : [];
|
||||
|
||||
SaveCheckAuth.value = Array.isArray(newValue.notices)
|
||||
? [...newValue.notices]
|
||||
: newValue.notices
|
||||
? [newValue.notices]
|
||||
: [];
|
||||
|
||||
if (newValue.factor) {
|
||||
onFactorsChange(newValue.factor);
|
||||
} else {
|
||||
factorNum.value = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,7 +111,9 @@ const onNoticesChange = (value, checked) => {
|
||||
if (SaveCheckAuth.value.length === 1 && SaveCheckAuth.value[0] === "") {
|
||||
SaveCheckAuth.value = [];
|
||||
}
|
||||
SaveCheckAuth.value = [...SaveCheckAuth.value, value];
|
||||
if (!SaveCheckAuth.value.includes(value)) {
|
||||
SaveCheckAuth.value = [...SaveCheckAuth.value, value];
|
||||
}
|
||||
} else {
|
||||
SaveCheckAuth.value = SaveCheckAuth.value.filter((v) => v !== value);
|
||||
}
|
||||
@ -96,6 +128,7 @@ const onOk = async () => {
|
||||
device_name_tag: searchParams.value?.subSys_id,
|
||||
notices: SaveCheckAuth.value ? SaveCheckAuth.value : [],
|
||||
});
|
||||
|
||||
if (res.isSuccess) {
|
||||
props.getData();
|
||||
closeModal();
|
||||
@ -105,10 +138,11 @@ const onOk = async () => {
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
formState.value = {};
|
||||
formState.value = initialFormState();
|
||||
SaveCheckAuth.value = [];
|
||||
factorNum.value = 1;
|
||||
handleErrorReset();
|
||||
props.onCancel();
|
||||
factorNum.value = 1;
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -134,12 +168,11 @@ const closeModal = () => {
|
||||
:options="OptionsData.devList"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.device_name") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
{{ formErrorMsg.device_number }}
|
||||
</span></template
|
||||
>
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">{{ formErrorMsg.device_number }}</span>
|
||||
</template>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
:value="formState"
|
||||
class="my-2"
|
||||
@ -149,12 +182,11 @@ const closeModal = () => {
|
||||
:options="OptionsData.alarmPoints"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.item") }}</template>
|
||||
<template #bottomLeft
|
||||
><span class="text-error text-base">
|
||||
{{ formErrorMsg.points }}
|
||||
</span></template
|
||||
>
|
||||
<template #bottomLeft>
|
||||
<span class="text-error text-base">{{ formErrorMsg.points }}</span>
|
||||
</template>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
:value="formState"
|
||||
class="my-2"
|
||||
@ -166,84 +198,63 @@ const closeModal = () => {
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.qualifications") }}</template>
|
||||
</Select>
|
||||
|
||||
<RadioGroup
|
||||
class="my-2"
|
||||
name="enable"
|
||||
:value="formState"
|
||||
:items="[
|
||||
{
|
||||
key: 1,
|
||||
value: 1,
|
||||
title: $t('alert.enable'),
|
||||
},
|
||||
{
|
||||
key: 0,
|
||||
value: 0,
|
||||
title: $t('alert.not_enabled'),
|
||||
},
|
||||
{ key: 1, value: 1, title: $t('alert.enable') },
|
||||
{ key: 0, value: 0, title: $t('alert.not_enabled') },
|
||||
]"
|
||||
:required="true"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.status") }}</template>
|
||||
<template #topLeft>{{ $t('alert.status') }}</template>
|
||||
</RadioGroup>
|
||||
|
||||
<template v-if="factorNum == 1">
|
||||
<InputNumber :value="formState" class="my-2" name="delay">
|
||||
<template #topLeft>{{ $t("alert.delay") }}</template>
|
||||
<template #topLeft>{{ $t('alert.delay') }}</template>
|
||||
</InputNumber>
|
||||
<span class="text-error text-base ml-1">{{ formErrorMsg.delay }}</span>
|
||||
</template>
|
||||
|
||||
<template v-if="factorNum == 2">
|
||||
<div class="flex gap-4 w-full">
|
||||
<InputNumber :value="formState" class="my-2" name="highLimit">
|
||||
<template #topLeft>{{ $t("alert.upper_limit") }}(>=)</template>
|
||||
<template #topLeft>{{ $t('alert.upper_limit') }}(>=)</template>
|
||||
</InputNumber>
|
||||
<InputNumber :value="formState" class="my-2" name="lowLimit">
|
||||
<template #topLeft>{{ $t("alert.lower_limit") }}(<=)</template>
|
||||
<template #topLeft>{{ $t('alert.lower_limit') }}(<=)</template>
|
||||
</InputNumber>
|
||||
</div>
|
||||
<div class="flex gap-4 w-full -mt-2">
|
||||
<span class="text-error text-base flex-1 ml-1">{{ formErrorMsg.highLimit }}</span>
|
||||
<span class="text-error text-base flex-1 ml-1">{{ formErrorMsg.lowLimit }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 w-full">
|
||||
<InputNumber :value="formState" class="my-2" name="highDelay">
|
||||
<template #topLeft>{{ $t("alert.highDelay") }}</template>
|
||||
<template #topLeft>{{ $t('alert.highDelay') }}</template>
|
||||
</InputNumber>
|
||||
<InputNumber :value="formState" class="my-2" name="lowDelay">
|
||||
<template #topLeft>{{ $t("alert.lowDelay") }}</template>
|
||||
<template #topLeft>{{ $t('alert.lowDelay') }}</template>
|
||||
</InputNumber>
|
||||
</div>
|
||||
<div class="flex gap-4 w-full -mt-2">
|
||||
<span class="text-error text-base flex-1 ml-1">{{ formErrorMsg.highDelay }}</span>
|
||||
<span class="text-error text-base flex-1 ml-1">{{ formErrorMsg.lowDelay }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="factorNum == 3">
|
||||
<Input :value="formState" class="my-2" name="alarm_value">
|
||||
<template #topLeft>{{ $t("alert.warning_value") }}</template>
|
||||
<template #topLeft>{{ $t('alert.warning_value') }}</template>
|
||||
</Input>
|
||||
</template>
|
||||
<!-- <Select
|
||||
:value="formState"
|
||||
class="my-2"
|
||||
selectClass="border-info focus-within:border-info"
|
||||
name="schedule_id"
|
||||
Attribute="schedule_name"
|
||||
:options="timesList"
|
||||
>
|
||||
<template #topLeft>{{ $t("alert.warning_time") }}</template>
|
||||
<template #topRight
|
||||
><button
|
||||
v-if="formState.schedule_id"
|
||||
class="text-base btn-text-without-border"
|
||||
@click="
|
||||
() => {
|
||||
formState.schedule_id = null;
|
||||
}
|
||||
"
|
||||
>
|
||||
<font-awesome-icon
|
||||
:icon="['fas', 'times']"
|
||||
class="text-[#a5abb1] me-1"
|
||||
/>{{ $t("alert.clear") }}
|
||||
</button>
|
||||
</template>
|
||||
</Select> -->
|
||||
|
||||
<div class="w-full mt-5">
|
||||
<p class="text-light text-lg ml-1">
|
||||
{{ $t("alert.warning_method") }}
|
||||
</p>
|
||||
<p class="text-light text-lg ml-1">{{ $t('alert.warning_method') }}</p>
|
||||
<AlertNoticesTable
|
||||
:SaveCheckAuth="SaveCheckAuth"
|
||||
:NoticeData="noticeList"
|
||||
@ -252,19 +263,12 @@ const closeModal = () => {
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<template #modalAction>
|
||||
<button
|
||||
type="reset"
|
||||
class="btn btn-outline-success mr-2"
|
||||
@click.prevent="closeModal"
|
||||
>
|
||||
<button type="reset" class="btn btn-outline-success mr-2" @click.prevent="closeModal">
|
||||
{{ $t("button.cancel") }}
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-outline-success"
|
||||
@click.prevent="onOk"
|
||||
>
|
||||
<button type="submit" class="btn btn-outline-success" @click.prevent="onOk">
|
||||
{{ $t("button.submit") }}
|
||||
</button>
|
||||
</template>
|
||||
|
@ -5,38 +5,51 @@ import DashboardSysCard from "./components/DashboardSysCard.vue";
|
||||
import DashboardProduct from "./components/DashboardProduct.vue";
|
||||
import DashboardProductComplete from "./components/DashboardProductComplete.vue";
|
||||
import DashboardIndoor from "./components/DashboardIndoor.vue";
|
||||
// import DashboardRefrigTemp from "./components/DashboardRefrigTemp.vue";
|
||||
// import DashboardIndoorTemp from "./components/DashboardIndoorTemp.vue";
|
||||
import DashboardElectricity from "./components/DashboardElectricity.vue";
|
||||
import DashboardEmission from "./components/DashboardEmission.vue";
|
||||
import DashboardAlert from "./components/DashboardAlert.vue";
|
||||
import DashboardRefrig from "./components/DashboardRefrig.vue";
|
||||
|
||||
import { computed, inject, ref, watch, onMounted, onUnmounted } from "vue";
|
||||
import useBuildingStore from "@/stores/useBuildingStore";
|
||||
import { getSystemDevices, getSystemRealTime } from "@/apis/system";
|
||||
import DashboardRefrig from "./components/DashboardRefrig.vue";
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 引入 getSystemConfig
|
||||
import { getSystemConfig } from "@/apis/system";
|
||||
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const buildingStore = useBuildingStore();
|
||||
|
||||
const subscribeData = ref([]);
|
||||
const systemData = ref({});
|
||||
let intervalId = null;
|
||||
|
||||
const productVisible = ref(false); // 產品產量儀表是否顯示
|
||||
const productCompleteVisible = ref(false); // 今日達成率是否顯示
|
||||
const productVisible = ref(false);
|
||||
const productCompleteVisible = ref(false);
|
||||
|
||||
// 開始定時器
|
||||
const startInterval = () => {
|
||||
// 清除之前的定時器(如果存在)
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
// 冷凍空調卡片顯示狀態(預設 false)
|
||||
const showRefrigeration = ref(false);
|
||||
|
||||
// 讀取系統配置
|
||||
const loadSystemConfig = async () => {
|
||||
const building_guid = buildingStore.selectedBuilding?.building_guid;
|
||||
if (!building_guid) {
|
||||
showRefrigeration.value = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await getSystemConfig(building_guid);
|
||||
const data = res?.data ?? res;
|
||||
showRefrigeration.value = !!data?.show_refrigeration;
|
||||
} catch (err) {
|
||||
console.error("[Dashboard] getSystemConfig error:", err);
|
||||
showRefrigeration.value = false; // 失敗時保守處理:不顯示
|
||||
}
|
||||
|
||||
// 每5秒呼叫一次 getData
|
||||
intervalId = setInterval(() => {
|
||||
getData();
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
// 取得設備資料
|
||||
const getData = async () => {
|
||||
const res = await getSystemDevices({
|
||||
building_guid: buildingStore.selectedBuilding?.building_guid,
|
||||
@ -45,20 +58,16 @@ const getData = async () => {
|
||||
subscribeData.value = res.data;
|
||||
console.log("devices", subscribeData.value);
|
||||
|
||||
// 轉換資料格式
|
||||
const transformedData = {};
|
||||
|
||||
subscribeData.value.forEach((floor) => {
|
||||
if (floor.device_list && floor.device_list.length > 0) {
|
||||
const fullUrl = floor.floor_map_name;
|
||||
const uuid = fullUrl ? fullUrl.replace(/\.svg$/, "") : "";
|
||||
transformedData[uuid] = floor.device_list.map((device) => {
|
||||
// 解析座標
|
||||
const coordinates = JSON.parse(device.device_coordinate || "[0,0]");
|
||||
const x = coordinates[0];
|
||||
const y = coordinates[1];
|
||||
|
||||
// 決定設備狀態和顏色
|
||||
let state = "Online";
|
||||
let bgColor = device.device_normal_color;
|
||||
|
||||
@ -78,10 +87,10 @@ const getData = async () => {
|
||||
x,
|
||||
y,
|
||||
{
|
||||
device_number: device.device_number || "", // 設備編號
|
||||
device_coordinate: device.device_coordinate || "", // 設備座標
|
||||
device_number: device.device_number || "",
|
||||
device_coordinate: device.device_coordinate || "",
|
||||
device_image_url: device.device_image_url,
|
||||
full_name: device.full_name, // 設備名稱
|
||||
full_name: device.full_name,
|
||||
main_id: device.main_id,
|
||||
points: device.points || [],
|
||||
floor: floor.full_name,
|
||||
@ -112,24 +121,32 @@ const getData = async () => {
|
||||
systemData.value = transformedData;
|
||||
};
|
||||
|
||||
// 每 5 秒輪詢設備資料
|
||||
const startInterval = () => {
|
||||
if (intervalId) clearInterval(intervalId);
|
||||
intervalId = setInterval(() => {
|
||||
getData();
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
// 當切換建物時:同時載入系統設定 + 設備資料
|
||||
watch(
|
||||
() => buildingStore.selectedBuilding,
|
||||
(newBuilding) => {
|
||||
async (newBuilding) => {
|
||||
if (newBuilding) {
|
||||
await loadSystemConfig(); // 先載設定(避免先渲染出不該顯示的卡片)
|
||||
getData();
|
||||
startInterval();
|
||||
} else {
|
||||
showRefrigeration.value = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 組件卸載時清除定時器
|
||||
// 卸載時清除定時器
|
||||
onUnmounted(() => {
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
if (intervalId) clearInterval(intervalId);
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -141,7 +158,9 @@ onUnmounted(() => {
|
||||
<div class="flex flex-col gap-5">
|
||||
<DashboardIndoor />
|
||||
</div>
|
||||
<div class="flex flex-col gap-5">
|
||||
|
||||
<!-- 依 show_refrigeration 決定是否渲染 -->
|
||||
<div class="flex flex-col gap-5" v-if="showRefrigeration">
|
||||
<DashboardRefrig />
|
||||
</div>
|
||||
</div>
|
||||
@ -152,9 +171,7 @@ onUnmounted(() => {
|
||||
<DashboardFloorBar />
|
||||
<DashboardEffectScatter :data="systemData" />
|
||||
</div>
|
||||
<!-- <div class="order-2 w-full lg:hidden my-3">
|
||||
<DashboardSysCard :data="systemData" />
|
||||
</div> -->
|
||||
|
||||
<div
|
||||
class="order-last w-full lg:w-1/4 flex flex-col justify-start border-dashboard z-20 gap-12"
|
||||
>
|
||||
|
@ -10,7 +10,10 @@ import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const { searchParams, changeParams } = useSearchParam();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
|
@ -1,60 +1,105 @@
|
||||
<script setup>
|
||||
// Tab 切換仍然緩慢 → 加上「快取 + 動畫關閉 + 更小抽樣 + 輕量 setOption」
|
||||
// 1) 先用快取立即顯示,再背景刷新(體感超快)。
|
||||
// 2) 關閉 ECharts 動畫、縮短 update 動畫時間,減少重排成本。
|
||||
// 3) 抽樣點從 30 → 20,計算更輕。
|
||||
// 4) Tab 切換不重啟輪詢,避免重設計時器造成 jank。
|
||||
|
||||
import LineChart from "@/components/chart/LineChart.vue";
|
||||
import { SECOND_CHART_COLOR } from "@/constant";
|
||||
import dayjs from "dayjs";
|
||||
import { ref, watch, onUnmounted, computed } from "vue";
|
||||
import { ref, watch, onUnmounted, computed, nextTick } from "vue";
|
||||
import useActiveBtn from "@/hooks/useActiveBtn";
|
||||
import { getDashboardTemp } from "@/apis/dashboard";
|
||||
import useSearchParams from "@/hooks/useSearchParam";
|
||||
import useBuildingStore from "@/stores/useBuildingStore";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { searchParams } = useSearchParams();
|
||||
const buildingStore = useBuildingStore();
|
||||
const timeoutTimer = ref(null); // 定時器參考
|
||||
|
||||
// --- UI:溫/濕度切換狀態 ---
|
||||
const { items, changeActiveBtn, setItems, selectedBtn } = useActiveBtn();
|
||||
const currentOptionType = ref(1); // 1 = 溫度、2 = 濕度
|
||||
|
||||
// --- 資料與顯示控制 ---
|
||||
const allTempData = ref([]);
|
||||
const currentOptionType = ref(1); // 當前顯示類型:1 = 溫度,2 = 濕度
|
||||
const noData = ref(false); // 無資料顯示控制
|
||||
const noData = ref(false);
|
||||
const indoorChartRef = ref(null);
|
||||
|
||||
// 確認是否有資料,無則不呼叫 getDashboardTemp 也不顯示 chart
|
||||
watch(
|
||||
() => buildingStore.selectedBuilding?.building_guid,
|
||||
async (guid) => {
|
||||
if (!guid) return;
|
||||
// --- 計時器與請求序列控制 ---
|
||||
const POLL_MS = 60000; // 每 60 秒輪詢
|
||||
const timeoutTimer = ref(null);
|
||||
let lastAcceptedSeq = 0; // 最新被接受的請求序號
|
||||
let seqCounter = 0; // 連增序號,避免併發覆蓋
|
||||
|
||||
await buildingStore.getSysConfig(guid);
|
||||
const showRoom = buildingStore.sysConfig?.value?.show_room;
|
||||
function clearPolling() {
|
||||
if (timeoutTimer.value) {
|
||||
clearInterval(timeoutTimer.value);
|
||||
timeoutTimer.value = null;
|
||||
}
|
||||
}
|
||||
function startPolling() {
|
||||
if (timeoutTimer.value) return; // 不要重複啟動
|
||||
timeoutTimer.value = setInterval(() => safeGetData(false), POLL_MS);
|
||||
}
|
||||
|
||||
if (timeoutTimer.value) clearInterval(timeoutTimer.value);
|
||||
// --- 簡易快取(大樓 + 類型) ---
|
||||
const cache = new Map();
|
||||
const cacheKey = (guid, opt) => `${guid}__${opt}`;
|
||||
function writeCache(guid, opt, data) {
|
||||
cache.set(cacheKey(guid, opt), data);
|
||||
}
|
||||
function readCache(guid, opt) {
|
||||
return cache.get(cacheKey(guid, opt));
|
||||
}
|
||||
|
||||
if (showRoom === false) {
|
||||
noData.value = true;
|
||||
return; // 不呼叫 getData
|
||||
}
|
||||
// 只接受最後一筆回應的取數封裝(並寫入快取)
|
||||
async function safeGetData(force = true) {
|
||||
const buildingGuid = buildingStore.selectedBuilding?.building_guid;
|
||||
if (!buildingGuid) return;
|
||||
|
||||
// 允許顯示圖表+呼叫資料
|
||||
noData.value = false;
|
||||
getData();
|
||||
timeoutTimer.value = setInterval(getData, 60000); // 每分鐘自動更新
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
const mySeq = ++seqCounter; // 本次請求的序號
|
||||
|
||||
// 預設圖表設定
|
||||
try {
|
||||
const res = await getDashboardTemp({
|
||||
building_guid: buildingGuid,
|
||||
tempOption: 1, // 室溫區域
|
||||
timeInterval: 1,
|
||||
option: currentOptionType.value,
|
||||
});
|
||||
|
||||
if (mySeq < lastAcceptedSeq) return; // 舊回應丟棄
|
||||
lastAcceptedSeq = mySeq;
|
||||
|
||||
const key = "室溫";
|
||||
const data = res?.isSuccess ? res.data?.[key] ?? [] : [];
|
||||
|
||||
allTempData.value = data;
|
||||
noData.value = data.length === 0;
|
||||
|
||||
writeCache(buildingGuid, currentOptionType.value, data);
|
||||
} catch (err) {
|
||||
if (mySeq < lastAcceptedSeq) return; // 舊錯誤丟棄
|
||||
console.error("getDashboardTemp error", err);
|
||||
allTempData.value = [];
|
||||
noData.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 預設圖表設定:關閉動畫以縮短切換延遲
|
||||
const defaultChartOption = ref({
|
||||
animation: false,
|
||||
animationDuration: 0,
|
||||
animationDurationUpdate: 150,
|
||||
animationEasingUpdate: "linear",
|
||||
tooltip: { trigger: "axis" },
|
||||
legend: {
|
||||
data: [],
|
||||
top: 0, // 靠最上方
|
||||
top: 0,
|
||||
textStyle: { color: "#ffffff", fontSize: 12 },
|
||||
},
|
||||
grid: {
|
||||
top: "35%",
|
||||
top: "35%",
|
||||
left: "0%",
|
||||
right: "0%",
|
||||
bottom: "0%",
|
||||
@ -74,129 +119,143 @@ const defaultChartOption = ref({
|
||||
series: [],
|
||||
});
|
||||
|
||||
const getData = async () => {
|
||||
const buildingGuid = buildingStore.selectedBuilding?.building_guid;
|
||||
if (!buildingGuid) return;
|
||||
|
||||
try {
|
||||
const res = await getDashboardTemp({
|
||||
building_guid: buildingGuid,
|
||||
tempOption: 1, // 室溫區域
|
||||
timeInterval: 1,
|
||||
option: currentOptionType.value,
|
||||
});
|
||||
|
||||
const key = "室溫";
|
||||
allTempData.value = res.isSuccess ? res.data?.[key] ?? [] : [];
|
||||
noData.value = allTempData.value.length === 0;
|
||||
} catch (e) {
|
||||
console.error("getDashboardTemp error", e);
|
||||
allTempData.value = [];
|
||||
noData.value = true;
|
||||
// 設定資料點顯示數量(更小抽樣,預設 20)
|
||||
function sampleData(data = [], maxCount = 20) {
|
||||
const len = data.length;
|
||||
if (len <= maxCount) return data;
|
||||
const sampled = [];
|
||||
const step = (len - 1) / (maxCount - 1);
|
||||
for (let i = 0; i < maxCount; i++) {
|
||||
const index = Math.round(i * step);
|
||||
sampled.push(data[index]);
|
||||
}
|
||||
};
|
||||
return sampled;
|
||||
}
|
||||
|
||||
// 溫度與濕度切換按鈕
|
||||
// 多語系切換時更新按鈕文字
|
||||
const buttonItems = computed(() => [
|
||||
{ key: 1, title: t("dashboard.temperature"), active: true },
|
||||
{ key: 2, title: t("dashboard.humidity"), active: false },
|
||||
]);
|
||||
|
||||
// 多語系切換時更新按鈕文字
|
||||
watch(
|
||||
() => locale.value,
|
||||
() => setItems(buttonItems.value),
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 切換溫度/濕度按鈕後更新資料與啟動定時器
|
||||
// 切換溫度/濕度按鈕
|
||||
// 切換溫/濕度:
|
||||
// 1) 先讀快取直接畫(立即回饋)
|
||||
// 2) 再觸發安全取數刷新
|
||||
watch(
|
||||
selectedBtn,
|
||||
(newVal) => {
|
||||
if ([1, 2].includes(newVal?.key)) {
|
||||
currentOptionType.value = newVal.key;
|
||||
() => selectedBtn.value?.key,
|
||||
async (key) => {
|
||||
if (!(key === 1 || key === 2)) return;
|
||||
currentOptionType.value = key;
|
||||
|
||||
// 再次確認 show_room 為 true 才重新取資料
|
||||
if (buildingStore.sysConfig?.value?.show_room) {
|
||||
getData();
|
||||
if (timeoutTimer.value) clearInterval(timeoutTimer.value);
|
||||
timeoutTimer.value = setInterval(getData, 60000);
|
||||
}
|
||||
const guid = buildingStore.selectedBuilding?.building_guid;
|
||||
if (!guid || buildingStore.sysConfig?.value?.show_room === false) return;
|
||||
|
||||
const cached = readCache(guid, key);
|
||||
if (cached) {
|
||||
allTempData.value = cached;
|
||||
noData.value = cached.length === 0;
|
||||
// 用 nextTick 確保 DOM/Chart 就緒再 setOption(體感更順)
|
||||
await nextTick();
|
||||
applyToChart(cached);
|
||||
}
|
||||
|
||||
// 背景刷新最新資料(回來後仍會覆蓋)
|
||||
safeGetData(false);
|
||||
// ⚠ 不重啟輪詢,避免 timer 抖動
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 設定資料點顯示數量
|
||||
function sampleData(data = [], maxCount = 30) {
|
||||
const len = data.length;
|
||||
if (len <= maxCount) return data;
|
||||
// 監看建築切換:統一流程(取消舊輪詢 → 讀取配置 → 先用快取 → 再取數 → 啟動輪詢)
|
||||
watch(
|
||||
() => buildingStore.selectedBuilding?.building_guid,
|
||||
async (guid) => {
|
||||
if (!guid) return;
|
||||
|
||||
const sampled = [];
|
||||
const step = (len - 1) / (maxCount - 1);
|
||||
clearPolling();
|
||||
lastAcceptedSeq = 0;
|
||||
seqCounter = 0;
|
||||
|
||||
for (let i = 0; i < maxCount; i++) {
|
||||
const index = Math.round(i * step);
|
||||
sampled.push(data[index]);
|
||||
}
|
||||
await buildingStore.getSysConfig(guid);
|
||||
const showRoom = buildingStore.sysConfig?.value?.show_room;
|
||||
|
||||
return sampled;
|
||||
if (showRoom === false) {
|
||||
noData.value = true;
|
||||
return; // 不取資料、不顯示圖
|
||||
}
|
||||
|
||||
noData.value = false;
|
||||
|
||||
const cached = readCache(guid, currentOptionType.value);
|
||||
if (cached) {
|
||||
allTempData.value = cached;
|
||||
noData.value = cached.length === 0;
|
||||
await nextTick();
|
||||
applyToChart(cached);
|
||||
}
|
||||
|
||||
await safeGetData();
|
||||
startPolling();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 將資料套到圖表(輕量 setOption,關閉動畫)
|
||||
function applyToChart(newVal) {
|
||||
const chart = indoorChartRef.value?.chart;
|
||||
if (!chart || !newVal?.length) return;
|
||||
|
||||
const firstValid = newVal.find((d) => d.data?.length);
|
||||
if (!firstValid) return;
|
||||
|
||||
const sampledXAxis = sampleData(firstValid.data).map(({ time }) =>
|
||||
dayjs(time).format("HH:mm:ss")
|
||||
);
|
||||
|
||||
const series = newVal.map((d, i) => ({
|
||||
name: d.full_name,
|
||||
type: "line",
|
||||
data: sampleData(d.data).map(({ value }) => value),
|
||||
showSymbol: false,
|
||||
// 關閉單序列動畫
|
||||
animation: false,
|
||||
itemStyle: { color: SECOND_CHART_COLOR[i % SECOND_CHART_COLOR.length] },
|
||||
}));
|
||||
|
||||
const vals = series.flatMap((s) => s.data).filter((v) => v != null);
|
||||
if (!vals.length) return;
|
||||
|
||||
chart.setOption(
|
||||
{
|
||||
animation: false,
|
||||
animationDurationUpdate: 150,
|
||||
animationEasingUpdate: "linear",
|
||||
legend: { data: newVal.map((d) => d.full_name) },
|
||||
xAxis: { data: sampledXAxis },
|
||||
yAxis: {
|
||||
min: Math.floor(Math.min(...vals)) - 1,
|
||||
max: Math.ceil(Math.max(...vals)) + 1,
|
||||
},
|
||||
series,
|
||||
},
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// 更新圖表資料
|
||||
watch(
|
||||
allTempData,
|
||||
(newVal) => {
|
||||
if (!newVal?.length || !indoorChartRef.value?.chart) return;
|
||||
// 資料變動 → 更新圖表(不 deep)
|
||||
watch(allTempData, (newVal) => {
|
||||
applyToChart(newVal);
|
||||
});
|
||||
|
||||
const firstValid = newVal.find((d) => d.data?.length);
|
||||
if (!firstValid) return;
|
||||
|
||||
const sampledXAxis = sampleData(firstValid.data).map(({ time }) =>
|
||||
dayjs(time).format("HH:mm:ss")
|
||||
);
|
||||
|
||||
const allValues = newVal
|
||||
.flatMap((d) => sampleData(d.data))
|
||||
.map((d) => d.value)
|
||||
.filter((v) => v != null);
|
||||
|
||||
if (!allValues.length) return;
|
||||
|
||||
const minVal = Math.min(...allValues);
|
||||
const maxVal = Math.max(...allValues);
|
||||
|
||||
const yMin = Math.floor(minVal) - 1;
|
||||
const yMax = Math.ceil(maxVal) + 1;
|
||||
|
||||
indoorChartRef.value.chart.setOption({
|
||||
legend: {
|
||||
data: newVal.map((d) => d.full_name),
|
||||
},
|
||||
xAxis: {
|
||||
data: sampledXAxis,
|
||||
},
|
||||
yAxis: {
|
||||
min: yMin,
|
||||
max: yMax,
|
||||
},
|
||||
series: newVal.map((d, i) => ({
|
||||
name: d.full_name,
|
||||
type: "line",
|
||||
data: sampleData(d.data).map(({ value }) => value),
|
||||
showSymbol: false,
|
||||
itemStyle: {
|
||||
color: SECOND_CHART_COLOR[i % SECOND_CHART_COLOR.length],
|
||||
},
|
||||
})),
|
||||
});
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
// 離開元件時清除定時器
|
||||
onUnmounted(() => {
|
||||
if (timeoutTimer.value) clearInterval(timeoutTimer.value);
|
||||
clearPolling();
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -204,18 +263,21 @@ onUnmounted(() => {
|
||||
<h3 class="text-info text-xl text-center">
|
||||
{{ $t("dashboard.indoor_chart") }}
|
||||
</h3>
|
||||
|
||||
<div class="w-full flex justify-center items-center relative">
|
||||
<ButtonConnectedGroup
|
||||
:items="items"
|
||||
:onclick="(e, item) => changeActiveBtn(item)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="noData"
|
||||
class="text-center text-white text-lg min-h-[260px] flex items-center justify-center"
|
||||
>
|
||||
{{ $t("dashboard.no_data") }}
|
||||
</div>
|
||||
|
||||
<LineChart
|
||||
v-if="!noData"
|
||||
id="dashboard_other_real_temp"
|
||||
|
@ -2,7 +2,10 @@
|
||||
import { ref, computed } from "vue";
|
||||
import useSearchParam from "@/hooks/useSearchParam";
|
||||
const { searchParams, changeParams } = useSearchParam();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
|
@ -8,7 +8,10 @@ import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const { openToast, cancelToastOpen } = inject("app_toast");
|
||||
const { sidebar_data } = inject("current_dir");
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -8,7 +8,10 @@ import useSearchParam from "@/hooks/useSearchParam";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const { openToast, cancelToastOpen } = inject("app_toast");
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { searchParams } = useSearchParam();
|
||||
|
||||
const { dataSource, openModal, updateEditRecord, search, tableLoading } =
|
||||
|
@ -12,7 +12,10 @@ import Select from "@/components/customUI/Select.vue";
|
||||
import SearchSelect from "@/components/customUI/SearchSelect.vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const props = defineProps({
|
||||
editRecord: Object,
|
||||
|
@ -70,7 +70,10 @@ import { getSystemDevices } from "@/apis/system";
|
||||
import { setRtspEnable } from "@/apis/rtsp"; // 已移除 setSambaDirectory
|
||||
import useActiveBtn from "@/hooks/useActiveBtn";
|
||||
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const DEFAULT_MONITOR_URL =
|
||||
"http://192.168.0.219:8026/?url=rtsp://admin02:mjmAdmin_99@192.168.0.200:554/stream1?tcp";
|
||||
|
||||
|
@ -7,7 +7,10 @@ import { useI18n } from "vue-i18n";
|
||||
import useBuildingStore from "@/stores/useBuildingStore";
|
||||
|
||||
const storeBuild = useBuildingStore();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { t } = useI18n();
|
||||
const { openToast, cancelToastOpen } = inject("app_toast");
|
||||
|
||||
|
@ -11,7 +11,10 @@ const { currentFloor, subscribeData } = inject("system_deviceList");
|
||||
const { getCurrentInfoModalData, selected_dbid } = inject(
|
||||
"system_selectedDevice"
|
||||
);
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const asset_floor_chart = ref(null);
|
||||
const sameOption = {
|
||||
|
@ -8,7 +8,10 @@ const { getCurrentInfoModalData, selected_dbid } = inject(
|
||||
const { subscribeData } = inject("system_deviceList");
|
||||
|
||||
const { showData } = useSystemShowData();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
|
||||
const fitToView = (forge_dbid, spriteDbId) => {
|
||||
selected_dbid.value = [forge_dbid, spriteDbId];
|
||||
|
@ -2,7 +2,10 @@
|
||||
import { computed, inject, watch, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// 本地開發 FILE_BASEURL
|
||||
// const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||
// docker 部屬 FILE_BASEURL (兩者視部屬方式擇一保留)
|
||||
const FILE_BASEURL = window.env?.VITE_FILE_API_BASEURL;
|
||||
const { selectedDeviceCog } = inject("system_selectedDevice");
|
||||
const imgData = ref([]);
|
||||
|
||||
|
@ -13,15 +13,17 @@ export default defineConfig({
|
||||
outDir: "./dist",
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
"/upload": {
|
||||
target: "https://ibms-Empower.production.mjmtech.com.tw",
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
// 本地開發:有 server
|
||||
// docker 部屬:註解整個 server
|
||||
// server: {
|
||||
// proxy: {
|
||||
// "/upload": {
|
||||
// target: "https://ibms-Empower.production.mjmtech.com.tw",
|
||||
// changeOrigin: true,
|
||||
// secure: false,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
plugins: [
|
||||
vue(),
|
||||
Components({
|
||||
|
Loading…
Reference in New Issue
Block a user