修复语法

master
lzq 2025-12-19 18:13:25 +08:00
parent a4a67b81de
commit 0b1827734d
15 changed files with 104 additions and 73 deletions

View File

@ -5,7 +5,7 @@ import axios, {
} from 'axios' } from 'axios'
import * as qs from 'qs' import * as qs from 'qs'
import { useAppUserStore } from '@/common/app/app-user-store.ts' import { useAppUserStore } from '@/common/app/app-user-store.ts'
import { throttle } from '@/common/utils/index.ts' import Utils from '@/common/utils/index.ts'
import mime from '@/common/utils/mime.ts' import mime from '@/common/utils/mime.ts'
import Evt from '@/common/utils/evt.ts' import Evt from '@/common/utils/evt.ts'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@ -41,7 +41,7 @@ const paramsSerializer = (params: any) => {
/* function errHandler(r?: R) { /* function errHandler(r?: R) {
Toast.error(r?.message ?? '操作失败') Toast.error(r?.message ?? '操作失败')
} */ } */
const errHandler = throttle(500, (r?: AxiosResponse<R<any>, any>) => { const errHandler = Utils.throttle(500, (r?: AxiosResponse<R<any>, any>) => {
console.log('异常处理', r) console.log('异常处理', r)
ElMessage.error(r?.data?.message ?? '服务器错误') ElMessage.error(r?.data?.message ?? '服务器错误')
}) })

View File

@ -1,3 +1,5 @@
import type { ReactiveFlags } from 'vue'
/** /**
* Object.prototype.toString.call(obj) * Object.prototype.toString.call(obj)
*/ */
@ -29,7 +31,7 @@ export class TypeTag {
* @param t ms * @param t ms
* @return * @return
*/ */
export function throttle<T extends any[]>(t: number, fn: (...args: T) => void) { function throttle<T extends any[]>(t: number, fn: (...args: T) => void) {
let lastExecTime = 0 let lastExecTime = 0
return function (this: any, ...args: T) { return function (this: any, ...args: T) {
let now = Date.now() let now = Date.now()
@ -48,7 +50,7 @@ export function throttle<T extends any[]>(t: number, fn: (...args: T) => void) {
* @param t ms * @param t ms
* @return * @return
*/ */
export function debounce<T extends any[]>(t: number, fn: (...args: T) => void) { function debounce<T extends any[]>(t: number, fn: (...args: T) => void) {
let deferTimer: number | null = null let deferTimer: number | null = null
return function (this: any, ...args: T) { return function (this: any, ...args: T) {
if (deferTimer != null) { if (deferTimer != null) {
@ -61,8 +63,66 @@ export function debounce<T extends any[]>(t: number, fn: (...args: T) => void) {
} }
} }
export function clone<T = any>(t: T) { function clone<T = any>(value: T): T {
return JSON.parse(JSON.stringify(t)) as T if (value === null || typeof value !== 'object') {
return value
}
const rawValue = isReactive(value) ? toRaw(value) : value
if (rawValue instanceof Date) {
return new Date(rawValue.getTime()) as T
}
if (rawValue instanceof RegExp) {
return new RegExp(rawValue.source, rawValue.flags) as T
}
if (Array.isArray(rawValue)) {
return rawValue.map((item) => clone(item)) as T
}
const clonedObj = {} as T
Object.keys(rawValue).forEach((key) => {
clonedObj[key as keyof T] = clone(rawValue[key as keyof T])
})
return clonedObj as T
}
type ExtractRawType<T> =
// 匹配 reactive 响应式对象(通过 Vue 内置的 RAW 标记提取原始类型)
T extends { [ReactiveFlags.RAW]: infer RawValue }
? RawValue
// 递归处理数组(兼容 reactive([]) 场景)
: T extends Array<infer U>
? Array<ExtractRawType<U>>
// 递归处理嵌套对象(兼容 reactive({ a: { b: 1 } }) 场景)
: T extends object
? { [K in keyof T]: ExtractRawType<T[K]> }
// 非对象类型直接返回(如 string/number 等)
: T;
type ResetAble<T> = T & { $reset: (val?: Partial<ExtractRawType<T>>) => void }
function resetAble<T extends object>(target: T): ResetAble<T> {
const initialData = clone(target) as T
(target as ResetAble<T>).$reset = (val?: Partial<ExtractRawType<T>>) => {
if (val == null) {
val = initialData
}
if (Array.isArray(val)) {
const arr = target as unknown as Array<unknown>
const initialArr = val as unknown as Array<unknown>
arr.splice(0, arr.length, ...initialArr)
} else {
Object.keys(val).forEach((key) => {
(target as Record<string, unknown>)[key] = (val as Record<string, unknown>)[key]
})
Object.getOwnPropertyNames(target).forEach((key) => {
if (key !== '$reset' && !(key in val)) {
(target as Record<string, unknown>)[key] = undefined
}
})
}
}
return target as ResetAble<T>
} }
export default { export default {
@ -70,4 +130,5 @@ export default {
debounce, debounce,
TypeTag, TypeTag,
clone, clone,
resetAble,
} }

View File

@ -61,7 +61,8 @@ function parse(date: Date | number | string | DateObjectUnits, fmt: string = FMT
* @param date luxon JS * @param date luxon JS
* @param fmt yyyy-MM-dd HH:mm:ss * @param fmt yyyy-MM-dd HH:mm:ss
*/ */
function format(date: DateTime<true | false> | Date, fmt: string = FMT.date_time_sec) { function format(date?: DateTime<true | false> | Date, fmt: string = FMT.date_time_sec) {
if (date == null) return ''
if (isDate(date)) { if (isDate(date)) {
return DateTime.fromJSDate(date as Date).toFormat(fmt) return DateTime.fromJSDate(date as Date).toFormat(fmt)
} else { } else {

View File

@ -5,7 +5,6 @@
// ------ // ------
// Generated by unplugin-vue-components // Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399 // Read more: https://github.com/vuejs/core/pull/3399
import { GlobalComponents } from 'vue'
export {} export {}
@ -15,11 +14,8 @@ declare module 'vue' {
ElAside: typeof import('element-plus/es')['ElAside'] ElAside: typeof import('element-plus/es')['ElAside']
ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElContainer: typeof import('element-plus/es')['ElContainer'] ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
@ -33,7 +29,6 @@ declare module 'vue' {
ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader'] ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon'] ElIcon: typeof import('element-plus/es')['ElIcon']
ElIconFilter: typeof import('@element-plus/icons-vue')['Filter']
ElIconPicture: typeof import('@element-plus/icons-vue')['Picture'] ElIconPicture: typeof import('@element-plus/icons-vue')['Picture']
ElImage: typeof import('element-plus/es')['ElImage'] ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
@ -48,7 +43,6 @@ declare module 'vue' {
ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTabsPane: typeof import('element-plus/es')['ElTabsPane']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElText: typeof import('element-plus/es')['ElText'] ElText: typeof import('element-plus/es')['ElText']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
@ -68,11 +62,8 @@ declare global {
const ElAside: typeof import('element-plus/es')['ElAside'] const ElAside: typeof import('element-plus/es')['ElAside']
const ElAvatar: typeof import('element-plus/es')['ElAvatar'] const ElAvatar: typeof import('element-plus/es')['ElAvatar']
const ElButton: typeof import('element-plus/es')['ElButton'] const ElButton: typeof import('element-plus/es')['ElButton']
const ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
const ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] const ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
const ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] const ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
const ElCollapse: typeof import('element-plus/es')['ElCollapse']
const ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
const ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] const ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
const ElContainer: typeof import('element-plus/es')['ElContainer'] const ElContainer: typeof import('element-plus/es')['ElContainer']
const ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] const ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
@ -86,7 +77,6 @@ declare global {
const ElFormItem: typeof import('element-plus/es')['ElFormItem'] const ElFormItem: typeof import('element-plus/es')['ElFormItem']
const ElHeader: typeof import('element-plus/es')['ElHeader'] const ElHeader: typeof import('element-plus/es')['ElHeader']
const ElIcon: typeof import('element-plus/es')['ElIcon'] const ElIcon: typeof import('element-plus/es')['ElIcon']
const ElIconFilter: typeof import('@element-plus/icons-vue')['Filter']
const ElIconPicture: typeof import('@element-plus/icons-vue')['Picture'] const ElIconPicture: typeof import('@element-plus/icons-vue')['Picture']
const ElImage: typeof import('element-plus/es')['ElImage'] const ElImage: typeof import('element-plus/es')['ElImage']
const ElInput: typeof import('element-plus/es')['ElInput'] const ElInput: typeof import('element-plus/es')['ElInput']
@ -101,7 +91,6 @@ declare global {
const ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] const ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
const ElTabPane: typeof import('element-plus/es')['ElTabPane'] const ElTabPane: typeof import('element-plus/es')['ElTabPane']
const ElTabs: typeof import('element-plus/es')['ElTabs'] const ElTabs: typeof import('element-plus/es')['ElTabs']
const ElTabsPane: typeof import('element-plus/es')['ElTabsPane']
const ElTag: typeof import('element-plus/es')['ElTag'] const ElTag: typeof import('element-plus/es')['ElTag']
const ElText: typeof import('element-plus/es')['ElText'] const ElText: typeof import('element-plus/es')['ElText']
const ElTooltip: typeof import('element-plus/es')['ElTooltip'] const ElTooltip: typeof import('element-plus/es')['ElTooltip']

View File

@ -89,10 +89,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import CustomerApi from "@/pages/cst/customer/customer-api.ts"; import CustomerApi from '@/pages/cst/customer/customer-api.ts'
import CustomerForm from "@/pages/cst/customer/CustomerForm.vue"; import CustomerForm from '@/pages/cst/customer/CustomerForm.vue'
import Page from "@/components/page/Page.vue"; import Page from '@/components/page/Page.vue'
import { elIcons } from "@/common/element/element.ts"; import { elIcons } from '@/common/element/element.ts'
const tableData = ref<CustomerTypes.SearchCustomerResult[]>([]); const tableData = ref<CustomerTypes.SearchCustomerResult[]>([]);
let searchForm = reactive<CustomerTypes.SearchCustomerParam>({ let searchForm = reactive<CustomerTypes.SearchCustomerParam>({
@ -132,10 +132,6 @@ function modifyHandler({ row }: { row: CustomerTypes.SearchCustomerResult }) {
showDialog(row); showDialog(row);
} }
function addHandler() {
showDialog();
}
function reset() { function reset() {
// Object.assign(searchForm, {}); // Object.assign(searchForm, {});
searchForm = reactive<CustomerTypes.SearchCustomerParam>({ searchForm = reactive<CustomerTypes.SearchCustomerParam>({

View File

@ -107,12 +107,6 @@ function selectDictHandle({row}: { row: DictTypes.SearchDictResult }) {
emits('searchDict', row) emits('searchDict', row)
} }
function pageChangeHandler(currentPage: number, pageSize: number) {
searchForm.current = currentPage
searchForm.size = pageSize
paging()
}
function reset() { function reset() {
searchForm.value = { searchForm.value = {
orders: 'dict_key,id', orders: 'dict_key,id',

View File

@ -101,11 +101,6 @@ const searching = ref(false)
const deling = ref(false) const deling = ref(false)
const showSearchForm = ref(true) const showSearchForm = ref(true)
const tplFormIns = useTemplateRef<InstanceType<typeof TplForm>>('tplForm') const tplFormIns = useTemplateRef<InstanceType<typeof TplForm>>('tplForm')
const pagination = reactive<G.Pagination>({
total: 0,
current: 1,
size: 1,
})
function showDialog(data?: TplTypes.SearchTplResult) { function showDialog(data?: TplTypes.SearchTplResult) {
tplFormIns.value?.open(data) tplFormIns.value?.open(data)

View File

@ -39,7 +39,16 @@
</ElInput> </ElInput>
<template #dropdown> <template #dropdown>
<div class="dropdown-table-wrapper"> <div class="dropdown-table-wrapper">
<ElTable ref="dropdownTable" :data="iconTableDataSource" empty-text="" highlight-current-row style="width: 324px" @current-change="currentChangeHandler"> <ElTable
ref="dropdownTable"
:data="iconTableDataSource"
cell-class-name="table-cell"
class="table-list"
empty-text="暂无数据"
header-row-class-name="table-header"
row-key="id"
width="324"
@current-change="currentChangeHandler">
<ElTableColumn label="#" type="index"/> <ElTableColumn label="#" type="index"/>
<ElTableColumn label="图标" prop="font_class"> <ElTableColumn label="图标" prop="font_class">
<template #default="scope"> <template #default="scope">

View File

@ -98,7 +98,7 @@ const searchForm = ref<MenuTypes.SearchForm>({})
const searching = ref(false) const searching = ref(false)
const showSearchForm = ref(true) const showSearchForm = ref(true)
const menuFormIns = useTemplateRef<InstanceType<typeof MenuForm>>('menuForm') const menuFormIns = useTemplateRef<InstanceType<typeof MenuForm>>('menuForm')
const dataTableIns = useTemplateRef<InstanceType<TableInstance>>('dataTable') const dataTableIns = useTemplateRef<TableInstance>('dataTable')
const deling = ref(false) const deling = ref(false)
function showDialog(data?: MenuTypes.MenuForm) { function showDialog(data?: MenuTypes.MenuForm) {
@ -148,7 +148,7 @@ function listAll() {
}) })
} }
function treeLoad(row: MenuTypes.SysMenu, expanded: boolean, resolve: (data: MenuTypes.SysMenu[]) => void) { function treeLoad(row: MenuTypes.SysMenu, expanded: any, resolve: (data: MenuTypes.SysMenu[]) => void) {
if (resolve == null && !expanded) return if (resolve == null && !expanded) return
searching.value = true searching.value = true
MenuApi.listAll({...searchForm.value, pid: row.id}) MenuApi.listAll({...searchForm.value, pid: row.id})
@ -159,7 +159,7 @@ function treeLoad(row: MenuTypes.SysMenu, expanded: boolean, resolve: (data: Men
return it return it
}) ?? []) }) ?? [])
} else { } else {
dataTableIns.value.updateKeyChildren(row.id,res.data?.map(it => { dataTableIns.value?.updateKeyChildren(row.id, res.data?.map(it => {
it.hasChildren = true it.hasChildren = true
it.children = [] it.children = []
return it return it

View File

@ -113,7 +113,6 @@ import TaskApi from '@/pages/sys/task/task-api.ts'
import Page from '@/components/page/Page.vue' import Page from '@/components/page/Page.vue'
import { elIcons } from '@/common/element/element.ts' import { elIcons } from '@/common/element/element.ts'
import TaskForm from '@/pages/sys/task/TaskForm.vue' import TaskForm from '@/pages/sys/task/TaskForm.vue'
import ScheduleRecode from '@/pages/sys/task/schedule-recode/ScheduleRecode.vue'
import ScheduleRecodePanel from '@/pages/sys/task/schedule-recode/ScheduleRecodePanel.vue' import ScheduleRecodePanel from '@/pages/sys/task/schedule-recode/ScheduleRecodePanel.vue'
import Times from '@/common/utils/times.ts' import Times from '@/common/utils/times.ts'
@ -127,7 +126,7 @@ const searching = ref(false)
const deling = ref(false) const deling = ref(false)
const showSearchForm = ref(true) const showSearchForm = ref(true)
const taskFormIns = useTemplateRef<InstanceType<typeof TaskForm>>('taskForm') const taskFormIns = useTemplateRef<InstanceType<typeof TaskForm>>('taskForm')
const scheduleRecodePanelIns = useTemplateRef<InstanceType<typeof ScheduleRecode>>('scheduleRecodePanel') const scheduleRecodePanelIns = useTemplateRef<InstanceType<typeof ScheduleRecodePanel>>('scheduleRecodePanel')
const pagination = reactive<G.Pagination>({ const pagination = reactive<G.Pagination>({
total: 0, total: 0,
pages: 0, pages: 0,

View File

@ -207,8 +207,8 @@ function paging() {
} = searchForm.value } = searchForm.value
TaskExecuteLogApi.paging({ TaskExecuteLogApi.paging({
logLevel, logLevel,
startLogTime: Colls.isEmpty(logTime) ? undefined : Times.format(logTime[0]), startLogTime: Colls.isEmpty(logTime) ? undefined : Times.format(logTime![0]),
endLogTime: Colls.isEmpty(logTime) ? undefined : Times.format(logTime[1]), endLogTime: Colls.isEmpty(logTime) ? undefined : Times.format(logTime![1]),
scheduleId: props.scheduleId, scheduleId: props.scheduleId,
}) })
.then(res => { .then(res => {

View File

@ -8,7 +8,7 @@ declare global {
// 日志等级 // 日志等级
logLevel?: string logLevel?: string
// 日志时间 // 日志时间
logTime?: string logTime?: Date[]
startLogTime?: string startLogTime?: string
endLogTime?: string endLogTime?: string
} }

View File

@ -245,8 +245,8 @@ function paging() {
scheduleType, scheduleType,
taskStatus, taskStatus,
manually, manually,
startTime: Colls.isEmpty(scheduleTime) ? undefined : Times.format(scheduleTime[0]), startTime: Colls.isEmpty(scheduleTime) ? undefined : Times.format(scheduleTime![0]),
endTime: Colls.isEmpty(scheduleTime) ? undefined : Times.format(scheduleTime[1]), endTime: Colls.isEmpty(scheduleTime) ? undefined : Times.format(scheduleTime![1]),
}) })
.then(res => { .then(res => {
tableData.value = res.data?.records ?? [] tableData.value = res.data?.records ?? []

View File

@ -7,7 +7,7 @@ declare global {
// 调度方式 // 调度方式
scheduleType?: string scheduleType?: string
// 调度时间 // 调度时间
scheduleTime?: string scheduleTime?: Date[]
// 任务开始时间 // 任务开始时间
startTime?: string startTime?: string
// 任务结束时间 // 任务结束时间

View File

@ -1,20 +1,10 @@
<template> <template>
<Page> <Page>
<ElForm v-show="showSearchForm" inline @submit.prevent="paging"> <ElForm v-show="showSearchForm" inline @submit.prevent="paging">
<ElFormItem label="昵称"> <ElFormItem label="姓名">
<ElInput <ElInput
v-model="searchForm.nickname" v-model="searchForm.nickname"
placeholder="昵称"/> placeholder="姓名"/>
</ElFormItem>
<ElFormItem label="头像">
<ElInput
v-model="searchForm.avatar"
placeholder="头像"/>
</ElFormItem>
<ElFormItem label="邮箱">
<ElInput
v-model="searchForm.email"
placeholder="邮箱"/>
</ElFormItem> </ElFormItem>
<ElFormItem label="手机号"> <ElFormItem label="手机号">
<ElInput <ElInput
@ -102,13 +92,14 @@ import {
import AppApi from '@/common/app/app-api.ts' import AppApi from '@/common/app/app-api.ts'
import BindRole from '@/pages/sys/user/BindRole.vue' import BindRole from '@/pages/sys/user/BindRole.vue'
import ClientUtil from '@/common/utils/client-util.ts' import ClientUtil from '@/common/utils/client-util.ts'
import Utils from '@/common/utils'
const totalCount = ref(0) const totalCount = ref(0)
const tableData = ref<UserTypes.SearchUserResult[]>([]) const tableData = Utils.resetAble(reactive<UserTypes.SearchUserResult[]>([]))
const searchForm = ref<UserTypes.SearchUserParam>({ const searchForm = Utils.resetAble(reactive<UserTypes.SearchUserParam>({
current: 1, current: 1,
size: 20, size: 20,
}) }))
const searching = ref(false) const searching = ref(false)
// const deling = ref(false) // const deling = ref(false)
const showSearchForm = ref(true) const showSearchForm = ref(true)
@ -163,10 +154,7 @@ function addHandler() {
} }
function reset() { function reset() {
searchForm.value = { searchForm.$reset()
current: 1,
size: 20,
}
paging() paging()
} }
@ -198,14 +186,13 @@ function disabledUserHandler(val: string | number | boolean, id: string) {
function paging() { function paging() {
searching.value = true searching.value = true
UserApi.paging(searchForm.value) UserApi.paging(searchForm)
.then(res => { .then(res => {
totalCount.value = res.data?.total ?? 0 totalCount.value = res.data?.total ?? 0
tableData.value = res.data?.records ?? [] tableData.$reset((res.data?.records ?? []).map(it => {
tableData.value.map(it => {
it.account.clients = ClientUtil.getClients(it.account.clientCode!).map(it => it.val) it.account.clients = ClientUtil.getClients(it.account.clientCode!).map(it => it.val)
return it return it
}) }))
}) })
.finally(() => { .finally(() => {
searching.value = false searching.value = false