|
|
@ -41,7 +41,7 @@ export class MenuComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
allOrList: any |
|
|
|
allOrList: any |
|
|
|
getAllOrganization() { |
|
|
|
getAllOrganization() { |
|
|
|
|
|
|
|
|
|
|
|
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id |
|
|
|
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id |
|
|
|
let params = { |
|
|
|
let params = { |
|
|
|
OrganizationUnitId: OrganizationUnitId, |
|
|
|
OrganizationUnitId: OrganizationUnitId, |
|
|
@ -50,7 +50,6 @@ export class MenuComponent implements OnInit { |
|
|
|
this.http.get('/api/services/app/Menu/GetAll', { |
|
|
|
this.http.get('/api/services/app/Menu/GetAll', { |
|
|
|
params: params |
|
|
|
params: params |
|
|
|
}).subscribe((data: any) => { |
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
|
|
|
|
|
|
|
this.totalCount = data.result.totalCount |
|
|
|
this.totalCount = data.result.totalCount |
|
|
|
data.result.items.forEach(element => { |
|
|
|
data.result.items.forEach(element => { |
|
|
|
element.key = element.id |
|
|
|
element.key = element.id |
|
|
@ -61,10 +60,7 @@ export class MenuComponent implements OnInit { |
|
|
|
this.nodes = [...this.toTree.toTree(data.result.items)] |
|
|
|
this.nodes = [...this.toTree.toTree(data.result.items)] |
|
|
|
this.defaultExpandedKeys = [this.nodes[0].id] |
|
|
|
this.defaultExpandedKeys = [this.nodes[0].id] |
|
|
|
this.defaultExpandedKeys = [...this.defaultExpandedKeys] |
|
|
|
this.defaultExpandedKeys = [...this.defaultExpandedKeys] |
|
|
|
// console.log(...this.nodes,444);
|
|
|
|
|
|
|
|
// console.log(this.defaultExpandedKeys,45);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -74,8 +70,6 @@ export class MenuComponent implements OnInit { |
|
|
|
defaultExpandedKeys = []; |
|
|
|
defaultExpandedKeys = []; |
|
|
|
|
|
|
|
|
|
|
|
nodes: any[] = [] |
|
|
|
nodes: any[] = [] |
|
|
|
datas:any[]=[{id:0,title:"首页",children:[]},{id:1,title:"数字油站",children:[]},{id:2,title:"今日预警",children:[]},{id:3,title:"预警记录",children:[{title:'预警类型统计',isGasStation:true},{title:'卸油统计',isGasStation:true},{title:'证照预警统计',isGasStation:true}]},{id:4,title:"证照管理",children:[{title:'经营类证照',isGasStation:true},{title:'资产类证照',isGasStation:true},{title:'待办',isGasStation:true},{title:'审批记录',isGasStation:true}]}] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addOr(node?: any) { |
|
|
|
addOr(node?: any) { |
|
|
|
console.log(node) |
|
|
|
console.log(node) |
|
|
|
const modal = this.modal.create({ |
|
|
|
const modal = this.modal.create({ |
|
|
@ -85,7 +79,6 @@ export class MenuComponent implements OnInit { |
|
|
|
nzWidth: 288, |
|
|
|
nzWidth: 288, |
|
|
|
nzComponentParams: {}, |
|
|
|
nzComponentParams: {}, |
|
|
|
nzOnOk: async () => { |
|
|
|
nzOnOk: async () => { |
|
|
|
console.log('hhhhhhh', instance.validateForm) |
|
|
|
|
|
|
|
if (instance.validateForm.valid) { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
await new Promise(resolve => { |
|
|
|
await new Promise(resolve => { |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
@ -191,133 +184,5 @@ export class MenuComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nzEvent(event: NzFormatEmitEvent): void { |
|
|
|
|
|
|
|
console.log('event', event) |
|
|
|
|
|
|
|
if (this.isDrag) { |
|
|
|
|
|
|
|
let parentId |
|
|
|
|
|
|
|
if (this.pos == 0) {//目标节点内部
|
|
|
|
|
|
|
|
parentId = event.node.key |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (event.node.level == 0) { |
|
|
|
|
|
|
|
parentId = null |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
parentId = event.node.origin.parentId |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let body = { |
|
|
|
|
|
|
|
id: event.dragNode.key, |
|
|
|
|
|
|
|
parentId: parentId, |
|
|
|
|
|
|
|
// code: instance.validateForm.value.code,
|
|
|
|
|
|
|
|
displayName: event.dragNode.origin.displayName, |
|
|
|
|
|
|
|
isGasStation: event.dragNode.origin.isGasStation |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.http.put('/api/services/app/Organization/Update', body).subscribe(data => { |
|
|
|
|
|
|
|
this.message.create('success', '拖拽成功!'); |
|
|
|
|
|
|
|
this.nzTreeComponent.getExpandedNodeList().forEach((item) => { |
|
|
|
|
|
|
|
this.defaultExpandedKeys.push(item.key) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.getAllOrganization() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
}, err => { |
|
|
|
|
|
|
|
this.message.create('warning', '拖拽失败'); |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('this.allOrList', this.allOrList)
|
|
|
|
|
|
|
|
// let orders = {}
|
|
|
|
|
|
|
|
// let originalData = JSON.parse(JSON.stringify(this.allOrList || [])) //tree原始数据
|
|
|
|
|
|
|
|
// let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位
|
|
|
|
|
|
|
|
//找到需要重新排序的数组
|
|
|
|
|
|
|
|
// if (this.pos == 0) {
|
|
|
|
|
|
|
|
// originalData.forEach(item => {
|
|
|
|
|
|
|
|
// if (item.parentId == event.node.key) {
|
|
|
|
|
|
|
|
// targetNodeData.push(item)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// if (event.node.origin.parentId) {//如果拖动目标为非一级节点
|
|
|
|
|
|
|
|
// originalData.forEach(item => {
|
|
|
|
|
|
|
|
// if (item.parentId == event.node.origin.parentId) {
|
|
|
|
|
|
|
|
// targetNodeData.push(item)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// } else {//如果拖动目标为一级节点
|
|
|
|
|
|
|
|
// originalData.forEach(item => {
|
|
|
|
|
|
|
|
// if (!item.parentId) {
|
|
|
|
|
|
|
|
// targetNodeData.push(item)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let idArr = []
|
|
|
|
|
|
|
|
// targetNodeData.forEach(i => {
|
|
|
|
|
|
|
|
// idArr.push(i.id)
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// if (this.pos == 0 && event.node.origin.children.length == 1) {
|
|
|
|
|
|
|
|
// // console.log("移入,没有兄弟")
|
|
|
|
|
|
|
|
// let key = event.dragNode.key
|
|
|
|
|
|
|
|
// orders[key] = 0
|
|
|
|
|
|
|
|
// parentId = event.node.key
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let array = []
|
|
|
|
|
|
|
|
// targetNodeData.forEach(item => {
|
|
|
|
|
|
|
|
// if (item.id != event.dragNode.key) { //将拖动项先移除掉
|
|
|
|
|
|
|
|
// array.push(item)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个
|
|
|
|
|
|
|
|
// // console.log("最后")
|
|
|
|
|
|
|
|
// array.push(event.dragNode.origin)
|
|
|
|
|
|
|
|
// } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个
|
|
|
|
|
|
|
|
// // console.log("第一")
|
|
|
|
|
|
|
|
// array.unshift(event.dragNode.origin)
|
|
|
|
|
|
|
|
// } else {//如果移入中间位置
|
|
|
|
|
|
|
|
// // console.log("中间")
|
|
|
|
|
|
|
|
// array.splice(event.node.origin.order, 0, event.dragNode.origin)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// array.forEach((item, key) => {
|
|
|
|
|
|
|
|
// orders[item.id] = key
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// console.log("移入,多个兄弟",orders)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let obj = {
|
|
|
|
|
|
|
|
// id: event.dragNode.origin.id,
|
|
|
|
|
|
|
|
// parentId: parentId,
|
|
|
|
|
|
|
|
// orders: orders
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.http.put("/api/DisposalNodes/Sort", obj).subscribe(data => {
|
|
|
|
|
|
|
|
// const config = new MatSnackBarConfig();
|
|
|
|
|
|
|
|
// config.verticalPosition = 'top';
|
|
|
|
|
|
|
|
// config.duration = 3000
|
|
|
|
|
|
|
|
// this.snackBar.open('排序成功', '确定', config)
|
|
|
|
|
|
|
|
// this.refurbishTreeData()
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
isDrag //是否可以拖动
|
|
|
|
|
|
|
|
pos//放置位置
|
|
|
|
|
|
|
|
beforeDrop = (arg: NzFormatBeforeDropEvent) => { |
|
|
|
|
|
|
|
console.log('arg', arg) |
|
|
|
|
|
|
|
if (arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点
|
|
|
|
|
|
|
|
this.message.create('warning', '不允许拖拽到一级节点'); |
|
|
|
|
|
|
|
this.isDrag = false |
|
|
|
|
|
|
|
return of(false); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.isDrag = true |
|
|
|
|
|
|
|
this.pos = arg.pos |
|
|
|
|
|
|
|
return of(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|