|
|
|
@ -1,8 +1,9 @@ |
|
|
|
import { toReactive } from "@vueuse/core"; |
|
|
|
import { toReactive } from "@vueuse/core"; |
|
|
|
import { reactive, ref, toRaw, shallowRef, watchEffect } from "vue"; |
|
|
|
import { reactive, ref, shallowRef, watchEffect } from "vue"; |
|
|
|
import * as Element from "../element"; |
|
|
|
import * as Element from "../element"; |
|
|
|
import { useI18n } from "vue3-i18n"; |
|
|
|
import { useI18n } from "vue3-i18n"; |
|
|
|
import { PageResponse } from "../http"; |
|
|
|
import { PageResponse } from "../http"; |
|
|
|
|
|
|
|
import { clearAndAssign, deepCopy } from "noob-mengyxu/utils"; |
|
|
|
|
|
|
|
|
|
|
|
const { showMessage } = Element; |
|
|
|
const { showMessage } = Element; |
|
|
|
|
|
|
|
|
|
|
|
@ -12,8 +13,8 @@ export interface TableColumn { |
|
|
|
i18n?: string; |
|
|
|
i18n?: string; |
|
|
|
type?: string; |
|
|
|
type?: string; |
|
|
|
width?: string | number; |
|
|
|
width?: string | number; |
|
|
|
fixed?: boolean | 'left' | 'right'; |
|
|
|
fixed?: boolean | "left" | "right"; |
|
|
|
align?: 'left' | 'center' | 'right'; |
|
|
|
align?: "left" | "center" | "right"; |
|
|
|
slot?: boolean; |
|
|
|
slot?: boolean; |
|
|
|
dict?: string; |
|
|
|
dict?: string; |
|
|
|
timestamp?: boolean; |
|
|
|
timestamp?: boolean; |
|
|
|
@ -64,14 +65,20 @@ export function useListTable(options: Options) { |
|
|
|
size: initialPageSize || 10, |
|
|
|
size: initialPageSize || 10, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const example = reactive<any>({ |
|
|
|
const defaultExample = () => ({ |
|
|
|
...pageParams, |
|
|
|
...pageParams, |
|
|
|
...initExample, |
|
|
|
...initExample, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const example = reactive<any>(defaultExample()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const setExample = (params: Record<string, any>) => { |
|
|
|
|
|
|
|
clearAndAssign(params, { ...defaultExample(), ...params }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const query = async () => { |
|
|
|
const query = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const resp = await options.query(toRaw(example)); |
|
|
|
const resp = await options.query(deepCopy(example)); |
|
|
|
setRows(resp); |
|
|
|
setRows(resp); |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
showMessage("error", t("common.errors.listTableQueryError")); |
|
|
|
showMessage("error", t("common.errors.listTableQueryError")); |
|
|
|
@ -86,6 +93,7 @@ export function useListTable(options: Options) { |
|
|
|
rows: toReactive(rows), |
|
|
|
rows: toReactive(rows), |
|
|
|
example, |
|
|
|
example, |
|
|
|
setRows, |
|
|
|
setRows, |
|
|
|
|
|
|
|
setExample, |
|
|
|
query, |
|
|
|
query, |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|