Commit f4525f7a0a25a8b2b5e2e9793cccb5d431db8c27

Authored by xingyu4j
1 parent eed6a9a6

perf: 添加 序号和操作栏标题

yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
... ... @@ -16,9 +16,11 @@ import { ComponentOptions } from '@/types/components'
16 16  
17 17 export type VxeCrudSchema = {
18 18 primaryKey?: string // 主键ID
  19 + primaryTitle?: string // 主键标题 默认为序号
19 20 primaryType?: VxeColumnPropTypes.Type // 不填写为数据库编号 还支持 "seq" | "radio" | "checkbox" | "expand" | "html" | null
20 21 action?: boolean // 是否开启操作栏插槽
21   - actionWidth?: string // 操作栏插槽宽度,一般1个 text 类型按钮 60-80
  22 + actionTitle?: string // 操作栏标题 默认为操作
  23 + actionWidth?: string // 操作栏插槽宽度,一般2个字带图标 text 类型按钮 50-70
22 24 columns: VxeCrudColumns[]
23 25 }
24 26 type VxeCrudColumns = Omit<VxeTableColumn, 'children'> & {
... ... @@ -169,7 +171,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
169 171 // 主键ID
170 172 if (crudSchema.primaryKey) {
171 173 const tableSchemaItem = {
172   - title: t('common.index'),
  174 + title: crudSchema.primaryTitle ? crudSchema.primaryTitle : t('common.index'),
173 175 field: crudSchema.primaryKey,
174 176 type: crudSchema.primaryType ? crudSchema.primaryType : null,
175 177 width: '50px'
... ... @@ -202,7 +204,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
202 204 // 操作栏插槽
203 205 if (crudSchema.action && crudSchema.action == true) {
204 206 const tableSchemaItem = {
205   - title: t('table.action'),
  207 + title: crudSchema.actionTitle ? crudSchema.actionTitle : t('table.action'),
206 208 field: 'actionbtns',
207 209 width: crudSchema.actionWidth ? crudSchema.actionWidth : '200px',
208 210 slots: {
... ...
yudao-ui-admin-vue3/src/views/system/post/index.vue
1 1 <template>
2 2 <ContentWrap>
3 3 <!-- 列表 -->
4   - <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  4 + <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar" :class="isDark">
5 5 <template #toolbar_buttons>
6 6 <!-- 操作:新增 -->
7 7 <XButton
... ... @@ -86,6 +86,8 @@ import { FormExpose } from &#39;@/components/Form&#39;
86 86 import * as PostApi from '@/api/system/post'
87 87 import { rules, allSchemas } from './post.data'
88 88  
  89 +import { useDark } from '@vueuse/core'
  90 +const isDark = useDark()
89 91 const { t } = useI18n() // 国际化
90 92 const message = useMessage() // 消息弹窗
91 93 // 列表相关的变量
... ...
yudao-ui-admin-vue3/src/views/system/post/post.data.ts
... ... @@ -15,6 +15,7 @@ export const rules = reactive({
15 15 // CrudSchema
16 16 const crudSchemas = reactive<VxeCrudSchema>({
17 17 primaryKey: 'id',
  18 + primaryType: 'seq',
18 19 action: true,
19 20 columns: [
20 21 {
... ...