From e77872fb56142f5b8fd3e342991d59e55beef30b Mon Sep 17 00:00:00 2001 From: xuqingkai Date: Wed, 25 Oct 2023 21:49:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20=E6=96=B0=E5=A2=9E=20Table?= =?UTF-8?q?=20=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/component/table.md | 3 + src/pages.json | 10 + src/pages/table/Index.vue | 279 ++++++++++++++++++ .../components/wd-table-col/API.md | 18 ++ .../components/wd-table-col/INDEX.md | 36 +++ .../components/wd-table-col/README.md | 4 + .../components/wd-table-col/index.scss | 13 + .../components/wd-table-col/wd-table-col.vue | 126 ++++++++ .../wot-design-uni/components/wd-table/API.md | 40 +++ .../components/wd-table/INDEX.md | 187 ++++++++++++ .../components/wd-table/README.md | 4 + .../components/wd-table/index.scss | 36 +++ .../components/wd-table/wd-table.vue | 161 ++++++++++ src/uni_modules/wot-design-uni/global.d.ts | 2 + 14 files changed, 919 insertions(+) create mode 100644 docs/component/table.md create mode 100644 src/pages/table/Index.vue create mode 100644 src/uni_modules/wot-design-uni/components/wd-table-col/API.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table-col/INDEX.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table-col/README.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table-col/index.scss create mode 100644 src/uni_modules/wot-design-uni/components/wd-table-col/wd-table-col.vue create mode 100644 src/uni_modules/wot-design-uni/components/wd-table/API.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table/INDEX.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table/README.md create mode 100644 src/uni_modules/wot-design-uni/components/wd-table/index.scss create mode 100644 src/uni_modules/wot-design-uni/components/wd-table/wd-table.vue diff --git a/docs/component/table.md b/docs/component/table.md new file mode 100644 index 00000000..92bbb790 --- /dev/null +++ b/docs/component/table.md @@ -0,0 +1,3 @@ + + +# Table 表格 \ No newline at end of file diff --git a/src/pages.json b/src/pages.json index 0d8c493d..feee3532 100644 --- a/src/pages.json +++ b/src/pages.json @@ -621,6 +621,16 @@ "navigationBarTitleText": "Navbar 导航栏", "navigationStyle": "custom" } + }, + { + "path": "pages/table/Index", + "name": "table", + "style": { + "mp-alipay": { + "allowsBounceVertical": "NO" + }, + "navigationBarTitleText": "Table 表格" + } } ], // "tabBar": { diff --git a/src/pages/table/Index.vue b/src/pages/table/Index.vue new file mode 100644 index 00000000..3e9b8d72 --- /dev/null +++ b/src/pages/table/Index.vue @@ -0,0 +1,279 @@ + + + diff --git a/src/uni_modules/wot-design-uni/components/wd-table-col/API.md b/src/uni_modules/wot-design-uni/components/wd-table-col/API.md new file mode 100644 index 00000000..ee23a704 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table-col/API.md @@ -0,0 +1,18 @@ +# hd-table-column + +Table-Column 表格列 + +## Props + + +|Name|Description|Type|Required|Default| +|---|---|---|---|---| +|prop|列对应字段|`String`|`false`|-| +|label|列标题|`String`|`false`|-| +|width|列宽度|`String`|`false`|-| +|fixed|列是否固定|`Boolean`|`false`|false| +|sortable|是否开启列排序|`Boolean`|`false`|false| + + + + diff --git a/src/uni_modules/wot-design-uni/components/wd-table-col/INDEX.md b/src/uni_modules/wot-design-uni/components/wd-table-col/INDEX.md new file mode 100644 index 00000000..3d853ec4 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table-col/INDEX.md @@ -0,0 +1,36 @@ + +## 代码演示 +### 基础用法 + +通过`prop`设置表格该列的对应字段,并通过`label`设置表格该列的标题。 + +``` html + + + +``` +### 列宽度 + +通过`width`设置表格该列的列宽度。 + +``` html + +``` +### 是否固定列 + +通过`fixed`设置表格该列是否固定,默认为`false`(不固定),且只支持钉钉固定在左侧。 + +``` html + + + +``` +### 列排序 + +通过`sortable`设置表格该列是否参与排序,默认为`false`(不排序)。 + +``` html + + + +``` diff --git a/src/uni_modules/wot-design-uni/components/wd-table-col/README.md b/src/uni_modules/wot-design-uni/components/wd-table-col/README.md new file mode 100644 index 00000000..e4e6f5c3 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table-col/README.md @@ -0,0 +1,4 @@ + + +# Table-Column 表格列 +表格组件的列元素。 diff --git a/src/uni_modules/wot-design-uni/components/wd-table-col/index.scss b/src/uni_modules/wot-design-uni/components/wd-table-col/index.scss new file mode 100644 index 00000000..c4ac86b5 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table-col/index.scss @@ -0,0 +1,13 @@ +@import '../common/abstracts/variable'; +@import '../common/abstracts/mixin'; + +@include b(table-col) { + flex: 0 0 auto; + + @include e(cell){ + + } + + @include e(row){ + } +} \ No newline at end of file diff --git a/src/uni_modules/wot-design-uni/components/wd-table-col/wd-table-col.vue b/src/uni_modules/wot-design-uni/components/wd-table-col/wd-table-col.vue new file mode 100644 index 00000000..57e1c7f6 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table-col/wd-table-col.vue @@ -0,0 +1,126 @@ + + + + + + diff --git a/src/uni_modules/wot-design-uni/components/wd-table/API.md b/src/uni_modules/wot-design-uni/components/wd-table/API.md new file mode 100644 index 00000000..c944e6ae --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table/API.md @@ -0,0 +1,40 @@ +# hd-table + +Table 表格 + +## Props + + +|Name|Description|Type|Required|Default| +|---|---|---|---|---| +|dataSource|table数据源|`Array`|`false`|[]| +|stripe|是否为斑马纹|`Boolean`|`false`|false| +|height|表格高度|`String`|`false`|默认值:'80vh'| +|rowHeight|行高|`String`/`Number`|`false`|默认值:'80rpx'| + + + + + + +## Events + + +|Event Name|Description|Parameters| +|---|---|---| +|sort-method|点击排序时触发|value:Object 当前列表头| +|row-click|点击行时触发|{rowIndex:number} 点击行的下标| + + + + +## Slots + + +|Name|Description|Default Slot Content| +|---|---|---| +|default|-|-| + + + + diff --git a/src/uni_modules/wot-design-uni/components/wd-table/INDEX.md b/src/uni_modules/wot-design-uni/components/wd-table/INDEX.md new file mode 100644 index 00000000..93e982e5 --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table/INDEX.md @@ -0,0 +1,187 @@ + +## 代码演示 + +### 基础用法 + +通过`dataSource`设置表格数据。 + +```html + + + + + +``` + +```ts +const dataList = ref> ([ + { + name: '赵云', + school: '武汉市阳逻妇幼保健学院', + major: '计算机科学与技术专业' + }, + { + name: '孔明', + school: '武汉市阳逻卧龙学院', + major: '计算机科学与技术专业' + } + { + name: '刘备', + school: '武汉市阳逻编织学院', + major: '计算机科学与技术专业' + } + ]) +``` + +### 斑马纹 + +通过`stripe`设置表格是否展示斑马纹,默认`false`(不展示)。 + +```html + + + + + +``` + +### 表格高度 + +通过`height`设置表格高度,默认为`80vh`。 + +```html + + + + + +``` + +### 排序事件 + +当存在列参与排序时,点击会触发`sort-method`排序事件。 + +```html + + + + + +``` + +```ts +function doSort(e) { + console.log('这里是排序事件') +} +``` + +### 自定义列模板 + +自定义列的显示内容,可组合其他组件使用。 +通过 `Scoped slot` 可以获取到 `row` 的数据,用法参考 demo。 + +```html + + + + + + + + + + + +``` + +```ts + +import { ref } from 'vue' + +const dataList = ref[]>([ + { + name: '张飞', + school: '武汉市阳逻杀猪学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 56, + compare: '10%', + hobby: '燕人张飞在此!' + }, + { + name: '关羽', + school: '武汉市阳逻绿豆学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 66, + compare: '11%', + hobby: '颜良文丑,以吾观之,如土鸡瓦犬耳。' + }, + { + name: '刘备', + school: '武汉市阳逻编织学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 45, + compare: '1%', + hobby: '我得空明,如鱼得水也' + }, + { + name: '赵云', + school: '武汉市阳逻妇幼保健学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 69, + compare: '14%', + hobby: '子龙,子龙,世无双' + }, + { + name: '孔明', + school: '武汉市阳逻卧龙学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 88, + compare: '21%', + hobby: '兴汉讨贼,克复中原' + }, + { + name: '姜维', + school: '武汉市阳逻停水停电技术学院', + major: '计算机科学与技术专业', + gender: '男', + graduation: '2022年1月12日', + grade: 87, + compare: '32%', + hobby: '我计不成,乃天命也!' + } +]) + +/** + * 排序 + * @param e + */ +function doSort(e) { + dataList.value = dataList.value.reverse() +} + +``` + +```css +.custom-class { + height: 80rpx; + width: 220rpx; + display: flex; + flex-direction: column; + align-items: center; +} +``` \ No newline at end of file diff --git a/src/uni_modules/wot-design-uni/components/wd-table/README.md b/src/uni_modules/wot-design-uni/components/wd-table/README.md new file mode 100644 index 00000000..d934dbeb --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table/README.md @@ -0,0 +1,4 @@ + + +# Table 表格 +表格组件,支持表格内容上下左右滚动。 diff --git a/src/uni_modules/wot-design-uni/components/wd-table/index.scss b/src/uni_modules/wot-design-uni/components/wd-table/index.scss new file mode 100644 index 00000000..bbd713bf --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table/index.scss @@ -0,0 +1,36 @@ +@import '../common/abstracts/variable'; +@import '../common/abstracts/mixin'; + +@include b(table) { + position: relative; + width: 100%; + overflow: auto; + background: #ffffff; + + @include e(header){ + position: sticky; + top: 0; + width: 100%; + height: 80rpx; + display: flex; + pointer-events: none; + overflow-x: auto; + white-space: nowrap; + } + + @include e(body){ + display: flex; + overflow: auto; + white-space: nowrap !important; + width: 100%; + } + + @include e(cell){ + display: inline-block; + flex: 0 0; + width: 220rpx; + } + + @include e(row){ + } +} \ No newline at end of file diff --git a/src/uni_modules/wot-design-uni/components/wd-table/wd-table.vue b/src/uni_modules/wot-design-uni/components/wd-table/wd-table.vue new file mode 100644 index 00000000..a336c36e --- /dev/null +++ b/src/uni_modules/wot-design-uni/components/wd-table/wd-table.vue @@ -0,0 +1,161 @@ + + + + + + diff --git a/src/uni_modules/wot-design-uni/global.d.ts b/src/uni_modules/wot-design-uni/global.d.ts index a996197e..48740918 100644 --- a/src/uni_modules/wot-design-uni/global.d.ts +++ b/src/uni_modules/wot-design-uni/global.d.ts @@ -85,6 +85,8 @@ declare module '@vue/runtime-core' { WdTabbarItem: typeof import('./components/wd-tabbar-item/wd-tabbar-item.vue')['default'] WdNavbar: typeof import('./components/wd-navbar/wd-navbar.vue')['default'] WdNavbarCapsule: typeof import('./components/wd-navbar-capsule/wd-navbar-capsule.vue')['default'] + WdTable: typeof import('./components/wd-table/wd-table.vue')['default'] + WdTableCol: typeof import('./components/wd-table-col/wd-table-col.vue')['default'] } }