fix: todo

pull/2/head
xingyu4j 2022-11-14 13:19:33 +08:00
parent 042c4e8390
commit 3b107f56a0
9 changed files with 49 additions and 37 deletions

View File

@ -116,7 +116,7 @@ const toggleClick = () => {
{{ dayjs(data[item.field]).format(item.dateFormat) }}
</slot>
<slot v-else-if="item.dictType">
<DictTag :type="item.dictType" :value="data[item.field]" />
<DictTag :type="item.dictType" :value="data[item.field] + ''" />
</slot>
<slot v-else :name="item.field" :row="data">{{ data[item.field] }}</slot>
</template>

View File

@ -24,20 +24,20 @@ export type VxeCrudSchema = {
columns: VxeCrudColumns[]
}
type VxeCrudColumns = Omit<VxeTableColumn, 'children'> & {
field: string
title?: string
formatter?: VxeColumnPropTypes.Formatter
isSearch?: boolean
search?: CrudSearchParams
isTable?: boolean
table?: CrudTableParams
isForm?: boolean
form?: CrudFormParams
isDetail?: boolean
detail?: CrudDescriptionsParams
print?: CrudPrintParams
children?: VxeCrudColumns[]
dictType?: string
field: string // 字段名
title?: string // 标题名
formatter?: VxeColumnPropTypes.Formatter // vxe formatter格式化
isSearch?: boolean // 是否在查询显示
search?: CrudSearchParams // 查询的详细配置
isTable?: boolean // 是否在列表显示
table?: CrudTableParams // 列表的详细配置
isForm?: boolean // 是否在表单显示
form?: CrudFormParams // 表单的详细配置
isDetail?: boolean // 是否在详情显示
detail?: CrudDescriptionsParams // 详情的详细配置
print?: CrudPrintParams // vxe 打印的字段
children?: VxeCrudColumns[] // 子级
dictType?: string // 字典类型
}
type CrudSearchParams = {
@ -189,6 +189,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
tableSchemaItem.showOverflow = 'tooltip'
if (schemaItem?.formatter) {
tableSchemaItem.formatter = schemaItem.formatter
tableSchemaItem.width = 160
}
if (schemaItem?.dictType) {
tableSchemaItem.cellRender = {
@ -222,6 +223,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
// 判断是否显示
if (schemaItem?.isForm !== false) {
// 默认为 input
let component = schemaItem?.form?.component || 'Input'
const options: ComponentOptions[] = []
let comonentProps = {}
@ -232,15 +234,14 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
comonentProps = {
options: options
}
if (!(schemaItem.form && schemaItem.form.component)) component = 'Select'
if (!(schemaItem.form && schemaItem.form.component)) component = 'SelectV2'
}
const formSchemaItem = {
// 默认为 input
component: component,
componentProps: comonentProps,
...schemaItem.form,
field: schemaItem.field,
label: schemaItem.form?.label || schemaItem.title
label: schemaItem.form?.label || schemaItem.title,
component: component,
componentProps: comonentProps
}
formSchema.push(formSchemaItem)

View File

@ -17,6 +17,7 @@ export default {
cancel: 'Cancel',
close: 'Close',
reload: 'Reload current',
success: 'Success',
closeTab: 'Close current',
closeTheLeftTab: 'Close left',
closeTheRightTab: 'Close right',

View File

@ -17,6 +17,7 @@ export default {
cancel: '取消',
close: '关闭',
reload: '重新加载',
success: '成功',
closeTab: '关闭标签页',
closeTheLeftTab: '关闭左侧标签页',
closeTheRightTab: '关闭右侧标签页',

View File

@ -16,8 +16,8 @@ export interface DictDataType {
dictType: string
label: string
value: string | number | boolean
colorType: ElementPlusInfoType | '' | 'default' | 'primary'
cssClass: string
colorType?: ElementPlusInfoType | '' | 'default' | 'primary'
cssClass?: string
}
export const getDictOptions = (dictType: string) => {
@ -41,10 +41,11 @@ export const getIntDictOptions = (dictType: string) => {
})
}
})
console.log(dictOptions)
return dictOptions
}
export const getDictObj = (dictType: string, value: string) => {
export const getDictObj = (dictType: string, value: string | number | boolean) => {
const dictOptions: DictDataType[] = getDictOptions(dictType)
dictOptions.forEach((dict: DictDataType) => {
if (dict.value === value) {

View File

@ -45,18 +45,24 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '访问令牌的有效期',
field: 'accessTokenValiditySeconds' // TODO @星语:数字输入框
field: 'accessTokenValiditySeconds',
form: {
component: 'InputNumber'
}
},
{
title: '刷新令牌的有效期',
field: 'refreshTokenValiditySeconds' // TODO @星语:数字输入框
field: 'refreshTokenValiditySeconds',
form: {
component: 'InputNumber'
}
},
{
title: '授权类型',
field: 'authorizedGrantTypes',
dictType: DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE,
form: {
component: 'Select' // TODO @星语:多选
component: 'SelectV2' // TODO @星语:多选
}
},
{
@ -102,7 +108,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate', // TODO @星语:宽度,保证时间可以展示出来
formatter: 'formatDate',
isForm: false
}
]

View File

@ -57,7 +57,6 @@
:rules="rules"
/>
<!-- 表单详情 -->
<!-- TODO @星语展示详情时有点小丑可额能得看看 -->
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"

View File

@ -58,10 +58,10 @@ const handleDetail = async (row: TokenApi.OAuth2TokenVO) => {
// 退
const handleForceLogout = (rowId: number) => {
message
.delConfirm()
.confirm('是否要强制退出用户')
.then(async () => {
await TokenApi.deleteAccessTokenApi(rowId)
message.success(t('common.delSuccess')) // TODO
message.success(t('common.success'))
})
.finally(() => {
//

View File

@ -45,6 +45,7 @@
// import
import { ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
// import
@ -53,6 +54,7 @@ import { allSchemas } from './operatelog.data'
import download from '@/utils/download'
const { t } = useI18n() //
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions } = useVxeGrid<OperateLogApi.OperateLogVO>({
@ -73,13 +75,14 @@ const handleDetail = (row: OperateLogApi.OperateLogVO) => {
}
//
// TODO @
const handleExport = async () => {
message.exportConfirm().then(async () => {
const queryParams = Object.assign(
{},
JSON.parse(JSON.stringify(xGrid.value?.getRefMaps().refForm.value.data)) // TODO @ util
)
const res = await OperateLogApi.exportOperateLogApi(queryParams)
download.excel(res, '岗位列表.xls')
})
}
</script>