<template>
|
<app-layout-row>
|
<app-layout-col :span="24">
|
<app-table-search
|
v-bind="searchProps"
|
/>
|
</app-layout-col>
|
<app-layout-col :span="24" :paddingTop="10">
|
<app-table-pro
|
v-bind="tableProps"
|
/>
|
</app-layout-col>
|
</app-layout-row>
|
</template>
|
|
<script setup>
|
import {useI18n} from 'vue-i18n';
|
|
import {meta} from "@/hooks";
|
|
import {useEntityStore} from '@/store/modules';
|
|
import {convertFilter} from '@/utils/filter.js';
|
|
const {t} = useI18n();
|
|
const {useMetaData} = meta;
|
|
const props = defineProps({
|
options: {
|
type: Object,
|
default: () => {
|
}
|
},
|
subSelection: {
|
type: Object,
|
default: () => {
|
}
|
}
|
});
|
|
const tableSearchRef = ref();
|
const tableProRef = ref();
|
const entityStore = useEntityStore();
|
|
const [columns, filters, fields] = useMetaData(
|
props.options.dataName,
|
async () => {
|
await onInit()
|
});
|
|
const tableProps = {
|
selection: true,
|
ref: tableProRef,
|
requestParams: {
|
base: {},
|
search: {}
|
},
|
complementHeight: 30,
|
subRequest: async (page) => {
|
const result = await entityStore.getEntitySet({
|
dataName: props.options.dataName,
|
filter: `${convertFilter({
|
andLikeParams: tableProps.requestParams.search
|
})}${props.options.filter}`,
|
...page
|
});
|
return result;
|
},
|
subSelection(selection) {
|
props.subSelection(selection)
|
},
|
title: t('views.discount.discountSettle.IndexPage.SettleTable.title'),
|
columns: []
|
};
|
|
const searchProps = {
|
ref: tableSearchRef,
|
formFields: filters,
|
subSubmit: (params) => {
|
tableProps.requestParams.search = params;
|
tableProRef.value.getTableData(true);
|
}
|
}
|
|
const onInit = async () => {
|
|
tableProps.columns = columns;
|
searchProps.formFields = filters;
|
|
await nextTick();
|
|
tableProRef.value.$forceUpdate(tableProps);
|
tableSearchRef.value.$forceUpdate(searchProps);
|
|
tableProRef.value.getTableData(true);
|
}
|
|
onMounted(async () => {
|
await onInit();
|
});
|
|
const onReload = () => {
|
tableProRef.value.getTableData(true);
|
}
|
|
const setSelected = (selected) => {
|
tableProRef.value.setSelected(selected);
|
}
|
|
defineExpose({
|
onReload,
|
setSelected
|
});
|
|
</script>
|