Authored by wangtao

fix: 端口侦测v2

1 -<div>  
2 - <el-dialog v-model="dialogVisible" title="新增" width="50%" :before-close="beforeClose">  
3 - <div>  
4 - <div style="margin-right:6px;">  
5 - <!--<cm-res-type-tree-input @callback="getResType" clearable collapseTags multiple/>-->  
6 - </div>  
7 - <div class="flex-div-start" style="float: left;">  
8 - <el-button :size="$global.elementConfig.size.button" @click="onBtnSearch()" style="margin-left: 6px" type="primary">搜索</el-button>  
9 - </div>  
10 - </div>  
11 - <template #footer>  
12 - <span class="dialog-footer">  
13 - <el-button @click="beforeClose">取消</el-button>  
14 - <el-button type="primary" @click="submit">确定</el-button>  
15 - </span>  
16 - </template>  
17 - </el-dialog>  
18 -</div>  
1 -export default {  
2 - name: 'portSenseAdd',  
3 - template: '',  
4 - components: {  
5 - },  
6 - props:{  
7 - dialogVisible:{  
8 - type:Boolean,  
9 - }  
10 - },  
11 - setup(props, {attrs, slots, emit}){  
12 - const {proxy} = Vue.getCurrentInstance();  
13 -  
14 - let types = Vue.ref([]);  
15 - //获取资源类型  
16 - let getResType = (arr) => {  
17 - types.value = arr.map(function (v) {  
18 - return v.id;  
19 - });  
20 - }  
21 -  
22 - const onBtnSearch = ()=>{  
23 -  
24 - }  
25 -  
26 - const submit = ()=>{  
27 - if (types.value.length === 0) {  
28 - proxy.$global.layer.msg('请选择一项', {icon: 7, timeout: 3000});  
29 - return false;  
30 - }  
31 - beforeClose();  
32 - }  
33 -  
34 - const beforeClose = () => {  
35 - emit('beforeClose')  
36 - }  
37 -  
38 - return {  
39 - getResType,  
40 - onBtnSearch,  
41 - submit,  
42 - beforeClose  
43 - }  
44 - }  
45 -}  
@@ -185,7 +185,8 @@ export default { @@ -185,7 +185,8 @@ export default {
185 proxy.$http.post("/api-web/bResourceExtendParam/conserve", portSenseConfigData.value, function (res) { 185 proxy.$http.post("/api-web/bResourceExtendParam/conserve", portSenseConfigData.value, function (res) {
186 if (res && res.success) { 186 if (res && res.success) {
187 proxy.$global.showMsg("保存成功!"); 187 proxy.$global.showMsg("保存成功!");
188 - loadTableDataList({page: 1, limit: pageSize.value}); 188 + // loadTableDataList({page: 1, limit: pageSize.value});
  189 + emit('saveSuccess')
189 } 190 }
190 }) 191 })
191 } 192 }
@@ -80,19 +80,26 @@ @@ -80,19 +80,26 @@
80 <cm-dialog :showDialogVisible="showPortSense" :showFooter="false" :showOkBtn="false" :title="title" 80 <cm-dialog :showDialogVisible="showPortSense" :showFooter="false" :showOkBtn="false" :title="title"
81 @hidedialog="showPortSenseDialog" cancelText="关闭" width="80%"> 81 @hidedialog="showPortSenseDialog" cancelText="关闭" width="80%">
82 <template v-slot> 82 <template v-slot>
83 - {{portSenseConfigData}}  
84 <el-steps :active="stepActive" align-center finish-status="success"> 83 <el-steps :active="stepActive" align-center finish-status="success">
85 <el-step title="选择资源" description="可以多选" /> 84 <el-step title="选择资源" description="可以多选" />
86 <el-step title="配置端口" description="" /> 85 <el-step title="配置端口" description="" />
87 </el-steps> 86 </el-steps>
88 87
89 - <div>  
90 - <el-button style="margin-top: 12px" @click="next">Next step</el-button> 88 + <div v-if="stepActive == 1" style="display: flex;justify-content: space-around;padding: 0px 25%;">
  89 + <el-tree-select
  90 + v-model="portSenseConfigData"
  91 + :data="resTreeArr"
  92 + filterable
  93 + multiple
  94 + collapse-tags
  95 + :render-after-expand="false"
  96 + :size="$global.elementConfig.size.input"
  97 + show-checkbox
  98 + :props="typeProps"/>
  99 + <el-button style="margin-top: 12px" @click="next">下一步</el-button>
91 </div> 100 </div>
92 101
93 - <port-sense-config v-if="stepActive == 1" :parameter="portSenseConfigData"></port-sense-config> 102 + <port-sense-config v-if="stepActive == 2" :parameter="portSenseConfigData" @saveSuccess="closeDialog"></port-sense-config>
94 </template> 103 </template>
95 </cm-dialog> 104 </cm-dialog>
96 -  
97 - <port-sense-add :dialogVisible="dialogVisible" @beforeClose="beforeClose"></port-sense-add>  
98 </div> 105 </div>
@@ -100,12 +100,7 @@ export default { @@ -100,12 +100,7 @@ export default {
100 } 100 }
101 }) 101 })
102 } 102 }
103 - // 挂载完  
104 - Vue.onMounted(() => {  
105 - init();  
106 - getListData({page: 1, limit: pageSize.value});  
107 - onReset();//清空搜索条件(资源id)  
108 - }) 103 +
109 //获取列表数据 104 //获取列表数据
110 const getListData = ({page, limit}) => { 105 const getListData = ({page, limit}) => {
111 //定义列表参数 106 //定义列表参数
@@ -193,37 +188,10 @@ export default { @@ -193,37 +188,10 @@ export default {
193 } 188 }
194 //添加 189 //添加
195 let save = () => { 190 let save = () => {
196 - //获取所有的端口侦测信息  
197 - let dataList = [];  
198 - let getParams = {  
199 - keyWords: '',  
200 - resTypes: '',  
201 - resIds: '',  
202 - busIds: '',  
203 - page: '',  
204 - limit: ''  
205 - };  
206 - proxy.$http.get("/api-web/bResourceExtendParam/page", getParams, function (res) {  
207 - if (res && res.success) {  
208 - dataList = res.data;  
209 - }  
210 - })  
211 - dataList = dataList.map(item => item.resId);  
212 - proxy.$global.openWin("template/res/reslist", "选择资源", {oldData: dataList}, ["选择"], function (index) {  
213 - //获取选中数据  
214 - let data = proxy.$global.layui.table.checkStatus('reslist_resListTable').data;  
215 - if (data.length === 0) {  
216 - //vue层级关系  
217 - // proxy.$global.showMsg("请至少选择一条数据!", "warning");  
218 - proxy.$global.layer.msg('请选择一项', {icon: 7, timeout: 3000});  
219 - return false;  
220 - }  
221 - //打开端口侦测配置页面  
222 - portSenseConfigData.value = data.map(item => item.resId);  
223 - showPortSense.value = true;  
224 - proxy.$global.layer.close(index);  
225 - }, null, ['80%', '83%']);  
226 - 191 + stepActive.value = 1;
  192 + showPortSense.value = true;
  193 + portSenseConfigData.value = [];
  194 + loadResTree();
227 } 195 }
228 //删除 196 //删除
229 let deleteOther = () => { 197 let deleteOther = () => {
@@ -247,8 +215,57 @@ export default { @@ -247,8 +215,57 @@ export default {
247 //打开端口侦测配置页面 215 //打开端口侦测配置页面
248 portSenseConfigData.value = [row.resId]; 216 portSenseConfigData.value = [row.resId];
249 showPortSense.value = true; 217 showPortSense.value = true;
  218 +
  219 + stepActive.value = 2;
250 } 220 }
  221 +
  222 + let stepActive = Vue.ref(0);
  223 + let resIds = Vue.ref([]);
  224 + let resTreeArr = Vue.ref([]);
  225 + const typeProps = Vue.reactive({
  226 + children: 'children',
  227 + label: 'label',
  228 + value: 'value'
  229 + })
  230 +
  231 + const next = () => {
  232 + if( portSenseConfigData.value.length == 0){
  233 + proxy.$global.showMsg("请至少选择一个资源!");
  234 + return;
  235 + }
  236 + if (stepActive.value++ > 2) stepActive.value = 1
  237 + }
  238 +
  239 + const closeDialog = () => {
  240 + showPortSense.value = false;
  241 + getListData({page: 1, limit: pageSize.value});
  242 + }
  243 +
  244 + const loadResTree = () => {
  245 + proxy.$http.get('/mj/user/selectResTreeAndSelectRes', {userId: proxy.$global.common.getUserId()}, function (res) {
  246 + if (res && res.success && res.data) {
  247 + resTreeArr.value = res.data.options;
  248 + }
  249 + })
  250 + }
  251 +
  252 + // 挂载完
  253 + Vue.onMounted(() => {
  254 + init();
  255 + getListData({page: 1, limit: pageSize.value});
  256 + onReset();//清空搜索条件(资源id)
  257 + })
  258 +
251 return { 259 return {
  260 + stepActive,
  261 + resIds,
  262 + resTreeArr,
  263 + typeProps,
  264 + next,
  265 + closeDialog,
  266 +
  267 +
  268 +
252 count, 269 count,
253 portSenseData, 270 portSenseData,
254 columns, 271 columns,