Authored by XuHaoJie

通用-端口侦测-页面优化

... ... @@ -592,7 +592,7 @@ layui.define(['xmSelect', 'md5'], function (exports) {
}
},
yes: function (index, layero) {
if (fn && fn()) {
if (fn && fn(index)) {
layer.close(index);
}
},
... ...
... ... @@ -480,18 +480,18 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'upload', 'admin', 'form',
$.each(data, function (i, e) {
resIds.push(e.resId)
})
if (data.length <= 0) {//不传参
var url = "/vue3/index.html#/vue3/portSense";//不传参
if (data.length > 0) {//传参
url = "/vue3/index.html#/vue3/portSense?resId="+resIds.toString();
}
layer.open({
type: 1
, title: '端口侦测'
, closeBtn: 1
, area: ['90%', '80%']
, id: 'lay_port_sense' //设定一个id,防止重复弹出
, content: '<iframe src="/vue3/index.html#/vue3/portSense" frameborder="0" class="layadmin-iframe"/>' //支持传入html
, content: '<iframe src='+url+' frameborder="0" class="layadmin-iframe"/>' //支持传入html
});
}else{//传参
}
})
function openResManageCollHtml(callback){
if(data.length<=0){
... ...
... ... @@ -32,6 +32,11 @@ const routes = [{
path: '/vue3/portSense',
name: 'portSense',
component: () => myImport('views/portSense/index')
},
{
path: '/vue3/portSenseConfig',
name: 'portSenseConfig',
component: () => myImport('views/portSenseConfig/index')
}
];
... ...
... ... @@ -8,6 +8,7 @@
var global = {};
global.layui = window.parent.layui;
global.layer = window.parent.layer;
global.common = {
getUserName : function (){
... ... @@ -278,6 +279,20 @@ global.openDetail = (resId, resType, proxy) => {
}
/**
* @description 打开选择layUI弹窗
* @author XuHaoJie
* @date 2022/1/5 2:07
*/
global.openWin = (url, name, params, btns, fn, cancelfn, area, done, layerParams) => {
let lyaui = global.layui;
/* url页面路径(template/res/reslist) name弹窗名称(选择资源) params传递参数({oldData:oldData})
* btns 按钮名称(["选择","取消"]) fn 回调函数(选择的回调) cancelfn 回调函数(取消的回调)
* area 页面大小设置(['80%', '90%']) done 弹窗加载完成的回调函数 layerParams layer弹窗的其他设置参数
*/
lyaui.common.openWin(url, name, params, btns, fn, cancelfn, area, done, layerParams);
}
/**
* 打开报表
* <p>
* 作者: Wang
... ...
... ... @@ -7,17 +7,7 @@
<div class="flex-div-start margin-top-bottom-10">
<el-input style="width:160px;" class="margin-right-10" v-model="keyWords"
placeholder="输入关键字"/>
<div class="flex-div-start">
<el-button type="primary" @click="onReset()">重置</el-button>
<el-button type="primary" @click="onBtnSearch()" style="margin-left: 10px">查询</el-button>
</div>
<!-- <el-select v-model="busTypeArr" multiple filterable clearable collapse-tags-->
<!-- placeholder="请选择业务">-->
<!-- <el-option-->
<!-- v-for="item in busTypeList"-->
<!-- :label="item.busTypeName" :value="item.busId"></el-option>-->
<!-- </el-select>-->
<el-dropdown style="margin-top: -15px;margin-left: 10px;">
<el-dropdown style="margin-top: -15px;">
<el-icon class="el-icon--right">
<arrow-down/>
</el-icon>
... ... @@ -31,12 +21,23 @@
<cm-res-type-tree-input multiple clearable collapseTags @callback="getResType"/>
</el-dropdown>
<div class="flex-div-start">
<!-- <el-button type="primary" @click="onReset()">重置</el-button>-->
<el-button type="primary" @click="onBtnSearch()" style="margin-left: 10px">查询</el-button>
</div>
</div>
</el-col>
</el-row>
<el-row>
<div class="flex-div-start">
<el-button type="primary" @click="save()" style="margin-left: 10px">新增</el-button>
<el-button type="primary" @click="deleteOther()" style="margin-left: 10px">删除</el-button>
</div>
</el-row>
<el-row class="margin-bottom-50">
<el-col :span="24" class="table-height">
<cm-table-page v-if="portSenseData" :columns="columns"
<cm-table-page :columns="columns"
:dataList="portSenseData"
:total="count"
:pageSize="pageSize"
... ... @@ -45,13 +46,13 @@
:showIndex="true"
:showSelection="true"
:showBorder="true"
:loading="false"
:loading="loading"
:showPage="true"
:showTools="true"
:height="(height - 500)">
:height="(height - 150)">
<template #tools="{scope}">
<el-button type="text" size="small" @click.prevent="deleteItem(scope.row,scope.$index)">
删除
<i class="el-icon-delete"/>
</el-button>
</template>
</cm-table-page>
... ... @@ -60,12 +61,11 @@
</div>
</el-col>
</el-row>
<!-- <div class="margin-top btn-faultDiagnosis flex-center position-bottom">-->
<!-- <el-button @click="cancleList">取消</el-button>-->
<!-- &lt;!&ndash; <el-button @click="saveList" type="primary">保存</el-button>&ndash;&gt;-->
<!-- </div>-->
<!--弹框-->
<cm-dialog :title="title" width="80%" :showDialogVisible="showPortSense" :showFooter="false" @hidedialog="showPortSenseDialog" :showOkBtn="false" cancelText="关闭">
<template v-slot>
<port-sense-config :parameter="portSenseConfigData"></port-sense-config>
</template>
</cm-dialog>
</div>
\ No newline at end of file
<!--<div id="ssss">-->
<!-- {{ portSenseData[0] }}-->
<!-- {{columns}}-->
<!--</div>-->
\ No newline at end of file
... ...
export default {
name: 'portSense',
template: '',
components: {},
components: {
// 人员信息
'port-sense-config': Vue.defineAsyncComponent(
() => myImport('views/portSenseConfig/index')
),
},
data() {
},
setup(props, {attrs, slots, emit}) {
... ... @@ -43,20 +48,34 @@ export default {
//搜索关键字
let keyWords = Vue.ref('');
//列表数据
let portSenseData = Vue.ref([{resName:'123',ip:'1.2.3.4'}]);
let portSenseData = Vue.ref([]);
//资源类型数据
let resTypeArr = Vue.ref([]);
//业务类型数据
let busTypeArr = Vue.ref([]);
//业务类型
let busTypeList = Vue.ref([]);
//资源类型数据
//资源数据
let resIdArr = Vue.ref([]);
//列表高度
let height = Vue.ref(window.innerHeight - 150);
let height = Vue.ref(window.innerHeight);
//列表分页
let pageSize = Vue.ref(50);
//加载
let loading = Vue.ref(true);
//选中数据
let pitch = Vue.ref([]);
//弹框配置
//是否展示弹框
let showPortSense = Vue.ref(false);
//弹框名称
let title = Vue.ref("端口侦测配置");
//弹框参数
let portSenseConfigData = Vue.ref([]);
let init = () => {
//获取传递过来的参数
var resId = proxy.$global.getQueryVariable('resId');
resIdArr.value = resId ? resId.split(",") : [];
proxy.$http.get("/api-web/home/business/findAllBusType", {}, function (res) {
if (res && res.data) {
busTypeList.value = res.data;
... ... @@ -66,37 +85,38 @@ export default {
// 挂载完
Vue.onMounted(() => {
init();
getListData();
getListData({page: 1, limit: pageSize.value});
onReset();//清空搜索条件(资源id)
})
//获取列表数据
const getListData = ({page, limit}) => {
//定义列表参数
let getParams = Vue.ref({
let getParams = {
keyWords: keyWords.value,
resTypes: resTypeArr.value.join(','),
resIds: resIdArr.value.join(','),
busIds: busTypeArr.value.join(','),
page: 1,
limit: pageSize
})
//获取列表数据
const getListData = () => {
proxy.$http.get("/api-web/bResourceExtendParam/page", getParams.value, function (res) {
if (res && res.data) {
// portSenseData.value = res.data;
// count.value = res.count;
page: page,
limit: limit
};
proxy.$http.get("/api-web/bResourceExtendParam/page", getParams, function (res) {
if (res && res.success) {
portSenseData.value = res.data;
count.value = res.count;
loading.value = false;
}
})
}
// 点击按钮搜索
let onBtnSearch = () => {
loadTableDataList({page: 1, limit: pageSize});
loadTableDataList({page: 1, limit: pageSize.value});
}
// 重置
let onReset = () => {
keyWords.value = '';
resTypeArr.value = '';
resIdArr.value = '';
busTypeArr.value = '';
resTypeArr.value = [];
resIdArr.value = [];
busTypeArr.value = [];
}
//获取资源类型
let getResType = (arr) => {
... ... @@ -104,7 +124,7 @@ export default {
return v.id;
});
resTypeArr.value = types;
loadTableDataList({page: 1, limit: pageSize});
loadTableDataList({page: 1, limit: pageSize.value});
}
//获取业务系统
let getBizType = (arr) => {
... ... @@ -112,11 +132,11 @@ export default {
return v.busId;
});
busTypeArr.value = types;
loadTableDataList({page: 1, limit: pageSize});
loadTableDataList({page: 1, limit: pageSize.value});
}
//表格全选事件
let selectionChange = (val) => {
pitch.value = val;
proxy.portSenseData.map((v, i) => {
v.checked = false;
});
... ... @@ -135,40 +155,82 @@ export default {
})
}
}
//删除单个数据
let deleteItem = (row, index) => {
let that = this;
this.$global.confirm("确认删除吗?", function () {
deleteItems = (that, [row.resId]);
proxy.$global.confirm("确认删除吗?", function () {
deleteItems([row.resId]);
})
}
//删除多个或单个
let deleteItems = (that, list) => {
let deleteItems = (list) => {
let params = {
redIds: list.toString()
}
that.$http.get('/api-web/bResourceExtendParam/delete', params, function (res) {
if (res) {
that.$global.showMsg('删除成功');
loadTableDataList({page: 1, limit: pageSize});
proxy.$http.get('/api-web/bResourceExtendParam/delete', params, function (res) {
if (res && res.success) {
proxy.$global.showMsg('删除成功');
loadTableDataList({page: 1, limit: pageSize.value});
}
// that.$emit('callbackDelete', item)
})
}
//添加
let save = () => {
//获取所有的端口侦测信息
let dataList = [];
let getParams = {
keyWords: '',
resTypes: '',
resIds: '',
busIds: '',
page: '',
limit: ''
};
proxy.$http.get("/api-web/bResourceExtendParam/page", getParams, function (res) {
if (res && res.success) {
dataList = res.data;
}
})
dataList = dataList.map(item => item.resId);
proxy.$global.openWin("template/res/reslist", "选择资源", {oldData: dataList}, ["选择"], function (index) {
//获取选中数据
let data = proxy.$global.layui.table.checkStatus('reslist_resListTable').data;
if (data.length === 0) {
//vue层级关系
// proxy.$global.showMsg("请至少选择一条数据!", "warning");
proxy.$global.layer.msg('请选择一项', {icon: 7, timeout: 3000});
return false;
}
//打开端口侦测配置页面
portSenseConfigData.value = data.map(item => item.resId);
showPortSense.value = true;
proxy.$global.layer.close(index);
}, null, ['80%', '81%']);
}
//删除
let deleteOther = () => {
let list = pitch.value.map(item => {
return item.resId;
})
deleteItems(list);
};
//重新加载表格数据
let loadTableDataList = ({page, limit}) => {
getParams.page = page;
getParams.pageSize = limit;
getListData();
getListData({page, limit});
}
//弹框事件
//弹框关闭触发
let showPortSenseDialog = () => {
showPortSense.value = false;
};
return {
count,
portSenseData,
columns,
height,
pageSize,
loading,
keyWords,
resTypeArr,
... ... @@ -179,12 +241,18 @@ export default {
deleteItem,
onBtnSearch,
onReset,
save,
deleteOther,
getListData,
loadTableDataList,
getResType,
getBizType,
showPortSense,
title,
portSenseConfigData,
showPortSenseDialog,
}
}
}
\ No newline at end of file
... ...
<div class="set-add-div" style="width: 100%;height: 30%">
<el-row>
<el-col :span="24">
<div class="set-add-div">
<el-row>
<div class="flex-div-start">
<el-button type="primary" @click="save()" style="margin-left: 10px">新增</el-button>
<el-button type="primary" @click="deleteOther()" style="margin-left: 10px">删除</el-button>
<el-button type="primary" @click="conserve()" style="margin-left: 10px">保存</el-button>
</div>
</el-row>
<el-row class="margin-bottom-50">
<el-col :span="24" class="table-height">
<cm-table-page :columns="columns"
:dataList="portSenseConfigData"
:total="count"
:pageSize="pageSize"
@loaddata="loadTableDataList"
@selectionChange="selectionChange"
:showIndex="true"
:showSelection="true"
:showBorder="true"
:loading="loading"
:showPage="true"
:showTools="true"
:height="(height - 150)">
<template #default="{row,prop,column}">
<div v-if="prop == 'protocolType'">
<!-- 展示下拉选项 -->
<el-select placeholder="请选择" size="small" style="width: 100%"
@change="changePortSense(row,prop,column)" v-model="row.protocolType"
:multiple="false"
collapse-tags clearable filterable placeholder="请选择">
<el-option label="TCP协议" :value="'tcp-port'"></el-option>
<el-option label="UDP协议" :value="'udp-port'"></el-option>
</el-select>
</div>
<div v-else>
<el-input @blur="changePortSense(row,prop,column)"
:type="prop == intervalTime ? 'number' : 'text'"
size="small" placeholder="请填写"v-model="row[prop]">
<template #suffix>
<i class="el-icon-edit-outline"/>
</template>
</el-input>
</div>
</template>
<template #tools="{scope}">
<el-button type="text" size="small" @click.prevent="deleteItem(scope.row,scope.$index)">
<i class="el-icon-delete"/>
</el-button>
</template>
</cm-table-page>
</el-col>
</el-row>
</div>
</el-col>
</el-row>
</div>
\ No newline at end of file
... ...
export default {
name: 'portSense',
template: '',
components: {},
data() {
},
props: {
parameter: {
type: Array,
default: []
}
},
setup: function (props, {attrs, slots, emit}) {
const {proxy} = Vue.getCurrentInstance();
const columns = [
{
prop: 'protocolType',
label: '协议类型',
sortable: true,
align: 'center',
},
{
prop: 'port',
label: '端口号',
sortable: true,
align: 'center',
},
{
prop: 'intervalTime',
label: '间隔时长',
sortable: true,
align: 'center',
},
{
prop: 'portDesc',
label: '端口备注',
sortable: true,
align: 'center',
},
{
prop: 'paramDesc',
label: '备注信息',
sortable: true,
align: 'center',
}
];
//配置列表总数
let count = Vue.ref(0);
//列表数据
let portSenseConfigData = Vue.ref([]);
//资源数据
let resIdArr = Vue.ref([]);
//列表高度
let height = Vue.ref(window.innerHeight);
//列表分页
let pageSize = Vue.ref(400);
//加载
let loading = Vue.ref(true);
//选中数据
let pitch = Vue.ref([]);
let init = () => {
//获取传递过来的参数
resIdArr.value = JSON.parse(JSON.stringify(props.parameter));
}
// 挂载完
Vue.onMounted(() => {
init();
getListData({page: 1, limit: pageSize.value});
})
//获取列表数据
const getListData = ({page, limit}) => {
//定义列表参数
let getParams = {
resIds: resIdArr.value.join(','),
page: page,
limit: limit
};
proxy.$http.get("/api-web/bResourceExtendParam/portSensePage", getParams, function (res) {
if (res && res.success) {
portSenseConfigData.value = res.data ? res.data : [];
count.value = res.count;
loading.value = false;
}
})
}
//表格全选事件
let selectionChange = (val) => {
pitch.value = val;
proxy.portSenseConfigData.map((v, i) => {
v.checked = false;
});
let selectData = val;
if (selectData.length > 0) {
selectData.map((item, index) => {
proxy.portSenseConfigData.map((v, i) => {
if (item.id == v.id) {
v.checked = true;
}
})
})
} else {
proxy.portSenseConfigData.map((v, i) => {
v.checked = false;
})
}
}
//删除单个数据
let deleteItem = (row, index) => {
proxy.$global.confirm("确认删除吗?", function () {
deleteItems([row]);
})
}
//删除多个或单个
let deleteItems = (list) => {
//新添加未保存的
let filter = list.filter(item => item.id === "");
deleteNotSave(filter);
if (filter.size === list.size) {
return false;
}
list = list.filter(item => item.id !== "");
proxy.$http.post('/api-web/bResourceExtendParam/deleteConfig', list, function (res) {
if (res && res.success) {
proxy.$global.showMsg('删除成功');
loadTableDataList({page: 1, limit: pageSize.value});
}
})
}
//删除新添加但未保存的
let deleteNotSave = (list) => {
}
//删除
let deleteOther = () => {
let list = pitch.value.map(item => {
return item.resId;
})
deleteItems(list);
};
//新增 添加一行数据
let save = () => {
let data = {
id: "",
intervalTime: null,
paramCode: "",
paramDesc: "",
paramValue: "",
port: "",
portDesc: "",
protocolType: "",
resId: "",
resIdList: resIdArr.value,
}
portSenseConfigData.value.push(data);
console.log(portSenseConfigData.value);
}
//下拉框值改变事件
let changePortSense = () => {
}
//保存
let conserve = () => {
}
//重新加载表格数据
let loadTableDataList = ({page, limit}) => {
getListData({page, limit});
}
return {
count,
portSenseConfigData,
columns,
height,
pageSize,
loading,
selectionChange,
deleteItem,
save,
deleteOther,
getListData,
loadTableDataList,
changePortSense,
conserve
}
}
}
\ No newline at end of file
... ...
... ... @@ -144,6 +144,11 @@ const routes = [{
path: '/vue3/portSense',
name: 'portSense',
component: () => myImport('views/portSense/index')
},
{
path: '/vue3/portSenseConfig',
name: 'portSenseConfig',
component: () => myImport('views/portSenseConfig/index')
}
];
... ...