mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-18 07:16:46 +08:00
--fix bug
This commit is contained in:
@@ -12,8 +12,9 @@
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import {defineProps, defineExpose, ref, computed, onMounted, defineEmits} from "vue";
|
||||
import {defineProps, defineExpose, ref, computed, onMounted, defineEmits, nextTick} from "vue";
|
||||
import {useRowsPageNoInit} from "@/api/request";
|
||||
import {useResetRef} from "@/utils/useCommon";
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
@@ -44,10 +45,10 @@ const props = defineProps({
|
||||
const emit = defineEmits(["update:params", "update:selectedRowKeys", "update:selectedRows"]);
|
||||
const rowSelectKeys = ref([]);
|
||||
const selectsData = ref([]);
|
||||
const params = ref({ pageNo: 1, pageSize: 10 });
|
||||
const params = useResetRef({ pageNo: 1, pageSize: 10 });
|
||||
const postParam = computed(() => ({ ...params.value, ...props.params }));
|
||||
|
||||
const { data, loading, total, fetch } = props.request(props.url, postParam);
|
||||
const { data, loading, total, fetch: onFetch } = props.request(props.url, postParam);
|
||||
|
||||
const rowSelection = computed(() => (props.type ? {
|
||||
type: props.type,
|
||||
@@ -76,6 +77,8 @@ const customRow = (record) => ({
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => props.init && nextTick(onFetch));
|
||||
|
||||
function onSelectChange(e, l) {
|
||||
rowSelectKeys.value = e;
|
||||
selectsData.value = l;
|
||||
@@ -92,14 +95,13 @@ const pagination = computed(() => ({
|
||||
}));
|
||||
const changePagination = (e) => {
|
||||
params.value.pageNo = e;
|
||||
fetch();
|
||||
onFetch();
|
||||
};
|
||||
onMounted(() => props.init && fetch());
|
||||
|
||||
function reset(v = {}) {
|
||||
params.value = { pageNo: 1, pageSize: 10, ...v };
|
||||
params.reset();
|
||||
emit("update:params", { ...v });
|
||||
fetch();
|
||||
nextTick(onFetch);
|
||||
}
|
||||
|
||||
function resetSelected() {
|
||||
@@ -109,18 +111,16 @@ function resetSelected() {
|
||||
emit("update:selectedRows", []);
|
||||
}
|
||||
|
||||
function clear() {
|
||||
function clear(v = {}) {
|
||||
rowSelectKeys.value = [];
|
||||
selectsData.value = [];
|
||||
params.value = { pageNo: 1, pageSize: 10 };
|
||||
emit("update:params", {});
|
||||
params.reset();
|
||||
emit("update:params", { ...v });
|
||||
emit("update:selectedRowKeys", []);
|
||||
emit("update:selectedRows", []);
|
||||
}
|
||||
|
||||
function toLoading() {
|
||||
loading.value = true;
|
||||
}
|
||||
const toLoading = () => loading.value = true;
|
||||
|
||||
function remove(i) {
|
||||
rowSelectKeys.value.splice(i, 1);
|
||||
@@ -129,6 +129,8 @@ function remove(i) {
|
||||
emit("update:selectedRows", selectsData.value);
|
||||
}
|
||||
|
||||
const fetch = () => nextTick(onFetch);
|
||||
|
||||
defineExpose({ fetch, reset, resetSelected, clear, toLoading, remove });
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user