ow
This commit is contained in:
1 parent
1404640f16
commit
2bbf016cbf
167 files changed
+18941
-589
No files matched your search
@@ -0,0 +1,89 @@
|
||||
import { SecurityUserPermissionInfo } from "@/data/auto/securityUserPermissionInfo";
|
||||
import { LoginProfile } from "@/data/auto/loginProfile";
|
||||
import { useLoginProfileStore } from "@/store/modules/loginProfile";
|
||||
import { YesNoPolicy } from "@/data/custom/yesNoPolicy";
|
||||
|
||||
export class PermissionContext {
|
||||
private userPermissons!: SecurityUserPermissionInfo;
|
||||
constructor(userPermissons: SecurityUserPermissionInfo) {
|
||||
this.userPermissons = userPermissons ?? new SecurityUserPermissionInfo();
|
||||
}
|
||||
|
||||
canView(permission: string, dataSensitiveId?: string): boolean {
|
||||
if (dataSensitiveId) {
|
||||
return (
|
||||
this.userPermissons.PermissionDependents?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission &&
|
||||
x.DependentDetailName === dataSensitiveId
|
||||
) === true
|
||||
);
|
||||
}
|
||||
return (
|
||||
this.userPermissons.Permissions?.some(
|
||||
(x) => x.PermissionName === permission
|
||||
) === true
|
||||
);
|
||||
}
|
||||
|
||||
canCreate(permission: string, dataSensitiveId?: string): boolean {
|
||||
if (dataSensitiveId) {
|
||||
return (
|
||||
this.userPermissons.PermissionDependents?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission &&
|
||||
x.DependentDetailName === dataSensitiveId &&
|
||||
x.CreateIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
return (
|
||||
this.userPermissons.Permissions?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission && x.CreateIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
|
||||
canAmend(permission: string, dataSensitiveId?: string): boolean {
|
||||
if (dataSensitiveId) {
|
||||
return (
|
||||
this.userPermissons.PermissionDependents?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission &&
|
||||
x.DependentDetailName === dataSensitiveId &&
|
||||
x.AmendIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
return (
|
||||
this.userPermissons.Permissions?.some(
|
||||
(x) => x.PermissionName === permission && x.AmendIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
|
||||
canDelete(permission: string, dataSensitiveId?: string): boolean {
|
||||
if (dataSensitiveId) {
|
||||
return (
|
||||
this.userPermissons.PermissionDependents?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission &&
|
||||
x.DependentDetailName === dataSensitiveId &&
|
||||
x.DeleteIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
return (
|
||||
this.userPermissons.Permissions?.some(
|
||||
(x) =>
|
||||
x.PermissionName === permission && x.DeleteIndc == YesNoPolicy.YES
|
||||
) === true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function usePermissionContext(): PermissionContext {
|
||||
const userLoginProfile = useLoginProfileStore();
|
||||
return new PermissionContext(userLoginProfile.getPermissionInfo()!);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { GridColumnInfo } from "@/data/auto/gridColumnInfo";
|
||||
export const useGridColumnInfo = () => {
|
||||
const getGridColumnInfo = (columns: Column[]): GridColumnInfo[] => {
|
||||
let gridColumnInfos: GridColumnInfo[] = [];
|
||||
let gridColumnInfo: GridColumnInfo = new GridColumnInfo();
|
||||
|
||||
columns.forEach((element) => {
|
||||
gridColumnInfo = new GridColumnInfo();
|
||||
gridColumnInfo.align = element.align??'';
|
||||
gridColumnInfo.dataIndex = element.dataIndex??'';
|
||||
gridColumnInfo.format = element.format??'';
|
||||
gridColumnInfo.hidden = element.hidden??'';
|
||||
gridColumnInfo.sequence = element.sequence??999;
|
||||
gridColumnInfo.title = element.title??'';
|
||||
gridColumnInfos.push(gridColumnInfo);
|
||||
});
|
||||
|
||||
return gridColumnInfos;
|
||||
};
|
||||
|
||||
return {
|
||||
getGridColumnInfo,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import {ref} from 'vue'
|
||||
|
||||
export const useName = ()=>{
|
||||
const name = ref('rose')
|
||||
const setName = (value:string):void=>{
|
||||
name.value = value
|
||||
}
|
||||
return {
|
||||
name,setName
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { shallowRef } from "vue";
|
||||
|
||||
export const useOrderedChildren = <T extends { uid: number }>() => {
|
||||
const children: Record<number, T> = {};
|
||||
const orderedChildren = shallowRef<T[]>([]);
|
||||
|
||||
const addChild = (child: T) => {
|
||||
children[child.uid] = child;
|
||||
orderedChildren.value.push(child);
|
||||
};
|
||||
const removeChild = (uid: number) => {
|
||||
delete children[uid];
|
||||
orderedChildren.value = orderedChildren.value.filter(
|
||||
(child) => child.uid !== uid
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
children: orderedChildren,
|
||||
addChild,
|
||||
removeChild,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
import { BindOption } from "@/data/custom/bindOption";
|
||||
import { SelectOption } from "@/data/auto/selectOption";
|
||||
export const useBindOption = () => {
|
||||
const getBindOption = (
|
||||
bindValue: string,
|
||||
displayName: string,
|
||||
type: string,
|
||||
operator: string
|
||||
): BindOption => {
|
||||
let bindOption: BindOption = new BindOption();
|
||||
|
||||
bindOption = new BindOption();
|
||||
bindOption.Type = type;
|
||||
bindOption.Operator = operator;
|
||||
bindOption.DisplayName = displayName;
|
||||
bindOption.BindValue = bindValue;
|
||||
|
||||
return bindOption;
|
||||
};
|
||||
const getBindSelectOption = (
|
||||
bindValue: string,
|
||||
displayName: string,
|
||||
type: string,
|
||||
operator: string,
|
||||
SelectOptions: SelectOption[]
|
||||
): BindOption => {
|
||||
let bindOption: BindOption = new BindOption();
|
||||
|
||||
bindOption = new BindOption();
|
||||
bindOption.Type = type;
|
||||
bindOption.Operator = operator;
|
||||
bindOption.DisplayName = displayName;
|
||||
bindOption.BindValue = bindValue;
|
||||
bindOption.SelectOptions = SelectOptions;
|
||||
return bindOption;
|
||||
};
|
||||
const getSelectOption = (
|
||||
bindValue: string,
|
||||
displayName: string
|
||||
): SelectOption => {
|
||||
let selectOption: SelectOption = new SelectOption();
|
||||
|
||||
selectOption = new SelectOption();
|
||||
selectOption.DisplayName = displayName;
|
||||
selectOption.BindValue = bindValue;
|
||||
return selectOption;
|
||||
};
|
||||
return {
|
||||
getBindOption,getBindSelectOption,getSelectOption
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
import { SelectOption } from "@/data/auto/selectOption";
|
||||
import yesNoPolicyService from "@/service/security/yesNoPolicyService";
|
||||
import { storage } from "@/store/storage";
|
||||
|
||||
export const useYesNoPolicy = () => {
|
||||
const getSelectOption = async (blank:boolean): Promise<SelectOption[]> => {
|
||||
const yesNoPolicy = "x-yesNoPolicy";
|
||||
|
||||
let selectOptions: SelectOption[] = [];
|
||||
let str = storage.get(yesNoPolicy);
|
||||
if (str === null) {
|
||||
selectOptions = await yesNoPolicyService.FindSelectOption(blank);
|
||||
storage.set(yesNoPolicy, JSON.stringify(selectOptions));
|
||||
return selectOptions;
|
||||
}
|
||||
|
||||
selectOptions = JSON.parse(str) as Array<SelectOption>;
|
||||
return selectOptions;
|
||||
};
|
||||
return {
|
||||
getSelectOption,
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user