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" v-model:sort="tableObjectRef.sort"
:selection="true" :selection="true"
:reserveSelection="true" :reserveSelection="true"
:searchTableSelectionsList="searchTableSelectionsList"
row-key="id" row-key="id"
@register="onMountedCallBack" @register="onMountedCallBack"
/> />
@ -69,7 +70,8 @@ const rowRef = ref()
const allSchemasRef = ref() const allSchemasRef = ref()
const multipleBol = ref(false) const multipleBol = ref(false)
const searchConditionRef = ref() 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 searchDialogVisible.value = true
formFieldRef.value = formField formFieldRef.value = formField
searchFieldRef.value = searchField searchFieldRef.value = searchField
@ -82,6 +84,7 @@ const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, s
multipleBol.value = multiple multipleBol.value = multiple
// dialogTitle.value = t('action.' + type) // dialogTitle.value = t('action.' + type)
dialogTitle.value = titleName dialogTitle.value = titleName
searchTableSelectionsList.value = searchTableSelections
const {tableObject, tableMethods } = useTable({ const {tableObject, tableMethods } = useTable({
getListApi: getPage.value // getListApi: getPage.value //
}) })

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

@ -53,6 +53,7 @@ export default defineComponent({
type: Array as PropType<Recordable[]>, type: Array as PropType<Recordable[]>,
default: () => [] default: () => []
}, },
searchTableSelectionsList:[],//
}, },
emits: ['update:pageSize', 'update:currentPage', 'register', 'update:sort'], emits: ['update:pageSize', 'update:currentPage', 'register', 'update:sort'],
setup(props, { attrs, slots, emit, expose }) { setup(props, { attrs, slots, emit, expose }) {
@ -62,6 +63,11 @@ export default defineComponent({
onMounted(() => { onMounted(() => {
const tableRef = unref(elTableRef) const tableRef = unref(elTableRef)
emit('register', tableRef?.$parent, 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) 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) => { const openItem = async (number: String) => {
deviceNumber.value = number deviceNumber.value = number
await CallBack1()
searchTableRef.value.open( searchTableRef.value.open(
'选择备件', '选择备件',
Item.allSchemas, Item.allSchemas,
@ -441,7 +442,8 @@ const openItem = async (number: String) => {
null, null,
null, 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(', ') const qrCodeList = tableObject.tableList.map(item => `'${item?.number}'`).join(', ')
window.open(src.value + "&number=" + qrCodeList) window.open(src.value + "&number=" + qrCodeList)
} }
const searchTableSelections = ref([])
const onMountedCallBack = (parent, searchTable) => { const CallBack1 = async () => {
getDeviceItemNoPage({ deviceNumber: deviceNumber.value }).then((res) => { await getDeviceItemNoPage({ deviceNumber: deviceNumber.value }).then(async(res) => {
ItemApi.getItemNoPage().then(response => { await ItemApi.getItemNoPage().then(response => {
const selections = response.filter(element => { searchTableSelections.value = response.filter(element => {
let flag = false; let flag = false;
res.forEach(item => { res.forEach(item => {
if (element.number == item.itemNumber) { if (element.number == item.itemNumber) {
@ -479,13 +481,6 @@ const onMountedCallBack = (parent, searchTable) => {
}); });
return flag; return flag;
}); });
// 使nextTick
// searchTable
if (searchTable && selections.length > 0) {
selections.forEach(row => {
searchTable.value.toggleRowSelection(row, true);
});
}
}); });
}); });
}; };

Loading…
Cancel
Save