Browse Source

查看地图

CzRger 4 months ago
parent
commit
72c4bfd824

+ 1 - 1
src/components/easyMap/initMapInfo.ts

@@ -31,7 +31,7 @@ export const baseMapLayers = [
     label: '陆图',
     maxZoom: 23,
     minZoom: 0,
-    visible: false,
+    visible: true,
     img: LutuImg
   },
 ]

+ 1 - 1
src/style/cus.scss

@@ -8,7 +8,7 @@
   // 主题自定义
   --cus-main-color: #2E81FF;
   --cus-main-color-rgb: 46, 129, 255;
-  --cus-main-color-hex-2: #273A58;
+  --cus-main-color-hex-2: var(--cus-main-color);
 }
 .__hover {
   &:hover {

+ 1 - 1
src/views/web/index.vue

@@ -36,7 +36,7 @@ const titleCpt = computed(() => {
 })
 const mapLoad = (map, mapFunc) => {
   state.map = map
-};
+}
 </script>
 
 <style lang="scss" scoped>

+ 92 - 0
src/views/web/tools/area-map.vue

@@ -0,0 +1,92 @@
+<template>
+  <CusDialog
+    :show="show"
+    title="预警区域"
+    @onClose="$emit('update:show', false)"
+    width="90%"
+    height="90%"
+    :loading="state.loading"
+    :show-submit="false"
+    :show-close="false"
+  >
+    <div class="__cus-dialog-form">
+      <EasyMapComponent
+        class="map"
+        @easyMapLoad="mapLoad"
+        layout="info"
+      />
+    </div>
+  </CusDialog>
+</template>
+
+<script setup lang="ts">
+import {computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch} from "vue";
+import * as style from 'ol/style'
+import * as layer from 'ol/layer'
+import * as source from 'ol/source'
+import * as format from "ol/format";
+
+const emit = defineEmits(['update:show'])
+const {proxy} = getCurrentInstance()
+const props = defineProps({
+  show: {default: false},
+  transfer: {}
+})
+const state: any = reactive({
+  map: null
+})
+const mapLoad = (map, mapFunc) => {
+  state.map = map
+  initArea()
+}
+const initArea = () => {
+  if (state.map) {
+    const _l = state.map?.getLayers().getArray().filter(v => v.get('__layerName') === 'areaMap')
+    if (_l?.length > 0) {
+      _l.forEach(v => {
+        state.map.removeLayer(v)
+      })
+    }
+    const feats = []
+    feats.push(new format.WKT().readFeature('POLYGON((108.67917953258203 19.334644670763034,109.31382856610153 19.334644670763034,109.31382856610153 19.716490227095417,108.67917953258203 19.716490227095417,108.67917953258203 19.334644670763034))'))
+    const _vector = new layer.Vector({
+      zIndex: 9999,
+      source: new source.Vector({
+        features: feats
+      }),
+      style: new style.Style({ //图层样式
+        fill: new style.Fill({
+          color: 'rgba(46,129,255,0.15)' //填充颜色
+        }),
+        stroke: new style.Stroke({
+          color: '#2E81FF',  //边框颜色
+          width: 2,   // 边框宽度
+          lineDash: [10, 10]
+        }),
+        image: new style.Circle({
+          radius: 7,
+          fill: new style.Fill({
+            color: '#ffcc33'
+          })
+        })
+      })
+    })
+    _vector.set('__layerName', 'areaMap')
+    state.map.addLayer(_vector)
+  }
+}
+watch(() => props.show, (n) => {
+  if (n) {
+    state.loading = false
+    initArea()
+  }
+})
+</script>
+
+<style lang="scss" scoped>
+.__cus-dialog-form {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+</style>

+ 7 - 7
src/views/web/tools/config.vue

@@ -24,7 +24,7 @@
             <el-button @click.stop="$util._console(node)">查看</el-button>
           </span>
           <span v-else>
-            <el-button @click.stop="onViewModel(data)">查看</el-button>
+            <el-button @click.stop="onAddRule(data)">新增</el-button>
           </span>
         </span>
         </template>
@@ -33,13 +33,13 @@
     <template v-else-if="state.tab == 2">
 
     </template>
-    <ModelDialog v-model:show="state.model.show" :transfer="state.model.transfer"/>
+    <ruleDetail v-model:show="state.ruleDetail.show" :transfer="state.ruleDetail.transfer"/>
   </div>
 </template>
 
 <script setup lang="ts">
 import {computed, getCurrentInstance, onMounted, reactive, ref, watch} from "vue";
-import ModelDialog from "./model-dialog.vue";
+import ruleDetail from "./rule-detail.vue";
 
 const {proxy} = getCurrentInstance()
 const props = defineProps({
@@ -50,7 +50,7 @@ const state: any = reactive({
   loading: false,
   text: '',
   rulesList: [],
-  model: {
+  ruleDetail: {
     transfer: {},
     show: false
   }
@@ -93,12 +93,12 @@ const expendRules = () => {
 const rulesExpandAllCpt = computed(() => {
   return ref_rulesTree.value?.root.childNodes.every(v => v.data.children?.length == 0 || v.expanded)
 })
-const onViewModel = (row) => {
+const onAddRule = (row) => {
   console.log(row)
-  state.model.transfer = {
+  state.ruleDetail.transfer = {
     id: row.id + ''
   }
-  state.model.show = true
+  state.ruleDetail.show = true
 }
 onMounted(() => {
   initData()

+ 0 - 115
src/views/web/tools/model-dialog.vue

@@ -1,115 +0,0 @@
-<template>
-  <CusDialog
-    :show="show"
-    :title="titleCpt"
-    @onClose="$emit('update:show', false)"
-    width="90%"
-    height="90%"
-    @onSubmit="onSubmit"
-    :loading="state.loading"
-  >
-    <div class="__cus-dialog-form">
-      <CusForm ref="ref_form" label-width="100px">
-        <CusFormColumn
-          :span="8"
-          required
-          label="数据服务名称"
-          label-width="120px"
-          v-model:param="state.form.serviceName"
-        />
-      </CusForm>
-    </div>
-  </CusDialog>
-</template>
-
-<script setup lang="ts">
-import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
-import {useDictionaryStore} from "@/stores";
-import {ElMessage, ElMessageBox} from "element-plus";
-
-const emit = defineEmits(['update:show', 'refresh'])
-const {proxy} = getCurrentInstance()
-const DictionaryStore = useDictionaryStore()
-const props = defineProps({
-  show: {default: false},
-  transfer: {}
- })
-const state: any = reactive({
-  form: {
-  },
-  loading: false,
-})
-const ref_form = ref()
-const titleCpt = computed(() => {
-  let t = '查看预警模型'
-  switch (props.transfer.mode) {
-    case 'add': t = '新增外部服务'
-      break
-  }
-  return t
-})
-const onSubmit = () => {
-  ref_form.value.submit().then(() => {
-    ElMessageBox.confirm("是否提交?", "提示", {
-      confirmButtonText: "确定",
-      cancelButtonText: "取消",
-      type: "warning",
-    } as any).then(() => {
-      state.loading = true
-    }).catch(() => {})
-  }).catch((e) => {
-    ElMessage({
-      message: e[0].message,
-      grouping: true,
-      type: 'warning',
-    })
-  })
-}
-const initDetail = () => {
-  state.loading = false
-}
-watch(() => props.show, (n) => {
-  if (n) {
-    state.loading = false
-    initDictionary()
-    state.form = {
-      requestType: 'GET'
-    }
-    if (props.transfer.mode !== 'add') {
-      initDetail()
-    }
-    nextTick(() => {
-      ref_form.value.reset()
-    })
-  }
-})
-const initDictionary = () => {
-  // DictionaryStore.initDict('format_type')
-}
-</script>
-
-<style lang="scss" scoped>
-.__cus-dialog-form {
-  height: 100%;
-  display: flex;
-  flex-direction: column;
-}
-.params-content {
-  flex: 1;
-  margin-top: 20px;
-  overflow: hidden;
-  .request-params, .request-headers, .request-body, .response-body {
-    width: 100%;
-    height: 100%;
-    display: flex;
-    flex-direction: column;
-  }
-}
-.tips {
-  background-color: rgba(var(--cus-main-color-rgb), 0.1);
-  border-radius: 6px;
-  padding: 7px;
-  margin-bottom: 10px;
-  width: 100%;
-}
-</style>

+ 205 - 0
src/views/web/tools/rule-detail.vue

@@ -0,0 +1,205 @@
+<template>
+  <CusDialog
+    :show="show"
+    :title="titleCpt"
+    @onClose="$emit('update:show', false)"
+    width="90%"
+    height="90%"
+    @onSubmit="onSubmit"
+    :loading="state.loading"
+  >
+    <div class="__cus-dialog-form">
+      <CusForm ref="ref_form" label-width="100px">
+        <div class="__cus-title_1">场景设定</div>
+        <CusFormColumn
+          :span="8"
+          required
+          label="预警名称"
+          v-model:param="state.form.serviceName"
+        />
+        <CusFormColumn
+          :span="8"
+          required
+          label="预警级别"
+          v-model:param="state.form.serviceName"
+        />
+        <CusFormColumn
+          :span="8"
+          required
+          label="预警模型"
+          v-model:param="state.form.serviceName"
+        />
+        <CusFormColumn
+          :span="24"
+          label="场景描述"
+          v-model:param="state.form.serviceName"
+          type="textarea"
+          :rows="5"
+        />
+        <div class="__cus-title_1">参数配置</div>
+        <div class="params-table" style="width: 100%">
+          <CusTable
+            :data="state.form.paramsTable"
+            :table-head="[
+              {value: 'key', label: '参数'},
+              {value: 'value', label: '值'},
+              {value: 'unit', label: '单位'},
+            ]"
+            :no-page="true"
+          >
+            <template #value-column-value="{scope}">
+              <CusFormColumn
+                required
+                class="__cus-table-form-column"
+                :span="24"
+                v-model:param="scope.row.value"
+                link="number"
+                :placeholder="'推荐值:' + scope.row.default"
+              />
+            </template>
+          </CusTable>
+        </div>
+        <div class="__cus-title_1">区域配置</div>
+        <el-col :span="12">
+          <CusFormColumn
+            required
+            :span="24"
+            label="预警区域"
+            v-model:param="state.areaIds.warning"
+            link="select"
+            multiple
+            :options="state.areaList.filter(v => !state.areaIds.white.includes(v.id))"
+            label-key="name"
+            value-key="id"
+          />
+          <el-button @click="onAreaMap">查看区域</el-button>
+        </el-col>
+        <el-col :span="12">
+          <CusFormColumn
+            required
+            :span="24"
+            label="白名单"
+            v-model:param="state.areaIds.white"
+            link="select"
+            multiple
+            :options="state.areaList.filter(v => !state.areaIds.warning.includes(v.id))"
+            label-key="name"
+            value-key="id"
+          />
+          <el-button @click="onAreaMap">查看区域</el-button>
+        </el-col>
+      </CusForm>
+      <areaMap v-model:show="state.areaMap.show" :transfer="state.areaMap.transfer"/>
+    </div>
+  </CusDialog>
+</template>
+
+<script setup lang="ts">
+import {computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch} from "vue";
+import {useDictionaryStore} from "@/stores";
+import {ElMessage, ElMessageBox} from "element-plus";
+import areaMap from './area-map.vue'
+
+const emit = defineEmits(['update:show', 'refresh'])
+const {proxy} = getCurrentInstance()
+const DictionaryStore = useDictionaryStore()
+const props = defineProps({
+  show: {default: false},
+  transfer: {}
+ })
+const state: any = reactive({
+  form: {},
+  loading: false,
+  areaList: [],
+  areaIds: {
+    warning: [],
+    white: [],
+  },
+  areaMap: {
+    show: false,
+    transfer: {}
+  }
+})
+const ref_form = ref()
+const titleCpt = computed(() => {
+  let t = '查看预警模型'
+  switch (props.transfer.mode) {
+    case 'add': t = '新增预警规则'
+      break
+    case 'edit': t = '编辑预警规则'
+      break
+  }
+  return t
+})
+const onSubmit = () => {
+  ref_form.value.submit().then(() => {
+    ElMessageBox.confirm("是否提交?", "提示", {
+      confirmButtonText: "确定",
+      cancelButtonText: "取消",
+      type: "warning",
+    } as any).then(() => {
+      state.loading = true
+    }).catch(() => {})
+  }).catch((e) => {
+    ElMessage({
+      message: e[0].message,
+      grouping: true,
+      type: 'warning',
+    })
+  })
+}
+const initDetail = () => {
+  state.loading = false
+}
+const initArea = () => {
+  setTimeout(() => {
+    const arr = []
+    for (let i = 0; i < 10; i++) {
+      arr.push({id: i, name: '区域_' + i})
+    }
+    state.areaList = arr
+  }, 1000)
+}
+watch(() => props.show, (n) => {
+  if (n) {
+    state.loading = false
+    initDictionary()
+    state.form = {
+      paramsTable: [
+        {key: '统计时长', value: '', unit: '秒', default: '200'}
+      ]
+    }
+    if (props.transfer.mode !== 'add') {
+      initDetail()
+    }
+    nextTick(() => {
+      ref_form.value.reset()
+    })
+  }
+})
+const onAreaMap = () => {
+  state.areaMap.transfer = {
+
+  }
+  state.areaMap.show = true
+}
+onMounted(() => {
+  state.form = {
+    paramsTable: [
+      {key: '统计时长', value: '', unit: '秒', default: '200'}
+    ]
+  }
+  initArea()
+})
+const initDictionary = () => {
+  // DictionaryStore.initDict('format_type')
+}
+</script>
+
+<style lang="scss" scoped>
+.__cus-dialog-form {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+</style>