Quellcode durchsuchen

修改图例库

shaun-sheep vor 5 Jahren
Ursprung
Commit
3b4c7e97cb

+ 24 - 35
src/views/legendLibrary/addForm.vue

@@ -3,7 +3,7 @@
         <div class='form1'>
             <span class='span1'>图例编码</span>
             <span class='span2'>图例名称</span>
-            <span class='span3' v-if='ruleForm.Type=="Zone" || ruleForm.Type=="Icon"'>展示预览</span>
+            <span class='span3' v-if='ruleForm.Type=="Zone" || ruleForm.Type=="Image"'>展示预览</span>
         </div>
         <div class='form2'>
             <div class='input-left'>
@@ -16,28 +16,11 @@
                     <el-option v-for='item in options' :key='item.value' :label='item.label' :value='item.value'></el-option>
                 </el-select>
             </div>
-            <div class='input-right' ref='graph' v-show='ruleForm.Type=="Zone" || ruleForm.Type=="Icon" || ruleForm.Type =="Line"'>
-                <!-- <div v-if=' ruleForm.Type=="Icon" ' class='input-right'>
+            <div class='input-right' ref='graph' v-show='ruleForm.Type=="Zone" || ruleForm.Type=="Image" || ruleForm.Type =="Line"'>
+                <div v-if=' ruleForm.Type=="Image" ' class='input-right'>
                     <img :src='`/serve/Picture/query/${ruleForm.Url}`' alt />
                 </div>
-                <div
-                    v-else-if='ruleForm.Type=="Zone" '
-                    class='model'
-                    :style='`background:${ruleForm.FillColor};border-width:${ruleForm.LineWidth}px;border-style:${ruleForm.LineDash}; border-color:${ruleForm.Color};`'
-                ></div>
-                <div
-                    v-else
-                    class='model1'
-                    :style='`border-width:${ruleForm.LineWidth}px;border-style:${ruleForm.LineDash}; border-color:${ruleForm.Color};`'
-<<<<<<< HEAD
-                ></div>
-=======
-                >
-                </div>-->
-                <!-- <div ref='graph' style='width:100%;height:100%'> -->
-                <canvas id='canvas' :width='canvasWidth' :height='canvasHeight'></canvas>
-                <!-- </div> -->
->>>>>>> 93c38f4666a4f0fcb5e8263afa5d1de70a34789c
+                <canvas id='canvas' :width='canvasWidth' :height='canvasHeight' v-else></canvas>
             </div>
         </div>
         <div v-if='ruleForm.Type=="Zone" || ruleForm.Type=="Line"' class='form3'>
@@ -69,19 +52,15 @@
                         <img :src='item.src' alt />
                     </el-option>
                 </el-select>
-<<<<<<< HEAD
-                <el-select v-model='ruleForm.LineWidth' placeholder='请选择' size='small' style='width:160px;' ref='select' @change='changeSelection'>
-                    <el-option v-for='item in linepxOption' :key='item.id' :label='item.src' :value='item.id' slot>
-=======
+
                 <el-select v-model='ruleForm.LineWidth' placeholder='请选择' size='small' style='width:160px;' ref='select' @change='changeLineWidth'>
                     <el-option v-for='item in linepxOption' :key='item.id' :label='item.src' :value='item.id'>
->>>>>>> 93c38f4666a4f0fcb5e8263afa5d1de70a34789c
                         <img :src='item.src' alt />
                     </el-option>
                 </el-select>
             </div>
         </div>
-        <div v-if='ruleForm.Type=="Icon"' class='form5'>
+        <div v-if='ruleForm.Type=="Image"' class='form5'>
             <div class='form5-top'>上传新图标</div>
             <div>
                 <el-upload
@@ -134,7 +113,7 @@ export default {
                     label: '区域'
                 },
                 {
-                    value: 'Icon',
+                    value: 'Image',
                     label: '图标'
                 },
                 {
@@ -184,7 +163,7 @@ export default {
             scene: null
         }
     },
-    props: ['ruleForm'],
+    props: ['ruleForm', 'title'],
     computed: {},
     methods: {
         getFile(file) {
@@ -209,6 +188,8 @@ export default {
                     this.$message.success('添加图例成功!')
                     this.$emit('addSuccess')
                     this.fileList = []
+                } else {
+                    this.$message.error(res.Message)
                 }
             })
         },
@@ -222,6 +203,8 @@ export default {
                     this.$message.success('图例修改成功!')
                     this.$emit('updateSuccess')
                     this.fileList = []
+                } else {
+                    this.$message.error(res.Message)
                 }
             })
         },
@@ -240,7 +223,6 @@ export default {
             if (this.ruleForm.Type == 'Zone' || this.ruleForm.Type == 'Line') {
                 this.clearGraphy(this.ruleForm.Type == 'Zone' ? 1 : 0)
             }
-            // this.scene = new FloorScene()
         },
         // 背景颜色改变
         changBgColor(val) {
@@ -300,20 +282,27 @@ export default {
                 var formData = new FormData()
                 formData.append('file', this.base64ToFile(data))
                 let postParams = formData
+                console.log(postParams, 'posssss')
                 uploadImg({ postParams }).then(res => {
                     if (res.Result == 'success') {
                         this.$set(this.ruleForm, 'Url', res.EntityList[0])
                         this.$message.success('图标上传成功!')
+                        if (this.title == '添加图例库') {
+                            this.create()
+                            this.$emit('addSuccess')
+                            this.view.canvas.clearRect(0, 0, this.width, this.height)
+                        } else if (this.title == '修改图例库') {
+                            this.update()
+                            this.$emit('updateSuccess')
+                            this.view.canvas.clearRect(0, 0, this.width, this.height)
+                        } else {
+                        }
                     }
                 })
-                // this.view.saveImage('1.png', 'png')
             }
         }
     },
-    mounted() {
-        console.log(this.ruleForm, 'ruleForm')
-        this.ruleForm.LineWidth = String(this.ruleForm.LineWidth)
-    }
+    mounted() {}
 }
 </script>
 

+ 8 - 14
src/views/legendLibrary/addLegend.vue

@@ -2,7 +2,7 @@
     <div class='add-legend'>
         <el-dialog :title='title' :visible.sync='dialogVisible'>
             <add-list v-if='title==""' ref='searchList' :GraphCategoryId='GraphCategoryId' @mesg='mesg'></add-list>
-            <add-form v-else ref='add' :ruleForm='info' @addSuccess='addSuccess' @updateSuccess='updateSuccess'></add-form>
+            <add-form v-else ref='add' :ruleForm='info' @addSuccess='addSuccess' @updateSuccess='updateSuccess' :title='title'></add-form>
             <span slot='footer' class='dialog-footer'>
                 <el-button @click='dialogVisible = false' size='small'>取 消</el-button>
                 <el-button type='primary' @click='save' size='small'>确 定</el-button>
@@ -23,7 +23,9 @@ export default {
                 Type: 'None',
                 Unit: '',
                 FillColor: '',
-                Url: ''
+                Url: '',
+                LineWidth: '',
+                LineDash: ''
             },
             title: '',
             GraphCategoryId: ''
@@ -70,18 +72,10 @@ export default {
         },
         save() {
             this.$refs.add.saveImg()
-            console.log('go')
-            return
-            // this.dialogVisible = false
-            // if (this.title == '添加图例库') {
-            //     this.$refs.add.create()
-            // }
-            // if (this.title == '修改图例库') {
-            //     this.$refs.add.update()
-            // }
-            // if (!this.title) {
-            // this.$refs.searchList.save()
-            // }
+            this.dialogVisible = false
+            if (!this.title) {
+                this.$refs.searchList.save()
+            }
         }
     }
 }

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

@@ -142,7 +142,7 @@ export default {
                     name: '区域'
                 },
                 {
-                    id: 'Icon',
+                    id: 'Image',
                     name: '图标'
                 },
                 {