瀏覽代碼

image upload

zhulizhen1111 4 年之前
父節點
當前提交
0f760c3133
共有 3 個文件被更改,包括 36 次插入23 次删除
  1. 10 2
      src/views/legendLibrary/addForm.vue
  2. 11 2
      src/views/legendLibrary/addLegend.vue
  3. 15 19
      vue.config.js

+ 10 - 2
src/views/legendLibrary/addForm.vue

@@ -163,6 +163,7 @@ export default {
                 }
             ],
             fileList: [],
+            file: '',
             // this.ruleForm.Url 图标的key,/serve/topology-wanda/Picture/query/${this.ruleForm.Url}
             value: '',
             linepxObject: {
@@ -182,11 +183,16 @@ export default {
     props: ['ruleForm', 'title'],
     methods: {
         getFile(file) {
+            this.file = file.file
+            console.log(file)
             var formData = new FormData()
             formData.append('file', file.file)
-            formData.append('uid', this.ruleForm.Url)
+            if (this.ruleForm.Url) {
+                formData.append('uid', this.ruleForm.Url)
+            }
             let postParams = formData
             uploadImg({ postParams }).then(res => {
+                console.log(res)
                 if (res.Result == 'success') {
                     this.$set(this.ruleForm, 'Url', res.EntityList[0])
                     this.$message.success('图标上传成功!')
@@ -199,6 +205,7 @@ export default {
                 Content: [this.ruleForm]
             }
             createLegend({ postParams }).then(res => {
+                console.log(res)
                 if (res.Result == 'success') {
                     this.$message.success('添加图例成功!')
                     this.$emit('addSuccess')
@@ -316,6 +323,7 @@ export default {
             return new File([u8arr], filename, { type: mime })
         },
         saveImg() {
+            let vm = this
             if (this.view) {
                 let data = this.view.canvasView.toDataURL('image/png')
                 var formData = new FormData()
@@ -323,7 +331,7 @@ export default {
                 let postParams = formData
                 uploadImg({ postParams }).then(res => {
                     if (res.Result == 'success') {
-                        this.$set(this.ruleForm, 'Url', res.EntityList[0])
+                        this.$set(vm.ruleForm, 'Url', res.EntityList[0])
                         this.$message.success('图标上传成功!')
                         if (this.title == '添加图例库') {
                             this.create()

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

@@ -2,7 +2,6 @@
     <div class='add-legend'>
         <el-dialog :title='title' :visible.sync='dialogVisible'>
             <!-- <add-list v-show='title=="" && GraphCategoryId' ref='searchList' :GraphCategoryId='GraphCategoryId' @mesg='mesg'></add-list> -->
-
             <add-form ref='add' :ruleForm='info' @addSuccess='addSuccess' @updateSuccess='updateSuccess' :title='title'></add-form>
             <span slot='footer' class='dialog-footer'>
                 <el-button @click='dialogVisible = false,cancal()' size='small'>取 消</el-button>
@@ -118,7 +117,17 @@ export default {
                 this.$message.info('请填写图例名称')
                 return false
             } else {
-                this.$refs.add.saveImg()
+                if (this.info.Type != 'Image') {
+                    this.$refs.add.saveImg()
+                } else {
+                    if (this.title == '添加图例库') {
+                        this.$refs.add.create()
+                        this.$emit('addSuccess')
+                    } else if (this.title == '修改图例库') {
+                        this.$refs.add.update()
+                        this.$emit('updateSuccess')
+                    }
+                }
                 this.dialogVisible = false
                 if (!this.title) {
                     this.$refs.searchList.save()

+ 15 - 19
vue.config.js

@@ -1,33 +1,29 @@
 module.exports = {
     devServer: {
         proxy: {
-            '/data': {
-                target: 'http://192.168.200.87:9003',
+            "/data": {
+                target: "http://192.168.200.87:9003",
                 changeOrigin: true,
                 secure: false,
                 pathRewrite: {
-                    '^/data': '',
+                    "^/data": "",
                 },
             },
-            '/wanda': {
-                target: 'http://map.wanda.cn/editor/fmap/1001724_29',
+            "/wanda": {
+                target: "http://map.wanda.cn/editor/fmap/1001724_29",
                 changeOrigin: true,
                 pathRewrite: {
-                    '^/wanda': '',
+                    "^/wanda": "",
                 },
             },
-            '/serve': {
-                target: 'http://192.168.200.87:8088',
+            "/serve": {
+                target: "http://192.168.200.87:8088",
                 changeOrigin: true,
                 pathRewrite: {
-                    '^/serve': '',
+                    "^/serve": "",
                 },
             },
         },
-        hot: true,
-        host: '192.168.200.82',
-        open: true,
-        port: 8080,
         // 关闭esline
         overlay: {
             warnings: false,
@@ -35,15 +31,15 @@ module.exports = {
         },
     },
     chainWebpack: (config) => {
-        const svgRule = config.module.rule('svg')
+        const svgRule = config.module.rule("svg")
         svgRule.uses.clear()
         svgRule
-            .use('babel-loader')
-            .loader('babel-loader')
+            .use("babel-loader")
+            .loader("babel-loader")
             .end()
-            .use('vue-svg-loader')
-            .loader('vue-svg-loader')
+            .use("vue-svg-loader")
+            .loader("vue-svg-loader")
     },
     lintOnSave: false,
-    publicPath: '/',
+    publicPath: "/",
 }