diff --git a/package.json b/package.json index d8650d4..b61d81d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lanhu-admin", - "version": "1.2.0", + "version": "1.3.0", "private": true, "scripts": { "dev": "next dev -H 0.0.0.0 -p 3001 --turbopack", diff --git a/src/actions/balance.ts b/src/actions/balance.ts index a29d110..f86c162 100644 --- a/src/actions/balance.ts +++ b/src/actions/balance.ts @@ -6,7 +6,7 @@ export async function getPageBalance(params: { page: number size: number user_phone?: string - bill_id?: string + bill_no?: string created_at_start?: Date created_at_end?: Date }) { @@ -21,7 +21,7 @@ export async function getBalance(params: { size: number user_id: number user_phone?: string - bill_id?: string + bill_no?: string created_at_start?: Date created_at_end?: Date }) { diff --git a/src/app/(root)/admin/page.tsx b/src/app/(root)/admin/page.tsx index 2c1fc32..48b46dc 100644 --- a/src/app/(root)/admin/page.tsx +++ b/src/app/(root)/admin/page.tsx @@ -36,7 +36,6 @@ import { UpdateAdmin } from "./update" export default function AdminPage() { const table = useDataTable((page, size) => getPageAdmin({ page, size })) - console.log(table, "table") return ( diff --git a/src/app/(root)/balance/page.tsx b/src/app/(root)/balance/page.tsx index 2237efb..44716e4 100644 --- a/src/app/(root)/balance/page.tsx +++ b/src/app/(root)/balance/page.tsx @@ -19,7 +19,7 @@ import type { Balance } from "@/models/balance" type FilterValues = { user_phone?: string - bill_id?: string + bill_no?: string admin_id?: string created_at_start?: Date created_at_end?: Date @@ -28,7 +28,7 @@ type FilterValues = { const filterSchema = z .object({ phone: z.string().optional(), - bill_id: z.string().optional(), + bill_no: z.string().optional(), admin_id: z.string().optional(), created_at_start: z.string().optional(), created_at_end: z.string().optional(), @@ -56,7 +56,7 @@ export default function BalancePage() { resolver: zodResolver(filterSchema), defaultValues: { phone: "", - bill_id: "", + bill_no: "", admin_id: "", created_at_start: "", created_at_end: "", @@ -70,11 +70,10 @@ export default function BalancePage() { const table = useDataTable(fetchUsers) - console.log(table, "table") const onFilter = handleSubmit(data => { const result: FilterValues = {} - if (data.phone) result.user_phone = data.phone - if (data.bill_id) result.bill_id = data.bill_id + if (data.phone?.trim()) result.user_phone = data.phone.trim() + if (data.bill_no?.trim()) result.bill_no = data.bill_no.trim() if (data.created_at_start) result.created_at_start = new Date(data.created_at_start) if (data.created_at_end) @@ -102,7 +101,7 @@ export default function BalancePage() { )} /> ( ({}) const { control, handleSubmit, reset } = useForm({ resolver: zodResolver(filterSchema), defaultValues: { phone: "", - bill_id: "", + bill_no: "", admin_id: "", created_at_start: "", created_at_end: "", @@ -72,12 +71,11 @@ export default function BalancePage() { const table = useDataTable((page, size) => getBalance({ page, size, user_id: Number(userId), ...filters }), ) - console.log(table, "仅用户的table") const onFilter = handleSubmit(data => { const result: FilterValues = {} - if (data.phone) result.user_phone = data.phone - if (data.bill_id) result.bill_id = data.bill_id + if (data.phone?.trim()) result.user_phone = data.phone.trim() + if (data.bill_no?.trim()) result.bill_no = data.bill_no.trim() if (data.created_at_start) result.created_at_start = new Date(data.created_at_start) if (data.created_at_end) @@ -102,7 +100,7 @@ export default function BalancePage() {
( { const result: FilterValues = {} - if (data.account) result.account = data.account - if (data.name) result.name = data.name + if (data.account?.trim()) result.account = data.account.trim() + if (data.name?.trim()) result.name = data.name.trim() if (data.identified && data.identified !== "all") result.identified = data.identified === "1" if (data.enabled && data.enabled !== "all") diff --git a/src/app/(root)/product/create.tsx b/src/app/(root)/product/create.tsx index 24652ab..f340c01 100644 --- a/src/app/(root)/product/create.tsx +++ b/src/app/(root)/product/create.tsx @@ -43,8 +43,7 @@ const schema = z.object({ .refine( v => !Number.isNaN(Number(v)) && Number(v) > 0, "请输入有效的正数单价", - ) - .refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"), + ), discount_id: z.string().optional(), price_min: z .string() @@ -52,8 +51,7 @@ const schema = z.object({ .refine( v => !Number.isNaN(Number(v)) && Number(v) > 0, "请输入有效的正数价格", - ) - .refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"), + ), }) export function CreateProductSku(props: { @@ -166,19 +164,19 @@ export function CreateProductSku(props: { placeholder="请输入单价" {...field} aria-invalid={fieldState.invalid} - onChange={(e: React.ChangeEvent) => { - let value = e.target.value - value = value.replace(/[^\d.]/g, "") - const dotCount = (value.match(/\./g) || []).length - if (dotCount > 1) { - value = value.slice(0, value.lastIndexOf(".")) - } - if (value.includes(".")) { - const [int, dec] = value.split(".") - value = `${int}.${dec.slice(0, 2)}` - } - field.onChange(value) - }} + // onChange={(e: React.ChangeEvent) => { + // let value = e.target.value + // value = value.replace(/[^\d.]/g, "") + // const dotCount = (value.match(/\./g) || []).length + // if (dotCount > 1) { + // value = value.slice(0, value.lastIndexOf(".")) + // } + // if (value.includes(".")) { + // const [int, dec] = value.split(".") + // value = `${int}.${dec.slice(0, 2)}` + // } + // field.onChange(value) + // }} /> {fieldState.invalid && ( @@ -197,19 +195,19 @@ export function CreateProductSku(props: { placeholder="请输入最低价格" {...field} aria-invalid={fieldState.invalid} - onChange={(e: React.ChangeEvent) => { - let value = e.target.value - value = value.replace(/[^\d.]/g, "") - const dotCount = (value.match(/\./g) || []).length - if (dotCount > 1) { - value = value.slice(0, value.lastIndexOf(".")) - } - if (value.includes(".")) { - const [int, dec] = value.split(".") - value = `${int}.${dec.slice(0, 2)}` - } - field.onChange(value) - }} + // onChange={(e: React.ChangeEvent) => { + // let value = e.target.value + // value = value.replace(/[^\d.]/g, "") + // const dotCount = (value.match(/\./g) || []).length + // if (dotCount > 1) { + // value = value.slice(0, value.lastIndexOf(".")) + // } + // if (value.includes(".")) { + // const [int, dec] = value.split(".") + // value = `${int}.${dec.slice(0, 2)}` + // } + // field.onChange(value) + // }} /> {fieldState.invalid && ( diff --git a/src/app/(root)/product/page.tsx b/src/app/(root)/product/page.tsx index 82e854c..424e239 100644 --- a/src/app/(root)/product/page.tsx +++ b/src/app/(root)/product/page.tsx @@ -99,7 +99,6 @@ function ProductSkus(props: { ) const table = useDataTable(action) - console.log(table, "table") return (
@@ -130,15 +129,15 @@ function ProductSkus(props: { ), }, { header: "套餐名称", accessorKey: "name" }, - { header: "单价", accessorFn: row => Number(row.price).toFixed(2) }, + { header: "单价", accessorFn: row => Number(row.price) }, { header: "折扣", accessorFn: row => row.discount?.name ?? "—" }, { - header: "最终价格", + header: "折后价", accessorFn: row => { const value = row.discount ? (Number(row.price) * Number(row.discount.discount)) / 100 : Number(row.price) - return Number(value.toFixed(2)) + return Number(value) }, }, { header: "最低价格", accessorKey: "price_min" }, diff --git a/src/app/(root)/product/update.tsx b/src/app/(root)/product/update.tsx index 7e682ef..0f6f0e9 100644 --- a/src/app/(root)/product/update.tsx +++ b/src/app/(root)/product/update.tsx @@ -43,8 +43,7 @@ const schema = z.object({ .refine( v => !Number.isNaN(Number(v)) && Number(v) > 0, "请输入有效的正数单价", - ) - .refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"), + ), discount_id: z.string().optional(), price_min: z .string() @@ -52,8 +51,7 @@ const schema = z.object({ .refine( v => !Number.isNaN(Number(v)) && Number(v) > 0, "请输入有效的正数价格", - ) - .refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"), + ), }) export function UpdateProductSku(props: { @@ -85,8 +83,6 @@ export function UpdateProductSku(props: { }, [open]) const onSubmit = async (data: z.infer) => { - console.log(data, "data") - try { const resp = await updateProductSku({ id: props.sku.id, @@ -171,19 +167,19 @@ export function UpdateProductSku(props: { placeholder="请输入单价" {...field} aria-invalid={fieldState.invalid} - onChange={(e: React.ChangeEvent) => { - let value = e.target.value - value = value.replace(/[^\d.]/g, "") - const dotCount = (value.match(/\./g) || []).length - if (dotCount > 1) { - value = value.slice(0, value.lastIndexOf(".")) - } - if (value.includes(".")) { - const [int, dec] = value.split(".") - value = `${int}.${dec.slice(0, 2)}` - } - field.onChange(value) - }} + // onChange={(e: React.ChangeEvent) => { + // let value = e.target.value + // value = value.replace(/[^\d.]/g, "") + // const dotCount = (value.match(/\./g) || []).length + // if (dotCount > 1) { + // value = value.slice(0, value.lastIndexOf(".")) + // } + // if (value.includes(".")) { + // const [int, dec] = value.split(".") + // value = `${int}.${dec.slice(0, 2)}` + // } + // field.onChange(value) + // }} /> {fieldState.invalid && ( @@ -202,19 +198,19 @@ export function UpdateProductSku(props: { placeholder="请输入最低价格" {...field} aria-invalid={fieldState.invalid} - onChange={(e: React.ChangeEvent) => { - let value = e.target.value - value = value.replace(/[^\d.]/g, "") - const dotCount = (value.match(/\./g) || []).length - if (dotCount > 1) { - value = value.slice(0, value.lastIndexOf(".")) - } - if (value.includes(".")) { - const [int, dec] = value.split(".") - value = `${int}.${dec.slice(0, 2)}` - } - field.onChange(value) - }} + // onChange={(e: React.ChangeEvent) => { + // let value = e.target.value + // value = value.replace(/[^\d.]/g, "") + // const dotCount = (value.match(/\./g) || []).length + // if (dotCount > 1) { + // value = value.slice(0, value.lastIndexOf(".")) + // } + // if (value.includes(".")) { + // const [int, dec] = value.split(".") + // value = `${int}.${dec.slice(0, 2)}` + // } + // field.onChange(value) + // }} /> {fieldState.invalid && ( diff --git a/src/app/(root)/resources/page.tsx b/src/app/(root)/resources/page.tsx index 2d371ba..8e2d343 100644 --- a/src/app/(root)/resources/page.tsx +++ b/src/app/(root)/resources/page.tsx @@ -225,7 +225,7 @@ function ResourceList({ resourceType }: ResourceListProps) { ) const table = useDataTable(fetchResources) - console.log(table, "我的套餐的table") + const refreshTable = useCallback(() => { setFilters(prev => ({ ...prev })) }, []) diff --git a/src/app/(root)/user/page.tsx b/src/app/(root)/user/page.tsx index f27c917..6c151c1 100644 --- a/src/app/(root)/user/page.tsx +++ b/src/app/(root)/user/page.tsx @@ -55,7 +55,7 @@ export default function UserPage() { const onFilter = handleSubmit(data => { const result: FilterValues = {} - if (data.phone) result.phone = data.phone + if (data.phone?.trim()) result.phone = data.phone.trim() setFilters(result) table.pagination.onPageChange(1) })