Cardview Popup içerisinde Lookup çağrıları
This commit is contained in:
parent
4bec5442a8
commit
566da635c6
1 changed files with 51 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import Container from '@/components/shared/Container'
|
||||
import { DX_CLASSNAMES } from '@/constants/app.constant'
|
||||
import { DbTypeEnum, GridDto, PlatformEditorTypes } from '@/proxy/form/models'
|
||||
import { DbTypeEnum, GridDto, PlatformEditorTypes, UiLookupDataSourceTypeEnum } from '@/proxy/form/models'
|
||||
import { useLocalization } from '@/utils/hooks/useLocalization'
|
||||
import { usePermission } from '@/utils/hooks/usePermission'
|
||||
import { usePWA } from '@/utils/hooks/usePWA'
|
||||
|
|
@ -364,6 +364,56 @@ const CardView = (props: CardViewProps) => {
|
|||
cols?.forEach((col) => {
|
||||
const eo = col.editorOptions
|
||||
|
||||
// Lookup desteği ekle (SchedulerView'daki gibi)
|
||||
// gridDto'dan ilgili columnFormat'ı bul
|
||||
const listFormField = gridDto?.columnFormats?.find((x: any) => x.fieldName === col.dataField)
|
||||
if (listFormField?.lookupDto) {
|
||||
const lookup = listFormField.lookupDto
|
||||
if (lookup.dataSourceType === UiLookupDataSourceTypeEnum.Query) {
|
||||
col.editorOptions = {
|
||||
...col.editorOptions,
|
||||
dataSource: new CustomStore({
|
||||
key: 'key',
|
||||
loadMode: 'raw',
|
||||
load: async () => {
|
||||
try {
|
||||
const { dynamicFetch } = await import('@/services/form.service')
|
||||
const response = await dynamicFetch('list-form-select/lookup', 'POST', null, {
|
||||
listFormCode,
|
||||
listFormFieldName: col.dataField,
|
||||
filters: [],
|
||||
})
|
||||
return (response.data ?? []).map((a: any) => ({
|
||||
key: a.Key,
|
||||
name: a.Name,
|
||||
group: a.Group,
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('Lookup load error:', error)
|
||||
return []
|
||||
}
|
||||
},
|
||||
}),
|
||||
valueExpr: 'key',
|
||||
displayExpr: 'name',
|
||||
}
|
||||
} else if (lookup.dataSourceType === UiLookupDataSourceTypeEnum.StaticData) {
|
||||
if (lookup.lookupQuery) {
|
||||
try {
|
||||
const staticData = JSON.parse(lookup.lookupQuery)
|
||||
col.editorOptions = {
|
||||
...col.editorOptions,
|
||||
dataSource: staticData,
|
||||
valueExpr: lookup.valueExpr || 'key',
|
||||
displayExpr: lookup.displayExpr || 'name',
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Static data parse error:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sadece phoneGlobal formatlı kolonlarda çalış
|
||||
if (eo?.format === 'phoneGlobal') {
|
||||
// DevExtreme bazen string tipinde formatter'ı çağırmaz
|
||||
|
|
|
|||
Loading…
Reference in a new issue