180 lines
4.5 KiB
TypeScript
180 lines
4.5 KiB
TypeScript
|
||
import { BaseLogic, VueType, Methods, KeyParams } from "@logic/Base.logic";
|
||
import { Inject } from "@ann/Ioc.annotation";
|
||
import { RoleServiceImpl } from "@impl/Role.service.impl";
|
||
|
||
export class FontEndMenuConfigLogic extends BaseLogic implements Methods {
|
||
|
||
@Inject()
|
||
public readonly RoleServiceImpl!: RoleServiceImpl;
|
||
|
||
public PageData: KeyParams[] = [];
|
||
|
||
// 控制添加后端权限的弹窗是否显示
|
||
public isShowDialog: boolean = false;
|
||
|
||
public TestPath: string = '';
|
||
|
||
public sss: string = '';
|
||
|
||
public statusTest: Object = JSON.stringify({
|
||
status: 1
|
||
})
|
||
|
||
// 设置前端页面的接口参数
|
||
public setFrontPage: KeyParams = {
|
||
id: '',
|
||
pid: '',
|
||
icon: '',
|
||
label: '',
|
||
web_href: '',
|
||
sort: '',
|
||
status: '',
|
||
is_menu: '',
|
||
page_type: '0',
|
||
component_id: '',
|
||
param: {},
|
||
auth_rule_ids: [],
|
||
actions: [],
|
||
};
|
||
public actionChioos: Array<any> = [];
|
||
public statusText: boolean = true;
|
||
public isMenuText: boolean = false;
|
||
// 保存后端权限简单列表的数据
|
||
public AccessListData: KeyParams[] = [];
|
||
// 保存前端页面简单列表的数据
|
||
public frontPageData: KeyParams[] = [];
|
||
// false 添加,true 编辑
|
||
public ApiStatus: boolean = false;
|
||
// 保存前端组件列表的数据
|
||
public ComponentListData: KeyParams[] = [];
|
||
|
||
constructor(point: any) {
|
||
super();
|
||
this.VueApp = point;
|
||
}
|
||
|
||
public async StartUp(): Promise<void> {
|
||
await this.PageGetList();
|
||
await this.frontPageSimpleList();
|
||
await this.ParentAccessList();
|
||
await this.ComponentListRequest()
|
||
}
|
||
|
||
public chiooseAction(v:any) {
|
||
if (this.actionChioos.includes(v.value) ) {
|
||
this.actionChioos = this.actionChioos.filter((t:string)=>{
|
||
return t != v.value
|
||
})
|
||
} else {
|
||
this.actionChioos.push(v.value)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 提交前端页面
|
||
* @constructor
|
||
*/
|
||
public async SubmitAddMenu(): Promise<void> {
|
||
console.log(this.setFrontPage)
|
||
if (this.setFrontPage.id == 0) {
|
||
this.setFrontPage.id = 0;
|
||
}
|
||
// true 编辑
|
||
if (this.ApiStatus) {
|
||
let res = await this.RoleServiceImpl.FrontEditPage(this.setFrontPage);
|
||
// false 添加
|
||
} else {
|
||
this.setFrontPage.actions = this.actionChioos;
|
||
let res = await this.RoleServiceImpl.FrontSetPage(this.setFrontPage);
|
||
}
|
||
|
||
await this.PageGetList();
|
||
await this.frontPageSimpleList();
|
||
}
|
||
|
||
public NodeCheck(e: any,t: boolean, a:boolean) {
|
||
|
||
if (e.hasOwnProperty("children")) {
|
||
console.log("一级或者二级节点,跳过保存")
|
||
} else {
|
||
console.log("三级节点")
|
||
// true 节点被选中
|
||
if (t) {
|
||
|
||
this.setFrontPage.auth_rule_ids.push(e.id)
|
||
console.log("节点被选中:", this.setFrontPage.auth_rule_ids)
|
||
|
||
// false 节点被取消选中
|
||
} else {
|
||
console.log("e.id :", e.id)
|
||
this.setFrontPage.auth_rule_ids = this.setFrontPage.auth_rule_ids.filter((v:number)=>{
|
||
return v != e.id
|
||
});
|
||
console.log("取消选中,去除数据:", this.setFrontPage.auth_rule_ids)
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 前端页面列表
|
||
* @constructor
|
||
*/
|
||
public async PageGetList(): Promise<void> {
|
||
this.PageData = await this.RoleServiceImpl.PageGetList({});
|
||
console.log("前端页面列表: ", this.PageData)
|
||
}
|
||
|
||
/**
|
||
* 获取后端权限简单列表
|
||
* @constructor
|
||
*/
|
||
public async ParentAccessList(): Promise<void> {
|
||
let res = await this.RoleServiceImpl.GetParentAccessList({
|
||
// mode: 'signal'
|
||
});
|
||
|
||
res.forEach((v:any)=>{
|
||
v.label = v.auth_title;
|
||
if (v.hasOwnProperty("children")) {
|
||
v.children.forEach((t:any)=>{
|
||
t.label = t.auth_title;
|
||
if (t.hasOwnProperty("children")) {
|
||
t.children.forEach((k:any)=>{
|
||
k.label = k.auth_title;
|
||
})
|
||
}
|
||
})
|
||
}
|
||
})
|
||
|
||
this.AccessListData = res;
|
||
console.log("后端权限简单列表: ", res)
|
||
}
|
||
|
||
/**
|
||
* 获取前端页面的简单列表
|
||
*/
|
||
public async frontPageSimpleList(): Promise<void> {
|
||
let res = await this.RoleServiceImpl.frontPageSimpleList({})
|
||
res.push({
|
||
id: 0,
|
||
pid: 0,
|
||
value: 0,
|
||
label: '顶级权限',
|
||
auth_title: '顶级权限'
|
||
})
|
||
this.frontPageData = res
|
||
console.log("获取前端页面的简单列表: ", res)
|
||
}
|
||
|
||
/**
|
||
* 获取前端组件列表
|
||
*/
|
||
public async ComponentListRequest(): Promise<void> {
|
||
this.ComponentListData = await this.RoleServiceImpl.componentList({})
|
||
console.log("获取前端组件列表: ", this.ComponentListData)
|
||
}
|
||
|
||
}
|