feat: 设备列表静态交互完成

dev-deviceSetting
donghao 1 year ago
parent e37535cbbe
commit ed023b30e3

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-12 14:35:28
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-02-23 10:46:54
* @LastEditTime: 2024-02-28 10:37:06
* @FilePath: \General-AI-Platform-Web-Client\index.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -25,7 +25,6 @@
/>
<script src="https://threejs.org/build/three.js"></script>
<!-- fabric引入 -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.4.6/fabric.min.js"></script>
<script>
window.process = {};
</script>

File diff suppressed because one or more lines are too long

@ -2,11 +2,11 @@
//
.head_info {
padding: 0 17px;
padding: 4px 17px 0;
.bg_icon {
width: 12px;
height: 22px;
background: #2de6ff;
background: url("@/assets/dataScreen/common/subTitleIcon.svg") no-repeat;
border-radius: 0px 0px 0px 0px;
margin-right: 12px;
}

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-02-26 17:24:07
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-02-27 14:29:15
* @LastEditTime: 2024-02-28 09:48:45
* @FilePath: \General-AI-Platform-Web-Client\src\components\DsBox\src\dsBox2.tsx
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -88,7 +88,10 @@ export default defineComponent({
{/* 标题 */}
{props.title && (
<div
class="head_info flex align-middle items-center"
class={[
props.bgTitleClass,
"head_info flex align-middle items-center"
]}
style={{
height: "50px",
width: options.width,

@ -99,7 +99,7 @@ onMounted(() => {
// bgNav
background: url("@/assets/dataScreen/common/bgNav.svg") no-repeat;
background-size: cover;
width: 100vw;
width: 100%;
height: 64px;
.left {

@ -90,12 +90,16 @@
}
}
.bg_banner_center {
// .bg_banner_center {
// width: 587px;
// height: 592px;
// background: url("@/assets/computePower/banner.png");
// background-repeat: no-repeat;
// background-size: contain;
// }
.device-icon-box {
width: 587px;
height: 592px;
background: url("@/assets/computePower/banner.png");
background-repeat: no-repeat;
background-size: contain;
}
.banner_right {

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-19 09:22:30
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-02-26 17:12:10
* @LastEditTime: 2024-02-28 10:53:36
* @FilePath: \General-AI-Platform-Web-Client\src\views\computePowerAllocation\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -122,9 +122,12 @@ const poolsData: ComputePowerPoolItem[] = [
<span class="ff1">苏胜天算力资源池</span>
<div class="title_side title_right" />
</div>
<div class="bg_banner_center">{{ null }}</div>
<!-- <div class="bg_banner_center">{{ null }}</div> -->
<AnimationPic
class="device-icon-box"
:value="computePowerAllocationIcon"
/>
</div>
<!-- <AnimationPic :value="computePowerAllocationIcon" /> -->
<!-- <AnimationPic class="device-icon-box" value="deviceClassify(device)" /> -->
<div class="flex items-center align-middle right_box banner_item_box">
<DsBox1 title="算力配置" type="w2h2">

@ -2,6 +2,9 @@
padding: 32px;
.bg_device_left {
background: url("@/assets/dataScreen/common/deviceListLeft.svg") no-repeat;
.bg_device_left_head {
padding-left: 26px;
}
}
.bg_device_right {
@ -18,7 +21,7 @@
/* 设备列表 */
.deviceList_params {
position: absolute;
left: 24px;
left: 26px;
top: 24px;
.el-input {
background-color: #00183e;

@ -2,13 +2,16 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-02-23 10:14:31
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-02-27 16:05:40
* @LastEditTime: 2024-02-28 13:23:26
* @FilePath: \General-AI-Platform-Web-Client\src\pages\dataScreen\views\device\deviceList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { fabric } from "fabric";
import { bgImageData } from "./testData/fabricImageSvg";
import { currJson } from "./testData/fabricDeviceList";
import { deviceStatusData, deviceTypeOptions } from "./testData/deviceListData";
import { DsBox2 } from "@/components/DsBox";
import DetailCard from "./modules/detailCard.vue";
@ -26,7 +29,7 @@ const clipPathData = ref<{
width: number;
height: number;
}>({
width: 1378, //
width: 1380, //
height: 728 //
});
const canvasRef = ref<any>(null);
@ -34,11 +37,11 @@ const cvs = ref<any>(null);
const currentDetail = ref<Record<string, any>>({
deviceType: "1", // 1 1 2 2
id: "1001", // id
status: "watchOnline", //
status: "0", //
deviceStatus: "启用",
deviceName: "工业摄像头01", //
deviceCode: "CRM001",
deviceLocation: "生产厂商: 南京苏胜天信息科技有限公司",
deviceLocation: "南京苏胜天信息科技有限公司",
deviceParams: "89hufd",
deviceCategory: "摄像设备",
diviceGroup: "组1",
@ -49,6 +52,30 @@ const currentDetail = ref<Record<string, any>>({
}
});
//
function closeSelectedModel(targetCvs?: any) {
let finalCvs = cvs;
if (targetCvs) {
finalCvs = targetCvs;
}
finalCvs.getObjects().forEach(item => {
// if (changeId.includes(item?.userProperty?.id)) {
const groupObject = item;
//
// canvasObject.setActiveObject(groupObject); // selectable
finalCvs.requestRenderAll();
//
// const objectsInGroup = groupObject.getObjects();
groupObject.item(0).item(6).set({
fill: ""
});
// groupObject.item(1).set({
// fill: "rgb(0,0,0)"
// });
finalCvs.renderAll();
});
}
function initCanvas() {
const canvasObject = new fabric.Canvas(canvasRef.value);
canvasObject.setBackgroundImage(
@ -61,6 +88,44 @@ function initCanvas() {
originY: "top"
}
);
canvasObject.loadFromJSON(JSON.stringify(currJson), () => {
canvasObject.renderAll();
// const groupObjectList = canvasObject.getObjects()
// const groupObject = canvasObject.getObjects()[0];
//
// console.log(groupObject, 'groupObject', canvasObject.getObjects());
//
// console.log(canvasObject, "targetObject");
canvasObject.on("mouse:down", event => {
//
const targetObject = event.target;
console.log(event, "targetObject");
// set_category_fk_id_open(false);
//
// if (targetObject && targetObject?.userProperty) {
// // setChangeId([targetObject?.userProperty?.id]);
// // setCurrentModelUserProperty(targetObject.userProperty);
// // set_category_fk_id_open(true);
// }
// //
if (targetObject) {
// setCurrentTargetObject(targetObject);
closeSelectedModel(canvasObject);
canvasObject.bringToFront(targetObject);
// console.log('mouse:down:', );
//
targetObject.item(0).item(6).set({
fill: "#00F0FF"
});
console.log(targetObject, "targetObject");
}
canvasObject.renderAll();
});
});
cvs.value = canvasObject;
console.log(canvasObject);
}
@ -73,7 +138,12 @@ onMounted(() => {
<template>
<div class="flex justify-between deviceList_wrap">
<div class="left">
<DsBox2 title="设备列表" type="w2h1" bgClass="bg_device_left">
<DsBox2
title="设备列表"
type="w2h1"
bgClass="bg_device_left"
bgTitleClass="bg_device_left_head"
>
<template #default>
<div
class="flex items-center justify-end w-full h-full device_left_box"

@ -0,0 +1,168 @@
import { fetchWatchGroupObjects } from "./fabricIcons";
// 模型状态 在线 离线 告警 故障
const startData: Record<string, any> = {
modelsList: [
{
deviceType: "1", // 模型类型 1 设备1 2 设备2
id: "1001", // 模型id
status: "1", //
deviceStatus: "启用",
deviceName: "工业摄像头01", // 模型名称
deviceCode: "CRM001",
deviceLocation: "南京苏胜天信息科技有限公司",
deviceParams: "89hufd",
deviceCategory: "摄像设备",
diviceGroup: "组1",
createTime: "2024-01-15 14:00",
baseInfo: {
left: 527.0215, // 相对x
top: 24.5797 // 相对y
}
},
{
deviceType: "1", // 模型类型 1 设备1 2 设备2
id: "1002", // 模型id
status: "0", // 模型状态 在线 离线 告警 故障
deviceName: "监控设备2", // 模型名称
deviceCode: "code1001",
deviceLocation: "客厅",
deviceParams: "设备参数",
deviceCategory: "控制器",
diviceGroup: "组1",
baseInfo: {
left: 397.0215, // 相对x
top: 444.5797 // 相对y
}
},
{
deviceType: "1", // 模型类型 1 设备1 2 设备2
id: "1003", // 模型id
status: "1", // 模型状态 在线 离线 告警 故障
deviceName: "监控设备2", // 模型名称
deviceCode: "code1001",
deviceLocation: "客厅",
deviceParams: "设备参数",
deviceCategory: "控制器",
diviceGroup: "组1",
baseInfo: {
left: 397.0215, // 相对x
top: 144.5797 // 相对y
}
},
{
deviceType: "1", // 模型类型 1 设备1 2 设备2
id: "1004", // 模型id
status: "2", // 模型状态 在线 离线 告警 故障
deviceName: "监控设备2", // 模型名称
deviceCode: "code1001",
deviceLocation: "客厅",
deviceParams: "设备参数",
deviceCategory: "控制器",
diviceGroup: "组1",
baseInfo: {
left: 297.0215, // 相对x
top: 644.5797 // 相对y
}
},
{
deviceType: "1", // 模型类型 1 设备1 2 设备2
id: "1005", // 模型id
status: "3", // 模型状态 在线 离线 告警 故障
deviceName: "监控设备2", // 模型名称
deviceCode: "code1001",
deviceLocation: "客厅",
deviceParams: "设备参数",
deviceCategory: "控制器",
diviceGroup: "组1",
baseInfo: {
left: 797.0215, // 相对x
top: 544.5797 // 相对y
}
}
]
};
// 生成100到1100之间的随机整数
// function generateRandomNumber(minNum, maxNum) {
// // 生成0到1之间的随机小数
// const randomFraction = Math.random();
// // 将随机小数映射到100到1100之间的范围
// const randomNumber = Math.floor(
// randomFraction * (maxNum - minNum + 1) + minNum
// );
// return randomNumber;
// }
// function initFabricRoomData() {
// for (let i = 0; i < 2; i++) {
// let currObjects = JSON.parse(JSON.stringify(startData.modelsList));
// currObjects = currObjects.map(item => {
// item.baseInfo = {
// left: generateRandomNumber(100, 1100),
// top: generateRandomNumber(100, 800)
// };
// return item;
// });
// startData.modelsList = startData.modelsList.concat(currObjects);
// }
// }
// initFabricRoomData();
const fabricRoomListData: Record<string, any>[] = [];
startData.modelsList.forEach((item: Record<string, any>) => {
const { baseInfo } = item;
fabricRoomListData.push(
JSON.parse(
JSON.stringify({
...fetchWatchGroupObjects(item),
...baseInfo,
userProperty: item,
selectable: false
})
)
);
});
export const currJson = {
version: "5.3.0",
objects: fabricRoomListData,
clipPath: {
type: "rect",
version: "5.3.0",
originX: "left",
originY: "top",
left: 0,
top: 0,
width: 1380,
height: 728,
fill: "rgba(255,255,255,1)",
stroke: null,
strokeWidth: 0,
strokeDashArray: null,
strokeLineCap: "butt",
strokeDashOffset: 0,
strokeLineJoin: "miter",
strokeUniform: false,
strokeMiterLimit: 4,
scaleX: 1,
scaleY: 1,
angle: 0,
flipX: false,
flipY: false,
opacity: 1,
shadow: null,
visible: true,
backgroundColor: "",
fillRule: "nonzero",
paintFirst: "fill",
globalCompositeOperation: "source-over",
skewX: 0,
skewY: 0,
rx: 0,
ry: 0,
selectable: false,
hasControls: true
}
};

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save