|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: donghao donghao@supervision.ltd
|
|
|
|
|
* @Date: 2024-08-02 10:52:32
|
|
|
|
|
* @LastEditors: donghao donghao@supervision.ltd
|
|
|
|
|
* @LastEditTime: 2024-08-15 17:11:29
|
|
|
|
|
* @LastEditTime: 2024-08-16 15:40:58
|
|
|
|
|
* @FilePath: \General-AI-Platform-Web-Client\src\views\deviceSetting\index.vue
|
|
|
|
|
* @Description: 设备点位管理设置
|
|
|
|
|
@ 交互说明
|
|
|
|
@ -16,6 +16,8 @@
|
|
|
|
|
// 设备设置
|
|
|
|
|
import DeviceAttr from "./components/deviceAttr.vue";
|
|
|
|
|
import DeviceSettingAdd from "./components/add.vue";
|
|
|
|
|
import DeviceSettingEdit from "./components/edit.vue";
|
|
|
|
|
|
|
|
|
|
import DeviceSelect from "./components/deviceSelect.vue";
|
|
|
|
|
import { IsDelete } from "@/components/Action";
|
|
|
|
|
import { usePointObject } from "./hooks/usePointObject";
|
|
|
|
@ -77,6 +79,8 @@ const { getPointObject } = usePointObject();
|
|
|
|
|
|
|
|
|
|
const pointList = ref([]);
|
|
|
|
|
const deviceSettingAddRef = ref("");
|
|
|
|
|
const deviceSettingEditRef = ref("");
|
|
|
|
|
|
|
|
|
|
const deviceSelectRef = ref("");
|
|
|
|
|
const activePointId = ref("");
|
|
|
|
|
const activePoint = ref({
|
|
|
|
@ -86,7 +90,7 @@ const deviceList = ref([]); // 所有设备列表
|
|
|
|
|
const currDeviceList = ref([]); // 当前点位下设备列表
|
|
|
|
|
const isDeleteVisible = ref(false);
|
|
|
|
|
// 插入文件绘制图
|
|
|
|
|
const refreshCanvas = () => {
|
|
|
|
|
const refreshCanvas = (isLoadDevice = true) => {
|
|
|
|
|
const currWorkSpace = document.getElementById("workspace");
|
|
|
|
|
canvasEditor.insertSvgFile(
|
|
|
|
|
getPointObject(toRaw(activePoint.value), {
|
|
|
|
@ -94,8 +98,7 @@ const refreshCanvas = () => {
|
|
|
|
|
height: currWorkSpace.clientHeight
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
fetchDeviceByPoint();
|
|
|
|
|
|
|
|
|
|
isLoadDevice && fetchDeviceByPoint();
|
|
|
|
|
console.log("插入文件");
|
|
|
|
|
};
|
|
|
|
|
// 初始化fabric&编辑器
|
|
|
|
@ -103,7 +106,10 @@ const initFabric = () => {
|
|
|
|
|
const canvas = new fabric.Canvas("canvas", {
|
|
|
|
|
fireRightClick: false, // 启用右键,button的数字为3
|
|
|
|
|
stopContextMenu: true, // 禁止默认右键菜单
|
|
|
|
|
controlsAboveOverlay: true // 超出clipPath后仍然展示控制条
|
|
|
|
|
controlsAboveOverlay: true, // 超出clipPath后仍然展示控制条
|
|
|
|
|
selectable: false,
|
|
|
|
|
hasControls: false,
|
|
|
|
|
selection: false
|
|
|
|
|
});
|
|
|
|
|
// 初始化编辑器
|
|
|
|
|
canvasEditor.init(canvas);
|
|
|
|
@ -128,9 +134,6 @@ const initFabric = () => {
|
|
|
|
|
canvasEditor.use(MaterialPlugin);
|
|
|
|
|
event.init(canvas);
|
|
|
|
|
state.showFabric = true;
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
refreshCanvas();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -167,6 +170,9 @@ async function fetchPointList() {
|
|
|
|
|
// ];
|
|
|
|
|
activePointId.value = pointList.value[0].id;
|
|
|
|
|
activePoint.value = pointList.value[0];
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
refreshCanvas();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 获取设备列表
|
|
|
|
|
async function fetchDeviceList() {
|
|
|
|
@ -200,14 +206,22 @@ function afterFinishAdd(record) {
|
|
|
|
|
activePoint.value = record;
|
|
|
|
|
console.log("afterFinishAdd", record);
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
refreshCanvas();
|
|
|
|
|
refreshCanvas(false); // 新增无需刷新获取当前点位下设备
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑点位
|
|
|
|
|
function editPoint() {
|
|
|
|
|
deviceSettingAddRef.value?.openDialog();
|
|
|
|
|
deviceSettingEditRef.value?.openDialog(toRaw(activePoint.value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 完成编辑点位后
|
|
|
|
|
function afterFinishEdit(record) {
|
|
|
|
|
console.log("afterFinishEdit", record);
|
|
|
|
|
|
|
|
|
|
// 手动修改点位,不额外刷新接口
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开始删除点位
|
|
|
|
|
function beforeDeletePoint() {
|
|
|
|
|
isDeleteVisible.value = true;
|
|
|
|
@ -278,54 +292,12 @@ async function addDevice(record) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //
|
|
|
|
|
// async function deleteDevice(record) {
|
|
|
|
|
// const resp = await deleteWorkshopDeviceApi({
|
|
|
|
|
// id: record.id
|
|
|
|
|
// });
|
|
|
|
|
// if (isSuccessApi(resp)) {
|
|
|
|
|
// isDeleteDeviceVisible.value = false;
|
|
|
|
|
// afterFinishDeleteDevice();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //
|
|
|
|
|
// async function updateDevice(record) {
|
|
|
|
|
// const resp = await updateWorkshopDeviceApi({
|
|
|
|
|
// id: record.id,
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 有点位了再初始化
|
|
|
|
|
watch(
|
|
|
|
|
() => pointList.value,
|
|
|
|
|
() => {
|
|
|
|
|
console.log("pointList", pointList);
|
|
|
|
|
if (pointList.value?.length) {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
initFabric();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// watch(
|
|
|
|
|
// () => activePoint.value,
|
|
|
|
|
// () => {
|
|
|
|
|
// console.log("activePoint", activePoint);
|
|
|
|
|
// if (activePoint.value?.id) {
|
|
|
|
|
// nextTick(() => {
|
|
|
|
|
// refreshCanvas();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
initFabric();
|
|
|
|
|
fetchPointList();
|
|
|
|
|
fetchDeviceList();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 发射全局事件
|
|
|
|
|
provide("fabric", fabric);
|
|
|
|
|
provide("event", event);
|
|
|
|
@ -413,6 +385,10 @@ provide("canvasEditor", canvasEditor);
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<DeviceSettingAdd ref="deviceSettingAddRef" @finishAdd="afterFinishAdd" />
|
|
|
|
|
<DeviceSettingEdit
|
|
|
|
|
ref="deviceSettingEditRef"
|
|
|
|
|
@finishEdit="afterFinishEdit"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|