fix: bugs

This commit is contained in:
xingyu
2022-11-28 16:50:53 +08:00
parent dec05a6c40
commit 005a3e6ab0
20 changed files with 113 additions and 95 deletions

View File

@ -115,7 +115,9 @@ const toggleClick = () => {
<template #default>
<slot v-if="item.dateFormat">
{{ dayjs(data[item.field]).format(item.dateFormat) }}
{{
data[item.field] !== null ? dayjs(data[item.field]).format(item.dateFormat) : ''
}}
</slot>
<slot v-else-if="item.dictType">
<DictTag :type="item.dictType" :value="data[item.field] + ''" />

View File

@ -22,6 +22,7 @@ export type VxeCrudSchema = {
actionTitle?: string // 操作栏标题 默认为操作
actionWidth?: string // 操作栏插槽宽度,一般2个字带图标 text 类型按钮 50-70
columns: VxeCrudColumns[]
searchSpan?: number
}
type VxeCrudColumns = Omit<VxeTableColumn, 'children'> & {
field: string // 字段名
@ -112,6 +113,8 @@ export const useVxeCrudSchemas = (
// 过滤 Search 结构
const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => {
const { t } = useI18n()
const span = crudSchema.searchSpan ? crudSchema.searchSpan : 6
const spanLength = 24 / span
const searchSchema: VxeFormItemProps[] = []
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
// 判断是否显示
@ -144,13 +147,14 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => {
props: { placeholder: t('common.selectText') }
}
}
const searchSchemaItem = {
// 默认为 input
folding: searchSchema.length > 3,
folding: searchSchema.length > spanLength,
itemRender: schemaItem.itemRender ? schemaItem.itemRender : itemRender,
field: schemaItem.field,
title: schemaItem.search?.title || schemaItem.title,
span: 6
span: span
}
searchSchema.push(searchSchemaItem)
@ -161,7 +165,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => {
const buttons: VxeFormItemProps = {
span: 24,
align: 'center',
collapseNode: searchSchema.length > 4,
collapseNode: searchSchema.length > spanLength + 1,
itemRender: {
name: '$buttons',
children: [
@ -181,11 +185,13 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
const tableSchema: VxeGridPropTypes.Columns = []
// 主键ID
if (crudSchema.primaryKey && crudSchema.primaryType) {
const primaryWidth =
(crudSchema.primaryTitle ? crudSchema.primaryTitle : t('common.index')).length * 20 + 'px'
const tableSchemaItem = {
title: crudSchema.primaryTitle ? crudSchema.primaryTitle : t('common.index'),
field: crudSchema.primaryKey,
type: crudSchema.primaryType ? crudSchema.primaryType : null,
width: '80px'
width: primaryWidth
}
tableSchema.push(tableSchemaItem)
}

View File

@ -150,7 +150,11 @@ VXETable.setup({
VXETable.formats.mixin({
// 格式日期,默认 yyyy-MM-dd HH:mm:ss
formatDate({ cellValue }, format) {
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
if (cellValue != null) {
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
} else {
return ''
}
},
// 四舍五入金额每隔3位逗号分隔默认2位数
formatAmount({ cellValue }, digits = 2) {

View File

@ -18,7 +18,7 @@
preIcon="ep:view"
:title="t('action.preview')"
v-hasPermi="['infra:codegen:query']"
@click="handlePreview(row.id)"
@click="handlePreview(row)"
/>
<!-- 操作编辑 -->
<XTextButton
@ -39,14 +39,14 @@
preIcon="ep:refresh"
:title="t('action.sync')"
v-hasPermi="['infra:codegen:update']"
@click="handleSynchDb(row.id)"
@click="handleSynchDb(row)"
/>
<!-- 操作生成 -->
<XTextButton
preIcon="ep:download"
:title="t('action.generate')"
v-hasPermi="['infra:codegen:download']"
@click="handleGenTable(row.id)"
@click="handleGenTable(row)"
/>
</template>
</vxe-grid>
@ -86,7 +86,6 @@ const openImportTable = () => {
importRef.value.show()
}
// 预览操作
// TODO 星语:点击后报错
const previewRef = ref()
const handlePreview = (row: CodegenTableVO) => {
previewRef.value.show(row)

View File

@ -85,7 +85,6 @@ import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
import { ElUpload, ElImage, UploadInstance, UploadRawFile } from 'element-plus'
// 业务相关的 import
// TODO 星语:貌似这个界面打开 404
import { allSchemas } from './fileList.data'
import * as FileApi from '@/api/infra/fileList'
import { getAccessToken, getTenantId } from '@/utils/auth'

View File

@ -12,8 +12,8 @@ export const rules = reactive({
email: [required],
phone: [
{
pattern:
/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/, // TODO @星语:前端只校验长度,格式交给后端;因为号码格式不断在变的
min: 11,
max: 11,
trigger: 'blur',
message: '请输入正确的手机号码'
}

View File

@ -17,6 +17,7 @@ export const crudSchemas = reactive<VxeCrudSchema>({
primaryType: null,
action: true,
actionWidth: '140px',
searchSpan: 12,
columns: [
{
title: '字典类型',

View File

@ -7,8 +7,7 @@ const { t } = useI18n() // 国际化
// 表单校验
export const dictTypeRules = reactive({
name: [required],
type: [required]
name: [required]
})
// 新增 + 修改
const crudSchemas = reactive<VxeCrudSchema>({
@ -16,6 +15,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
primaryType: null,
action: true,
actionWidth: '140px',
searchSpan: 12,
columns: [
{
title: '字典名称',

View File

@ -1,7 +1,6 @@
<template>
<div class="flex">
<!-- ====== 字典分类 ====== -->
<!-- TODO 星语筛选框很小 -->
<el-card class="w-1/2 dict" :gutter="12" shadow="always">
<template #header>
<div class="card-header">
@ -94,7 +93,7 @@
ref="typeFormRef"
>
<template #type>
<template v-if="dictTypeValue">
<template v-if="actionType == 'typeUpdate'">
<el-tag>{{ dictTypeValue }}</el-tag>
</template>
<template v-else><el-input v-model="dictTypeValue" /> </template>
@ -232,7 +231,7 @@ const submitTypeForm = async () => {
const elForm = unref(typeFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
if (valid && dictTypeValue.value != '') {
actionLoading.value = true
// 提交请求
try {

View File

@ -75,7 +75,18 @@
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailData"
/>
>
<template #tags="{ row }">
<el-tag
:disable-transitions="true"
:key="index"
v-for="(tag, index) in row.tags"
:index="index"
>
{{ tag }}
</el-tag>
</template>
</Descriptions>
<!-- 操作按钮 -->
<template #footer>
<!-- 按钮保存 -->

View File

@ -15,7 +15,7 @@ export const rules = reactive({
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'seq',
primaryTitle: '敏感词编号', // TODO 星语:如果长度超过 4 个字符,会导致表格列宽度不够,需要优化
primaryTitle: '敏感词编号',
action: true,
columns: [
{
@ -25,7 +25,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '标签',
field: 'tags', // TODO 星语:如果是数组的话,是不是使用 el tag 展示呀?
field: 'tags',
table: {
slots: {
default: 'tags_default'

View File

@ -122,7 +122,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
{
title: t('table.createTime'),
field: 'createTime',
formatter: 'formatDate', // TODO 星语:要不给 formatter = formatDate 的时候,设置一个它的默认宽度,避免缩进
formatter: 'formatDate',
isForm: false
}
]

View File

@ -25,7 +25,7 @@
ref="formRef"
>
<template #menuIds>
<el-card class="box-card">
<el-card class="w-120">
<template #header>
<div class="card-header">
全选/全不选:

View File

@ -36,7 +36,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '菜单权限',
field: 'menuIds', // TODO 星语:菜单权限,表单可以搞大点哇?
field: 'menuIds',
isTable: false
},
{

View File

@ -142,11 +142,14 @@
<span>{{ row.dept?.name }}</span>
</template>
<template #postIds="{ row }">
<el-tag v-for="(post, index) in row.postIds" :key="index" index="">
<template v-for="postObj in postOptions">
{{ post === postObj.id ? postObj.name : '' }}
</template>
</el-tag>
<template v-if="row.postIds !== ''">
<el-tag v-for="(post, index) in row.postIds" :key="index" index="">
<template v-for="postObj in postOptions">
{{ post === postObj.id ? postObj.name : '' }}
</template>
</el-tag>
</template>
<template v-else> </template>
</template>
</Descriptions>
<!-- 操作按钮 -->
@ -379,7 +382,7 @@ const handleCreate = async () => {
// 修改操作
const handleUpdate = async (rowId: number) => {
setDialogTile('update') // TODO @星语:有警告
setDialogTile('update')
await nextTick()
unref(formRef)?.delSchema('username')
unref(formRef)?.delSchema('password')

View File

@ -13,8 +13,8 @@ export const rules = reactive({
status: [required],
mobile: [
{
pattern:
/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/, // TODO @星语:前端只校验长度,格式交给后端;因为号码格式不断在变的
min: 11,
max: 11,
trigger: 'blur',
message: '请输入正确的手机号码'
}
@ -57,12 +57,12 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '部门',
field: 'deptId', // TODO 星语:详情的部门没展示
field: 'deptId',
isTable: false
},
{
title: '岗位',
field: 'postIds', // TODO 星语:岗位为空的时候,要不要不展示
field: 'postIds',
isTable: false
},
{
@ -75,7 +75,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
{
title: '最后登录时间',
field: 'loginDate',
formatter: 'formatDate', // TODO 星语:未登录的时候,不要展示 Invalid Date
formatter: 'formatDate',
isForm: false
},
{