50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
|
||
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!);
|
||
}
|
||
},
|
||
},
|
||
}); |