Browse Source

列表弹窗加上回显

master
zhang_li 8 months ago
parent
commit
679faa9612
  1. 5
      src/components/SearchTable/src/SearchTable.vue
  2. 6
      src/components/Table/src/Table.vue
  3. 21
      src/views/eam/device/deviceAccounts/index.vue

5
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 //
})

6
src/components/Table/src/Table.vue

@ -53,6 +53,7 @@ export default defineComponent({
type: Array as PropType<Recordable[]>,
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)

21
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);
});
}
});
});
};

Loading…
Cancel
Save