瀏覽代碼

添加接口,修改图例展示等问题

shaun-sheep 5 年之前
父節點
當前提交
89c876e3cf
共有 4 個文件被更改,包括 55 次插入62 次删除
  1. 1 0
      src/api/legendLibrary.js
  2. 23 24
      src/views/legendLibrary/addLegend.vue
  3. 11 21
      src/views/legendLibrary/index.vue
  4. 20 17
      src/views/legendRules/index.vue

+ 1 - 0
src/api/legendLibrary.js

@@ -29,6 +29,7 @@ export function getLegendTree({
 }) {
     return httputils.getJson(`/serve/topology-wanda/graphCategory/queryByGroup`, getParams)
 }
+
 //图例库-系统tree相关表格查询
 export function queryRelation({
     data,

+ 23 - 24
src/views/legendLibrary/addLegend.vue

@@ -2,24 +2,17 @@
     <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> -->
-            <!-- 
-            <Transfer
-                :data='treeData3'
-                :linkage='false'
-                :lastStage='true'
-                @confirm='treeConfirm3'
-                v-if='title=="" && GraphCategoryId'
-                ref='searchList'
-            />-->
-            <!-- <template v-else> -->
+
             <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>
                 <el-button type='primary' @click='save' size='small'>确 定</el-button>
             </span>
-            <!-- </template> -->
         </el-dialog>
         <TransferSelectModal
+            defaultExpandAll
+            default-expand-all
+            v-if='treeData.length'
             :modalShow='modalShow4'
             placeholder='搜索'
             :linkage='false'
@@ -34,18 +27,8 @@
 <script>
 import addForm from './addForm'
 import addList from '../legendRules/addList'
-import { groupByCategory } from '@/api/legendLibrary.js'
-import func from '../../../vue-temp/vue-editor-bridge'
+import { groupByCategory, updateRelation } from '@/api/legendLibrary.js'
 
-// function getTree(data) {
-//     data.id = data.Id
-//     data.name = data.Name
-//     for (var i = 0; i < data.Children.length; i++) {
-//         if (data.Children[i] && data.Children[i].length > 0) {
-//             getTree(data.Children[i])
-//         }
-//     }
-// }
 export default {
     data() {
         return {
@@ -74,8 +57,7 @@ export default {
             if (GraphCategoryId) {
                 groupByCategory({}).then(res => {
                     this.treeData = []
-                    res.Data.forEach(i => {})
-                    // console.log(getTree(this.treeData))
+                    this.treeData = res.Data.map(i => this.getTree(i))
                 })
                 //treeSelect
                 this.modalShow4 = true
@@ -104,6 +86,13 @@ export default {
                 this.$refs.searchList.queryAll()
             }
         },
+        getTree(data) {
+            return {
+                id: data.Id,
+                name: data.Name,
+                children: data.Children && data.Children.length > 0 ? data.Children.map(i => this.getTree(i)) : []
+            }
+        },
         cancal() {
             this.info = {
                 Name: '',
@@ -139,6 +128,16 @@ export default {
         treeConfirm(ids, dataObj) {
             console.log('确定:::', ids)
             console.log('确定:::', dataObj)
+            let postParams = {
+                GraphCategoryId: this.GraphCategoryId,
+                GraphElementIds: ids
+            }
+            updateRelation({ postParams }).then(res => {
+                if (res.Result == 'success') {
+                    this.$message.success('添加成功!')
+                    this.$emit('mesg')
+                }
+            })
         },
         treeCancel() {
             this.modalShow4 = false

+ 11 - 21
src/views/legendLibrary/index.vue

@@ -27,7 +27,7 @@
                     :selectdata='positionSelect'
                     :placeholder='"请选择"'
                     style='margin:0 12px'
-                    @change='getTableList'
+                    @confirm='getTableListPosition'
                 ></Select>
                 <Select width='180' tipPlace='top' caption='位置/设备分类:' :selectdata='dataSelect2' @change='getTableList' :placeholder='"请选择"'></Select>
                 <Select
@@ -128,7 +128,7 @@
 <script>
 import addLegend from './addLegend'
 import Select from '@/components/Select/Select.vue'
-import { queryLegend, deleteLegend, queryTypeId, getVisualization } from '@/api/legendLibrary.js'
+import { queryLegend, deleteLegend, queryTypeId, getVisualization, queryRelation } from '@/api/legendLibrary.js'
 export default {
     components: { addLegend, Select },
     data() {
@@ -185,32 +185,13 @@ export default {
         }
     },
     methods: {
-        // filtersTree() {
-        //     let cloneData = JSON.parse(JSON.stringify(this.list))
-        //     return cloneData.filter(father => {
-        //         let branchArr = cloneData.filter(child => father.id == child.parentId)
-        //         branchArr.length > 0 ? (father.children = branchArr) : ''
-        //         return father.parentId == 0 //返回第一层
-        //     })
-        //     console.log(cloneData, 'cloone')
-        // },
         dumpRules() {
             this.$router.push('/home/legendRules')
         },
         getTypeId() {
             let postParams = {}
             queryTypeId({ postParams }).then(res => {
-                console.log(res, 33333)
                 this.typeIdSelect = res.Content
-
-                // let content = res.Content
-                // content.forEach(el => {
-                //     this.typeIdSelect.push({
-                //         id: el.Type + '',
-                //         name: el.Name
-                //     })
-                // })
-                // console.log(this.typeIdSelect)
             })
         },
         visualization() {
@@ -259,6 +240,15 @@ export default {
             this.currentPage = page
             this.getTableList()
         },
+        getTableListPosition(val) {
+            let postParams = val.map(({ id }) => id)
+            let data = {}
+            queryRelation({ data, postParams }).then(res => {
+                this.tableData = res.data.Content
+                this.total = res.Total
+                console.log(this.tableData, res)
+            })
+        },
         getTableList() {
             let postParams = {
                 PageNumber: this.currentPage,

+ 20 - 17
src/views/legendRules/index.vue

@@ -8,7 +8,15 @@
         <div class='legend-rules-bottom'>
             <div class='legend-rules-left'>
                 <p>楼层功能</p>
-                <el-tree :data='treeData' default-expand-all @node-click='handleNodeClick'></el-tree>
+                <!-- <el-tree :data='treeData' :default-checked-keys='`GDXT`' :props='defaultProps' default-expand-all @node-click='handleNodeClick'></el-tree> -->
+                <a-tree
+                    :tree-data='treeData'
+                    v-if='treeData.length'
+                    defaultExpandAll
+                    :replaceFields='defaultProps'
+                    :default-selected-keys='["GDXT"]'
+                    @select='handleNodeClick'
+                ></a-tree>
             </div>
             <div class='legend-rules-right'>
                 <el-table :data='tableData' style='width: 100%'>
@@ -43,13 +51,18 @@ export default {
     data() {
         return {
             treeData: [],
-            GraphCategoryId: 'DTXT',
-            tableData: []
+            GraphCategoryId: ['GDXT'],
+            tableData: [],
+            defaultProps: {
+                children: 'Category',
+                title: 'Name',
+                key: 'Id'
+            }
         }
     },
     methods: {
         handleNodeClick(data) {
-            this.GraphCategoryId = data.Id
+            this.GraphCategoryId = data
             this.getData()
         },
         deleteClick(row) {
@@ -79,23 +92,13 @@ export default {
         init() {
             let getParams = {}
             getLegendTree({ getParams }).then(res => {
-                let content = res.Content
-                content.forEach(el => {
-                    el.label = el.Name
-                    el.children = el.Category || []
-                    el.Category.forEach(ele => {
-                        ele.label = ele.Name
-                    })
-                })
-                this.treeData = content
+                this.treeData = res.Content
                 this.getData()
             })
         },
         getData() {
-            let postParams = {}
-            let data = {
-                graphCategoryId: this.GraphCategoryId
-            }
+            let postParams = this.GraphCategoryId
+            let data = {}
             queryRelation({ data, postParams }).then(res => {
                 this.tableData = res.data.Content
             })