fix: error

This commit is contained in:
xingyu4j 2022-11-15 13:59:22 +08:00
parent a701c1d76c
commit c7972f9a06
8 changed files with 31 additions and 25 deletions

View File

@ -249,6 +249,7 @@ export default defineComponent({
const renderOptions = (item: FormSchema) => { const renderOptions = (item: FormSchema) => {
switch (item.component) { switch (item.component) {
case 'Select': case 'Select':
case 'SelectV2':
const { renderSelectOptions } = useRenderSelect(slots) const { renderSelectOptions } = useRenderSelect(slots)
return renderSelectOptions(item) return renderSelectOptions(item)
case 'Radio': case 'Radio':

View File

@ -14,7 +14,7 @@ import { ColProps } from '@/types/components'
export const setTextPlaceholder = (schema: FormSchema): PlaceholderMoel => { export const setTextPlaceholder = (schema: FormSchema): PlaceholderMoel => {
const { t } = useI18n() const { t } = useI18n()
const textMap = ['Input', 'Autocomplete', 'InputNumber', 'InputPassword'] const textMap = ['Input', 'Autocomplete', 'InputNumber', 'InputPassword']
const selectMap = ['Select', 'TimePicker', 'DatePicker', 'TimeSelect', 'TimeSelect'] const selectMap = ['Select', 'SelectV2', 'TimePicker', 'DatePicker', 'TimeSelect', 'TimeSelect']
if (textMap.includes(schema?.component as string)) { if (textMap.includes(schema?.component as string)) {
return { return {
placeholder: t('common.inputText') placeholder: t('common.inputText')

View File

@ -206,7 +206,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
const tableSchemaItem = { const tableSchemaItem = {
title: t('table.action'), title: t('table.action'),
field: 'actionbtns', field: 'actionbtns',
width: crudSchema.actionWidth ? crudSchema.actionWidth : '240px', width: crudSchema.actionWidth ? crudSchema.actionWidth : '200px',
slots: { slots: {
default: 'actionbtns_default' default: 'actionbtns_default'
} }
@ -234,7 +234,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
comonentProps = { comonentProps = {
options: options options: options
} }
if (!(schemaItem.form && schemaItem.form.component)) component = 'SelectV2' if (!(schemaItem.form && schemaItem.form.component)) component = 'Select'
} }
const formSchemaItem = { const formSchemaItem = {
...schemaItem.form, ...schemaItem.form,
@ -267,10 +267,9 @@ const filterDescriptionsSchema = (crudSchema: VxeCrudSchema): DescriptionsSchema
descriptionsSchemaItem.dictType = schemaItem.dictType descriptionsSchemaItem.dictType = schemaItem.dictType
} }
if (schemaItem.detail?.dateFormat || schemaItem.formatter == 'formatDate') { if (schemaItem.detail?.dateFormat || schemaItem.formatter == 'formatDate') {
// descriptionsSchemaItem.dateFormat = schemaItem.detail.dateFormat descriptionsSchemaItem.dateFormat = schemaItem.dateFormat
// ? schemaItem?.detail?.dateFormat ? schemaItem?.detail?.dateFormat
// : 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ss'
descriptionsSchemaItem.dateFormat = 'YYYY-MM-DD HH:mm:ss'
} }
descriptionsSchema.push(descriptionsSchemaItem) descriptionsSchema.push(descriptionsSchemaItem)

View File

@ -139,10 +139,6 @@ VXETable.formats.mixin({
formatDate({ cellValue }, format) { formatDate({ cellValue }, format) {
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss') return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
}, },
// 格式字典
formatDict() {
return 'cellValue 123'
},
// 四舍五入金额每隔3位逗号分隔默认2位数 // 四舍五入金额每隔3位逗号分隔默认2位数
formatAmount({ cellValue }, digits = 2) { formatAmount({ cellValue }, digits = 2) {
return XEUtils.commafy(Number(cellValue), { digits }) return XEUtils.commafy(Number(cellValue), { digits })
@ -158,6 +154,10 @@ VXETable.formats.mixin({
// 向下舍入,默认两位数 // 向下舍入,默认两位数
formatCutNumber({ cellValue }, digits = 2) { formatCutNumber({ cellValue }, digits = 2) {
return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits) return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
},
// 格式化图片将图片链接转换为html标签
formatImg({ cellValue }) {
return '<img height="40" src="' + cellValue + '"> '
} }
}) })
export const setupVxeTable = (app: App<Element>) => { export const setupVxeTable = (app: App<Element>) => {

View File

@ -15,19 +15,16 @@ const dictStore = useDictStoreWithOut()
export interface DictDataType { export interface DictDataType {
dictType: string dictType: string
label: string label: string
value: string | number | boolean value: string | number
colorType?: ElementPlusInfoType | '' | 'default' | 'primary' colorType: ElementPlusInfoType | '' | 'default' | 'primary'
cssClass?: string cssClass: string
} }
export const getDictOptions = (dictType: string) => { export const getDictOptions = (dictType: string) => {
const dictOptions: DictDataType[] = [] const dictOptions: DictDataType[] = []
dictStore.getDictMap.forEach((dict: DictDataType) => { dictStore.getDictMap.forEach((dict: DictDataType) => {
if (dict.dictType.toString() === dictType) { if (dict.dictType + '' === dictType) {
dictOptions.push({ dictOptions.push(dict)
...dict,
value: dict.value
})
} }
}) })
return dictOptions return dictOptions

View File

@ -36,6 +36,9 @@ const crudSchemas = reactive<VxeCrudSchema>({
{ {
title: '公告内容', title: '公告内容',
field: 'content', field: 'content',
table: {
type: 'html'
},
form: { form: {
component: 'Editor', component: 'Editor',
colProps: { colProps: {

View File

@ -35,12 +35,16 @@ const crudSchemas = reactive<VxeCrudSchema>({
}, },
{ {
title: '应用图标', title: '应用图标',
field: 'logo' field: 'logo',
table: {
type: 'html',
formatter: 'formatImg'
}
}, },
{ {
title: t('common.status'), title: t('common.status'),
field: 'status', field: 'status',
dictType: DICT_TYPE.COMMON_STATUS, // TODO @星语编辑时status 展示为 0 或者 1 了 dictType: DICT_TYPE.COMMON_STATUS,
isSearch: true isSearch: true
}, },
{ {
@ -60,9 +64,11 @@ const crudSchemas = reactive<VxeCrudSchema>({
{ {
title: '授权类型', title: '授权类型',
field: 'authorizedGrantTypes', field: 'authorizedGrantTypes',
dictType: DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE, table: {
form: { width: 300,
component: 'SelectV2' // TODO @星语:多选 slots: {
default: 'authorizedGrantTypes_default'
}
} }
}, },
{ {

View File

@ -12,7 +12,7 @@
@click="handleCreate()" @click="handleCreate()"
/> />
</template> </template>
<template #authorizedGrantTypes="{ row }"> <template #authorizedGrantTypes_default="{ row }">
<el-tag <el-tag
:disable-transitions="true" :disable-transitions="true"
:key="index" :key="index"