...
|
...
|
@@ -2,6 +2,9 @@ export default { |
|
|
name: 'resourcePer',
|
|
|
template: '',
|
|
|
components: {
|
|
|
'ChangeUsersList': Vue.defineAsyncComponent(
|
|
|
() => myImport('views/batchChangeLeaders/changeUsersList/index')
|
|
|
),
|
|
|
},
|
|
|
data() {
|
|
|
},
|
...
|
...
|
@@ -13,7 +16,22 @@ export default { |
|
|
},
|
|
|
setup: function (props, {attrs, slots, emit}) {
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
|
|
|
//变更人员弹框
|
|
|
let show=Vue.ref(false);
|
|
|
//变更人员列表是否多选
|
|
|
let isMulti=Vue.ref(false);
|
|
|
//变更人员列表是否是两组
|
|
|
let isTwoGroup=Vue.ref(false);
|
|
|
//配置列表总数
|
|
|
let count = Vue.ref(0);
|
|
|
//列表高度
|
|
|
let height = Vue.ref(window.innerHeight);
|
|
|
//列表分页
|
|
|
let limit = Vue.ref(400);
|
|
|
//加载
|
|
|
let loading = Vue.ref(true);
|
|
|
//选中数据
|
|
|
let pitch = Vue.ref([]);
|
|
|
let showTypeList=Vue.ref([]);
|
|
|
let search = Vue.ref({
|
|
|
resType: '',
|
...
|
...
|
@@ -22,8 +40,6 @@ export default { |
|
|
limit: 20,
|
|
|
});
|
|
|
let resTypeOptions=Vue.ref([])
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
{
|
|
|
prop: 'resName',
|
...
|
...
|
@@ -97,48 +113,34 @@ export default { |
|
|
}
|
|
|
}
|
|
|
];
|
|
|
//配置列表总数
|
|
|
let count = Vue.ref(0);
|
|
|
|
|
|
//列表数据
|
|
|
let portSenseConfigData = Vue.ref([]);
|
|
|
//数据库的数据
|
|
|
let portSenseConfigList = Vue.ref([]);
|
|
|
let resourceData = 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 portSenseSelectData = Vue.ref([]);
|
|
|
|
|
|
|
|
|
//获取列表数据
|
|
|
const getListData = ({page, limit}) => {
|
|
|
//获取传递过来的参数
|
|
|
resIdArr.value = JSON.parse(JSON.stringify(props.parameter));
|
|
|
//传递参数赋值给下拉框
|
|
|
portSenseSelectData.value = resIdArr.value;
|
|
|
const getListData = () => {
|
|
|
|
|
|
let username=proxy.$route.query.username;
|
|
|
let resName=proxy.$route.query.resName;
|
|
|
//定义列表参数
|
|
|
let getParams = {
|
|
|
resIds: resIdArr.value.join(','),
|
|
|
resType:search.value.resType,
|
|
|
keyword:search.value.keyword,
|
|
|
resName: resName,
|
|
|
userId: username,
|
|
|
page: page,
|
|
|
limit: limit
|
|
|
page: search.value.page,
|
|
|
limit: search.value.limit
|
|
|
};
|
|
|
proxy.$http.get("/api-web/manage/resource/getAllResByUser", getParams, function (res) {
|
|
|
if (res && res.success) {
|
|
|
portSenseConfigData.value = res.data ? res.data : [];
|
|
|
resourceData.value = res.data ? res.data : [];
|
|
|
count.value = res.count;
|
|
|
loading.value = false;
|
|
|
portSenseConfigList.value = res.data ? JSON.parse(JSON.stringify(res.data)) : [];
|
|
|
}
|
|
|
})
|
|
|
}
|
...
|
...
|
@@ -146,222 +148,85 @@ export default { |
|
|
//表格全选事件
|
|
|
let selectionChange = (val) => {
|
|
|
pitch.value = val;
|
|
|
proxy.portSenseConfigData.map((v, i) => {
|
|
|
proxy.resourceData.map((v, i) => {
|
|
|
v.checked = false;
|
|
|
});
|
|
|
let selectData = val;
|
|
|
if (selectData.length > 0) {
|
|
|
selectData.map((item, index) => {
|
|
|
proxy.portSenseConfigData.map((v, i) => {
|
|
|
proxy.resourceData.map((v, i) => {
|
|
|
if (item.id == v.id) {
|
|
|
v.checked = true;
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
proxy.portSenseConfigData.map((v, i) => {
|
|
|
proxy.resourceData.map((v, i) => {
|
|
|
v.checked = false;
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
//删除单个数据
|
|
|
let deleteItem = (row, index) => {
|
|
|
proxy.$global.confirm("确认删除吗?", function () {
|
|
|
deleteItems(row, index);
|
|
|
})
|
|
|
}
|
|
|
//删除多个或单个
|
|
|
let deleteItems = (row, index) => {
|
|
|
//新添加未保存的
|
|
|
let sign = deleteNotSave(row, index);
|
|
|
if (sign) {
|
|
|
return false;
|
|
|
}
|
|
|
proxy.$http.post('/api-web/bResourceExtendParam/deleteConfig', row, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('删除成功');
|
|
|
loadTableDataList({page: 1, limit: pageSize.value});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//删除新添加但未保存的
|
|
|
let deleteNotSave = (row, index) => {
|
|
|
let sign = false;
|
|
|
let list = portSenseConfigData.value;
|
|
|
if(row.id === ""){
|
|
|
portSenseConfigData.value = list.filter((item, i, array) => index !== i);
|
|
|
}
|
|
|
if (list.length > portSenseConfigData.value.length) {
|
|
|
proxy.$global.showMsg('删除成功');
|
|
|
sign = true;
|
|
|
}
|
|
|
return sign;
|
|
|
}
|
|
|
//新增 添加一行数据
|
|
|
let save = () => {
|
|
|
let data = {
|
|
|
id: "",
|
|
|
intervalTime: null,
|
|
|
paramCode: "",
|
|
|
paramDesc: "",
|
|
|
paramValue: "",
|
|
|
port: "",
|
|
|
portDesc: "",
|
|
|
protocolType: "",
|
|
|
resId: "",
|
|
|
resIdList: resIdArr.value,
|
|
|
}
|
|
|
portSenseConfigData.value.push(data);
|
|
|
}
|
|
|
//下拉框值改变事件
|
|
|
let changePortSense = () => {
|
|
|
|
|
|
}
|
|
|
//保存
|
|
|
let conserve = () => {
|
|
|
//数据验证
|
|
|
let msg = verifyData();
|
|
|
if (msg !== "") {
|
|
|
proxy.$global.showMsg(msg, "warning");
|
|
|
return false;
|
|
|
}
|
|
|
//逻辑验证
|
|
|
let identifying = isSave();
|
|
|
if (identifying !== "") {
|
|
|
proxy.$global.showMsg(identifying, "warning");
|
|
|
return false;
|
|
|
//批量取消相关资源
|
|
|
let changeCancel = () => {
|
|
|
console.log("123654",pitch.value)
|
|
|
if(pitch.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
|
|
|
}else{
|
|
|
proxy.$global.confirm("确定取消相关资源?", function () {
|
|
|
proxy.$global.showMsg('取消成功!');
|
|
|
|
|
|
// proxy.$http.get(`/api-web/alarmsubscribe/exclude/delete/${row.id}`, {}, function (res) {
|
|
|
// if (res && res.success) {
|
|
|
// proxy.$global.showMsg('取消成功!');
|
|
|
// getListData()
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
});
|
|
|
}
|
|
|
proxy.$http.post("/api-web/bResourceExtendParam/conserve", portSenseConfigData.value, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg("保存成功!");
|
|
|
loadTableDataList({page: 1, limit: pageSize.value});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//保存表单验证
|
|
|
let verifyData = () => {
|
|
|
let msg = "";
|
|
|
//协议类型不能为空,端口备注不能为空,端口号请输入数字,间隔时长请输入数字,
|
|
|
let list = portSenseConfigData.value;
|
|
|
let li = columns.filter(item => "paramDesc" !== item.prop);
|
|
|
list.forEach(function (item, index, arr) {
|
|
|
li.forEach(function (e, i, array) {
|
|
|
if (item[e.prop] == null || item[e.prop] === '') {
|
|
|
msg = e.label + '不能为空';
|
|
|
} else {
|
|
|
if (['protocolType', 'portDesc'].indexOf(e.prop) === -1 && !/^\d+$/.test(item[e.prop])) {
|
|
|
msg = e.label + '请输入数字';
|
|
|
}else{
|
|
|
if(['protocolType', 'portDesc'].indexOf(e.prop) === -1 && item[e.prop].length>=8){
|
|
|
msg = e.label + '不能超过8位';
|
|
|
}else{
|
|
|
if(['protocolType', 'portDesc'].indexOf(e.prop) === -1 && item[e.prop]<=0){
|
|
|
msg = e.label + '只能大于零';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
return msg
|
|
|
}
|
|
|
//是否可以保存
|
|
|
let isSave = () => {
|
|
|
let msg = "";
|
|
|
//零个资源不用判断
|
|
|
if (resIdArr.value.length === 0) {
|
|
|
return "必须选中资源";
|
|
|
}
|
|
|
//单个资源不用判断
|
|
|
if (resIdArr.value.length === 1) {
|
|
|
return msg;
|
|
|
}
|
|
|
//多个资源时,如果当前已选资源中存在列表新增加的协议类型和端口号对应的数据时,提示不允许进行保存,提示信息中必须包含资源名称+端口类型、端口号,
|
|
|
let list = [];
|
|
|
let arr = [];
|
|
|
portSenseConfigData.value.forEach(item => {
|
|
|
item.resIdList.forEach(map => {
|
|
|
let obj = Object.assign({}, item);
|
|
|
obj["resId"] = map;
|
|
|
obj["resIdList"] = [map];
|
|
|
list.push(obj);
|
|
|
})
|
|
|
});
|
|
|
//查看当前页面数据是否重复
|
|
|
groupByCount(list, arr);
|
|
|
if (arr.length > 0) {
|
|
|
return arr.join(',');
|
|
|
|
|
|
//变更负责人
|
|
|
let changeAdmin = () => {
|
|
|
if(pitch.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
|
|
|
}else{
|
|
|
show.value=true;
|
|
|
}
|
|
|
//查看当前页面数据跟数据库是否重复
|
|
|
let presentArray = [];
|
|
|
//过滤不是新增的数据
|
|
|
list = list.filter(item => item.id === "");
|
|
|
resIdArr.value.forEach(item => {
|
|
|
let li = [];
|
|
|
let getParams = {
|
|
|
resIds: item,
|
|
|
page: 1,
|
|
|
limit: 9999
|
|
|
};
|
|
|
proxy.$http.get("/api-web/bResourceExtendParam/portSensePage", getParams, function (res) {
|
|
|
if (res && res.success) {
|
|
|
li = res.data ? res.data : [];
|
|
|
list.forEach(e => {
|
|
|
li.forEach(map => {
|
|
|
if (map.resId === e.resId && map.paramCode === e.protocolType && map.port === e.port) {
|
|
|
let obj = Object.assign({}, e);
|
|
|
obj["resName"] = map.resName;
|
|
|
presentArray.push(obj);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}, null, null, null, false);
|
|
|
});
|
|
|
presentArray.forEach(item => {
|
|
|
let str = item.resName + "的" + item.paramCode.split("-")[0] + "协议" + "侦测的" + item.port + "端口号已侦测";
|
|
|
arr.push(str);
|
|
|
})
|
|
|
msg = arr.join(',');
|
|
|
return msg;
|
|
|
|
|
|
}
|
|
|
|
|
|
//重新加载表格数据
|
|
|
let loadTableDataList = ({page, limit}) => {
|
|
|
getListData({page, limit});
|
|
|
search.value.page=page;
|
|
|
search.value.limit=limit;
|
|
|
getListData();
|
|
|
}
|
|
|
//修改父组件的值
|
|
|
let selectRes = (item) => {
|
|
|
portSenseConfigData.value = item;
|
|
|
|
|
|
//变更人员的弹框关闭后
|
|
|
let hideDialog =(flag)=>{
|
|
|
show.value=flag;
|
|
|
// getListData();
|
|
|
}
|
|
|
//数组查找重复数据并统计行数
|
|
|
let groupByCount = (arr, array) => {
|
|
|
let list = [];
|
|
|
arr.sort((a, b) => {
|
|
|
if (a.resId !== b.resId) {
|
|
|
return a.resId < b.resId ? -1 : 1;
|
|
|
} else {
|
|
|
return a.name < b.name ? -1 : 1;
|
|
|
}
|
|
|
});
|
|
|
for (let i = 0; i < arr.length;) {
|
|
|
let count = 0;
|
|
|
for (let j = i; j < arr.length; j++) {
|
|
|
if (arr[i].resId === arr[j].resId && arr[i].protocolType === arr[j].protocolType && arr[i].port === arr[j].port) {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
list.push({array: arr[i], count: count});
|
|
|
i += count;
|
|
|
}
|
|
|
list.forEach(item => {
|
|
|
if (item.count > 1) {
|
|
|
let str = item.array.resName + "的" + item.array.paramCode.split("-")[0] + "协议" + "侦测的" + item.array.port + "端口号已侦测";
|
|
|
array.push(str);
|
|
|
//变更人员的弹框保存后
|
|
|
let savebtn =(obj)=>{
|
|
|
show.value=false;
|
|
|
//obj.selectModel 选中的用户组(一个/主负责人) obj.selectModelSecond 辅负责人,都是数组
|
|
|
console.log("&&&",obj)
|
|
|
getListData();
|
|
|
}
|
|
|
//获取资源类型数据
|
|
|
let getResourceTypoe=()=>{
|
|
|
proxy.$http.get(`/api-web/manage/restype/list`, {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
resTypeOptions.value=res.data
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
//获取展示类型的字典数据
|
|
|
let initShowType=()=>{
|
|
|
proxy.$http.get("/api-web/manage/resource/getAllResByUser", {}, function (res) {
|
...
|
...
|
@@ -379,34 +244,36 @@ export default { |
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 挂载完
|
|
|
Vue.onMounted(() => {
|
|
|
getListData({page: 1, limit: pageSize.value});
|
|
|
getResourceTypoe();
|
|
|
getListData();
|
|
|
})
|
|
|
return {
|
|
|
isMulti,
|
|
|
isTwoGroup,
|
|
|
show,
|
|
|
initShowType,
|
|
|
showTypeList,
|
|
|
search,
|
|
|
resTypeOptions,
|
|
|
|
|
|
changeCancel,
|
|
|
count,
|
|
|
portSenseConfigData,
|
|
|
hideDialog,
|
|
|
savebtn,
|
|
|
changeAdmin,
|
|
|
getResourceTypoe,
|
|
|
|
|
|
resourceData,
|
|
|
columns,
|
|
|
height,
|
|
|
pageSize,
|
|
|
loading,
|
|
|
|
|
|
selectionChange,
|
|
|
deleteItem,
|
|
|
save,
|
|
|
|
|
|
getListData,
|
|
|
loadTableDataList,
|
|
|
changePortSense,
|
|
|
conserve,
|
|
|
selectRes,
|
|
|
|
|
|
portSenseSelectData
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|