From 679faa9612e22714895476b04de1b630e1502957 Mon Sep 17 00:00:00 2001 From: zhang_li <2235006734@qqq.com> Date: Tue, 19 Mar 2024 15:59:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=BC=B9=E7=AA=97=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchTable/src/SearchTable.vue | 5 ++++- src/components/Table/src/Table.vue | 6 ++++++ src/views/eam/device/deviceAccounts/index.vue | 21 +++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/components/SearchTable/src/SearchTable.vue b/src/components/SearchTable/src/SearchTable.vue index b990d25..54d8830 100644 --- a/src/components/SearchTable/src/SearchTable.vue +++ b/src/components/SearchTable/src/SearchTable.vue @@ -24,6 +24,7 @@ v-model:sort="tableObjectRef.sort" :selection="true" :reserveSelection="true" + :searchTableSelectionsList="searchTableSelectionsList" row-key="id" @register="onMountedCallBack" /> @@ -69,7 +70,8 @@ const rowRef = ref() const allSchemasRef = ref() const multipleBol = ref(false) const searchConditionRef = ref() -const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any ) => { +const searchTableSelectionsList = ref()//表格弹窗回显的列表 +const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any, searchTableSelections:any) => { searchDialogVisible.value = true formFieldRef.value = formField searchFieldRef.value = searchField @@ -82,6 +84,7 @@ const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, s multipleBol.value = multiple // dialogTitle.value = t('action.' + type) dialogTitle.value = titleName + searchTableSelectionsList.value = searchTableSelections const {tableObject, tableMethods } = useTable({ getListApi: getPage.value // 分页接口 }) diff --git a/src/components/Table/src/Table.vue b/src/components/Table/src/Table.vue index 9162864..c8e2828 100644 --- a/src/components/Table/src/Table.vue +++ b/src/components/Table/src/Table.vue @@ -53,6 +53,7 @@ export default defineComponent({ type: Array as PropType, default: () => [] }, + searchTableSelectionsList:[],//回显列表 }, emits: ['update:pageSize', 'update:currentPage', 'register', 'update:sort'], setup(props, { attrs, slots, emit, expose }) { @@ -62,6 +63,11 @@ export default defineComponent({ onMounted(() => { const tableRef = unref(elTableRef) emit('register', tableRef?.$parent, elTableRef) + if (props.searchTableSelectionsList && props.searchTableSelectionsList.length > 0) { + props.searchTableSelectionsList.forEach(row => { + elTableRef.value.toggleRowSelection(row, true); + }); + } }) const pageSizeRef = ref(props.pageSize) diff --git a/src/views/eam/device/deviceAccounts/index.vue b/src/views/eam/device/deviceAccounts/index.vue index 457f2c4..6e3c831 100644 --- a/src/views/eam/device/deviceAccounts/index.vue +++ b/src/views/eam/device/deviceAccounts/index.vue @@ -431,6 +431,7 @@ const searchTableRef = ref() /** 绑定备件操作 */ const openItem = async (number: String) => { deviceNumber.value = number + await CallBack1() searchTableRef.value.open( '选择备件', Item.allSchemas, @@ -441,7 +442,8 @@ const openItem = async (number: String) => { null, null, null, - null + null, + searchTableSelections.value ) } @@ -466,11 +468,11 @@ const qrCodeBatch = async (val,item) => { const qrCodeList = tableObject.tableList.map(item => `'${item?.number}'`).join(', ') window.open(src.value + "&number=" + qrCodeList) } - -const onMountedCallBack = (parent, searchTable) => { - getDeviceItemNoPage({ deviceNumber: deviceNumber.value }).then((res) => { - ItemApi.getItemNoPage().then(response => { - const selections = response.filter(element => { +const searchTableSelections = ref([]) +const CallBack1 = async () => { + await getDeviceItemNoPage({ deviceNumber: deviceNumber.value }).then(async(res) => { + await ItemApi.getItemNoPage().then(response => { + searchTableSelections.value = response.filter(element => { let flag = false; res.forEach(item => { if (element.number == item.itemNumber) { @@ -479,13 +481,6 @@ const onMountedCallBack = (parent, searchTable) => { }); return flag; }); - // 使用nextTick确保表格渲染完成 - // 确保searchTable是有效的 - if (searchTable && selections.length > 0) { - selections.forEach(row => { - searchTable.value.toggleRowSelection(row, true); - }); - } }); }); };