Browse Source

fix: misc

dev
hechang27-sprt 6 months ago
parent
commit
d56310e84f
  1. 3
      packages/base/item/tzDatePicker.vue
  2. 4
      packages/base/item/tzDateTime.vue
  3. 4
      plugs/composables/useListTable.ts
  4. 5
      plugs/composables/useSysDict.ts
  5. 13
      plugs/http/axios3.ts

3
packages/base/item/tzDatePicker.vue

@ -1,5 +1,5 @@
<template> <template>
<el-date-picker v-model="model"> </el-date-picker> <el-date-picker v-model="model" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -50,5 +50,6 @@ const model = defineModel<string | number, string, Date, Date>({
else return isoWithMillis.slice(0, 19).concat("Z"); else return isoWithMillis.slice(0, 19).concat("Z");
} }
}, },
default: () => new Date(),
}); });
</script> </script>

4
packages/base/item/tzDateTime.vue

@ -1,5 +1,6 @@
<template> <template>
{{ display }} <slot v-if="slot" :display="display" />
<template v-else>{{ display }}</template>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -13,6 +14,7 @@ interface Props {
displayFormat?: string; displayFormat?: string;
locale?: string; locale?: string;
type?: "iso8601" | "unix" | "unixMillis"; type?: "iso8601" | "unix" | "unixMillis";
slot?: boolean;
} }
const props = defineProps<Props>(); const props = defineProps<Props>();

4
plugs/composables/useListTable.ts

@ -1,5 +1,5 @@
import { toReactive } from "@vueuse/core"; import { toReactive } from "@vueuse/core";
import { reactive, ref, shallowRef, watchEffect } from "vue"; import { reactive, ref, toRaw, 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";
@ -66,7 +66,7 @@ export function useListTable(options: Options) {
const query = async () => { const query = async () => {
try { try {
const resp = await options.query(example); const resp = await options.query(toRaw(example));
setRows(resp); setRows(resp);
} catch (error) { } catch (error) {
showMessage("error", t("common.errors.listTableQueryError")); showMessage("error", t("common.errors.listTableQueryError"));

5
plugs/composables/useSysDict.ts

@ -1,11 +1,12 @@
import { computed } from "vue"; import { computed } from "vue";
import { useStore } from "vuex"; import { useStore } from "vuex";
export function useSysDict() {
type Callback = () => Record<string, string> | Promise<Record<string, string>>; type Callback = () => Record<string, string> | Promise<Record<string, string>>;
const store = useStore();
const callbacks: Record<string, Callback> = {}; const callbacks: Record<string, Callback> = {};
export function useSysDict() {
const store = useStore();
const normalize = (content: Record<string, string>) => { const normalize = (content: Record<string, string>) => {
if (content == null) return {}; if (content == null) return {};
return Object.fromEntries( return Object.fromEntries(

13
plugs/http/axios3.ts

@ -29,10 +29,11 @@ export const registerRouter = (routerP) => {
_axios.interceptors.request.use( _axios.interceptors.request.use(
function (config) { function (config) {
const time = new Date().getTime().toString(); const time = new Date().getTime().toString();
const params = config.params; const params = new URLSearchParams(config.params);
if (params) { if (params.toString()) {
delEmpty(params); delEmpty(params);
params.t = time; params.append("t", time);
config.params = params;
} }
const data = config.data; const data = config.data;
if (data != null && typeof data === "object") { if (data != null && typeof data === "object") {
@ -47,7 +48,11 @@ _axios.interceptors.request.use(
); );
function delEmpty(data) { function delEmpty(data) {
if (data) { if (data && data instanceof URLSearchParams) {
for (const [k, v] of data.entries()) {
if (!v) data.delete(k);
}
} else if (data && typeof data === "object") {
for (const item in data) { for (const item in data) {
if (data.hasOwnProperty(item)) { if (data.hasOwnProperty(item)) {
const val = data[item]; const val = data[item];

Loading…
Cancel
Save