Bladeren bron

地图测试

123 1 jaar geleden
bovenliggende
commit
f5dbce4d1a

+ 9 - 7
index.html

@@ -1,16 +1,18 @@
 <!DOCTYPE html>
 <html lang="en">
-
-<head>
+  <head>
     <meta charset="UTF-8" />
     <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <script
+      type="text/javascript"
+      src="https://webapi.amap.com/maps?v=1.4.15&key=190ca276eab6a1a369fa80e1f9977a8f&plugin=AMap.PolyEditor,AMap.ControlBar,ElasticMarker,AMap.MouseTool"
+    ></script>
     <title>永登</title>
-</head>
+  </head>
 
-<body>
+  <body>
     <div id="app"></div>
     <script type="module" src="/src/main.ts"></script>
-</body>
-
-</html>
+  </body>
+</html>

+ 1 - 0
package.json

@@ -9,6 +9,7 @@
     "preview": "vite preview"
   },
   "dependencies": {
+    "@amap/amap-jsapi-loader": "^1.0.1",
     "axios": "^1.4.0",
     "dayjs": "^1.11.10",
     "echarts": "^5.4.3",

+ 13 - 14
src/router/index.ts

@@ -37,21 +37,20 @@ const allRoutes: Array<RouteRecordRaw> = [
                 component: () => import('@/views/logs/index.vue'),
                 meta: { title: '日志数据' },
             }]
+    },
+    {
+        path: '/demo',
+        component: Layout,
+        redirect: '/demo/index',
+        name: 'demo',
+        children: [
+            {
+                path: 'index',
+                name: 'demoIndex',
+                component: () => import('@/views/demo/index.vue'),
+                meta: { title: 'demo数据' },
+            }]
     }
-
-    // {
-    //     path: '/demo',
-    //     component: Layout,
-    //     redirect: '/demo/index',
-    //     name: 'demo',
-    //     children: [
-    //         {
-    //             path: 'index',
-    //             name: 'demoIndex',
-    //             component: () => import('@/views/demo/index.vue'),
-    //             meta: { title: 'demo数据' },
-    //         }]
-    // }
 ];
 
 

+ 25 - 145
src/views/demo/index.vue

@@ -1,151 +1,31 @@
 <template>
-  <div class="container-app">
-    <t-form
-      ref="form"
-      :rules="rules"
-      :data="formData"
-      :colon="true"
-      @reset="onReset"
-      @submit="onSubmit"
-    >
-      <template v-for="(item, index) in formData.curvatureList" :key="index">
-        <t-row>
-          <t-form-item label="开始" :name="'curvatureList.' + index + '.start'">
-            <t-input-number
-              v-model="item.start"
-              theme="normal"
-              style="width: 200px"
-              placeholder="请输入内容"
-            ></t-input-number>
-          </t-form-item>
-          <t-form-item
-            label="结束"
-            :name="'curvatureList.' + index + '.end'"
-            :rules="validatorValue(item, index)"
-          >
-            <t-input-number
-              v-model="item.end"
-              theme="normal"
-              style="width: 200px"
-              @change="qulvInputChange(formData.curvatureList, item, index)"
-              :disabled="index === formData.curvatureList.length - 1"
-              :tips="item.errorTip"
-              placeholder="请输入内容"
-            ></t-input-number>
-          </t-form-item>
-          <t-button @click="addItem" v-if="index === 0">添加</t-button>
-          <t-button v-else @click="removeItem(item, index)">删除</t-button>
-        </t-row>
-      </template>
-
-      <t-form-item>
-        <t-button theme="primary" type="submit">提交</t-button>
-        <t-button theme="default" variant="base" type="reset">重置</t-button>
-      </t-form-item>
-    </t-form>
+  <div style="width: 100%; height: 100%">
+    <div id="mapContainer" style="width: 100%; height: 100%"></div>
   </div>
 </template>
-
-<script lang="ts" setup>
-import { ref, toRefs, reactive, computed } from 'vue';
-
-const validatorValue = (item, index) => {
-  return [
-    { required: true, message: '值必填', type: 'error' },
-    {
-      validator: (val) => {
-        if (Number(val) > 30 || Number(val) < -50) {
-          return {
-            result: false,
-            message: '范围在-50至30之间',
-            type: 'error',
-          };
-        }
-        if (val && val < item.start) {
-          return {
-            result: false,
-            message: '结束范围不能小于开始范围',
-            type: 'error',
-          };
-        }
-        return true;
-      },
-    },
-  ];
-
-  return true;
-};
-// const currentIndex = ref(null);
-const rules = {
-  enumVal: [
-    { required: true, message: '值必填', type: 'error' },
-    { validator: validatorValue },
-  ],
-};
-const formData = reactive({
-  sysName: '',
-  energyStationId: '',
-  weatherCode: '',
-  controlModel: 1,
-  startTemperature: 0, //起始温度
-  targetTemperature: 0, //目标温度
-  curvatureList: [
-    //曲率
-    {
-      start: -50,
-      end: 30,
-      qulv: 0.5,
-      errorTip: '',
-    },
-  ],
-  amendmentList: [
-    // 分时修正
-    {
-      startTime: '00:00',
-      endTime: '23:59',
-      value: 0,
-    },
-  ],
+<script setup lang="ts">
+import AMapLoader from '@amap/amap-jsapi-loader';
+import { ref, onMounted, reactive } from 'vue';
+const state = reactive({
+  map: null,
 });
-
-const qulvInputChange = (data: any, row: any, index: number) => {
-  const { end } = data[index];
-  formData.curvatureList[index + 1].start = end;
-  //   row.errorTip = index !== 0 && end < row.start ? '不能小于当前值' : '';
-};
-
-const addItem = () => {
-  formData.curvatureList[formData.curvatureList.length - 1].end = '';
-  let obj = { start: '', end: 30, qulv: 0.5 };
-  formData.curvatureList.push(obj);
-};
-
-const removeItem = (item, index) => {
-  let list = formData.curvatureList;
-  if (index == list.length - 1) {
-    list.splice(index, 1);
-    list[list.length - 1].end = 30;
-  } else {
-    list[index + 1].start = list[index - 1].end;
-    list.splice(index, 1);
-  }
-};
-const onSubmit = ({ validateResult, firstError, e }) => {
-  e.preventDefault();
-  if (validateResult === true) {
-    console.log('提交成功');
-    // MessagePlugin.success('提交成功');
-  } else {
-    console.log('Validate Errors: ', firstError, validateResult);
-    // MessagePlugin.warning(firstError);
-  }
+onMounted(() => {
+  initMap();
+});
+const initMap = () => {
+  AMapLoader.reset();
+  AMapLoader.load({
+    key: '190ca276eab6a1a369fa80e1f9977a8f', // 此处填入我们注册账号后获取的Key
+    version: '1.4.15', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
+    plugins: ['AMap.Marker'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
+  }).then((AMap) => {
+    var GMap = new AMap.Map('mapContainer', {
+      zoom: 10, //  地图显示的缩放级别
+      center: [103.260315, 36.736032], // 初始化地图中心点位置, //  地图中心点坐标 此处填【经度,纬度】
+      mapStyle: 'amap://styles/normal', //设置地图的显示样式
+      resizeEnable: true, //  是否监控地图容器尺寸变化
+    });
+    state.map = GMap;
+  });
 };
-
-const onReset = () => {};
 </script>
-
-<style lang="less" scoped>
-.dialog-content-title {
-  padding: 0 0 10px 0;
-}
-</style>

+ 9 - 4
src/views/logs/index.vue

@@ -113,19 +113,24 @@ const gridOptions = reactive<VxeGridProps>({
     storage: true,
   },
   columns: [
+    {
+      field: 'energyStationName',
+      title: '换热站',
+      width: 120,
+      fixed: 'left',
+    },
     {
       field: 'sysName',
       title: '系统名称',
+      width: 120,
+      fixed: 'left',
     },
     {
       field: 'rid',
       title: '系统编号',
       width: 100,
     },
-    {
-      field: 'energyStationName',
-      title: '换热站',
-    },
+
     {
       field: 'date',
       title: '日期',

+ 2 - 2
src/views/runData/components/systemData/components/HistoryDialog.vue

@@ -174,8 +174,8 @@ const openDialog = (row) => {
   state.formData.saveEndData = currentDate;
   state.formData.rid = row._id;
   state.dataCodesArr = [
-    { value: 'ycgswd', label: '一次供温' },
-    { value: 'ychswd', label: '一次回温' },
+    { value: 'ecgswd', label: '二次供温' },
+    { value: 'echswd', label: '二次回温' },
   ]; //默认选中两个点
   getChartData();
 };

+ 1 - 1
src/views/runData/components/systemData/constants.ts

@@ -7,9 +7,9 @@ export interface RowVO {
 
 
 export const tableCloumn = [
+    { field: 'energyStationName', title: '换热站', width: 120, fixed: 'left' },
     { field: 'sysName', title: '系统名称', width: 120, fixed: 'left' },
     { field: '_id', title: '系统编号', width: 100 },
-    { field: 'energyStationName', title: '换热站', width: 120 },
     {
         field: 'controlModel', title: '控制模式', width: 100, formatter: ({ cellValue, row }) => {
             if (!cellValue) return null

+ 12 - 8
src/views/runData/components/systemData/index.vue

@@ -32,15 +32,10 @@
         <vxe-button
           type="text"
           status="primary"
+          :disabled="permissDisable"
           @click="handleButton(row, 'permiss')"
           >权限</vxe-button
         >
-        <!-- <vxe-button
-          type="text"
-          status="primary"
-          @click="handleButton(row, 'log')"
-          >日志</vxe-button
-        > -->
       </template>
     </vxe-grid>
     <!--修改 弹框 -->
@@ -50,14 +45,23 @@
   </div>
 </template>
 <script lang="ts" setup>
-import { ref, reactive, onUnmounted } from 'vue';
+import { ref, reactive, onUnmounted, computed } from 'vue';
 import { RefreshIcon } from 'tdesign-icons-vue-next';
 import { VxeGridProps } from 'vxe-table';
 import { EditDialog, HistoryDialog } from './components';
 import { tableCloumn, RowVO } from './constants';
 import { getRunData } from '@/api/runData/index';
+import { useUserStore } from '@/store';
+const UserStore = useUserStore();
 
-const formData = reactive({ deviceType: 'hr', sysName: '' });
+const formData = reactive({
+  operationName: UserStore.userInfo.username,
+  deviceType: 'hr',
+  sysName: '',
+});
+const permissDisable = computed(() => {
+  return UserStore.userInfo.isadmin !== '1';
+});
 const editDialogRef = ref(null);
 const historyDialogRef = ref(null);
 const gridOptions = reactive<VxeGridProps<RowVO>>({