mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:39:34 +00:00
fix: china region code eq
This commit is contained in:
parent
dd9f5d5e52
commit
6434b5d8dc
@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
import { uid } from '@formily/shared';
|
||||
import { defaultProps, operators } from './properties';
|
||||
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';
|
||||
import { defaultProps, operators } from './properties';
|
||||
|
||||
export class ChinaRegionFieldInterface extends CollectionFieldInterface {
|
||||
name = 'chinaRegion';
|
||||
@ -86,6 +86,16 @@ export class ChinaRegionFieldInterface extends CollectionFieldInterface {
|
||||
|
||||
filterable = {
|
||||
children: [
|
||||
{
|
||||
name: 'code',
|
||||
title: '{{t("Province/city/area code")}}',
|
||||
operators: operators.regionCode,
|
||||
schema: {
|
||||
title: '{{t("Province/city/area code")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
title: '{{t("Province/city/area name")}}',
|
||||
|
@ -16,6 +16,8 @@ export const string = [
|
||||
{ label: '{{t("is not empty")}}', value: '$notEmpty', noValue: true },
|
||||
];
|
||||
|
||||
export const regionCode = [{ label: '{{t("is")}}', value: '$regionCodeEq' }];
|
||||
|
||||
export const array = [
|
||||
{
|
||||
label: '{{t("is")}}',
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import { resolve } from 'path';
|
||||
import _ from 'lodash';
|
||||
import { ChinaRegionInterface } from './interfaces/china-region-interface';
|
||||
|
||||
function getChinaDivisionData(key: string) {
|
||||
@ -26,10 +26,19 @@ export class PluginFieldChinaRegionServer extends Plugin {
|
||||
}
|
||||
|
||||
async load() {
|
||||
await this.importCollections(resolve(__dirname, 'collections'));
|
||||
|
||||
this.app.acl.allow('chinaRegions', 'list', 'loggedIn');
|
||||
|
||||
this.db.registerOperators({
|
||||
$regionCodeEq: (value, ctx) => {
|
||||
const eq = this.db.operators.get('$eq');
|
||||
if (Array.isArray(value)) {
|
||||
const obj = _.castArray(value).pop();
|
||||
return eq(obj?.code, ctx);
|
||||
}
|
||||
return eq(value, ctx);
|
||||
},
|
||||
});
|
||||
|
||||
this.app.resourcer.use(async (ctx, next) => {
|
||||
const { resourceName, actionName } = ctx.action.params;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user