refactor: multipleFormattter→formattter

This commit is contained in:
2023-08-16 11:54:06 +08:00
parent 2d561d1c83
commit c0dd9c3958

View File

@ -2,7 +2,7 @@
* @Author: zhaojinfeng 121016171@qq.com * @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-07-18 12:30:07 * @Date: 2023-07-18 12:30:07
* @LastEditors: zhaojinfeng 121016171@qq.com * @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-08-14 12:25:07 * @LastEditTime: 2023-08-16 11:45:31
* @FilePath: \vue3\packages\select-table-modal\index.vue * @FilePath: \vue3\packages\select-table-modal\index.vue
* @Description: 模态框选择表格 * @Description: 模态框选择表格
* *
@ -115,7 +115,8 @@ const props = withDefaults(
/** 是否多选 */ /** 是否多选 */
multiple?: boolean multiple?: boolean
zIndex?: number zIndex?: number
multipleFormattter?: (row: Record<string, any>) => any /** 单击确认按钮后的数据格式化函数 */
formattter?: (row: Record<string, any>) => any
}>(), }>(),
{ {
hidePagination: false, hidePagination: false,
@ -128,7 +129,7 @@ const props = withDefaults(
title: '选择', title: '选择',
emptyText: '暂无数据', emptyText: '暂无数据',
zIndex: 2023, zIndex: 2023,
multipleFormattter(row: Record<string, any>) { formattter: (row: Record<string, any>) => {
return { ...row } return { ...row }
}, },
}, },
@ -185,7 +186,7 @@ const queryParams = reactive({
}) })
function initSelections() { function initSelections() {
const rows = tableData.map(props.multipleFormattter) const rows = tableData.map(props.formattter)
tableRef?.toggleRowSelection(rows, true) tableRef?.toggleRowSelection(rows, true)
} }
function initSelection() { function initSelection() {
@ -218,7 +219,7 @@ async function getList() {
/** 多选框选中数据 */ /** 多选框选中数据 */
function handleSelectionChange(rows: any[]) { function handleSelectionChange(rows: any[]) {
selections = rows.map(props.multipleFormattter) selections = rows.map(props.formattter)
} }
function confirm() { function confirm() {
if (props.multiple) { if (props.multiple) {