Commit 28ea779f832030b457847f55a4b05c2ab05b4cb5
1 parent
1fd90564
feat: 调整分页样式,增加获取选中行方法
Showing
4 changed files
with
62 additions
and
12 deletions
yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue
| @@ -229,19 +229,19 @@ const getPageConfig = (options: XTableProps) => { | @@ -229,19 +229,19 @@ const getPageConfig = (options: XTableProps) => { | ||
| 229 | if (pagination != false) { | 229 | if (pagination != false) { |
| 230 | options.pagerConfig = { | 230 | options.pagerConfig = { |
| 231 | border: false, // 带边框 | 231 | border: false, // 带边框 |
| 232 | - background: true, // 带背景颜色 | 232 | + background: false, // 带背景颜色 |
| 233 | perfect: false, // 配套的样式 | 233 | perfect: false, // 配套的样式 |
| 234 | pageSize: 10, // 每页大小 | 234 | pageSize: 10, // 每页大小 |
| 235 | pagerCount: 7, // 显示页码按钮的数量 | 235 | pagerCount: 7, // 显示页码按钮的数量 |
| 236 | autoHidden: false, // 当只有一页时自动隐藏 | 236 | autoHidden: false, // 当只有一页时自动隐藏 |
| 237 | pageSizes: [5, 10, 20, 30, 50, 100], // 每页大小选项列表 | 237 | pageSizes: [5, 10, 20, 30, 50, 100], // 每页大小选项列表 |
| 238 | layouts: [ | 238 | layouts: [ |
| 239 | + 'Sizes', | ||
| 239 | 'PrevJump', | 240 | 'PrevJump', |
| 240 | 'PrevPage', | 241 | 'PrevPage', |
| 241 | - 'JumpNumber', | 242 | + 'Number', |
| 242 | 'NextPage', | 243 | 'NextPage', |
| 243 | 'NextJump', | 244 | 'NextJump', |
| 244 | - 'Sizes', | ||
| 245 | 'FullJump', | 245 | 'FullJump', |
| 246 | 'Total' | 246 | 'Total' |
| 247 | ] | 247 | ] |
| @@ -324,12 +324,47 @@ const getSearchData = () => { | @@ -324,12 +324,47 @@ const getSearchData = () => { | ||
| 324 | return queryParams | 324 | return queryParams |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | +// 获取当前列 | ||
| 328 | +const getCurrentColumn = () => { | ||
| 329 | + const g = unref(xGrid) | ||
| 330 | + if (!g) { | ||
| 331 | + return | ||
| 332 | + } | ||
| 333 | + return g.getCurrentColumn() | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +// 获取当前选中列,redio | ||
| 337 | +const getRadioRecord = () => { | ||
| 338 | + const g = unref(xGrid) | ||
| 339 | + if (!g) { | ||
| 340 | + return | ||
| 341 | + } | ||
| 342 | + return g.getRadioRecord(false) | ||
| 343 | +} | ||
| 344 | + | ||
| 345 | +// 获取当前选中列,checkbox | ||
| 346 | +const getCheckboxRecords = () => { | ||
| 347 | + const g = unref(xGrid) | ||
| 348 | + if (!g) { | ||
| 349 | + return | ||
| 350 | + } | ||
| 351 | + return g.getCheckboxRecords(false) | ||
| 352 | +} | ||
| 327 | const setProps = (prop: Partial<XTableProps>) => { | 353 | const setProps = (prop: Partial<XTableProps>) => { |
| 328 | innerProps.value = { ...unref(innerProps), ...prop } | 354 | innerProps.value = { ...unref(innerProps), ...prop } |
| 329 | } | 355 | } |
| 330 | 356 | ||
| 331 | defineExpose({ reload, Ref: xGrid, getSearchData, deleteData, exportList }) | 357 | defineExpose({ reload, Ref: xGrid, getSearchData, deleteData, exportList }) |
| 332 | -emit('register', { reload, getSearchData, setProps, deleteData, exportList }) | 358 | +emit('register', { |
| 359 | + reload, | ||
| 360 | + getSearchData, | ||
| 361 | + setProps, | ||
| 362 | + deleteData, | ||
| 363 | + exportList, | ||
| 364 | + getCurrentColumn, | ||
| 365 | + getRadioRecord, | ||
| 366 | + getCheckboxRecords | ||
| 367 | +}) | ||
| 333 | </script> | 368 | </script> |
| 334 | <style lang="scss"> | 369 | <style lang="scss"> |
| 335 | @import './style/index.scss'; | 370 | @import './style/index.scss'; |
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| @@ -18,6 +18,7 @@ export type VxeCrudSchema = { | @@ -18,6 +18,7 @@ export type VxeCrudSchema = { | ||
| 18 | primaryKey?: string // 主键ID | 18 | primaryKey?: string // 主键ID |
| 19 | primaryTitle?: string // 主键标题 默认为序号 | 19 | primaryTitle?: string // 主键标题 默认为序号 |
| 20 | primaryType?: VxeColumnPropTypes.Type | 'id' // 还支持 "id" | "seq" | "radio" | "checkbox" | "expand" | "html" | null | 20 | primaryType?: VxeColumnPropTypes.Type | 'id' // 还支持 "id" | "seq" | "radio" | "checkbox" | "expand" | "html" | null |
| 21 | + firstColumn?: VxeColumnPropTypes.Type // 第一列显示类型 | ||
| 21 | action?: boolean // 是否开启表格内右侧操作栏插槽 | 22 | action?: boolean // 是否开启表格内右侧操作栏插槽 |
| 22 | actionTitle?: string // 操作栏标题 默认为操作 | 23 | actionTitle?: string // 操作栏标题 默认为操作 |
| 23 | actionWidth?: string // 操作栏插槽宽度,一般2个字带图标 text 类型按钮 50-70 | 24 | actionWidth?: string // 操作栏插槽宽度,一般2个字带图标 text 类型按钮 50-70 |
| @@ -184,6 +185,14 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => { | @@ -184,6 +185,14 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => { | ||
| 184 | const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns => { | 185 | const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns => { |
| 185 | const { t } = useI18n() | 186 | const { t } = useI18n() |
| 186 | const tableSchema: VxeGridPropTypes.Columns = [] | 187 | const tableSchema: VxeGridPropTypes.Columns = [] |
| 188 | + // 第一列 | ||
| 189 | + if (crudSchema.firstColumn) { | ||
| 190 | + const tableSchemaItem = { | ||
| 191 | + type: crudSchema.firstColumn, | ||
| 192 | + width: '50px' | ||
| 193 | + } | ||
| 194 | + tableSchema.push(tableSchemaItem) | ||
| 195 | + } | ||
| 187 | // 主键ID | 196 | // 主键ID |
| 188 | if (crudSchema.primaryKey && crudSchema.primaryType) { | 197 | if (crudSchema.primaryKey && crudSchema.primaryType) { |
| 189 | const primaryTitle = crudSchema.primaryTitle ? crudSchema.primaryTitle : t('common.index') | 198 | const primaryTitle = crudSchema.primaryTitle ? crudSchema.primaryTitle : t('common.index') |
yudao-ui-admin-vue3/src/hooks/web/useXTable.ts
| @@ -2,10 +2,13 @@ import { ref, unref } from 'vue' | @@ -2,10 +2,13 @@ import { ref, unref } from 'vue' | ||
| 2 | import { XTableProps } from '@/components/XTable/src/type' | 2 | import { XTableProps } from '@/components/XTable/src/type' |
| 3 | 3 | ||
| 4 | export interface tableMethod { | 4 | export interface tableMethod { |
| 5 | - reload: () => void | 5 | + reload: () => void // 刷新表格 |
| 6 | setProps: (props: XTableProps) => void | 6 | setProps: (props: XTableProps) => void |
| 7 | - deleteData: (ids: string | number) => void | ||
| 8 | - exportList: (fileName?: string) => void | 7 | + deleteData: (ids: string | number) => void // 删除数据 |
| 8 | + exportList: (fileName?: string) => void // 导出列表 | ||
| 9 | + getCurrentColumn: () => void // 获取当前列 | ||
| 10 | + getRadioRecord: () => void // 获取当前选中列,redio | ||
| 11 | + getCheckboxRecords: () => void //获取当前选中列, checkbox | ||
| 9 | } | 12 | } |
| 10 | 13 | ||
| 11 | export const useXTable = (props: XTableProps): [Function, tableMethod] => { | 14 | export const useXTable = (props: XTableProps): [Function, tableMethod] => { |
| @@ -26,7 +29,10 @@ export const useXTable = (props: XTableProps): [Function, tableMethod] => { | @@ -26,7 +29,10 @@ export const useXTable = (props: XTableProps): [Function, tableMethod] => { | ||
| 26 | reload: () => getInstance().reload(), | 29 | reload: () => getInstance().reload(), |
| 27 | setProps: (props) => getInstance().setProps(props), | 30 | setProps: (props) => getInstance().setProps(props), |
| 28 | deleteData: (ids: string | number) => getInstance().deleteData(ids), | 31 | deleteData: (ids: string | number) => getInstance().deleteData(ids), |
| 29 | - exportList: (fileName?: string) => getInstance().exportList(fileName) | 32 | + exportList: (fileName?: string) => getInstance().exportList(fileName), |
| 33 | + getCurrentColumn: () => getInstance().getCheckboxRecords(), | ||
| 34 | + getRadioRecord: () => getInstance().getRadioRecord(), | ||
| 35 | + getCheckboxRecords: () => getInstance().getCheckboxRecords() | ||
| 30 | } | 36 | } |
| 31 | return [register, methods] | 37 | return [register, methods] |
| 32 | } | 38 | } |
yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts
| @@ -76,20 +76,20 @@ VXETable.setup({ | @@ -76,20 +76,20 @@ VXETable.setup({ | ||
| 76 | }, | 76 | }, |
| 77 | pagerConfig: { | 77 | pagerConfig: { |
| 78 | border: false, | 78 | border: false, |
| 79 | - background: true, | 79 | + background: false, |
| 80 | autoHidden: true, | 80 | autoHidden: true, |
| 81 | perfect: true, | 81 | perfect: true, |
| 82 | pageSize: 10, | 82 | pageSize: 10, |
| 83 | pagerCount: 7, | 83 | pagerCount: 7, |
| 84 | pageSizes: [5, 10, 15, 20, 50, 100, 200, 500], | 84 | pageSizes: [5, 10, 15, 20, 50, 100, 200, 500], |
| 85 | layouts: [ | 85 | layouts: [ |
| 86 | + 'Sizes', | ||
| 86 | 'PrevJump', | 87 | 'PrevJump', |
| 87 | 'PrevPage', | 88 | 'PrevPage', |
| 88 | - 'Jump', | ||
| 89 | - 'PageCount', | 89 | + 'Number', |
| 90 | 'NextPage', | 90 | 'NextPage', |
| 91 | 'NextJump', | 91 | 'NextJump', |
| 92 | - 'Sizes', | 92 | + 'FullJump', |
| 93 | 'Total' | 93 | 'Total' |
| 94 | ] | 94 | ] |
| 95 | } | 95 | } |