Skip to content

Commit b9a58cf

Browse files
Merge pull request #21 from github-learning/dev
Dev
2 parents 217afee + 6a84cd4 commit b9a58cf

File tree

7 files changed

+53
-18
lines changed

7 files changed

+53
-18
lines changed

components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ declare module 'vue' {
4545
ElSwitch: typeof import('element-plus/es')['ElSwitch']
4646
ElTable: typeof import('element-plus/es')['ElTable']
4747
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
48+
ElTag: typeof import('element-plus/es')['ElTag']
4849
ElTooltip: typeof import('element-plus/es')['ElTooltip']
4950
ElTree: typeof import('element-plus/es')['ElTree']
5051
Form: typeof import('./src/components/ProTable/components/form.vue')['default']
@@ -63,4 +64,7 @@ declare module 'vue' {
6364
SearchForm: typeof import('./src/components/ProTable/components/searchForm.vue')['default']
6465
SidebarItemLink: typeof import('./src/layout/components/layout-menu/SidebarItemLink.vue')['default']
6566
}
67+
export interface ComponentCustomProperties {
68+
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
69+
}
6670
}

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export default [
6868
'@typescript-eslint/no-unused-vars': ['warn'], // 设置为 warning
6969
'@typescript-eslint/no-explicit-any': 'warn', // 允许使用 any
7070
'@typescript-eslint/no-empty-object-type': 'off', // {} 类型而不触发错误
71-
'@typescript-eslint/no-unused-expressions': "warn" // 未使用的表达式
71+
'@typescript-eslint/no-unused-expressions': "warn", // 未使用的表达式,
72+
'no-undef': 'off', // 禁用 no-undef 规则
7273
},
7374
},
7475
prettierRecommended, // 覆盖掉eslint的规范

src/components/ProTable/components/tableColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ElTable, ElTableColumn } from 'element-plus'
33
// import { useTable } from '@/hooks/useTable'
44
import notDataImage from '@/assets/images/notData.png' // 采用 import 语法引入图片
55
import { ColumnProps, RenderScope } from '../model'
6-
// const { handleSizeChange, handleCurrentChange } = useTable()
6+
77
export default defineComponent({
88
props: {
99
columns: {

src/components/ProTable/index.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
:columns="searchColumns"
1212
:search-param="searchParam"
1313
></SearchForm>
14-
xx{{ searchParam }}
1514

16-
<!-- :columns="searchColumns" -->
17-
<TableColumn v-bind="props" :data="processTableData"></TableColumn>
15+
<TableColumn
16+
v-bind="props"
17+
:data="processTableData"
18+
v-loading="!processTableData || !processTableData.length"
19+
></TableColumn>
20+
1821
<Pagination
1922
v-if="pagination"
2023
:pageable="pageable"

src/hooks/useTable.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ export const useTable = (
9393
...state.totalParam
9494
})
9595
console.log('data', data)
96-
dataCallBack && (data = dataCallBack(data))
97-
state.tableData = isPageable ? data.list : data
96+
setTimeout(() => {
97+
dataCallBack && (data = dataCallBack(data))
98+
state.tableData = isPageable ? data.list : data
99+
}, 1000)
98100

99101
// 解构后台返回的分页数据 (如果有分页更新分页信息)
100102
if (isPageable) {

src/style/el-table.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
// 解决表格数据为空时样式不居中问题(仅在element-plus中)
8585
.el-table__empty-block {
8686
.el-table__empty-text {
87+
width: auto;
8788
height: 300px;
8889
display: flex;
8990

src/views/guide/index.vue

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<template>
2-
<!-- <proTable :table-columns="tableColumns" :data="fetchData" stripe /> -->
32
<div class="table-box">
43
<ProTable
54
ref="proTable"
@@ -9,11 +8,7 @@
98
:request-api="getUserList"
109
></ProTable>
1110
</div>
12-
<!-- :row-class-name="tableRowClassName"
13-
:span-method="objectSpanMethod"
14-
:show-summary="true"
15-
:summary-method="getSummaries"
16-
@row-click="rowClick" -->
11+
1712
<el-button @click="focusHandler">聚焦</el-button>
1813
<my-input v-model="msg" ref="myInputRef">
1914
<template #prepend>Prepend</template>
@@ -38,7 +33,10 @@ const tableColumns = ref([
3833
label: '名称',
3934
prop: 'username',
4035
width: '150',
41-
dataIndex: 'username'
36+
dataIndex: 'username',
37+
render: (row) => {
38+
return <el-tag type="primary">{row.username}</el-tag>
39+
}
4240
},
4341
{
4442
label: '描述',
@@ -47,7 +45,19 @@ const tableColumns = ref([
4745
{
4846
label: '手机',
4947
prop: 'mobile',
50-
dataIndex: 'mobile'
48+
dataIndex: 'mobile',
49+
render: (row) => {
50+
return (
51+
<>
52+
{row.mobile ? (
53+
<el-icon>
54+
<Cellphone />
55+
</el-icon>
56+
) : null}{' '}
57+
{row.mobile}
58+
</>
59+
)
60+
}
5161
},
5262
{
5363
label: '状态',
@@ -64,12 +74,26 @@ const tableColumns = ref([
6474
{
6575
label: '操作',
6676
prop: 'action',
67-
width: '180',
77+
width: '280',
6878
render: (row) => {
6979
const handleAction = (row) => {
70-
console.log(row)
80+
console.log(
81+
'%c [ row ]-71',
82+
'font-size:13px; background:pink; color:#bf2c9f;',
83+
row
84+
)
7185
}
72-
return <el-button onClick={() => handleAction(row)}>操作按钮</el-button>
86+
return (
87+
<>
88+
<el-button type="primary" onClick={() => handleAction(row)}>
89+
新增
90+
</el-button>
91+
<el-button onClick={() => handleAction(row)}>编辑</el-button>
92+
<el-button type="danger" onClick={() => handleAction(row)}>
93+
删除
94+
</el-button>
95+
</>
96+
)
7397
}
7498
}
7599
])

0 commit comments

Comments
 (0)