From 6094c0ed1baa40ffa0ce587704660b2a6d493bbf Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期一, 25 七月 2022 19:15:38 +0800
Subject: [PATCH] #D

---
 src/components/Tab/Plot.vue |  124 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 109 insertions(+), 15 deletions(-)

diff --git a/src/components/Tab/Plot.vue b/src/components/Tab/Plot.vue
index 1082c5a..02cc09e 100644
--- a/src/components/Tab/Plot.vue
+++ b/src/components/Tab/Plot.vue
@@ -12,7 +12,7 @@
                         创建
                     </el-button>
                 </el-col>
-                <el-col :span="6">
+                <!-- <el-col :span="6">
                     <el-button
                         icon="el-icon-delete"
                         size="small"
@@ -21,7 +21,7 @@
                     >
                         清空
                     </el-button>
-                </el-col>
+                </el-col> -->
                 <el-col :span="6">
                     <el-button
                         icon="el-icon-view"
@@ -44,18 +44,19 @@
                         circle
                         @click="() => focusHandle(label.attr.id)"
                     />
-                    <el-button
-                        icon="el-icon-edit"
-                        size="mini"
-                        circle
-                        @click="() => editHandle(label)"
-                    />
+
+<!--                    <el-button-->
+<!--                        icon="el-icon-edit"-->
+<!--                        size="mini"-->
+<!--                        circle-->
+<!--                        @click="() => editHandle(label)"-->
+<!--                    />-->
                     <el-button
                         icon="el-icon-delete"
                         type="danger"
                         size="mini"
                         circle
-                        @click="() => removeHandle(label.attr.id)"
+                        @click="() => removeHandle(label)"
                     />
                 </el-col>
             </el-row>
@@ -70,6 +71,15 @@
         >
             <p>请输入内容:</p>
             <el-input v-model="label.name" placeholder="请输入内容" />
+            <p>请选择风险等级:</p>
+            <el-select v-model="color" placeholder="请选择" >
+                <el-option
+                v-for="item in colorList"
+                :key="item.id"
+                :value="item.name"
+                :label="item.text"
+                ></el-option>
+            </el-select>
             <span slot="footer" class="dialog-footer">
         <el-button @click="closeCreateHandle">取 消</el-button>
         <el-button type="primary" @click="createHandle">确 定</el-button>
@@ -79,6 +89,7 @@
 </template>
 
 <script>
+    import { addMap , deleteColorMap} from '@/api/fourColorMap'
     import { global } from '../../global';
 
     // 默认样式
@@ -97,6 +108,7 @@
     };
 
     export default {
+        props:['type','colorMapList'],
         components: {},
         data() {
             return {
@@ -104,8 +116,39 @@
                     id: null,
                     name: '',
                 },
+                color:'',
+                colorList:[{id:1,name:'blue',text:'低风险'},{id:2,name:'yellow',text:'一般风险'},{id:3,name:'orange',text:'较大风险'},{id:4,name:'red',text:'重大风险'},],
                 showCreatePanel: false,
                 showPlot: true,
+                form:{
+                    id:'',
+                    etype:1,
+                    "type": "Feature",
+                    "properties": {
+                    "type": "polygon",
+                    "style": { "text": "D号楼", "clampToGround": true ,color:'',},
+                    "attr": {
+                        "name": "",
+                        "id": ""
+                    }
+                    },
+                    "geometry": {
+                    "type": "Polygon",
+                    "coordinates": [
+                        [
+                            [120.728524, 31.258178, 0],
+                            [120.727911, 31.257992, 0],
+                            [120.728024, 31.25772, 0],
+                            [120.727986, 31.2577, 0],
+                            [120.728039, 31.257535, 0],
+                            [120.728759, 31.257714, 0],
+                            [120.728524, 31.258178, 0],
+                            [120.728524, 31.258178, 0],
+                            [120.728524, 31.258178, 0]
+                            ]
+                        ]
+                    }
+                },
             };
         },
         computed: {
@@ -132,10 +175,27 @@
                 };
                 this.showCreatePanel = true;
             },
-            removeHandle(id) {
+            removeHandle(label) {
+                debugger
                 if (!global.map) return;
-                global.map.deletePlot(id);
-                this.$store.dispatch('map/updateTimestamp');
+                for(let i in this.colorMapList){
+                    if(JSON.parse(this.colorMapList[i].properties).attr.id === label.attr.id){
+                        deleteColorMap({id:this.colorMapList[i].id}).then(res =>{
+                        if(res.data.code === '200'){
+                            this.$message({
+                                title:'成功',
+                                message:'删除成功',
+                                duration:2000,
+                                type:'success'
+                                })
+                        global.map.deletePlot(label.attr.id);
+                        this.$store.dispatch('map/updateTimestamp');
+                            }
+                        })
+                    }
+                }
+
+
             },
             closeCreateHandle() {
                 this.showCreatePanel = false;
@@ -149,7 +209,11 @@
                     name: '',
                 };
             },
-            createHandle() {
+            async createHandle() {
+                // debugger
+                // this.form.geometry = JSON.stringify(this.form.geometry)
+                // this.form.properties = JSON.stringify(this.form.properties)
+                // let res = await addMap(this.form)
                 if (!global.map) return;
                 let map = global.map;
                 const { id, name } = this.label;
@@ -164,14 +228,44 @@
                     map.startDraw(
                         {
                             type: 'polygon',
-                            style: { text: name },
+                            style: { text: name ,color:this.color, clampToGround: true},
                             attr: {
                                 name,
                             },
                         },
-                        () => {
+                        (entity) => {
+                            console.log(wutu3d.draw.attr.getCoordinates(entity));
                             this._initLabel();
                             this.$store.dispatch('map/updateTimestamp');
+                            this.form = {
+                                id:'',
+                                etype:this.type,
+                                "type": "Feature",
+                                "properties":
+                                    JSON.stringify(entity.attribute),
+                                "geometry": JSON.stringify({
+                                "type": "Polygon",
+                                "coordinates": [
+
+                                    wutu3d.draw.attr.getCoordinates(entity)
+
+                                    ]
+                                })
+                            }
+                            // this.form.properties.style.color = this.color
+                            // this.form.properties = JSON.stringify(this.form.properties)
+                            addMap(this.form).then(res =>{
+                                if(res.data.code === '200'){
+                                    // this.$emit('testLoadedData')
+                                    this.$message({
+                                        type:'success',
+                                        duration:2000,
+                                        title:'成功',
+                                        message:'四色图新增成功',
+                                    })
+                                }
+                                this.$emit('getList')
+                            })
                         }
                     );
                 }

--
Gitblit v1.9.2