|
|
@@ -41,30 +41,35 @@
|
|
|
</div>
|
|
|
</div> -->
|
|
|
<div class="top-bar">
|
|
|
+ <div class="back-btn" @click="router.back">
|
|
|
+ <img src="@/assets/rollback.png" />
|
|
|
+ <span>返回</span>
|
|
|
+ <div class="company-name">{{ companyName }}</div>
|
|
|
+ </div>
|
|
|
<!-- <el-button @click="toJson">tojson</el-button> -->
|
|
|
- <el-upload
|
|
|
- class="avatar-uploader flex justify-center items-center"
|
|
|
- :action="actionUrl"
|
|
|
- :show-file-list="false"
|
|
|
- :on-success="handleAvatarSuccess"
|
|
|
- :before-upload="handleBeforeUpload"
|
|
|
- :with-credentials="true"
|
|
|
- name="file"
|
|
|
- :data="{ companyId, deleteFileName: bgImg }"
|
|
|
- :headers="getHeaders()"
|
|
|
- >
|
|
|
- <el-button :icon="Refresh" :disabled="!hasBg"> 替换照片 </el-button>
|
|
|
- </el-upload>
|
|
|
+ <div class="operation-btns">
|
|
|
+ <el-upload
|
|
|
+ class="avatar-uploader"
|
|
|
+ :action="actionUrl"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess"
|
|
|
+ :before-upload="handleBeforeUpload"
|
|
|
+ :with-credentials="true"
|
|
|
+ name="file"
|
|
|
+ :data="{ companyId, deleteFileName: bgImg }"
|
|
|
+ :headers="getHeaders()"
|
|
|
+ >
|
|
|
+ <el-button :icon="Refresh"> 替换照片 </el-button>
|
|
|
+ </el-upload>
|
|
|
|
|
|
- <el-button :icon="Refresh" @click="clearLayout"> 重置 </el-button>
|
|
|
+ <el-button :icon="Refresh" @click="clearLayout"> 重置 </el-button>
|
|
|
|
|
|
- <el-button @click="handleSave" type="primary" :disabled="!companyId && !label">
|
|
|
- 保存
|
|
|
- </el-button>
|
|
|
+ <el-button @click="handleSave" type="primary" :disabled="!companyId"> 保存 </el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="paint-tool flex">
|
|
|
+ <div class="paint-tool">
|
|
|
<div class="camera-list">
|
|
|
<div>
|
|
|
<span class="label-text flex">车间列表:</span>
|
|
|
@@ -100,7 +105,6 @@
|
|
|
ref="mapContainerRef"
|
|
|
:is-mobile-view="isMobileView"
|
|
|
:module-code="labelMouduleCode"
|
|
|
- :stageSize="mapContainerStageSize"
|
|
|
@on-open="openConfig"
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -166,7 +170,7 @@
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
import { ElMessage, ElInput, ElSwitch, ElMessageBox } from 'element-plus';
|
|
|
import { onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
|
|
- import { WorkShopInfoItem, getWorkshopListApi } from '@/api/scene/scene';
|
|
|
+ import { getWorkshopListApi } from '@/api/scene/scene';
|
|
|
import { computed } from 'vue';
|
|
|
import { Search, Refresh, ArrowLeftBold } from '@element-plus/icons-vue';
|
|
|
import usePageConfig from './usePageConfig';
|
|
|
@@ -178,7 +182,7 @@
|
|
|
import urlJoin from 'url-join';
|
|
|
import { useGlobSetting } from '@/hooks/setting';
|
|
|
import { getHeaders } from '@/utils/http/axios';
|
|
|
- import { companyLayoutType, LayoutType, ShopType } from '@/types/page-config/type';
|
|
|
+ import { CompanyLayoutType, LayoutType, ShopType } from '@/types/page-config/type';
|
|
|
import ShopTagEditArea from './component/ShopTagEditArea.vue';
|
|
|
|
|
|
const mapEditor = useMapEditor();
|
|
|
@@ -201,11 +205,13 @@
|
|
|
const isMobileView = ref(false);
|
|
|
|
|
|
const companyId = ref<number>();
|
|
|
+ const companyName = ref<string>();
|
|
|
+ const viewType = ref<number>();
|
|
|
|
|
|
const shopList = ref<ShopType[]>([]); // 车间列表
|
|
|
|
|
|
- // mapContainer宽高
|
|
|
- const mapContainerStageSize = reactive({ height: 0, width: 777 });
|
|
|
+ // // mapContainer宽高
|
|
|
+ // const mapContainerStageSize = reactive({ height: 0, width: 777 });
|
|
|
|
|
|
const handleBeforeUpload = (rawFile) => {
|
|
|
// if (!selectedCompany.value || !label.value) {
|
|
|
@@ -279,8 +285,6 @@
|
|
|
/** ------------- */
|
|
|
|
|
|
const handleAvatarSuccess = (e) => {
|
|
|
- console.log('handleAvatarSuccess', e);
|
|
|
-
|
|
|
bgImg.value = e.data;
|
|
|
hasBg.value = true;
|
|
|
addBg();
|
|
|
@@ -307,10 +311,9 @@
|
|
|
shopList.value = res;
|
|
|
});
|
|
|
|
|
|
- getCompanyLayoutApi().then((res) => {
|
|
|
- console.log('res', res);
|
|
|
- console.log('layout', JSON.parse(res.layout));
|
|
|
-
|
|
|
+ getCompanyLayoutApi({
|
|
|
+ companyId: companyId.value!,
|
|
|
+ }).then((res) => {
|
|
|
if (!res) {
|
|
|
layoutId.value = undefined;
|
|
|
return;
|
|
|
@@ -354,6 +357,12 @@
|
|
|
return shopList.value?.filter((x) => x.name?.includes(k));
|
|
|
});
|
|
|
|
|
|
+ const setNodePosition = (positionX = 50, positionY = 50) => {
|
|
|
+ if (addedShops.value.find((item) => item.x === positionX && item.y === positionY)) {
|
|
|
+ return setNodePosition(positionX, positionY + 50);
|
|
|
+ } else return { positionX, positionY };
|
|
|
+ };
|
|
|
+
|
|
|
const handleAddShop = (shop: ShopType) => {
|
|
|
//如果已经存在车间,则禁止加入
|
|
|
const existingCamera = addedShops.value.find((item) => item.id === shop.id);
|
|
|
@@ -365,10 +374,13 @@
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ const nodePosition = setNodePosition();
|
|
|
+
|
|
|
const shopNode = {
|
|
|
...shop,
|
|
|
- x: 50,
|
|
|
- y: 50,
|
|
|
+ x: nodePosition.positionX,
|
|
|
+ y: nodePosition.positionY,
|
|
|
scaleX: 1,
|
|
|
scaleY: 1,
|
|
|
bgColor: 'rgba(58, 170, 209, 1)',
|
|
|
@@ -381,8 +393,11 @@
|
|
|
};
|
|
|
|
|
|
const handleSave = () => {
|
|
|
- const json = mapContainerRef.value?.getLayout();
|
|
|
- const layout = calcLayout(json);
|
|
|
+ const { json, scale } = mapContainerRef.value?.getLayout();
|
|
|
+ console.log('layout json', JSON.parse(json));
|
|
|
+ console.log('scale', scale);
|
|
|
+ const layout = hasBg.value === false ? '' : calcLayout(json, scale);
|
|
|
+ if (hasBg.value) console.log('Calc layout', JSON.parse(layout));
|
|
|
const param = {
|
|
|
layout,
|
|
|
targetId: companyId.value || 2,
|
|
|
@@ -394,9 +409,11 @@
|
|
|
ElMessage.success('保存成功');
|
|
|
});
|
|
|
} else {
|
|
|
- updateCompanyLayout({ ...param, id: layoutId.value }).then((_res) => {
|
|
|
- ElMessage.success('更新成功');
|
|
|
- });
|
|
|
+ updateCompanyLayout({ ...param, id: layoutId.value, viewType: viewType.value! }).then(
|
|
|
+ (_res) => {
|
|
|
+ ElMessage.success('更新成功');
|
|
|
+ },
|
|
|
+ );
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -410,6 +427,8 @@
|
|
|
|
|
|
if (routerParams.companyId) {
|
|
|
companyId.value = Number(routerParams.companyId);
|
|
|
+ companyName.value = String(routerParams.companyName);
|
|
|
+ viewType.value = Number(routerParams.viewType);
|
|
|
}
|
|
|
// if (routerParams.labelId) {
|
|
|
// label.value = Number(routerParams.labelId);
|
|
|
@@ -421,10 +440,10 @@
|
|
|
getShopContent();
|
|
|
}
|
|
|
|
|
|
- console.log('clientHeight', document.getElementById('shopEditContainer')?.clientHeight);
|
|
|
- console.log('clientWidth', document.getElementById('shopEditContainer')?.clientWidth);
|
|
|
- mapContainerStageSize.height = document.getElementById('shopEditContainer')?.clientHeight!;
|
|
|
- mapContainerStageSize.width = document.getElementById('shopEditContainer')?.clientWidth!;
|
|
|
+ // console.log('clientHeight', document.getElementById('shopEditContainer')?.clientHeight);
|
|
|
+ // console.log('clientWidth', document.getElementById('shopEditContainer')?.clientWidth);
|
|
|
+ // mapContainerStageSize.height = document.getElementById('shopEditContainer')?.clientHeight!;
|
|
|
+ // mapContainerStageSize.width = document.getElementById('shopEditContainer')?.clientWidth!;
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
@@ -470,6 +489,8 @@
|
|
|
position: relative;
|
|
|
height: calc(100vh - 138px);
|
|
|
margin-top: 2px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
}
|
|
|
|
|
|
.camera-list {
|
|
|
@@ -579,11 +600,35 @@
|
|
|
}
|
|
|
|
|
|
.top-bar {
|
|
|
- width: 350px;
|
|
|
+ width: 100%;
|
|
|
display: flex;
|
|
|
- // justify-content: space-around;
|
|
|
- .el-button {
|
|
|
- margin-left: 20px;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ .back-btn {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ img {
|
|
|
+ width: 14px;
|
|
|
+ height: 14px;
|
|
|
+ }
|
|
|
+ span {
|
|
|
+ line-height: 14px;
|
|
|
+ }
|
|
|
+ .company-name {
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 14px;
|
|
|
+ color: rgba(0, 0, 0, 0.85);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .operation-btns {
|
|
|
+ width: 350px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .el-button {
|
|
|
+ margin-left: 20px;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|