cmdb数据同步树结构资源接口调用,表格组件增加展开功能
Showing
7 changed files
with
124 additions
and
57 deletions
@@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
7 | @import "../css/alarmsClear.css"; | 7 | @import "../css/alarmsClear.css"; |
8 | /*日志详情*/ | 8 | /*日志详情*/ |
9 | @import "../css/esData.css"; | 9 | @import "../css/esData.css"; |
10 | +/*cmdb数据同步*/ | ||
11 | +@import "../css/cmdbdatasync.css"; | ||
10 | 12 | ||
11 | .d-flex { | 13 | .d-flex { |
12 | display: flex; | 14 | display: flex; |
1 | +.protocol-btn{ | ||
2 | + display: flex; | ||
3 | + justify-content: center; | ||
4 | + align-items: center; | ||
5 | +} | ||
6 | +.icon-add{ | ||
7 | + margin-left:10px; | ||
8 | + width:20px; | ||
9 | + height:20px; | ||
10 | + background: #1e9fff; | ||
11 | + display: flex; | ||
12 | + align-items: center; | ||
13 | + justify-content: center; | ||
14 | + cursor: pointer; | ||
15 | +} | ||
16 | +.protocol-btn i{ | ||
17 | + color:#ffffff; | ||
18 | +} |
1 | <div > | 1 | <div > |
2 | <!-- 表格--> | 2 | <!-- 表格--> |
3 | <el-table :border="showBorder" v-loading="loading" :size="size" ref="multipleTable" @selection-change="handleSelectionChange" :data="dataList" stripe header-row-class-name="tbl-header-class" :height="height" | 3 | <el-table :border="showBorder" v-loading="loading" :size="size" ref="multipleTable" @selection-change="handleSelectionChange" :data="dataList" stripe header-row-class-name="tbl-header-class" :height="height" |
4 | - style="width: 100%;margin: 0px 0px; font-size:13.5px;"> | 4 | + style="width: 100%;margin: 0px 0px; font-size:13.5px;" :row-key="getRowKeys" :expand-row-keys="expands"> |
5 | + | ||
6 | + <el-table-column type="expand" v-if="showExpand"> | ||
7 | + <template #default="scope"> | ||
8 | + <slot name="expand" :scope="scope" > | ||
9 | + | ||
10 | + </slot> | ||
11 | + </template> | ||
12 | + </el-table-column> | ||
5 | <el-table-column v-if="showSelection && columns.length > 0" align="center" type="selection" width="55" /> | 13 | <el-table-column v-if="showSelection && columns.length > 0" align="center" type="selection" width="55" /> |
6 | <el-table-column v-if="showIndex && columns.length > 0" type="index" :label="indexLabel" align="center" width="50"/> | 14 | <el-table-column v-if="showIndex && columns.length > 0" type="index" :label="indexLabel" align="center" width="50"/> |
7 | 15 |
@@ -87,6 +87,21 @@ export default { | @@ -87,6 +87,21 @@ export default { | ||
87 | multipleSelection:{ | 87 | multipleSelection:{ |
88 | type:Array, | 88 | type:Array, |
89 | default:[] | 89 | default:[] |
90 | + }, | ||
91 | + //展开行 | ||
92 | + showExpand:{ | ||
93 | + type: Boolean, | ||
94 | + default: false | ||
95 | + }, | ||
96 | + //行数据的key | ||
97 | + getRowKeys:{ | ||
98 | + type: String, | ||
99 | + default: 'id' | ||
100 | + }, | ||
101 | + //是否默认展开所有行 | ||
102 | + expands:{ | ||
103 | + type: Array, | ||
104 | + default: [] | ||
90 | } | 105 | } |
91 | }, | 106 | }, |
92 | data() { | 107 | data() { |
1 | <div class="cmdbdatasyncEdit-container" style="min-height: 500px;"> | 1 | <div class="cmdbdatasyncEdit-container" style="min-height: 500px;"> |
2 | + | ||
2 | <div class="search-table"> | 3 | <div class="search-table"> |
3 | - <cm-table-page :columns="columns" :dataList="editTbaleData" | 4 | + <cm-table-page :columns="tableData.columns" :dataList="editTbaleData" |
4 | :showIndex="true" | 5 | :showIndex="true" |
5 | @loaddata = "loaddata" | 6 | @loaddata = "loaddata" |
6 | :showSelection="false" | 7 | :showSelection="false" |
@@ -8,8 +9,14 @@ | @@ -8,8 +9,14 @@ | ||
8 | :loading="false" | 9 | :loading="false" |
9 | :pageSize="pageSize" | 10 | :pageSize="pageSize" |
10 | :showPage="false" | 11 | :showPage="false" |
11 | - :showTools="false" | 12 | + :showTools="true" |
13 | + :showExpand="true" | ||
14 | + :getRowKeys="tableData.getRowKeys" | ||
15 | + :expands="tableData.expands" | ||
12 | :height="height - 110"> | 16 | :height="height - 110"> |
17 | + <template #expand="{scope}"> | ||
18 | + aaa{{scope.row.expand}} | ||
19 | + </template> | ||
13 | <template #default="{row,prop,column}"> | 20 | <template #default="{row,prop,column}"> |
14 | <div> | 21 | <div> |
15 | <el-input v-model="row[prop]" placeholder="Please input" /> | 22 | <el-input v-model="row[prop]" placeholder="Please input" /> |
@@ -22,6 +29,11 @@ | @@ -22,6 +29,11 @@ | ||
22 | </el-select>--> | 29 | </el-select>--> |
23 | </div> | 30 | </div> |
24 | </template> | 31 | </template> |
32 | + <template #tools="{scope}"> | ||
33 | + <div class="protocol-btn"> | ||
34 | + <span class="icon-add" @click="addProtocol" title="协议参数"><i class="el-icon-plus"></i></span> | ||
35 | + </div> | ||
36 | + </template> | ||
25 | </cm-table-page> | 37 | </cm-table-page> |
26 | </div> | 38 | </div> |
27 | <div class="save-button" style="text-align:right;"> | 39 | <div class="save-button" style="text-align:right;"> |
@@ -14,7 +14,9 @@ export default { | @@ -14,7 +14,9 @@ export default { | ||
14 | const {proxy} = Vue.getCurrentInstance(); | 14 | const {proxy} = Vue.getCurrentInstance(); |
15 | let height = Vue.ref(window.innerHeight); | 15 | let height = Vue.ref(window.innerHeight); |
16 | let editTbaleData=Vue.ref(props.tableData.dataList); | 16 | let editTbaleData=Vue.ref(props.tableData.dataList); |
17 | - let columns=Vue.ref(props.tableData.columns) | 17 | + // let columns=Vue.ref(props.tableData.columns); |
18 | + // let getRowKeys=Vue.ref(props.tableData.getRowKeys); | ||
19 | + // let expands=Vue.ref(props.tableData.expands); | ||
18 | //保存编辑 | 20 | //保存编辑 |
19 | let saveEdit=()=>{ | 21 | let saveEdit=()=>{ |
20 | //保存接口 todo | 22 | //保存接口 todo |
@@ -24,6 +26,33 @@ export default { | @@ -24,6 +26,33 @@ export default { | ||
24 | } | 26 | } |
25 | emit("callbackedit",param) | 27 | emit("callbackedit",param) |
26 | } | 28 | } |
29 | + //添加协议 | ||
30 | + let addProtocol=()=>{ | ||
31 | + proxy.$global.layer.open({ | ||
32 | + title:'资源协议', | ||
33 | + id:'resManageChooseProtocolHtml', | ||
34 | + type:1, | ||
35 | + area: ['80%', '90%'], | ||
36 | + btn:['确定','取消'], | ||
37 | + scrollbar:true, | ||
38 | + success: function(){ | ||
39 | + proxy.$global.layui.view('resManageChooseProtocolHtml').render('/baseconfig/protocol/index',{'hasParam':'1'}); | ||
40 | + }, | ||
41 | + yes:function (index,layero) { | ||
42 | + var data = proxy.$global.layui.table.checkStatus('protocol_table').data; | ||
43 | + formData.ip = $('#resManageAddForm').find('input[name="ip"]').val(); | ||
44 | + formData.port = $('#resManageAddForm').find('input[name="port"]').val(); | ||
45 | + if(data.length>0){ | ||
46 | + createProtocolDom(data,false); | ||
47 | + form.render() | ||
48 | + layer.close(index); | ||
49 | + }else{ | ||
50 | + layer.msg("无选中的数据或当",{ offset: '15px' , icon: 7 , time: 2000 }) | ||
51 | + return false; | ||
52 | + } | ||
53 | + } | ||
54 | + }) | ||
55 | + } | ||
27 | // 挂载完 | 56 | // 挂载完 |
28 | Vue.onMounted(() => { | 57 | Vue.onMounted(() => { |
29 | }) | 58 | }) |
@@ -32,8 +61,11 @@ export default { | @@ -32,8 +61,11 @@ export default { | ||
32 | return { | 61 | return { |
33 | height, | 62 | height, |
34 | editTbaleData, | 63 | editTbaleData, |
35 | - columns, | ||
36 | - saveEdit | 64 | + // columns, |
65 | + saveEdit, | ||
66 | + addProtocol, | ||
67 | + // getRowKeys, | ||
68 | + // expands | ||
37 | } | 69 | } |
38 | } | 70 | } |
39 | 71 |
@@ -10,56 +10,19 @@ export default { | @@ -10,56 +10,19 @@ export default { | ||
10 | setup(props, {attrs, slots, emit}) { | 10 | setup(props, {attrs, slots, emit}) { |
11 | const {proxy} = Vue.getCurrentInstance(); | 11 | const {proxy} = Vue.getCurrentInstance(); |
12 | let height = Vue.ref(window.innerHeight); | 12 | let height = Vue.ref(window.innerHeight); |
13 | - let treeData=Vue.ref([ | ||
14 | - { | ||
15 | - label: '计算机设备计算机设备计算机设备计算机设备计算机设备', | ||
16 | - id:1, | ||
17 | - children: [ | ||
18 | - { | ||
19 | - label: '小型机分区', | ||
20 | - id:"1-1", | ||
21 | - }, | ||
22 | - { | ||
23 | - label: 'PC服务器', | ||
24 | - id:'1-2', | ||
25 | - children:[] | ||
26 | - }, | ||
27 | - ], | ||
28 | - }, | ||
29 | - { | ||
30 | - label: '虚拟化', | ||
31 | - id:2, | ||
32 | - children: [ | ||
33 | - { | ||
34 | - label: 'VMWARE', | ||
35 | - id:'2-1', | ||
36 | - children: [ | ||
37 | - { | ||
38 | - label: 'vm资源池', | ||
39 | - id:"2-1-1", | ||
40 | - children: [] | ||
41 | - }, | ||
42 | - ], | ||
43 | - }, | ||
44 | - { | ||
45 | - label: '虚拟机', | ||
46 | - id:"2-2", | ||
47 | - }, | ||
48 | - ], | ||
49 | - }, | ||
50 | - { | ||
51 | - label: '存储设备', | ||
52 | - id:'3', | ||
53 | - children: [ | ||
54 | - { | ||
55 | - label: '共享存储', | ||
56 | - id:'3-1', | ||
57 | - }, | ||
58 | - | ||
59 | - ], | ||
60 | - }]) // 所有的树结点 | 13 | + let defaultProps=Vue.ref({ |
14 | + children: 'children', | ||
15 | + label: 'title' | ||
16 | + }) | ||
17 | + let treeData=Vue.ref([]) // 所有的树结点 | ||
18 | + let defaultNode=Vue.ref(true);//默认节点 | ||
19 | + let resType=Vue.ref('');//选中的树节点值 | ||
61 | let handleNodeClick=(data,node)=>{ | 20 | let handleNodeClick=(data,node)=>{ |
62 | //点击树节点,根据某个字段获取列表 todo | 21 | //点击树节点,根据某个字段获取列表 todo |
22 | + console.log("*(*(*(*",data,node) | ||
23 | + proxy.$global.showMsg(data.id,'warning') | ||
24 | + resType.value=data.value; | ||
25 | + defaultNode.value=false; | ||
63 | getDataList(); | 26 | getDataList(); |
64 | } | 27 | } |
65 | 28 | ||
@@ -72,8 +35,10 @@ export default { | @@ -72,8 +35,10 @@ export default { | ||
72 | let tableData = Vue.ref({ | 35 | let tableData = Vue.ref({ |
73 | count:0, | 36 | count:0, |
74 | dataList: [{ | 37 | dataList: [{ |
38 | + id:1, | ||
75 | resName:'资源一' | 39 | resName:'资源一' |
76 | },{ | 40 | },{ |
41 | + id:2, | ||
77 | resName:'资源34' | 42 | resName:'资源34' |
78 | }], | 43 | }], |
79 | columns: [ | 44 | columns: [ |
@@ -140,6 +105,14 @@ export default { | @@ -140,6 +105,14 @@ export default { | ||
140 | hideDialog(true); | 105 | hideDialog(true); |
141 | dialog.value.tableData.dataList= row; | 106 | dialog.value.tableData.dataList= row; |
142 | dialog.value.tableData.columns=tableData.value.columns; | 107 | dialog.value.tableData.columns=tableData.value.columns; |
108 | + dialog.value.tableData.getRowKeys= 'id'; | ||
109 | + let arr=[]; | ||
110 | + row.map(item=>{ | ||
111 | + arr.push(item.id) | ||
112 | + }) | ||
113 | + //默认展开第一行 | ||
114 | + dialog.value.tableData.expands= [arr[0]]; | ||
115 | + | ||
143 | } | 116 | } |
144 | //编辑 | 117 | //编辑 |
145 | let handleEdit = (flag,row) =>{ | 118 | let handleEdit = (flag,row) =>{ |
@@ -179,9 +152,9 @@ export default { | @@ -179,9 +152,9 @@ export default { | ||
179 | proxy.$global.openDetail(resId, resType, proxy); | 152 | proxy.$global.openDetail(resId, resType, proxy); |
180 | 153 | ||
181 | } | 154 | } |
182 | - //获取资源树数据 todo | 155 | + //获取资源树数据 |
183 | let getResData=()=>{ | 156 | let getResData=()=>{ |
184 | - proxy.$http.post(`/api-web/`, {}, function (res) { | 157 | + proxy.$http.post(`/api-web/attribute/getTree`, {}, function (res) { |
185 | if (res && res.data) { | 158 | if (res && res.data) { |
186 | treeData.value = res.data; | 159 | treeData.value = res.data; |
187 | } | 160 | } |
@@ -189,7 +162,11 @@ export default { | @@ -189,7 +162,11 @@ export default { | ||
189 | } | 162 | } |
190 | // 获取列表 todo | 163 | // 获取列表 todo |
191 | let getDataList = () => { | 164 | let getDataList = () => { |
165 | + if(defaultNode.value){ | ||
166 | + resType.value=treeData.value[0].children[0].value; | ||
167 | + } | ||
192 | let params={ | 168 | let params={ |
169 | + resType:resType.value, | ||
193 | pageNum: search.value.pageNum, | 170 | pageNum: search.value.pageNum, |
194 | pageSize: search.value.pageSize, | 171 | pageSize: search.value.pageSize, |
195 | keyword:search.value.keyword | 172 | keyword:search.value.keyword |
@@ -208,12 +185,14 @@ export default { | @@ -208,12 +185,14 @@ export default { | ||
208 | // 挂载完 | 185 | // 挂载完 |
209 | Vue.onMounted(() => { | 186 | Vue.onMounted(() => { |
210 | // getDataList();//获取列表数据 | 187 | // getDataList();//获取列表数据 |
211 | - // getResData();//获取资源树数据 | 188 | + getResData();//获取资源树数据 |
212 | }) | 189 | }) |
213 | 190 | ||
214 | 191 | ||
215 | return { | 192 | return { |
193 | + defaultProps, | ||
216 | treeData, | 194 | treeData, |
195 | + defaultNode, | ||
217 | handleNodeClick, | 196 | handleNodeClick, |
218 | getResData, | 197 | getResData, |
219 | height, | 198 | height, |
@@ -230,6 +209,7 @@ export default { | @@ -230,6 +209,7 @@ export default { | ||
230 | handleRefresh, | 209 | handleRefresh, |
231 | callbackedit, | 210 | callbackedit, |
232 | goResDetail, | 211 | goResDetail, |
212 | + resType | ||
233 | } | 213 | } |
234 | } | 214 | } |
235 | 215 |
-
Please register or login to post a comment