提交 9f4d1719 编写于 作者: 无木

fix(table): support change event

修复表格不支持change事件的问题。

fix #677
上级 035f55af
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
'edit-row-end', 'edit-row-end',
'edit-change', 'edit-change',
'expanded-rows-change', 'expanded-rows-change',
'change',
], ],
setup(props, { attrs, emit, slots }) { setup(props, { attrs, emit, slots }) {
const tableElRef = ref<ComponentRef>(null); const tableElRef = ref<ComponentRef>(null);
...@@ -116,7 +117,7 @@ ...@@ -116,7 +117,7 @@
} = useRowSelection(getProps, tableData, emit); } = useRowSelection(getProps, tableData, emit);
const { const {
handleTableChange, handleTableChange: onTableChange,
getDataSourceRef, getDataSourceRef,
getDataSource, getDataSource,
setTableData, setTableData,
...@@ -138,6 +139,11 @@ ...@@ -138,6 +139,11 @@
emit emit
); );
function handleTableChange(...args) {
onTableChange.call(undefined, ...args);
emit('change', ...args);
}
const { const {
getViewColumns, getViewColumns,
getColumns, getColumns,
...@@ -204,7 +210,7 @@ ...@@ -204,7 +210,7 @@
propsData = omit(propsData, 'scroll'); propsData = omit(propsData, 'scroll');
} }
propsData = omit(propsData, 'class'); propsData = omit(propsData, ['class', 'onChange']);
return propsData; return propsData;
}); });
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<a-button class="mr-2" @click="clearSelect"> 清空选中行 </a-button> <a-button class="mr-2" @click="clearSelect"> 清空选中行 </a-button>
<a-button class="mr-2" @click="getPagination"> 获取分页信息 </a-button> <a-button class="mr-2" @click="getPagination"> 获取分页信息 </a-button>
</div> </div>
<BasicTable @register="registerTable" /> <BasicTable @register="registerTable" @change="onChange" />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
components: { BasicTable }, components: { BasicTable },
setup() { setup() {
const { createMessage } = useMessage(); const { createMessage } = useMessage();
function onChange() {
console.log('onChange', arguments);
}
const [ const [
registerTable, registerTable,
{ {
...@@ -121,6 +124,7 @@ ...@@ -121,6 +124,7 @@
getSelectRowKeyList, getSelectRowKeyList,
setSelectedRowKeyList, setSelectedRowKeyList,
clearSelect, clearSelect,
onChange,
}; };
}, },
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册