diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d85cfb1..0a4d550 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -echo "window.env = { VITE_API_BASEURL: '${VITE_API_BASEURL}', VITE_FILE_API_BASEURL: '${VITE_FILE_API_BASEURL}', VITE_MQTT_BASEURL: '${VITE_MQTT_BASEURL}', VITE_APP_TITLE: '${VITE_APP_TITLE}' };" > /usr/share/nginx/html/env.js +echo "window.env = { VITE_API_BASEURL: '${VITE_API_BASEURL}', VITE_FILE_API_BASEURL: '${VITE_FILE_API_BASEURL}', VITE_APP_TITLE: '${VITE_APP_TITLE}' };" > /usr/share/nginx/html/env.js sed -i "s|.*|${VITE_APP_TITLE}|g" /usr/share/nginx/html/index.html sed -i "s| { code: res.code, }); }; + +export const postMqttTopic = async ({ iotTag, Topic }) => { + const res = await instance.post(POST_MQTT_TOPIC_API, { iotTag, Topic }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const postMqttTopicStop = async ({ iotTag, Topic }) => { + const res = await instance.post(POST_MQTT_TOPIC_STOP_API, { iotTag, Topic }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; diff --git a/src/apis/headquarters/api.js b/src/apis/headquarters/api.js index 517ce4f..351ef49 100644 --- a/src/apis/headquarters/api.js +++ b/src/apis/headquarters/api.js @@ -3,4 +3,6 @@ export const GET_SITES_SYSTEM_ENERGY_COST_RANK_API = `/api/energy-manager/all-si export const GET_SITES_SYSTEM_ENERGY_COST_TREND_API = `/api/energy-manager/all-site/energy-cost-trend`; export const GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API = `/api/energy-manager/all-site/energy-cost-growth-rate`; +export const GET_USER_API = `/api/user/user-list`; + diff --git a/src/apis/headquarters/index.js b/src/apis/headquarters/index.js index a54c757..83a61e1 100644 --- a/src/apis/headquarters/index.js +++ b/src/apis/headquarters/index.js @@ -3,6 +3,7 @@ import { GET_SITES_SYSTEM_ENERGY_COST_RANK_API, GET_SITES_SYSTEM_ENERGY_COST_TREND_API, GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API, + GET_USER_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apiHandler"; @@ -37,6 +38,25 @@ export const getSystemEnergyCostTrend = async (building_ids) => { export const getSystemEnergyCostGrowth = async (building_ids) => { const res = await instance.get(GET_SITES_SYSTEM_ENERGY_COST_GROWTH_API, building_ids); + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +} + +export const getUserList = async (params = {}) => { + const { + page = 1, + pageSize = 9999999 + } = params; + + const requestData = { + Page: page, + PageSize: pageSize + }; + + const res = await instance.post(GET_USER_API, requestData); + return apihandler(res.code, res.data, { msg: res.msg, code: res.code, diff --git a/src/config/cn.json b/src/config/cn.json index 2a661ef..51672fa 100644 --- a/src/config/cn.json +++ b/src/config/cn.json @@ -23,6 +23,7 @@ "graphManagement": "图资管理", "AssetManagement": "资产管理", "accountManagement": "帐号管理", + "UserManagement": "帐号管理", "Setting": "系统设定", "energy_analysis": "能源分析", "consumption_report": "用电报表", @@ -430,6 +431,7 @@ }, "msg": { "sure_to_delete": "是否确认删除该项目?", + "is_headquarters": "该帐号为总部帐号,是否仍要删除该项目?", "sure_to_delete_permanent": "是否确认永久删除该项目?", "delete_success": "删除成功", "delete_failed": "删除失败", diff --git a/src/config/tw.json b/src/config/tw.json index d07a7bb..7d3ba29 100644 --- a/src/config/tw.json +++ b/src/config/tw.json @@ -23,6 +23,7 @@ "graphManagement": "圖資管理", "AssetManagement": "資產管理", "accountManagement": "帳號管理", + "UserManagement": "帳號管理", "Setting": "系統設定", "energy_analysis": "能耗分析", "consumption_report": "用電報表", @@ -430,6 +431,7 @@ }, "msg": { "sure_to_delete": "是否確認刪除該項目?", + "is_headquarters": "該帳號為總部帳號,是否仍要刪除該項目?", "sure_to_delete_permanent": "是否確認永久刪除該項目?", "delete_success": "刪除成功", "delete_failed": "刪除失敗", diff --git a/src/config/us.json b/src/config/us.json index 371f346..41a6b87 100644 --- a/src/config/us.json +++ b/src/config/us.json @@ -23,8 +23,9 @@ "graphManagement": "Graph", "AssetManagement": "Devices", "accountManagement": "Account", + "UserManagement": "Account", "Setting": "Setting", - "energy_analysis": "Energy Analysis", + "energy_analysis": "Energy Analysis", "consumption_report": "Consumption Report", "chart_analysis": "Chart Analysis", "historical_curve": "Historical Curve", @@ -430,6 +431,7 @@ }, "msg": { "sure_to_delete": "Are you sure to delete this item?", + "is_headquarters": "This account is a headquarters account. Are you sure you want to delete this item?", "sure_to_delete_permanent": "Are you sure you want to permanently delete this item?", "delete_success": "Delete successfully", "delete_failed": "Delete failed", diff --git a/src/hooks/forge/useForgeHeatmap.js b/src/hooks/forge/useForgeHeatmap.js index 7ae588c..81e159d 100644 --- a/src/hooks/forge/useForgeHeatmap.js +++ b/src/hooks/forge/useForgeHeatmap.js @@ -18,6 +18,7 @@ export default function useForgeHeatmap() { //create the heatmap function getSensorValue(device, sensorType, pointData) { + console.log("heatmap", device, realtimeData.value); const dev = realtimeData.value.find( ({ device_number }) => device_number === device.id ); diff --git a/src/router/index.js b/src/router/index.js index 5558e27..f1c3588 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -10,6 +10,7 @@ import ProductSetting from "@/views/productSetting/ProductSetting.vue"; import EnergyManagement from "@/views/energyManagement/EnergyManagement.vue"; import SettingManagement from "@/views/setting/SettingManagement.vue"; import HeadquartersManagement from "@/views/headquarters/HeadquartersManagement.vue"; +import UserManagement from "@/views/headquarters/HeadquartersAccountManagement.vue"; import Login from "@/views/login/Login.vue"; import useUserInfoStore from "@/stores/useUserInfoStore"; import useBuildingStore from "@/stores/useBuildingStore"; @@ -97,6 +98,11 @@ const router = createRouter({ name: "headquarters", component: HeadquartersManagement, }, + { + path: "/UserManagement", + name: "UserManagement", + component: UserManagement, + }, { path: "/mytestfile/mjm", name: "mytestfile", diff --git a/src/views/AssetManagement/AssetManagement.vue b/src/views/AssetManagement/AssetManagement.vue index acf2863..6fcc882 100644 --- a/src/views/AssetManagement/AssetManagement.vue +++ b/src/views/AssetManagement/AssetManagement.vue @@ -12,13 +12,23 @@ const { searchParams, changeParams } = useSearchParam(); const companyOptions = ref([]); const iotSchemaOptions = ref([]); const elecTypeOptions = ref([]); +const iotSchemaTag = ref(""); // 儲存 IOT Schema 的 tagIoT const getCompany = async () => { const res = await getOperationCompanyList(); companyOptions.value = res.data.map((d) => ({ ...d, key: d.id })); }; const getIOTSchemaOptions = async (id) => { const res = await getIOTSchema(Number(id)); - iotSchemaOptions.value = res.data.map((d) => ({ ...d, key: d.id })); + const data = res.data || []; + + iotSchemaOptions.value = data.map((d) => ({ ...d, key: d.id })); + + // 取出第一筆的 tagIoT,提供給最深層元件使用 + if (data.length > 0 && data[0].tagIoT) { + iotSchemaTag.value = data[0].tagIoT; + } else { + iotSchemaTag.value = ""; + } }; const getElecType = async () => { const res = await getElecTypeList(); @@ -51,6 +61,7 @@ provide("asset_modal_options", { elecTypeOptions, departmentList, floors, + iotSchemaTag }); diff --git a/src/views/AssetManagement/components/AssetTable.vue b/src/views/AssetManagement/components/AssetTable.vue index 4ec838b..5fd279b 100644 --- a/src/views/AssetManagement/components/AssetTable.vue +++ b/src/views/AssetManagement/components/AssetTable.vue @@ -146,13 +146,15 @@ const edit = async (id) => { // changeParams({ ...searchParams.value, main_id: record.id }); const res = await getAssetSingle(id); if (res.isSuccess) { - res.data.oriFile = res.data.oriFile.map((file, index) => ({ - ...file, - key: index, - src: file.file_url, - name: file.orgName, - ext: file.saveName.split(".")[file.saveName.split(".").length - 1], - })); + res.data.oriFile = res.data.oriFile + .filter((file) => file.saveName) + .map((file, index) => ({ + ...file, + key: index, + src: file.file_url, + name: file.orgName, + ext: file.saveName.split(".")[file.saveName.split(".").length - 1], + })); res.data.sub_device = res.data.sub_device?.map( ({ device_number, points }) => ({ device_number, diff --git a/src/views/AssetManagement/components/AssetTableModalLeftInfoGraph.vue b/src/views/AssetManagement/components/AssetTableModalLeftInfoGraph.vue index fdf15d6..adcbac8 100644 --- a/src/views/AssetManagement/components/AssetTableModalLeftInfoGraph.vue +++ b/src/views/AssetManagement/components/AssetTableModalLeftInfoGraph.vue @@ -32,7 +32,9 @@ const getMenuData = async () => { const getData = async (id) => { const res = await getGraphData(id); if (res.isSuccess) { - dataSource.value = res.data.map((d) => ({ ...d, key: d.id })); + dataSource.value = res.data + .filter((d) => d.oriSavName) + .map((d) => ({ ...d, key: d.id })); } }; diff --git a/src/views/AssetManagement/components/AssetTableModalLeftInfoMQTT.vue b/src/views/AssetManagement/components/AssetTableModalLeftInfoMQTT.vue index 299452f..a7c79eb 100644 --- a/src/views/AssetManagement/components/AssetTableModalLeftInfoMQTT.vue +++ b/src/views/AssetManagement/components/AssetTableModalLeftInfoMQTT.vue @@ -1,98 +1,122 @@ + + + + diff --git a/src/views/system/System.vue b/src/views/system/System.vue index 06f44c8..c105153 100644 --- a/src/views/system/System.vue +++ b/src/views/system/System.vue @@ -191,7 +191,7 @@ const getAllDeviceRealtime = async () => { const res = await getSystemRealTime( subscribeData.value.map((d) => d.device_number) ); - console.log(res.data); + console.log("realtimeData",res.data); realtimeData.value = res.data; }; await fetchData(); // 立即執行一次