Skip to content

Commit 1a0446b

Browse files
lolarunsendya
authored andcommitted
refactor(@ant-design-vue/pro-table): editableProTable
1 parent de975b5 commit 1a0446b

File tree

22 files changed

+831
-292
lines changed

22 files changed

+831
-292
lines changed

Diff for: .prettierrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"printWidth": 120,
5+
"proseWrap": "never",
6+
"arrowParens": "always",
7+
"trailingComma": "none",
8+
"overrides": [
9+
{
10+
"files": ".prettierrc",
11+
"options": {
12+
"parser": "json"
13+
}
14+
}
15+
]
16+
}

Diff for: packages/pro-table/examples/main.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@ant-design-vue/pro-table/style.less';
33
import { createApp } from 'vue';
44
import ProLayout, { PageContainer } from '@ant-design-vue/pro-layout';
55

6-
import Protable from '@ant-design-vue/pro-table';
76
import App from './App.vue';
87
import router from './router';
98
import icons from './icons';
@@ -16,8 +15,4 @@ import 'ant-design-vue/es/message/style';
1615
import 'ant-design-vue/dist/antd.dark.less';
1716
import '@ant-design-vue/pro-layout/dist/style.css';
1817

19-
const app = createApp(App);
20-
21-
app.use(router);
22-
23-
app.use(Protable).use(ProLayout).use(PageContainer).use(icons).mount('#app');
18+
createApp(App).use(router).use(ProLayout).use(PageContainer).use(icons).mount('#app');
+49-63
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,55 @@
11
<template>
2-
<editable-pro-table
3-
@valuesChange="handleValuesChange"
4-
:editableKeys="editableKeys"
5-
@change="handleChane"
6-
:request="request"
7-
:columns="columns"
8-
:bordered="true"
9-
:pagination="pagination"
10-
>
11-
<template #bodyCell="{ column, text, record }">
12-
<div v-if="column.dataIndex === 'action'">点击</div>
13-
<div v-else>{{ text }}</div>
14-
</template>
15-
</editable-pro-table>
2+
<editable-pro-table v-model:value="value" :columns="columns" :data-source="dataSource" />
3+
{{ JSON.stringify(value) }}
164
</template>
175

18-
<script setup lang="ts">
19-
import { reactive, ref } from 'vue';
6+
<script lang="ts" setup>
7+
import { ref } from 'vue';
8+
import { EditableProTable, type ProColumnsType } from '@ant-design-vue/pro-table';
209
21-
import type { ColumnsType } from '@ant-design-vue/pro-table';
22-
const editableKeys = ref([0, 1]);
23-
const handleChane = values => {
24-
console.log(values, '分页handleChane keys');
25-
editableKeys.value = [0, 1, 2, 4, 5];
26-
};
27-
const pagination = reactive({
28-
pageSize: 10
29-
});
30-
const columns = reactive<ColumnsType>([
31-
{
32-
dataIndex: 'name',
33-
title: '姓名',
34-
key: 'name',
35-
search: true
36-
},
37-
{
38-
dataIndex: 'age',
39-
title: '年龄',
40-
key: 'age',
41-
search: true
42-
},
43-
{
44-
dataIndex: 'action',
45-
title: '操作',
46-
key: 'action',
47-
disabled: true
48-
}
49-
]);
50-
const request = async (params: any = {}) => {
51-
let data: any[] = [];
10+
const columns: ProColumnsType = [
11+
{
12+
title: 'Name',
13+
dataIndex: 'name',
14+
key: 'name'
15+
},
16+
{
17+
title: 'Age',
18+
dataIndex: 'age',
19+
key: 'age'
20+
},
21+
{
22+
title: 'Address',
23+
dataIndex: 'address',
24+
key: 'address'
25+
},
26+
{
27+
title: 'Tags',
28+
key: 'tags',
29+
dataIndex: 'tags'
30+
}
31+
];
5232
53-
console.log('params', params);
54-
for (let i = 0; i < params.pageSize; i++) {
55-
data.push({
56-
name: '' + params.current + '页的' + +(i + 1) + (params?.name || ''),
57-
age: 18
58-
});
59-
}
60-
return {
61-
data,
62-
success: true,
63-
total: 100
64-
};
65-
};
66-
const handleValuesChange = (values: any) => {
67-
console.log('handleValuesChange', values);
68-
};
33+
const dataSource = [
34+
{
35+
key: '1',
36+
name: 'John Brown',
37+
age: 32,
38+
address: 'New York No. 1 Lake Park'
39+
},
40+
{
41+
key: '2',
42+
name: 'Jim Green',
43+
age: 42,
44+
address: 'London No. 1 Lake Park'
45+
},
46+
{
47+
key: '3',
48+
name: 'Joe Black',
49+
age: 32,
50+
address: 'Sidney No. 1 Lake Park'
51+
}
52+
];
53+
54+
const value = ref<Record<string, unknown>[]>([]);
6955
</script>

0 commit comments

Comments
 (0)