diff --git a/packages/ui-vue/.gitignore b/packages/ui-vue/.gitignore index ca8018c48b20a44abef75a8ca13ce6f2aa0c518a..1e5980fc0dec38f13e308a13a6ea8e8aa8b5229e 100644 --- a/packages/ui-vue/.gitignore +++ b/packages/ui-vue/.gitignore @@ -29,3 +29,5 @@ package # Vitepress */.vitepress/cache */.vitepress/dist + +public/assets/i18n \ No newline at end of file diff --git a/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.component.tsx b/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.component.tsx index c76ac03b52bed342b4e9d8057c59d525d7760c61..7b8b7a328490840345e26d6359a6e3c3a32b2592 100644 --- a/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.component.tsx +++ b/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.component.tsx @@ -22,12 +22,14 @@ export default defineComponent({ const searchValue = ref(queryState.value); const isNavigation = ref(props.isNavigation); const searchFieldRef = ref(); + const isEqualSearch = ref(false); const eventParams = computed(() => { return { field: searchField.value, value: searchValue.value, - isNavigation: isNavigation.value + isNavigation: isNavigation.value, + type: isEqualSearch.value ? 'equal' : 'like' }; }); @@ -96,8 +98,8 @@ export default defineComponent({ enableClear={false} > -
- + - {/* */} + {props.enableEqualSearch &&
+ + +
}
; }; diff --git a/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.props.ts b/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.props.ts index c07406e9022c151cf030543004f879ab802129d4..31a969d5619410de290397f7c9bf8551e69af05e 100644 --- a/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.props.ts +++ b/packages/ui-vue/components/lookup/src/components/search-bar/search-bar.props.ts @@ -5,7 +5,9 @@ export const searchBarProps = { fields: { type: Array, default: () => [] }, showAllColumns: { type: Boolean, default: true }, isNavigation: { type: Boolean, default: false }, - id: { type: String, default: '' } + id: { type: String, default: '' }, + enableEqualSearch: { type: Boolean, default: false }, + exactLabel: { type: String, default: '精确' } }; export type SearchBarProps = ExtractPropTypes; diff --git a/packages/ui-vue/components/lookup/src/composition/use-http.ts b/packages/ui-vue/components/lookup/src/composition/use-http.ts index 100e81acaa95c47ce592a4b031bc364935e443fa..c455bdd2d40cdb08cf129b0663320af419e91ab9 100644 --- a/packages/ui-vue/components/lookup/src/composition/use-http.ts +++ b/packages/ui-vue/components/lookup/src/composition/use-http.ts @@ -82,7 +82,7 @@ export function useHttp(props: LookupProps, context: any): UseHttpComposition { }; }; - function buildConditionsWhenSearchAnyFields(searchFields: any[], searchValues: string): any[] { + function buildConditionsWhenSearchAnyFields(searchFields: any[], searchValues: string, searchType = 'like'): any[] { // 处理空值或只包含空格的情况 if (searchValues == null || !searchValues.trim()) { return []; @@ -94,6 +94,8 @@ export function useHttp(props: LookupProps, context: any): UseHttpComposition { if (!searchFields || !searchKeys.length) { return []; } + const isEqual = searchType === 'equal'; + const compare = isEqual ? Compare.Equal: Compare.Like; const conditions = (searchFields || []).map((n: { label: string; value: string }, i) => { const fieldConditions = searchKeys.map((s, j) => { @@ -103,7 +105,7 @@ export function useHttp(props: LookupProps, context: any): UseHttpComposition { lbracket: '', rbracket: '', relation: FilterRelation.And, - compare: Compare.Like, + compare, }; }); if (fieldConditions.length) { @@ -162,7 +164,7 @@ export function useHttp(props: LookupProps, context: any): UseHttpComposition { if (!props.enableMultiFieldSearch && searchParam.searchField === '*') { const searchFields = isNavigation ? navSearchFieldItems.value : searchFieldItems.value; - const conditions = buildConditionsWhenSearchAnyFields(searchFields, value); + const conditions = buildConditionsWhenSearchAnyFields(searchFields, value, searchType); if (conditions && conditions.length) { if (isNavigation) { navSearchConditions = conditions; diff --git a/packages/ui-vue/components/lookup/src/composition/use-locales.ts b/packages/ui-vue/components/lookup/src/composition/use-locales.ts index daa33bd659b61cc9b80b892d6af2040c564c73c0..dc883ff9c4b99d274478f883f6effab307cb069e 100644 --- a/packages/ui-vue/components/lookup/src/composition/use-locales.ts +++ b/packages/ui-vue/components/lookup/src/composition/use-locales.ts @@ -6,7 +6,8 @@ export const LOOKUP_LOCALES = Symbol('FARRIS_LOOKUP_LOCALES'); export interface LookupLocaleData { searchColumns: { allColumns: string, - anyFields: string + anyFields: string, + exactLabel: string, }, placeholder: string, tabs: { @@ -84,7 +85,8 @@ export function useLookupLocales(props: LookupProps): LookupLocaleData { const searchColumns= { allColumns: getLocaleValue('lookup.allColumns') || '所有列', - anyFields: getLocaleValue('lookup.anyFields') || '全部' + anyFields: getLocaleValue('lookup.anyFields') || '全部', + exactLabel: getLocaleValue('lookup.exact') || '精确', }; return { diff --git a/packages/ui-vue/components/lookup/src/composition/use-search-bar.tsx b/packages/ui-vue/components/lookup/src/composition/use-search-bar.tsx index 8c968c11fcc40ba6735a2572c1d7ccd227bae144..6b3ecf5c8ff4024d96a45ba5ae24822f190bd841 100644 --- a/packages/ui-vue/components/lookup/src/composition/use-search-bar.tsx +++ b/packages/ui-vue/components/lookup/src/composition/use-search-bar.tsx @@ -42,6 +42,7 @@ export function useSearchbar(props: LookupProps, isNavigation: boolean, lookupSt function onSearch($event: { field: string; value: string }) { const searchData = {...$event}; + if (isNavigation) { searchState.navigation = searchData; return; @@ -61,6 +62,8 @@ export function useSearchbar(props: LookupProps, isNavigation: boolean, lookupSt showAllColumns={ props.searchAnyField } isNavigation={ isNavigation } onSearch={ onSearch } + enableEqualSearch={ props.enableEqualSearch && !isNavigation } + exactLabel={ lookupLocales.searchColumns.exactLabel || '精确' } > ; } diff --git a/packages/ui-vue/components/lookup/src/locales/ui/en.json b/packages/ui-vue/components/lookup/src/locales/ui/en.json index f63993a7fb9821a3dd3344c65be1684d9c7c7165..1f3906a9b6d285774c589300047bdf9974eb007e 100644 --- a/packages/ui-vue/components/lookup/src/locales/ui/en.json +++ b/packages/ui-vue/components/lookup/src/locales/ui/en.json @@ -1,5 +1,6 @@ { "lookup": { + "exact": "Exact", "placeholder": "Please select", "favorites": "Favorites", "selected": "Selected Items", diff --git a/packages/ui-vue/components/lookup/src/locales/ui/zh-CHS.json b/packages/ui-vue/components/lookup/src/locales/ui/zh-CHS.json index a1a6ee1867dc311dbf689822a343916bbbacf6d4..b9ca0d8c0530ab93f338873c3ecadaf1e511dd7d 100644 --- a/packages/ui-vue/components/lookup/src/locales/ui/zh-CHS.json +++ b/packages/ui-vue/components/lookup/src/locales/ui/zh-CHS.json @@ -1,5 +1,6 @@ { "lookup": { + "exact": "精确", "placeholder": "请选择", "favorites": "收藏夹", "selected": "已选数据", diff --git a/packages/ui-vue/components/lookup/src/locales/ui/zh-CHT.json b/packages/ui-vue/components/lookup/src/locales/ui/zh-CHT.json index 04f898894952e4c0f4eae7d134748f4a66d62265..22b595389999b7b2e0d92169690f36fc2f053b7a 100644 --- a/packages/ui-vue/components/lookup/src/locales/ui/zh-CHT.json +++ b/packages/ui-vue/components/lookup/src/locales/ui/zh-CHT.json @@ -1,5 +1,6 @@ { "lookup": { + "exact": "精確", "placeholder": "請選擇", "favorites": "收藏夾", "selected": "已選數據", diff --git a/packages/ui-vue/components/lookup/src/lookup.props.ts b/packages/ui-vue/components/lookup/src/lookup.props.ts index 9f3877e77f968393cf7ee3f9a73881dbe1172b6a..cd06dd320c660aac2a01a51a0841bd6edc8eb4e1 100644 --- a/packages/ui-vue/components/lookup/src/lookup.props.ts +++ b/packages/ui-vue/components/lookup/src/lookup.props.ts @@ -81,7 +81,9 @@ export const lookupProps = { /** 0: 不展开; -1: 全部展开;>0: 展开到指定级数 */ expandLevel: { type: Number, default: 0 }, openType: { type: String as PropType<'Modal' | 'Popup'>, default: 'Modal' }, - enableTitle: { type: Boolean, default: false } + enableTitle: { type: Boolean, default: false }, + /** 是否启用等于搜索功能 */ + enableEqualSearch: { type: Boolean, default: false } } as Record; export type LookupProps = ExtractPropTypes; diff --git a/packages/ui-vue/components/lookup/src/property-config/lookup.property-config.ts b/packages/ui-vue/components/lookup/src/property-config/lookup.property-config.ts index b25a4d2365de2f59fa8c611abf1dd2327535a9ed..08bed10590c9fc44a581a66eb9dd11cafa509cb1 100644 --- a/packages/ui-vue/components/lookup/src/property-config/lookup.property-config.ts +++ b/packages/ui-vue/components/lookup/src/property-config/lookup.property-config.ts @@ -57,6 +57,7 @@ export class LookupPropertyConfig extends InputBaseProperty { const dialog = this.getDialogPropertyConfig(propertyData); const pager = this.getPageConfig(propertyData.editor); const treeConfig = this.getTreePropConfig(propertyData.editor); + const searchConfig = this.getSearchConfig(propertyData); // 'compute', 'dependency', const expressions = this.getExpressionConfig(propertyData, 'Field'); @@ -69,7 +70,8 @@ export class LookupPropertyConfig extends InputBaseProperty { treeConfig, dialog, pager, - expressions + expressions, + searchConfig }; if (propertyData.type === 'form-group') { @@ -152,6 +154,31 @@ export class LookupPropertyConfig extends InputBaseProperty { return ''; } + public getSearchConfig(propertyData: any) { + return { + description: "Lookup Search Infomation", + title: "搜索", + parentPropertyID: 'editor', + properties: { + enableSearchBar: { + $converter: lookupDefaultConverter, + description: "是否启用搜索栏", + refreshPanelAfterChanged: true, + title: "启用搜索栏", + type: "boolean" + }, + enableEqualSearch: { + $converter: lookupDefaultConverter, + description: "是否启用等于搜索", + title: "启用精确搜索", + type: "boolean", + visible: propertyData.editor.openType !== 'Popup' && (propertyData.editor?.enableSearchBar ?? true) !== false + }, + }, + hide: propertyData.editor.openType === 'Popup' + }; + } + public getLookupConfig(propertyData: any) { const editorOptions = propertyData.editor; const getRemoteParams = () => { diff --git a/packages/ui-vue/components/lookup/src/schema/lookup.schema.json b/packages/ui-vue/components/lookup/src/schema/lookup.schema.json index 25e2977e77face334d87cc033f963ae5c3fe2ef9..2f4c5714604a51ceeb87add64ea8ee614a2e50cc 100644 --- a/packages/ui-vue/components/lookup/src/schema/lookup.schema.json +++ b/packages/ui-vue/components/lookup/src/schema/lookup.schema.json @@ -260,6 +260,10 @@ "includeChildNodesValue": { "type": "boolean", "default": true + }, + "enableEqualSearch": { + "type": "boolean", + "default": false } }, "required": [