oak-general-business/app/pages/pickers/area/index.ts

50 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default OakPage({
path: 'area:picker',
entity: 'area',
projection: {
id: 1,
name: 1,
depth: 1,
level: 1,
},
filters: [
{
filter: {
parent: {
level: 'country',
},
},
},
],
isList: true,
formData: async ({ data: arealist }) => ({
arealist,
}),
properties: {
depth: Number,
},
methods: {
onItemClicked(input: any) {
// resolveInput里用的是target原来的代码用的是currentTarget可能有问题
const { dataset } = this.resolveInput(input);
const item = this.state.arealist!.find(
(ele) => ele?.id === dataset!.id
);
const { depth, id } = item!;
if (depth !== this.props.depth) {
this.setFilters([
{
filter: {
parentId: id,
},
},
]);
} else {
this.setForeignKey(id!);
}
},
},
});