shaun-sheep 4 rokov pred
rodič
commit
5b1a5afed4

+ 2 - 1
public/systemConf.js

@@ -25,7 +25,8 @@ var __systemConf = {
     conf: {
         // 阿里云
         editerUrl: 'http://60.205.177.43:80/wandaEditer/', // 编辑器地址
-        wandaBmGuideUrl: 'http://60.205.177.43:80/wandaBmGuide/', //管理书地址
+        // wandaBmGuideUrl: 'http://60.205.177.43:80/wandaBmGuide/', //管理书地址
+        wandaBmGuideUrl: 'http://192.168.200.100:8090/wandaBmGuide/', //管理书地址
     },
 }
 window.__systemConf = __systemConf

+ 98 - 12
src/views/legendLibrary/addForm.vue

@@ -114,6 +114,7 @@
                     @change='treeConfirm'
                     @focusChange='focusChange'
                     :hideClear='true'
+                    :selectedIds='selectedIds'
                 />
             </div>
         </div>
@@ -146,9 +147,8 @@ export default {
                     label: '线条'
                 }
             ],
-            options1: [],
-            options2: [],
 
+            selectedIds: [],
             borderLineOption: [
                 {
                     id: 'solid',
@@ -231,6 +231,11 @@ export default {
         },
         create() {
             //新增
+            if (this.ruleForm.FillColor.indexOf('#') > -1) {
+                this.ruleForm.FillColor = this.ruleForm.FillColor
+            } else {
+                this.ruleForm.FillColor = this.hexify(this.ruleForm.FillColor)
+            }
             let postParams = {
                 Content: [this.ruleForm]
             }
@@ -246,6 +251,11 @@ export default {
         },
         update() {
             //修改
+            if (this.ruleForm.FillColor.indexOf('#') > -1) {
+                this.ruleForm.FillColor = this.ruleForm.FillColor
+            } else {
+                this.ruleForm.FillColor = this.hexify(this.ruleForm.FillColor)
+            }
             let postParams = {
                 Content: [this.ruleForm]
             }
@@ -284,16 +294,92 @@ export default {
         },
         //rgba转成16进制
         hexify(color) {
-            var values = color
-                .replace(/rgba?\(/, '')
-                .replace(/\)/, '')
-                .replace(/[\s+]/g, '')
-                .split(',')
-            var a = parseFloat(values[3] || 1),
-                r = Math.floor(a * parseInt(values[0]) + (1 - a) * 255),
-                g = Math.floor(a * parseInt(values[1]) + (1 - a) * 255),
-                b = Math.floor(a * parseInt(values[2]) + (1 - a) * 255)
-            return '#' + ('0' + r.toString(16)).slice(-2) + ('0' + g.toString(16)).slice(-2) + ('0' + b.toString(16)).slice(-2)
+            console.log(color, 'color')
+            // var values = color
+            //     .replace(/rgba?\(/, '')
+            //     .replace(/\)/, '')
+            //     .replace(/[\s+]/g, '')
+            //     .split(',')
+            // var a = parseFloat(values[3] || 1),
+            //     r = Math.floor(a * parseInt(values[0]) + (1 - a) * 255),
+            //     g = Math.floor(a * parseInt(values[1]) + (1 - a) * 255),
+            //     b = Math.floor(a * parseInt(values[2]) + (1 - a) * 255),
+            //     opacity = ''
+            var opacity = ''
+            var rgb = color.split(',')
+            var r = parseInt(rgb[0].split('(')[1])
+            var g = parseInt(rgb[1])
+            var b = parseInt(rgb[2].split(')')[0])
+            switch (parseFloat(rgb[3] || 1) + '') {
+                case '0':
+                    opacity = '00'
+                    break
+                case '0.05':
+                    opacity = '0C'
+                    break
+                case '0.1':
+                    opacity = '19'
+                    break
+                case '0.15':
+                    opacity = '26'
+                    break
+                case '0.2':
+                    opacity = '33'
+                    break
+                case '0.25':
+                    opacity = '3F'
+                    break
+                case '0.3':
+                    opacity = '4C'
+                    break
+                case '0.35':
+                    opacity = '59'
+                    break
+                case '0.4':
+                    opacity = '66'
+                    break
+                case '0.45':
+                    opacity = '72'
+                    break
+                case '0.5':
+                    opacity = '7F'
+                    break
+                case '0.55':
+                    opacity = '8C'
+                    break
+                case '0.6':
+                    opacity = '99'
+                    break
+                case '0.65':
+                    opacity = 'A5'
+                    break
+                case '0.7':
+                    opacity = 'B2'
+                    break
+                case '0.75':
+                    opacity = 'BF'
+                    break
+                case '0.8':
+                    opacity = 'CC'
+                    break
+                case '0.85':
+                    opacity = 'D8'
+                    break
+                case '0.9':
+                    opacity = 'E5'
+                    break
+                case '0.95':
+                    opacity = 'F2'
+                    break
+                case '1':
+                    opacity = 'FF'
+                    break
+            }
+            var hex = '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) + opacity
+            console.log(hex, 'hrc')
+            return hex
+
+            // return '#' + ('0' + r.toString(16)).slice(-2) + ('0' + g.toString(16)).slice(-2) + ('0' + b.toString(16)).slice(-2) + opacity
         },
         // 背景颜色改变
         changBgColor(val) {

+ 2 - 17
src/views/legendLibrary/addLegend.vue

@@ -19,6 +19,7 @@
             :data='treeData'
             @cancel='treeCancel'
             @confirm='treeConfirm'
+            :key='new Date().getTime()'
         />
     </div>
 </template>
@@ -133,23 +134,7 @@ export default {
             if (this.info.Name == '') {
                 this.$message.info('请填写图例名称')
                 return false
-            }
-            //  else if (this.info.Type == 'Zone') {
-            //     if (this.info.FillColor == '') {
-            //         this.$message.info('请选择填充色以及透明度')
-            //         return false
-            //     }
-            //     if (this.info.Color == '') {
-            //         this.$message.info('请选择边框颜色')
-            //         return false
-            //     }
-            // } else if (this.info.Type == 'Line') {
-            //     if (this.info.Color == '') {
-            //         this.$message.info('请选择边框颜色')
-            //         return false
-            //     }
-            // }
-            else {
+            } else {
                 if (this.info.Type != 'Image' && this.info.Type != 'None') {
                     this.$refs.add.saveImg()
                 } else {

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

@@ -169,6 +169,86 @@ import {
     getVisualization,
     queryRelation
 } from '@/api/legendLibrary.js'
+
+function hexToRgba(hex) {
+    let opacity = ''
+    switch (hex.slice(7, 9)) {
+        case '00':
+            opacity = '0'
+            break
+        case '0C':
+            opacity = '0.05'
+            break
+        case '19':
+            opacity = '0.1'
+            break
+        case '26':
+            opacity = '0.15'
+            break
+        case '33':
+            opacity = '0.2'
+            break
+        case '3F':
+            opacity = '0.25'
+            break
+        case '4C':
+            opacity = '0.3'
+            break
+        case '59':
+            opacity = '0.35'
+            break
+        case '66':
+            opacity = '0.4'
+            break
+        case '72':
+            opacity = '0.45'
+            break
+        case '7F':
+            opacity = '0.5'
+            break
+        case '8C':
+            opacity = '0.55'
+            break
+        case '99':
+            opacity = '0.6'
+            break
+        case 'A5':
+            opacity = '0.65'
+            break
+        case 'B2':
+            opacity = '0.7'
+            break
+        case 'BF':
+            opacity = '0.75'
+            break
+        case 'CC':
+            opacity = '0.8'
+            break
+        case 'D8':
+            opacity = '0.85'
+            break
+        case 'E5':
+            opacity = '0.9'
+            break
+        case 'F2':
+            opacity = '0.95'
+            break
+        case 'FF':
+            opacity = '1'
+            break
+    }
+    return (
+        'rgba(' +
+        parseInt('0x' + hex.slice(1, 3)) +
+        ',' +
+        parseInt('0x' + hex.slice(3, 5)) +
+        ',' +
+        parseInt('0x' + hex.slice(5, 7)) +
+        ',' +
+        opacity +
+        ')'
+    )
+}
 export default {
     components: { addLegend, Select },
     data() {
@@ -362,8 +442,16 @@ export default {
             }
             graphElementSearch({ postParams }).then(res => {
                 this.key++
-                this.tableData = res.Content
+                // this.tableData = res.Content
                 this.total = res.Total
+                console.log(res.Content)
+                this.tableData = res.Content.map(i => {
+                    if (i.FillColor.length == '9') {
+                        i.FillColor = hexToRgba(i.FillColor)
+                    }
+                    return i
+                })
+                console.log(this.tableData)
             })
         },