Commit edb85712 authored by chenqikuai's avatar chenqikuai

权限转换函数更新、网点管理搜索下拉菜单50%

parent c59e40f4
......@@ -41,10 +41,10 @@ export default class StaffService {
page_size?: number
parent_id?: number
}) {
return baseAxios({
return baseAxios<{ item: { ID: number; Name: string }[]; total: number }>({
url: '/staff/branch',
method: 'get',
data,
params: data,
})
}
......
import { eLevel } from '@/types/level'
import { eNewRoleRelatedToBackEnd, eRole } from '@/types/role'
import { eUserType } from '@/types/userType'
import { iUserMsg } from '../userMsg/types'
export function getOldRoleFromUserMsg(usermsg: iUserMsg) {
if (usermsg.userType === eUserType.manager) {
if (usermsg.level === eLevel.firstLevel_branch)
return eRole.firstLevel_branch
else if (usermsg.level === eLevel.secondary_branch)
return eRole.secondary_branch
else if (usermsg.level === eLevel.firstLevel_sub_branch)
return eRole.firstLevel_sub_branch
else if (usermsg.level === eLevel.secondary_sub_branch)
return eRole.secondary_sub_branch
} else if (usermsg.userType === eUserType.employ) {
if (usermsg.level === eLevel.firstLevel_sub_branch)
return eRole.firstLevel_sub_clientManager
else if (usermsg.level === eLevel.secondary_sub_branch) {
return eRole.secondary_sub_clientManager
}
}
export function getOldRoleFromUserMsg(usermsg: iUserMsg): eRole | undefined {
if (usermsg.newRole === eNewRoleRelatedToBackEnd.PlatformAdmin)
return eRole.platform_management
else if (usermsg.newRole === eNewRoleRelatedToBackEnd.BackAdmin)
return eRole.superManager
else {
if (usermsg.level === eLevel.firstLevel_branch) {
return eRole.firstLevel_branch
} else if (usermsg.level === eLevel.secondary_branch) {
return eRole.secondary_branch
} else if (usermsg.level === eLevel.firstLevel_sub_branch) {
return usermsg.newRole === eNewRoleRelatedToBackEnd.ACM
? eRole.firstLevel_sub_branch
: eRole.firstLevel_sub_clientManager
} else if (usermsg.level === eLevel.secondary_sub_branch) {
return usermsg.newRole === eNewRoleRelatedToBackEnd.ACM
? eRole.secondary_branch
: eRole.secondary_sub_clientManager
}
}
}
......@@ -146,7 +146,7 @@ export default Vue.extend({
toggleLoginWay(key: Number) {
this.loginWay = key == 1 ? eLoginWay.PWD : eLoginWay.CODE;
},
async sendSmsFunc(phone: string) {
sendSmsFunc(phone: string) {
return VerifyCodeService.getInstance().send({
phone,
smsType: eSmsType.registerOrLogin,
......
export const fooList = [
{
placeholder: '请选择一级分行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
},
{
placeholder: '请选择二级分行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
},
{
placeholder: '请选择一级支行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
},
{
placeholder: '请选择一级支行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
},
]
<template>
<div class="header-select">
<a-select
v-for="(item, index) in fooList"
:key="index"
class="header-select-item mx-3"
placeholder="请选择一级分行"
:value="selectValue.f"
:disabled="selectDisable.f"
@popupScroll="popupScroll1"
@change="(value) => handleSelectChange(value, index)"
:placeholder="item.placeholder"
:value="item.value"
:disabled="item.disable"
>
<a-select-option
:value="option.value"
:key="option.value"
v-for="option in selectOptions.f"
>{{ option.label }}</a-select-option
>
</a-select>
<a-select
class="header-select-item mx-3"
placeholder="请选择二级分行"
:value="selectValue.s"
:disabled="selectDisable.s"
@popupScroll="popupScroll1"
>
<a-select-option
:value="option.value"
:key="option.value"
v-for="option in selectOptions.s"
>{{ option.label }}</a-select-option
>
</a-select>
<a-select
class="header-select-item mx-3"
placeholder="请选择一级支行"
:value="selectValue.fs"
:disabled="selectDisable.fs"
@popupScroll="popupScroll1"
>
<a-select-option
:value="option.value"
:key="option.value"
v-for="option in selectOptions.fs"
>{{ option.label }}</a-select-option
>
</a-select>
<a-select
class="header-select-item mx-3"
placeholder="请选择一级支行"
:value="selectValue.ss"
:disabled="selectDisable.ss"
@popupScroll="popupScroll1"
>
<a-select-option
:value="option.value"
:key="option.value"
v-for="option in selectOptions.ss"
>{{ option.label }}</a-select-option
:value="option.ID"
:key="option.ID"
v-for="option in item.options"
>{{ option.Name }}</a-select-option
>
</a-select>
</div>
</template>
<script lang="ts">
import { eLevel } from "@/types/level";
import { eNewRoleRelatedToBackEnd } from "@/types/role";
import { getSelfOutLet } from "@/utils/outlet";
import { getUserMsg } from "@/utils/userMsg/userMsg";
import { message } from "ant-design-vue";
import Vue from "vue";
import StaffService from "@/service/StaffService";
import { fooList } from "./const";
import Vue, { PropType } from "vue";
import { iOutLet } from "@/service/StaffService/types";
export default Vue.extend({
props: [
"selectValue",
"selectDisable",
"selectOptions",
"setSelectValue",
"setSelectDisable",
"setSelectOptions",
],
props: {
fooList: {
type: Array as PropType<typeof fooList>,
},
setFooList: Function,
level: Number,
role: String as PropType<eNewRoleRelatedToBackEnd>,
},
data() {
return {};
},
mounted() {
this.init();
},
methods: {
handleSelectChange(value: number, index: number) {
this.fooList[index].value = value;
const newList = this.fooList.map((i, idx) => {
idx > index && console.log(i);
return {
...i,
options: idx > index ? [] : i.options,
value: idx > index ? undefined : i.value,
};
});
this.changeFooList([...newList]);
index + 1 !== 4 && this.fetchOptions(index + 1);
},
async fetchOptions(index: number) {
const ret = await StaffService.getInstance().getBranch({
level: index + 1,
page_size: 10000,
parent_id: this.fooList[index - 1].value,
});
if (ret.code === 200) {
this.fooList[index].options = ret.data.item;
this.changeFooList(this.fooList);
}
},
changeFooList(v: any[]) {
let lastIndexhasValue = true;
const newList = v.map((item, index) => {
if (index >= this.level) {
const shouldDisable = !lastIndexhasValue;
lastIndexhasValue = item.value !== undefined;
return {
...item,
disable: shouldDisable,
options: shouldDisable ? [] : item.options,
};
} else {
return {
...item,
};
}
});
this.setFooList(newList);
},
async init() {
const selfOutLet = await getSelfOutLet();
if (this.role === eNewRoleRelatedToBackEnd.BackAdmin) {
const ret = await StaffService.getInstance().getBranch({
level: eLevel.firstLevel_branch,
});
if (ret.code === 200) {
const options = ret.data.item;
this.fooList[0].options = options;
const newList = this.fooList.map((item, i) => {
return {
...item,
disable: i >= 1,
};
});
this.setFooList(newList);
}
} else if (this.level === eLevel.firstLevel_branch) {
this.init_firstLevel(selfOutLet);
} else if (this.level === eLevel.secondary_branch) {
this.init_firstLevel(selfOutLet);
// this.setSelectValue([selfOutLet.fid, selfOutLet.sid]);
} else if (this.level === eLevel.firstLevel_sub_branch) {
// this.
// this.setSelectValue([selfOutLet.fid, selfOutLet.sid, selfOutLet.fs_id]);
} else if (this.level === eLevel.secondary_sub_branch) {
// this.setSelectValue([
// selfOutLet.fid,
// selfOutLet.sid,
// selfOutLet.fs_id,
// selfOutLet.ss_id,
// ]);
}
},
init_firstLevel(selfOutLet: iOutLet) {
const { fid, first_branch } = selfOutLet;
this.fooList[0].value = fid;
this.fooList[0].options = [{ ID: fid, Name: first_branch }];
this.fooList[0].disable = true;
this.setFooList(this.fooList);
},
init_secondLevel(selfOutLet: iOutLet) {},
init_first_sub_Level(selfOutLet: iOutLet) {},
init_second_sub_Level(selfOutLet: iOutLet) {},
popupScroll1(e: Event) {
let h = e.target as HTMLElement;
if (h.scrollHeight - h.scrollTop <= h.clientHeight) {
......
......@@ -4,12 +4,10 @@
<p class="text-2xl font-bold mb-5">网点管理</p>
<div>
<header-select
:selectValue="selectValue"
:selectDisable="selectDisable"
:selectOptions="selectOptions"
:setSelectValue="setSelectValue"
:setSelectDisable="setSelectDisable"
:setSelectOptions="setSelectOptions"
:setFooList="setFooList"
:fooList="fooList"
:level="level"
:role="role"
/>
</div>
<div class="mt-4">
......@@ -195,8 +193,8 @@ import { getSelfOutLet } from "@/utils/outlet/index";
import { getUserMsg } from "@/utils/userMsg/userMsg";
import { eLevel } from "@/types/level";
import { eNewRoleRelatedToBackEnd } from "@/types/role";
import StaffService from "@/service/StaffService";
import HeaderSelect from "./components/HeaderSelect/index.vue";
import { fooList } from "./components/HeaderSelect/const";
const FormModelItem = FormModel.Item;
const SelectOption = Select.Option;
......@@ -223,24 +221,7 @@ export default Vue.extend({
},
data() {
return {
selectValue: {
f: undefined as undefined | number,
s: undefined as undefined | number,
fs: undefined as undefined | number,
ss: undefined as undefined | number,
},
selectDisable: {
f: true,
s: false,
fs: false,
ss: false,
},
selectOptions: {
f: [] as any[],
s: [] as any[],
fs: [] as any[],
ss: [] as any[],
},
fooList,
cascaderValue: [] as any[],
addressSearchValue: "",
searchPageReqParams: {
......@@ -301,36 +282,10 @@ export default Vue.extend({
dataSource: [{}],
};
},
async mounted() {
this.initCascaderValue();
},
async mounted() {},
methods: {
setSelectValue(v: any) {
this.selectValue = v;
},
setSelectDisable(v: any) {
this.selectDisable = v;
},
setSelectOptions(v: any) {
this.selectOptions = v;
},
async initCascaderValue() {
const data = await getSelfOutLet();
const usermsg = getUserMsg();
if (usermsg?.newRole === eNewRoleRelatedToBackEnd.PlatformAdmin) {
this.cascaderValue = [];
StaffService.getInstance().getBranch({
level: eLevel.firstLevel_branch,
});
} else if (usermsg?.level === eLevel.firstLevel_branch) {
this.cascaderValue = [data.fid];
} else if (usermsg?.level === eLevel.secondary_branch) {
this.cascaderValue = [data.fid, data.sid];
} else if (usermsg?.level === eLevel.firstLevel_sub_branch) {
this.cascaderValue = [data.fid, data.sid, data.fs_id];
} else if (usermsg?.level === eLevel.secondary_sub_branch) {
this.cascaderValue = [data.fid, data.sid, data.fs_id, data.ss_id];
}
setFooList(v: any[]) {
this.fooList = [...v];
},
clickEdit(record: any) {
this.modalType = eModalType.edit;
......@@ -409,9 +364,6 @@ export default Vue.extend({
this.addressSearchValue = "";
},
onChange(value: any[]) {
if (value.length === 0) {
this.initCascaderValue();
}
this.cascaderValue = value;
if (this.cascaderValue.length === LEVE_ORG) {
this.$router.push({
......@@ -466,6 +418,12 @@ export default Vue.extend({
return true;
}
},
role() {
return getUserMsg()?.newRole;
},
level(): number | undefined {
return getUserMsg()?.level;
},
rangePickerValue(): any {
return (
(this.searchPageReqParams.startTime &&
......
......@@ -92,6 +92,8 @@ export const menuList: iMenuConfigItem[] = [
eRole.secondary_branch,
eRole.firstLevel_sub_branch,
eRole.secondary_sub_branch,
eRole.secondary_sub_clientManager,
eRole.firstLevel_sub_clientManager
],
onClick: (e: Event) => {},
},
......
......@@ -73,21 +73,24 @@ export default Vue.extend({
openKeys: [],
};
},
mounted(){
console.log(this.menuList, "show menulist")
mounted() {
console.log(this.menuList, "show menulist");
},
computed: {
role(): eRole | undefined {
const msg = getUserMsg()
return ((msg && getOldRoleFromUserMsg(msg))) as unknown as eRole | undefined
role(): eRole | undefined {
const msg = getUserMsg();
return (msg && getOldRoleFromUserMsg(msg)) as unknown as
| eRole
| undefined;
},
menuList(): iMenuList {
return this.role !== undefined && getMenuList(this.role) || [];
console.log(this.role, "show this.role");
return (this.role !== undefined && getMenuList(this.role)) || [];
},
filteredMenuList(): iMenuList {
return this.menuList.filter((i) => !i.hiddeInMenu);
},
selectedKeys():Array<String> {
selectedKeys(): Array<String> {
return [(this.$route.meta as { selectedName: string }).selectedName];
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment