Commit 73a29199 authored by chenqikuai's avatar chenqikuai

feat:网点管理新增网点

parent 26fb48b5
/staff/view /staff/view
查询和某管理员同一个网点的 客服经理 查询和某管理员同一个网点的 客服经理
新增网点
export const fooList = [
{
label: '所属一级分行',
placeholder: '请选择一级分行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
propName: 'firstBranch',
},
{
label: '所属二级分行',
placeholder: '请选择二级分行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
propName: 'secondBranch',
},
{
label: '所属一级支行',
placeholder: '请选择一级支行',
options: [] as { ID: number; Name: string }[],
disable: false,
value: undefined as number | undefined,
propName: 'firstSubBranch',
},
]
<template>
<div class="header-select">
<FormModelItem
v-for="(item, index) in fooList"
:prop="item.propName"
class="base_form_item my-2"
style="position: relative"
:key="index"
:label="item.label"
>
<a-select
class="header-select-item my-2"
@change="(value) => handleSelectChange(value, index)"
:placeholder="item.placeholder"
:value="item.value"
:disabled="index + 1 <= userLevel ? true : item.disable"
>
<a-select-option
:value="option.ID"
:key="option.ID"
v-for="option in item.options"
>{{ option.Name }}</a-select-option
>
</a-select>
</FormModelItem>
</div>
</template>
<script lang="ts">
import { eLevel } from "@/types/level";
import { message } from "ant-design-vue";
import StaffService from "@/service/StaffService";
import { fooList } from "./const";
import Vue, { PropType } from "vue";
import { iOutLet } from "@/service/StaffService/types";
import { FormModel } from "ant-design-vue";
import { getSelfOutLet } from "@/utils/outlet";
import { getUserMsg } from "@/utils/userMsg/userMsg";
import { eNewRoleRelatedToBackEnd } from "@/types/role";
const FormModelItem = FormModel.Item;
export default Vue.extend({
components: {
FormModelItem,
FormModel,
},
props: {
fooList: {
type: Array as PropType<typeof fooList>,
},
setFooList: Function,
level: Number,
userLevel: Number,
},
data() {
return {};
},
mounted() {
this.init();
},
methods: {
handleSelectChange(value: number, index: number) {
const baseList = [...this.fooList];
baseList[index].value = value;
const newList = baseList.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 !== 3 && 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) {
const baseList = [...this.fooList];
baseList[index].options = ret.data.item;
this.changeFooList(baseList);
}
},
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);
},
resetList() {
const list = this.fooList.map((i) => {
return {
...i,
disable: false,
value: undefined,
options: [],
};
});
this.setFooList([...list]);
},
async init() {
const selfOutLet = await getSelfOutLet();
const role = getUserMsg()?.newRole;
this.resetList();
this.$nextTick(() => {
if (role === eNewRoleRelatedToBackEnd.BackAdmin) {
this.initBackAdmin(selfOutLet);
}
});
},
async initBackAdmin(selfOutLet: iOutLet) {
const ret = await StaffService.getInstance().getBranch({
level: eLevel.firstLevel_branch,
});
if (ret.code === 200) {
const options = ret.data.item;
const baseList = [...this.fooList];
baseList[0].options = options;
const newList = baseList.map((item, i) => {
return {
...item,
disable: i >= 1,
};
});
this.setFooList(newList);
}
},
init_firstLevel(selfOutLet: iOutLet) {
const list = this.initFooListBasicValues(
selfOutLet,
eLevel.firstLevel_branch
);
this.setFooList(list);
},
async init_secondLevel(selfOutLet: iOutLet) {
const { fid, first_branch, sid, second_branch } = selfOutLet;
const list = this.initFooListBasicValues(
selfOutLet,
eLevel.secondary_branch
);
this.setFooList(list);
const ret = await StaffService.getInstance().getBranch({
level: eLevel.firstLevel_sub_branch,
page_size: 10000,
parent_id: sid,
});
const baseList = [...this.fooList];
if (ret.code === 200) {
baseList[2].options = ret.data.item;
}
this.setFooList(baseList);
},
async init_first_sub_Level(selfOutLet: iOutLet) {
const baseList = [...this.fooList];
const { fid, first_branch, sid, second_branch, fs_id, first_sub_branch } =
selfOutLet;
const list = this.initFooListBasicValues(
selfOutLet,
eLevel.firstLevel_sub_branch
);
this.setFooList(list);
const ret = await StaffService.getInstance().getBranch({
level: eLevel.secondary_sub_branch,
page_size: 1000,
parent_id: fs_id,
});
if (ret.code === 200) {
baseList[3].options = ret.data.item;
}
this.setFooList(baseList);
},
init_second_sub_Level(selfOutLet: iOutLet) {
this.initFooListBasicValues(selfOutLet, eLevel.secondary_sub_branch);
},
initFooListBasicValues(selfOutLet: iOutLet, level: eLevel) {
let list = this.fooList;
const {
fid,
first_branch,
sid,
second_branch,
fs_id,
first_sub_branch,
ss_id,
second_sub_branch,
} = selfOutLet;
if (
[
eLevel.firstLevel_branch,
eLevel.secondary_branch,
eLevel.firstLevel_sub_branch,
eLevel.secondary_sub_branch,
].includes(level)
) {
list[0].value = fid;
list[0].options = [{ ID: fid, Name: first_branch }];
list[0].disable = true;
}
if (
[
eLevel.secondary_branch,
eLevel.firstLevel_sub_branch,
eLevel.secondary_sub_branch,
].includes(level)
) {
list[1].value = sid;
list[1].options = [{ ID: sid, Name: second_branch }];
list[1].disable = true;
}
if (
[eLevel.firstLevel_sub_branch, eLevel.secondary_sub_branch].includes(
level
)
) {
list[2].value = fs_id;
list[2].options = [{ ID: fs_id, Name: first_sub_branch }];
list[2].disable = true;
}
if ([eLevel.secondary_sub_branch].includes(level)) {
list[3].value = ss_id;
list[3].options = [{ ID: ss_id, Name: second_sub_branch }];
list[3].disable = true;
}
return list;
},
popupScroll1(e: Event) {
let h = e.target as HTMLElement;
if (h.scrollHeight - h.scrollTop <= h.clientHeight) {
message.info("臣妾做不到啊");
}
},
popupScroll2(e: Event) {
let h = e.target as HTMLElement;
if (h.scrollHeight - h.scrollTop <= h.clientHeight) {
message.info("臣妾做不到啊");
}
},
popupScroll3(e: Event) {
let h = e.target as HTMLElement;
if (h.scrollHeight - h.scrollTop <= h.clientHeight) {
message.info("臣妾做不到啊");
}
},
popupScroll4(e: Event) {
let h = e.target as HTMLElement;
if (h.scrollHeight - h.scrollTop <= h.clientHeight) {
message.info("臣妾做不到啊");
}
},
},
});
</script>
<style scoped lang="less">
.header-select {
.header-select-item {
width: 200px;
}
}
</style>
\ No newline at end of file
import baseAxios from '../index' import baseAxios from '../index'
import { iOutLetDetail } from './types' import { iOutLetDetail, iOutletMsg } from './types'
export default class AddressService { export default class AddressService {
private prefix: string private prefix: string
...@@ -57,11 +57,17 @@ export default class AddressService { ...@@ -57,11 +57,17 @@ export default class AddressService {
} }
} }
getOutlet(data: { outlet_name: string }) { getOutlet(data: { outlet_name?: string; id?: number }) {
let theData = {} as any
if (data.outlet_name) {
theData.name = data.outlet_name
} else if (data.id !== undefined) {
theData.id = data.id
}
return baseAxios<iOutLetDetail>({ return baseAxios<iOutLetDetail>({
url: '/address/getOutlet', url: '/address/getOutlet',
method: 'post', method: 'post',
data, data: theData,
}) })
} }
...@@ -82,6 +88,7 @@ export default class AddressService { ...@@ -82,6 +88,7 @@ export default class AddressService {
location: string location: string
note: string note: string
opening_hours: string opening_hours: string
name: string
weekend_status: number weekend_status: number
}) { }) {
return baseAxios({ return baseAxios({
...@@ -90,4 +97,20 @@ export default class AddressService { ...@@ -90,4 +97,20 @@ export default class AddressService {
data, data,
}) })
} }
delete(data: { id: number }) {
return baseAxios({
url: '/address/delete',
method: 'post',
data,
})
}
add(data: iOutletMsg) {
return baseAxios({
url: '/address/add',
method: 'post',
data,
})
}
} }
...@@ -8,4 +8,20 @@ export interface iOutLetDetail { ...@@ -8,4 +8,20 @@ export interface iOutLetDetail {
opening_hours: string opening_hours: string
outlet_name: string outlet_name: string
region_name: string region_name: string
weekend_status: number
province_name: string
}
export interface iOutletMsg {
city_id: number
is_normal_work: boolean
lat_lon: string
location: string
name: string
note: string
opening_hours: string
province_id: number
region_id: number
region_name: string
weekend_status?: number,
} }
This diff is collapsed.
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