Authored by 鲁尚清

【#1162】 变更负责人相关业务-变更人员组件 #3

... ... @@ -306,7 +306,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions',
let title=`
<div style="display: flex;justify-content: space-between; align-items: center;">
<span>相关业务批量变更</span>
<button id="exportBtn" type="button" class="layui-btn layui-btn-sm layui-btn-normal">导出</button>
<button id="exportBtn" type="button" class="layui-btn layui-btn-sm layui-btn-normal exportBtn">导出</button>
</div>
`;
layer.open({
... ... @@ -316,9 +316,11 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions',
shadeClose: true,//开启遮罩层
id: 'batch_change_leaders',
content: ['/vue3/index.html#/vue3/batchChangeLeaders?'+urlParams, 'no'],
success:function (){
success:function (layero,index){
console.log("112233",$("#exportBtn"))
$("#exportBtn").unbind().on("click",function () {
$(".exportBtn").unbind('click').on('click', function () {
console.log("669")
debugger
layer.open({
id:'exportChange',
... ...
<cm-dialog :title="title" width="500px" :showDialogVisible="show" @hidedialog="hidedialog" @okfunc="getUser">
<template v-slot>
<el-row >
<el-col :span="24" class="table-height">
<span v-if="isTwoGroup">主负责人:</span>
<el-select
v-model="selectModel"
:multiple="isMulti"
placeholder="请选择用户"
style="width:80%"
clearable
filterable
>
<el-option
v-for="item in userList"
:key="item.username"
:label="item.nickname"
:value="item.username"
>
<div >
<span>{{item.orgName}}/{{item.nickname}}</span>
</div>
</el-option>
</el-select>
</el-col>
</el-row>
<el-row v-if="isTwoGroup" style="margin-top:10px;">
<el-col :span="24">
<span>辅负责人:</span>
<el-select
v-model="selectModelSecond"
multiple
placeholder="请选择用户"
style="width:80%"
clearable
filterable
>
<el-option
v-for="item in userListSecond"
:key="item.username"
:label="item.nickname"
:value="item.username"
>
<div >
<span>{{item.orgName}}/{{item.nickname}}</span>
</div>
</el-option>
</el-select>
</el-col>
</el-row>
</template>
</cm-dialog>
\ No newline at end of file
... ...
export default {
name: 'changeUsersList',
template: '',
components: {
},
data() {
},
props: {
title: {
type: String,
default: '用户列表'
},
show:{
type:Boolean,
default: false
},
//是否为多选
isMulti:{
type:Boolean,
default:false
},
//如果是主/辅负责人时为true
isTwoGroup:{
type:Boolean,
default:false
}
},
setup: function (props, {attrs, slots, emit}) {
const {proxy} = Vue.getCurrentInstance();
let height=Vue.ref(window.innerHeight);
let selectModel=Vue.ref([]);
let selectModelSecond=Vue.ref([]);
let hidedialog = () => {
emit('hideDialog', false);
}
let getUser = () =>{
let obj={}
let arr=[];
if(props.isMulti){
arr=selectModel.value
}else{
arr=[selectModel.value];
}
if(props.isTwoGroup){
obj={
selectModel: arr,
selectModelSecond: selectModelSecond.value
}
}else{
obj={
selectModel: arr,
}
}
emit('savebtn', obj);
}
let search=Vue.ref({
username:'',
nickname:'',
enabled:'',
orgId:'',
roles:'',
limit:999999,
page:1
})
let userList=Vue.ref([]);
let userListSecond=Vue.ref([]);
let count=Vue.ref(0);
//获取所有用户
let getAllUser = () =>{
proxy.$http.get('/api-user/users', search.value, function (res) {
if (res && res.data) {
userList.value=res.data;
userListSecond.value=res.data;
count.value=res.count;
}
})
}
// 挂载完
Vue.onMounted(() => {
getAllUser();
})
return {
selectModel,
height,
selectModelSecond,
getAllUser,
userList,
userListSecond,
count,
hidedialog,
getUser,
search
}
}
}
\ No newline at end of file
... ...
... ... @@ -8,11 +8,9 @@
<el-select clearable multiple v-model="search.resType" placeholder="请选择资源类型">
<el-option
v-for="item in resTypeOptions"
:key="item.kpiId"
:label="item.kpiName"
:value="item.kpiId">
<span style="float: left">{{ item.kpiId }}</span>
<span style="float: right;color: var(--el-text-color-secondary);font-size: 13px;">{{ item.kpiName }}</span>
:key="item.resTypeCode"
:label="item.resTypeName"
:value="item.resTypeCode">
</el-option>
</el-select>
</el-form-item>
... ... @@ -24,15 +22,14 @@
</el-row>
<el-row style="margin-bottom: 10px;">
<div class="flex-div-start">
<el-button type="primary" @click="save()" size="small">取消</el-button>
<el-button type="primary" @click="conserve()" size="small" style="margin-left: 6px">变更</el-button>
<el-button type="primary" @click="conserve()" size="small" style="margin-left: 6px">导出</el-button>
<el-button type="primary" @click="changeCancel()" size="small">取消</el-button>
<el-button type="primary" @click="changeAdmin()" size="small" style="margin-left: 6px">变更</el-button>
</div>
</el-row>
<el-row class="margin-bottom-50" style="margin-top: 3px">
<el-col :span="24" class="table-height">
<cm-table-page :columns="columns"
:dataList="portSenseConfigData"
:dataList="resourceData"
:total="count"
:pageSize="pageSize"
@loaddata="loadTableDataList"
... ... @@ -46,29 +43,11 @@
:height="(height - 200)">
<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>
<ChangeUsersList :show="show" :isTwoGroup="isTwoGroup" :isMulti="isMulti" @hideDialog="hideDialog" @savebtn="savebtn"></ChangeUsersList>
... ...
... ... @@ -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
... ...
... ... @@ -2,7 +2,9 @@ export default {
name: 'resourceTypePer',
template: '',
components: {
'ChangeUsersList': Vue.defineAsyncComponent(
() => myImport('views/batchChangeLeaders/changeUsersList/index')
),
},
data() {
},
... ...