Parcourir la source

新增配置文件,设置设备类的默认样式

yunxing il y a 4 ans
Parent
commit
87fea65a78

+ 1 - 7
public/index.html

@@ -7,15 +7,9 @@
         <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
         <link rel="stylesheet" href="//at.alicdn.com/t/font_2231660_v6l4r3hhhnp.css" />
         <title>博锐尚格科技股份有限公司--平面图编辑工具</title>
+        <script src="<%= BASE_URL %>systemConf.js"></script>
     </head>
     <body>
-        <noscript>
-            <strong
-                >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to
-                continue.</strong
-            >
-        </noscript>
         <div id="app"></div>
-        <!-- built files will be auto injected -->
     </body>
 </html>

+ 40 - 0
public/systemConf.js

@@ -0,0 +1,40 @@
+/**
+ * 项目配置文件
+ * @author yunxing
+ *
+ */
+// eslint-disable-next-line no-var
+var __systemConf = {
+    // 设备类样式,
+    equipStyle: {
+
+        // 默认设备类样式 (设备类名匹配不到时,使用默认类图标 比如: 文件服务器中没有油烟机的图标时,使用此默认样式)
+        defaultEquipStyle: {
+            color: "#1F2429",
+            size: 12,
+            url: "tognyong2020102700.svg", //对应文件服务器中,图片对应的的键值
+            formula: [],
+        },
+        // 风机盘管
+        ACATFC: {
+            color: "#1F2429",
+            size: 12,
+            url: "1611297831086.svg", //对应文件服务器中,图片对应的的键值
+            formula: [],
+        },
+        // 通风风口
+        ACVTIO: {
+            color: "#1F2429",
+            size: 12,
+            url: "1611299075489.svg", //对应文件服务器中,图片对应的的键值
+            formula: [],
+        },
+        // 冷却塔
+        ACCCOT:{
+            size: 12,
+            url: "1611299075489.svg", //对应文件服务器中,图片对应的的键值
+            formula: [],
+        }
+    },
+};
+window.__systemConf = __systemConf;

+ 10 - 14
src/components/editview/basePlanEditer.vue

@@ -490,7 +490,6 @@ export default {
                 }
                 this.INITOBJEXTINFO(objExtInfo);
             }
-
             // 初始化样式信息
             if (res.content.style) {
                 // 拼接设备默认样式
@@ -557,16 +556,7 @@ export default {
                 if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
             }
             // 加载区域显示
-            // TODO: 12
-            // res.content.outline = [
-            //     { x: -24257.467785976827, y: -188397.297908777 },
-            //     {
-            //         x: 129712.73367871458,
-            //         y: -100521.62195087993,
-            //     },
-            // ];
             if (res.content.outline) {
-                // this.
                 const outline = res.content.outline;
                 const item = this.scene.initMaskItem(outline);
                 this.SETOUTLINE(item);
@@ -596,15 +586,21 @@ export default {
                     equipItem.visible = Boolean(equipItem.legendData.bimLocation);
                     // equipItem.connect("finishCreated", this.scene, this.scene.finishCreated);
                     equipItem.connect("onContextMenu", this, this.scene.getItem);
-                    // 优先设备自身的样式
+                    console.log(equip.classCode, equip.codeName);
+                    // TODO: 设备样式
+                    const equipStyle = window.__systemConf.equipStyle;
+                    // 使用设备自身的样式
                     if (this.styleMap[equip.id]) {
                         SPlanDecorator.equipDecorator(equipItem, this.styleMap[equip.id]);
                     } else if (this.styleMap[equip.classCode]) {
-                        // 设备类的样式
+                        // 使用自身设备类的样式
                         SPlanDecorator.equipDecorator(equipItem, this.styleMap[equip.classCode]);
+                    } else if (equipStyle[equip.classCode]) {
+                        // 使用配置文件中的设备类样式
+                        SPlanDecorator.equipDecorator(equipItem, equipStyle[equip.classCode]);
                     } else {
-                        // 默认设备类的样式
-                        SPlanDecorator.equipDecorator(equipItem, this.styleMap["defaultEquipStyle"]);
+                        // 使用配置文件中的默认样式
+                        SPlanDecorator.equipDecorator(equipItem, equipStyle["defaultEquipStyle"]);
                     }
                     this.scene.addItem(equipItem);
                     this.ADDEQUIP(equipItem);

+ 5 - 7
src/components/editview/leftToolBar/editInfoPoint.vue

@@ -98,12 +98,7 @@
                 </div>
                 <div class="icon">
                     <p>显示图标</p>
-                    <el-upload
-                        class="avatar-uploader"
-                        action="#"
-                        :show-file-list="false"
-                        :http-request="uploadImage"
-                    >
+                    <el-upload class="avatar-uploader" action="#" :show-file-list="false" :http-request="uploadImage">
                         <img v-if="equipmentData.url" :src="equipmentData.imgUrl" class="avatar" />
 
                         <el-button v-else type="small">替换图标</el-button>
@@ -368,7 +363,10 @@ export default {
          * 初始化设备数据
          */
         initEquipment() {
-            const styleMap = { ...this.styleMap.defaultEquipStyle, ...(this.styleMap[this.code] || {}) };
+            // 配置文件设备类样式
+            const equipStyle = window.__systemConf.equipStyle;
+            // 使用样式的优先级:   配置文件中的默认样式 <  配置文件中的设备类样式 < read接口保存到vuex的设备类样式(styleMap)
+            const styleMap = { ...equipStyle.defaultEquipStyle, ...equipStyle[this.code], ...this.styleMap[this.code] };
             const { formula, url, color, size } = styleMap;
             if (typeof formula === "string") {
                 this.formula = JSON.parse(formula || "[]");

+ 6 - 6
src/store/index.ts

@@ -89,12 +89,12 @@ export default new Vuex.Store({
         // 初始化样式库信息
         INITSTYLE(state, data) {
             // 设备默认样式
-            data.defaultEquipStyle = {
-                color: "#1F2429",
-                size: 12,
-                url: "tognyong2020102700.svg",
-                formula: [],
-            };
+            // data.defaultEquipStyle = {
+            //     color: "#1F2429",
+            //     size: 12,
+            //     url: "tognyong2020102700.svg",
+            //     formula: [],
+            // };
             // 空间默认样式
             data.defaultZoneStyle = {
                 color: "#1F2429",