Commit 28ea779f832030b457847f55a4b05c2ab05b4cb5

Authored by xingyu
1 parent 1fd90564

feat: 调整分页样式,增加获取选中行方法

yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue
... ... @@ -229,19 +229,19 @@ const getPageConfig = (options: XTableProps) => {
229 229 if (pagination != false) {
230 230 options.pagerConfig = {
231 231 border: false, // 带边框
232   - background: true, // 带背景颜色
  232 + background: false, // 带背景颜色
233 233 perfect: false, // 配套的样式
234 234 pageSize: 10, // 每页大小
235 235 pagerCount: 7, // 显示页码按钮的数量
236 236 autoHidden: false, // 当只有一页时自动隐藏
237 237 pageSizes: [5, 10, 20, 30, 50, 100], // 每页大小选项列表
238 238 layouts: [
  239 + 'Sizes',
239 240 'PrevJump',
240 241 'PrevPage',
241   - 'JumpNumber',
  242 + 'Number',
242 243 'NextPage',
243 244 'NextJump',
244   - 'Sizes',
245 245 'FullJump',
246 246 'Total'
247 247 ]
... ... @@ -324,12 +324,47 @@ const getSearchData = () => {
324 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 353 const setProps = (prop: Partial<XTableProps>) => {
328 354 innerProps.value = { ...unref(innerProps), ...prop }
329 355 }
330 356  
331 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 368 </script>
334 369 <style lang="scss">
335 370 @import './style/index.scss';
... ...
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
... ... @@ -18,6 +18,7 @@ export type VxeCrudSchema = {
18 18 primaryKey?: string // 主键ID
19 19 primaryTitle?: string // 主键标题 默认为序号
20 20 primaryType?: VxeColumnPropTypes.Type | 'id' // 还支持 "id" | "seq" | "radio" | "checkbox" | "expand" | "html" | null
  21 + firstColumn?: VxeColumnPropTypes.Type // 第一列显示类型
21 22 action?: boolean // 是否开启表格内右侧操作栏插槽
22 23 actionTitle?: string // 操作栏标题 默认为操作
23 24 actionWidth?: string // 操作栏插槽宽度,一般2个字带图标 text 类型按钮 50-70
... ... @@ -184,6 +185,14 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] =&gt; {
184 185 const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns => {
185 186 const { t } = useI18n()
186 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 196 // 主键ID
188 197 if (crudSchema.primaryKey && crudSchema.primaryType) {
189 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 &#39;vue&#39;
2 2 import { XTableProps } from '@/components/XTable/src/type'
3 3  
4 4 export interface tableMethod {
5   - reload: () => void
  5 + reload: () => void // 刷新表格
6 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 14 export const useXTable = (props: XTableProps): [Function, tableMethod] => {
... ... @@ -26,7 +29,10 @@ export const useXTable = (props: XTableProps): [Function, tableMethod] =&gt; {
26 29 reload: () => getInstance().reload(),
27 30 setProps: (props) => getInstance().setProps(props),
28 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 37 return [register, methods]
32 38 }
... ...
yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts
... ... @@ -76,20 +76,20 @@ VXETable.setup({
76 76 },
77 77 pagerConfig: {
78 78 border: false,
79   - background: true,
  79 + background: false,
80 80 autoHidden: true,
81 81 perfect: true,
82 82 pageSize: 10,
83 83 pagerCount: 7,
84 84 pageSizes: [5, 10, 15, 20, 50, 100, 200, 500],
85 85 layouts: [
  86 + 'Sizes',
86 87 'PrevJump',
87 88 'PrevPage',
88   - 'Jump',
89   - 'PageCount',
  89 + 'Number',
90 90 'NextPage',
91 91 'NextJump',
92   - 'Sizes',
  92 + 'FullJump',
93 93 'Total'
94 94 ]
95 95 }
... ...