179 lines
3.9 KiB
JavaScript
179 lines
3.9 KiB
JavaScript
import {
|
|
GET_DASHBOARD_INIT_API,
|
|
GET_DASHBOARD_DEVICE_API,
|
|
GET_DASHBOARD_PRODUCT_COMPLETE_API,
|
|
GET_DASHBOARD_TEMP_API,
|
|
GET_DASHBOARD_ROOM_TEMP_API,
|
|
GET_DASHBOARD_ENERGY_API,
|
|
POST_DASHBOARD_PRODUCT_TARGET_SETTING_API,
|
|
GET_DASHBOARD_PRODUCT_TARGET_SETTING_API,
|
|
GET_DASHBOARD_PRODUCT_HISTORY_API,
|
|
GET_DASHBOARD_ENERGY_INFO_API,
|
|
GET_DASHBOARD_ENERGY_COST_API,
|
|
GET_DASHBOARD_ALARMOPERATION_INFO_API,
|
|
} from "./api";
|
|
import instance from "@/util/request";
|
|
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, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardDevice = async ({ option }) => {
|
|
const res = await instance.post(GET_DASHBOARD_DEVICE_API, {
|
|
option: parseInt(option),
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardProductCompletion = async () => {
|
|
const res = await instance.post(GET_DASHBOARD_PRODUCT_COMPLETE_API);
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardEnergy = async () => {
|
|
const res = await instance.post(GET_DASHBOARD_ENERGY_API);
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardFormulaRoom = async ({ timeInterval, typeOption }) => {
|
|
const res = await instance.post(GET_DASHBOARD_ROOM_TEMP_API, {
|
|
timeInterval,
|
|
typeOption,
|
|
});
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardTemp = async ({
|
|
timeInterval,
|
|
tempOption,
|
|
typeOption = "",
|
|
}) => {
|
|
const res = typeOption
|
|
? await instance.post(GET_DASHBOARD_TEMP_API, {
|
|
timeInterval,
|
|
tempOption,
|
|
typeOption,
|
|
})
|
|
: await instance.post(GET_DASHBOARD_TEMP_API, {
|
|
timeInterval,
|
|
tempOption,
|
|
});
|
|
console.log(res);
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const postDashboardProductTarget = async ({ date, type, data }) => {
|
|
let formatData = [];
|
|
|
|
for (let [key, value] of Object.entries(data)) {
|
|
formatData.push({
|
|
name: key,
|
|
value,
|
|
});
|
|
}
|
|
|
|
const res = await instance.post(POST_DASHBOARD_PRODUCT_TARGET_SETTING_API, {
|
|
target: {
|
|
date,
|
|
type,
|
|
data: formatData,
|
|
},
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardProductTarget = async ({ date, type }) => {
|
|
const res = await instance.post(GET_DASHBOARD_PRODUCT_TARGET_SETTING_API, {
|
|
target: {
|
|
date,
|
|
type,
|
|
},
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getDashboardProductRecord = async ({ start_time, end_time }) => {
|
|
const res = await instance.post(GET_DASHBOARD_PRODUCT_HISTORY_API, {
|
|
start_time,
|
|
end_time,
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getEnergyInfo = async (building_guid) => {
|
|
const res = await instance.post(GET_DASHBOARD_ENERGY_INFO_API, {
|
|
building_guid,
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getEnergyCost = async ({
|
|
department_id,
|
|
floor_guid,
|
|
building_guid,
|
|
}) => {
|
|
const res = await instance.post(GET_DASHBOARD_ENERGY_COST_API, {
|
|
department_id,
|
|
floor_guid,
|
|
building_guid,
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|
|
|
|
export const getAlarmOperationInfo = async (building_guid) => {
|
|
const res = await instance.post(GET_DASHBOARD_ALARMOPERATION_INFO_API, {
|
|
building_guid,
|
|
});
|
|
|
|
return apihandler(res.code, res.data, {
|
|
msg: res.msg,
|
|
code: res.code,
|
|
});
|
|
};
|