|
|
@@ -4,7 +4,7 @@
|
|
|
<div class="head-opt flex-1 flex justify-between items-center" style="margin-left: 0px">
|
|
|
<div>
|
|
|
<!-- <span>场景:</span> -->
|
|
|
- <el-select
|
|
|
+ <!-- <el-select
|
|
|
v-model="selectedCompany"
|
|
|
class="m-2"
|
|
|
placeholder="请选择相关公司"
|
|
|
@@ -17,9 +17,9 @@
|
|
|
:label="item.name"
|
|
|
:value="item.id"
|
|
|
/>
|
|
|
- </el-select>
|
|
|
+ </el-select> -->
|
|
|
</div>
|
|
|
- <div v-if="selectedCompany" style="display: flex">
|
|
|
+ <!-- <div v-if="selectedCompany" style="display: flex">
|
|
|
<div style="display: flex">
|
|
|
<div class="label-workshop" style="margin-left: 0px">选择标签:</div>
|
|
|
<div>
|
|
|
@@ -39,14 +39,8 @@
|
|
|
</el-radio-group></div
|
|
|
>
|
|
|
</div>
|
|
|
- <!-- <div v-if="false" style="display: flex">
|
|
|
- <div class="label-workshop" style="margin-left: 10px">是否开启移动端视角</div>
|
|
|
- <div>
|
|
|
- <el-switch v-model="isMobileView" style="margin-left: 10px" />
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
- </div>
|
|
|
- <div class="flex">
|
|
|
+ </div> -->
|
|
|
+ <div class="top-bar">
|
|
|
<!-- <el-button @click="toJson">tojson</el-button> -->
|
|
|
<el-upload
|
|
|
class="avatar-uploader flex justify-center items-center"
|
|
|
@@ -56,18 +50,16 @@
|
|
|
:before-upload="handleBeforeUpload"
|
|
|
:with-credentials="true"
|
|
|
name="file"
|
|
|
- :data="{ companyId: selectedCompany, labelId: label, deleteFileName: bgImg }"
|
|
|
+ :data="{ companyId, deleteFileName: bgImg }"
|
|
|
:headers="getHeaders()"
|
|
|
>
|
|
|
<el-button :icon="Refresh" :disabled="!hasBg"> 替换照片 </el-button>
|
|
|
</el-upload>
|
|
|
|
|
|
- <el-button
|
|
|
- @click="handleSave"
|
|
|
- style="margin-left: 40px"
|
|
|
- type="primary"
|
|
|
- :disabled="!selectedCompany && !label"
|
|
|
- >保存为布局
|
|
|
+ <el-button :icon="Refresh" @click="clearLayout"> 重置 </el-button>
|
|
|
+
|
|
|
+ <el-button @click="handleSave" type="primary" :disabled="!companyId && !label">
|
|
|
+ 保存
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -84,10 +76,10 @@
|
|
|
:suffix-icon="Search"
|
|
|
/>
|
|
|
</div>
|
|
|
- <span v-if="filterShopList.length == 0" class="ml-1" style="color: #3f3f3f">
|
|
|
+ <!-- <span v-if="filterShopList.length == 0" class="ml-1" style="color: #3f3f3f">
|
|
|
提示:请先选择相应公司和图片
|
|
|
- </span>
|
|
|
- <el-scrollbar v-else style="position: relative; height: calc(100% - 90px)">
|
|
|
+ </span> -->
|
|
|
+ <el-scrollbar style="position: relative; height: calc(100% - 90px)">
|
|
|
<div
|
|
|
v-for="item in filterShopList"
|
|
|
:key="item.code"
|
|
|
@@ -103,11 +95,12 @@
|
|
|
</el-scrollbar>
|
|
|
</div>
|
|
|
<div ref="drawContainer" id="drawContainer" class="draw-container">
|
|
|
- <div id="shopEditContainer" v-moveable:1>
|
|
|
+ <div id="shopEditContainer" v-moveable:1 class="shop-edit-container">
|
|
|
<MapContainer
|
|
|
ref="mapContainerRef"
|
|
|
:is-mobile-view="isMobileView"
|
|
|
:module-code="labelMouduleCode"
|
|
|
+ :stageSize="mapContainerStageSize"
|
|
|
@on-open="openConfig"
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -120,17 +113,20 @@
|
|
|
:on-success="handleAvatarSuccess"
|
|
|
:with-credentials="true"
|
|
|
name="file"
|
|
|
- :data="{ companyId: selectedCompany, labelId: label }"
|
|
|
+ :data="{ companyId }"
|
|
|
:headers="getHeaders()"
|
|
|
>
|
|
|
<img src="~@/assets/images/img-upload.png" />
|
|
|
</el-upload>
|
|
|
</div>
|
|
|
+ <div class="shop-tag-edit-area" v-if="hasBg">
|
|
|
+ <ShopTagEditArea @transformer-change="transformChange" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <el-tooltip
|
|
|
+ <!-- <el-tooltip
|
|
|
class="box-item position-tooltip"
|
|
|
effect="dark"
|
|
|
- content="显示侧边栏"
|
|
|
+ content="显示侧边栏"
|
|
|
:offset="12"
|
|
|
placement="left"
|
|
|
>
|
|
|
@@ -145,15 +141,15 @@
|
|
|
<el-icon class="left-icon" size="16px"><ArrowLeftBold /></el-icon>
|
|
|
<el-icon style="margin-top: 7px" size="16px"><ArrowLeftBold /></el-icon>
|
|
|
</div>
|
|
|
- </el-tooltip>
|
|
|
+ </el-tooltip> -->
|
|
|
|
|
|
- <ConfigDialog
|
|
|
+ <!-- <ConfigDialog
|
|
|
v-if="!isMobileView"
|
|
|
ref="configDrawer"
|
|
|
@on-close="onClose"
|
|
|
@transformer-change="transformChange"
|
|
|
class="drawer-position"
|
|
|
- />
|
|
|
+ /> -->
|
|
|
|
|
|
<ConfigFinish
|
|
|
:visible="visibleResult"
|
|
|
@@ -168,9 +164,9 @@
|
|
|
import ConfigDialog from './component/ConfigDrawer.vue';
|
|
|
import ConfigFinish from './component/ConfigFinish.vue';
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
- import { ElMessage, ElInput, ElSwitch } from 'element-plus';
|
|
|
- import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
|
- import { WorkShopInfoItem } from '@/types/scene/type.ts';
|
|
|
+ import { ElMessage, ElInput, ElSwitch, ElMessageBox } from 'element-plus';
|
|
|
+ import { onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
|
|
+ import { WorkShopInfoItem, getWorkshopListApi } from '@/api/scene/scene';
|
|
|
import { computed } from 'vue';
|
|
|
import { Search, Refresh, ArrowLeftBold } from '@element-plus/icons-vue';
|
|
|
import usePageConfig from './usePageConfig';
|
|
|
@@ -182,6 +178,8 @@
|
|
|
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 ShopTagEditArea from './component/ShopTagEditArea.vue';
|
|
|
|
|
|
const mapEditor = useMapEditor();
|
|
|
const { bgImg, addedShops, activeShopId, showShops } = storeToRefs(mapEditor);
|
|
|
@@ -190,7 +188,7 @@
|
|
|
const router = useRouter();
|
|
|
|
|
|
const pageConfig = usePageConfig();
|
|
|
- const { selectedCompany, scenesInfos, label, labelList, shopList, layoutId } = pageConfig;
|
|
|
+ const { scenesInfos, label, labelList, layoutId } = pageConfig;
|
|
|
const { urlPrefix } = useGlobSetting();
|
|
|
const drawContainer = ref<HTMLDivElement>();
|
|
|
const mapContainerRef = ref();
|
|
|
@@ -202,13 +200,20 @@
|
|
|
// 是否开启移动端视图
|
|
|
const isMobileView = ref(false);
|
|
|
|
|
|
+ const companyId = ref<number>();
|
|
|
+
|
|
|
+ const shopList = ref<ShopType[]>([]); // 车间列表
|
|
|
+
|
|
|
+ // mapContainer宽高
|
|
|
+ const mapContainerStageSize = reactive({ height: 0, width: 777 });
|
|
|
+
|
|
|
const handleBeforeUpload = (rawFile) => {
|
|
|
- if (!selectedCompany.value || !label.value) {
|
|
|
- ElMessage.error({
|
|
|
- message: '请先选择公司和标签',
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
+ // if (!selectedCompany.value || !label.value) {
|
|
|
+ // ElMessage.error({
|
|
|
+ // message: '请先选择公司和标签',
|
|
|
+ // });
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
if (
|
|
|
rawFile.type !== 'image/jpg' &&
|
|
|
rawFile.type !== 'image/jpeg' &&
|
|
|
@@ -236,7 +241,8 @@
|
|
|
};
|
|
|
|
|
|
const actionUrl = computed(() => {
|
|
|
- return urlJoin(urlPrefix, '/homepageConfig/updateCompanyPicture');
|
|
|
+ // return urlJoin(urlPrefix, '/homepageConfig/updateCompanyPicture');
|
|
|
+ return urlJoin(urlPrefix, '/admin/homepageConfig/uploadCompanyPicture');
|
|
|
});
|
|
|
|
|
|
watch(
|
|
|
@@ -273,6 +279,8 @@
|
|
|
/** ------------- */
|
|
|
|
|
|
const handleAvatarSuccess = (e) => {
|
|
|
+ console.log('handleAvatarSuccess', e);
|
|
|
+
|
|
|
bgImg.value = e.data;
|
|
|
hasBg.value = true;
|
|
|
addBg();
|
|
|
@@ -281,7 +289,7 @@
|
|
|
const labelMouduleCode = computed(() => {
|
|
|
return (
|
|
|
scenesInfos.value
|
|
|
- .find((item) => item.id === selectedCompany.value)
|
|
|
+ .find((item) => item.id === companyId.value)
|
|
|
?.labelModuleList.find((item) => item.sceneLabel.id === label.value)?.sceneModule.code ||
|
|
|
'default'
|
|
|
);
|
|
|
@@ -294,28 +302,42 @@
|
|
|
};
|
|
|
|
|
|
const getShopContent = () => {
|
|
|
- getCompanyLayoutApi({ companyId: selectedCompany.value || 2, labelId: label.value || 1 }).then(
|
|
|
- (res) => {
|
|
|
- if (!res) {
|
|
|
- layoutId.value = undefined;
|
|
|
- return;
|
|
|
- }
|
|
|
- layoutId.value = res.id;
|
|
|
- const layoutJSON = res.layout ? safeParse(res.layout) : null;
|
|
|
-
|
|
|
- if (!layoutJSON) {
|
|
|
- return;
|
|
|
- }
|
|
|
- hasBg.value = true;
|
|
|
- createMap(layoutJSON);
|
|
|
- },
|
|
|
- );
|
|
|
+ // getCompanyLayoutApi({ companyId: selectedCompany.value || 2 }).then((res) => {
|
|
|
+ getWorkshopListApi({ companyId: companyId.value! }).then((res) => {
|
|
|
+ shopList.value = res;
|
|
|
+ });
|
|
|
+
|
|
|
+ getCompanyLayoutApi().then((res) => {
|
|
|
+ console.log('res', res);
|
|
|
+ console.log('layout', JSON.parse(res.layout));
|
|
|
+
|
|
|
+ if (!res) {
|
|
|
+ layoutId.value = undefined;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ layoutId.value = res.id;
|
|
|
+ const layoutJSON = res.layout ? safeParse(res.layout) : null;
|
|
|
+
|
|
|
+ if (!layoutJSON) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ hasBg.value = true;
|
|
|
+ createMap(layoutJSON);
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
- const changeCompany = () => {
|
|
|
- label.value = undefined;
|
|
|
- resetMap();
|
|
|
- hasBg.value = false;
|
|
|
+ // const changeCompany = () => {
|
|
|
+ const clearLayout = () => {
|
|
|
+ // label.value = undefined;
|
|
|
+
|
|
|
+ ElMessageBox.confirm('是否重置当前设置?', '提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ resetMap();
|
|
|
+ hasBg.value = false;
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const handleKeyDown = (e) => {
|
|
|
@@ -326,29 +348,13 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- onMounted(() => {
|
|
|
- const routerParams = router.currentRoute.value.query;
|
|
|
- if (routerParams.companyId) {
|
|
|
- selectedCompany.value = Number(routerParams.companyId);
|
|
|
- }
|
|
|
- if (routerParams.labelId) {
|
|
|
- label.value = Number(routerParams.labelId);
|
|
|
- }
|
|
|
-
|
|
|
- window.addEventListener('keydown', handleKeyDown);
|
|
|
-
|
|
|
- if (selectedCompany.value && label.value) {
|
|
|
- getShopContent();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
const filterShopList = computed(() => {
|
|
|
const k = searchKey.value.trim();
|
|
|
if (!k) return shopList.value;
|
|
|
return shopList.value?.filter((x) => x.name?.includes(k));
|
|
|
});
|
|
|
|
|
|
- const handleAddShop = (shop: WorkShopInfoItem) => {
|
|
|
+ const handleAddShop = (shop: ShopType) => {
|
|
|
//如果已经存在车间,则禁止加入
|
|
|
const existingCamera = addedShops.value.find((item) => item.id === shop.id);
|
|
|
if (existingCamera) return;
|
|
|
@@ -371,7 +377,7 @@
|
|
|
posType: LabelPositionEnum.LEFT,
|
|
|
};
|
|
|
addShop(shopNode);
|
|
|
- dialogReopen();
|
|
|
+ // dialogReopen();
|
|
|
};
|
|
|
|
|
|
const handleSave = () => {
|
|
|
@@ -379,7 +385,7 @@
|
|
|
const layout = calcLayout(json);
|
|
|
const param = {
|
|
|
layout,
|
|
|
- targetId: selectedCompany.value || 2,
|
|
|
+ targetId: companyId.value || 2,
|
|
|
labelId: label.value || 1,
|
|
|
};
|
|
|
if (!layoutId.value) {
|
|
|
@@ -398,6 +404,28 @@
|
|
|
window.removeEventListener('keydown', handleKeyDown);
|
|
|
resetMap();
|
|
|
});
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ const routerParams = router.currentRoute.value.query;
|
|
|
+
|
|
|
+ if (routerParams.companyId) {
|
|
|
+ companyId.value = Number(routerParams.companyId);
|
|
|
+ }
|
|
|
+ // if (routerParams.labelId) {
|
|
|
+ // label.value = Number(routerParams.labelId);
|
|
|
+ // }
|
|
|
+
|
|
|
+ window.addEventListener('keydown', handleKeyDown);
|
|
|
+
|
|
|
+ if (companyId.value) {
|
|
|
+ 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!;
|
|
|
+ });
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@@ -490,10 +518,17 @@
|
|
|
}
|
|
|
|
|
|
.draw-container {
|
|
|
+ height: calc(100vh - 160px);
|
|
|
position: relative;
|
|
|
- width: calc(100% - 300px);
|
|
|
- margin: 20px;
|
|
|
+ width: calc(100% - 600px);
|
|
|
+ margin: 10px;
|
|
|
overflow: hidden;
|
|
|
+ border: 1px solid #1890ff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .shop-edit-container {
|
|
|
+ height: 100%;
|
|
|
+ border: 1px solid #ff7118;
|
|
|
}
|
|
|
|
|
|
.drawer-position {
|
|
|
@@ -543,6 +578,20 @@
|
|
|
z-index: 9999;
|
|
|
}
|
|
|
|
|
|
+ .top-bar {
|
|
|
+ width: 350px;
|
|
|
+ display: flex;
|
|
|
+ // justify-content: space-around;
|
|
|
+ .el-button {
|
|
|
+ margin-left: 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .shop-tag-edit-area {
|
|
|
+ width: 300px;
|
|
|
+ background-color: #ffffff;
|
|
|
+ }
|
|
|
+
|
|
|
:deep(.search-put .el-input__wrapper) {
|
|
|
background-color: #f0f2f5;
|
|
|
}
|