搜索框加空格校验 & 发布v1.3.0版本
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lanhu-admin",
|
"name": "lanhu-admin",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -H 0.0.0.0 -p 3001 --turbopack",
|
"dev": "next dev -H 0.0.0.0 -p 3001 --turbopack",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export async function getPageBalance(params: {
|
|||||||
page: number
|
page: number
|
||||||
size: number
|
size: number
|
||||||
user_phone?: string
|
user_phone?: string
|
||||||
bill_id?: string
|
bill_no?: string
|
||||||
created_at_start?: Date
|
created_at_start?: Date
|
||||||
created_at_end?: Date
|
created_at_end?: Date
|
||||||
}) {
|
}) {
|
||||||
@@ -21,7 +21,7 @@ export async function getBalance(params: {
|
|||||||
size: number
|
size: number
|
||||||
user_id: number
|
user_id: number
|
||||||
user_phone?: string
|
user_phone?: string
|
||||||
bill_id?: string
|
bill_no?: string
|
||||||
created_at_start?: Date
|
created_at_start?: Date
|
||||||
created_at_end?: Date
|
created_at_end?: Date
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import { UpdateAdmin } from "./update"
|
|||||||
|
|
||||||
export default function AdminPage() {
|
export default function AdminPage() {
|
||||||
const table = useDataTable((page, size) => getPageAdmin({ page, size }))
|
const table = useDataTable((page, size) => getPageAdmin({ page, size }))
|
||||||
console.log(table, "table")
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import type { Balance } from "@/models/balance"
|
|||||||
|
|
||||||
type FilterValues = {
|
type FilterValues = {
|
||||||
user_phone?: string
|
user_phone?: string
|
||||||
bill_id?: string
|
bill_no?: string
|
||||||
admin_id?: string
|
admin_id?: string
|
||||||
created_at_start?: Date
|
created_at_start?: Date
|
||||||
created_at_end?: Date
|
created_at_end?: Date
|
||||||
@@ -28,7 +28,7 @@ type FilterValues = {
|
|||||||
const filterSchema = z
|
const filterSchema = z
|
||||||
.object({
|
.object({
|
||||||
phone: z.string().optional(),
|
phone: z.string().optional(),
|
||||||
bill_id: z.string().optional(),
|
bill_no: z.string().optional(),
|
||||||
admin_id: z.string().optional(),
|
admin_id: z.string().optional(),
|
||||||
created_at_start: z.string().optional(),
|
created_at_start: z.string().optional(),
|
||||||
created_at_end: z.string().optional(),
|
created_at_end: z.string().optional(),
|
||||||
@@ -56,7 +56,7 @@ export default function BalancePage() {
|
|||||||
resolver: zodResolver(filterSchema),
|
resolver: zodResolver(filterSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
phone: "",
|
phone: "",
|
||||||
bill_id: "",
|
bill_no: "",
|
||||||
admin_id: "",
|
admin_id: "",
|
||||||
created_at_start: "",
|
created_at_start: "",
|
||||||
created_at_end: "",
|
created_at_end: "",
|
||||||
@@ -70,11 +70,10 @@ export default function BalancePage() {
|
|||||||
|
|
||||||
const table = useDataTable<Balance>(fetchUsers)
|
const table = useDataTable<Balance>(fetchUsers)
|
||||||
|
|
||||||
console.log(table, "table")
|
|
||||||
const onFilter = handleSubmit(data => {
|
const onFilter = handleSubmit(data => {
|
||||||
const result: FilterValues = {}
|
const result: FilterValues = {}
|
||||||
if (data.phone) result.user_phone = data.phone
|
if (data.phone?.trim()) result.user_phone = data.phone.trim()
|
||||||
if (data.bill_id) result.bill_id = data.bill_id
|
if (data.bill_no?.trim()) result.bill_no = data.bill_no.trim()
|
||||||
if (data.created_at_start)
|
if (data.created_at_start)
|
||||||
result.created_at_start = new Date(data.created_at_start)
|
result.created_at_start = new Date(data.created_at_start)
|
||||||
if (data.created_at_end)
|
if (data.created_at_end)
|
||||||
@@ -102,7 +101,7 @@ export default function BalancePage() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Controller
|
<Controller
|
||||||
name="bill_id"
|
name="bill_no"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ export default function BatchPage() {
|
|||||||
{ header: "批次号", accessorKey: "batch_no" },
|
{ header: "批次号", accessorKey: "batch_no" },
|
||||||
{ header: "省份", accessorKey: "prov" },
|
{ header: "省份", accessorKey: "prov" },
|
||||||
{ header: "城市", accessorKey: "city" },
|
{ header: "城市", accessorKey: "city" },
|
||||||
{ header: "提取IP", accessorKey: "ip" },
|
{ header: "用户IP", accessorKey: "ip" },
|
||||||
{ header: "运营商", accessorKey: "isp" },
|
{ header: "运营商", accessorKey: "isp" },
|
||||||
{ header: "提取数量", accessorKey: "count" },
|
{ header: "提取数量", accessorKey: "count" },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import type { Balance } from "@/models/balance"
|
|||||||
|
|
||||||
type FilterValues = {
|
type FilterValues = {
|
||||||
user_phone?: string
|
user_phone?: string
|
||||||
bill_id?: string
|
bill_no?: string
|
||||||
created_at_start?: Date
|
created_at_start?: Date
|
||||||
created_at_end?: Date
|
created_at_end?: Date
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ type FilterValues = {
|
|||||||
const filterSchema = z
|
const filterSchema = z
|
||||||
.object({
|
.object({
|
||||||
phone: z.string().optional(),
|
phone: z.string().optional(),
|
||||||
bill_id: z.string().optional(),
|
bill_no: z.string().optional(),
|
||||||
admin_id: z.string().optional(),
|
admin_id: z.string().optional(),
|
||||||
created_at_start: z.string().optional(),
|
created_at_start: z.string().optional(),
|
||||||
created_at_end: z.string().optional(),
|
created_at_end: z.string().optional(),
|
||||||
@@ -55,14 +55,13 @@ export default function BalancePage() {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const userId = searchParams.get("userId")
|
const userId = searchParams.get("userId")
|
||||||
const userPhone = searchParams.get("phone")
|
const userPhone = searchParams.get("phone")
|
||||||
console.log(userPhone, "userPhone")
|
|
||||||
|
|
||||||
const [filters, setFilters] = useState<FilterValues>({})
|
const [filters, setFilters] = useState<FilterValues>({})
|
||||||
const { control, handleSubmit, reset } = useForm<FormValues>({
|
const { control, handleSubmit, reset } = useForm<FormValues>({
|
||||||
resolver: zodResolver(filterSchema),
|
resolver: zodResolver(filterSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
phone: "",
|
phone: "",
|
||||||
bill_id: "",
|
bill_no: "",
|
||||||
admin_id: "",
|
admin_id: "",
|
||||||
created_at_start: "",
|
created_at_start: "",
|
||||||
created_at_end: "",
|
created_at_end: "",
|
||||||
@@ -72,12 +71,11 @@ export default function BalancePage() {
|
|||||||
const table = useDataTable<Balance>((page, size) =>
|
const table = useDataTable<Balance>((page, size) =>
|
||||||
getBalance({ page, size, user_id: Number(userId), ...filters }),
|
getBalance({ page, size, user_id: Number(userId), ...filters }),
|
||||||
)
|
)
|
||||||
console.log(table, "仅用户的table")
|
|
||||||
|
|
||||||
const onFilter = handleSubmit(data => {
|
const onFilter = handleSubmit(data => {
|
||||||
const result: FilterValues = {}
|
const result: FilterValues = {}
|
||||||
if (data.phone) result.user_phone = data.phone
|
if (data.phone?.trim()) result.user_phone = data.phone.trim()
|
||||||
if (data.bill_id) result.bill_id = data.bill_id
|
if (data.bill_no?.trim()) result.bill_no = data.bill_no.trim()
|
||||||
if (data.created_at_start)
|
if (data.created_at_start)
|
||||||
result.created_at_start = new Date(data.created_at_start)
|
result.created_at_start = new Date(data.created_at_start)
|
||||||
if (data.created_at_end)
|
if (data.created_at_end)
|
||||||
@@ -102,7 +100,7 @@ export default function BalancePage() {
|
|||||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="bill_id"
|
name="bill_no"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ export default function UserQueryPage() {
|
|||||||
2: "代理商注册",
|
2: "代理商注册",
|
||||||
3: "代理商添加",
|
3: "代理商添加",
|
||||||
}
|
}
|
||||||
return sourceMap[row.original.source] ?? "未知"
|
return sourceMap[row.original.source] ?? "官网注册"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ export default function CustPage() {
|
|||||||
|
|
||||||
const onFilter = handleSubmit(data => {
|
const onFilter = handleSubmit(data => {
|
||||||
const result: FilterValues = {}
|
const result: FilterValues = {}
|
||||||
if (data.account) result.account = data.account
|
if (data.account?.trim()) result.account = data.account.trim()
|
||||||
if (data.name) result.name = data.name
|
if (data.name?.trim()) result.name = data.name.trim()
|
||||||
if (data.identified && data.identified !== "all")
|
if (data.identified && data.identified !== "all")
|
||||||
result.identified = data.identified === "1"
|
result.identified = data.identified === "1"
|
||||||
if (data.enabled && data.enabled !== "all")
|
if (data.enabled && data.enabled !== "all")
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ const schema = z.object({
|
|||||||
.refine(
|
.refine(
|
||||||
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
||||||
"请输入有效的正数单价",
|
"请输入有效的正数单价",
|
||||||
)
|
),
|
||||||
.refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"),
|
|
||||||
discount_id: z.string().optional(),
|
discount_id: z.string().optional(),
|
||||||
price_min: z
|
price_min: z
|
||||||
.string()
|
.string()
|
||||||
@@ -52,8 +51,7 @@ const schema = z.object({
|
|||||||
.refine(
|
.refine(
|
||||||
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
||||||
"请输入有效的正数价格",
|
"请输入有效的正数价格",
|
||||||
)
|
),
|
||||||
.refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export function CreateProductSku(props: {
|
export function CreateProductSku(props: {
|
||||||
@@ -166,19 +164,19 @@ export function CreateProductSku(props: {
|
|||||||
placeholder="请输入单价"
|
placeholder="请输入单价"
|
||||||
{...field}
|
{...field}
|
||||||
aria-invalid={fieldState.invalid}
|
aria-invalid={fieldState.invalid}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
let value = e.target.value
|
// let value = e.target.value
|
||||||
value = value.replace(/[^\d.]/g, "")
|
// value = value.replace(/[^\d.]/g, "")
|
||||||
const dotCount = (value.match(/\./g) || []).length
|
// const dotCount = (value.match(/\./g) || []).length
|
||||||
if (dotCount > 1) {
|
// if (dotCount > 1) {
|
||||||
value = value.slice(0, value.lastIndexOf("."))
|
// value = value.slice(0, value.lastIndexOf("."))
|
||||||
}
|
// }
|
||||||
if (value.includes(".")) {
|
// if (value.includes(".")) {
|
||||||
const [int, dec] = value.split(".")
|
// const [int, dec] = value.split(".")
|
||||||
value = `${int}.${dec.slice(0, 2)}`
|
// value = `${int}.${dec.slice(0, 2)}`
|
||||||
}
|
// }
|
||||||
field.onChange(value)
|
// field.onChange(value)
|
||||||
}}
|
// }}
|
||||||
/>
|
/>
|
||||||
{fieldState.invalid && (
|
{fieldState.invalid && (
|
||||||
<FieldError errors={[fieldState.error]} />
|
<FieldError errors={[fieldState.error]} />
|
||||||
@@ -197,19 +195,19 @@ export function CreateProductSku(props: {
|
|||||||
placeholder="请输入最低价格"
|
placeholder="请输入最低价格"
|
||||||
{...field}
|
{...field}
|
||||||
aria-invalid={fieldState.invalid}
|
aria-invalid={fieldState.invalid}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
let value = e.target.value
|
// let value = e.target.value
|
||||||
value = value.replace(/[^\d.]/g, "")
|
// value = value.replace(/[^\d.]/g, "")
|
||||||
const dotCount = (value.match(/\./g) || []).length
|
// const dotCount = (value.match(/\./g) || []).length
|
||||||
if (dotCount > 1) {
|
// if (dotCount > 1) {
|
||||||
value = value.slice(0, value.lastIndexOf("."))
|
// value = value.slice(0, value.lastIndexOf("."))
|
||||||
}
|
// }
|
||||||
if (value.includes(".")) {
|
// if (value.includes(".")) {
|
||||||
const [int, dec] = value.split(".")
|
// const [int, dec] = value.split(".")
|
||||||
value = `${int}.${dec.slice(0, 2)}`
|
// value = `${int}.${dec.slice(0, 2)}`
|
||||||
}
|
// }
|
||||||
field.onChange(value)
|
// field.onChange(value)
|
||||||
}}
|
// }}
|
||||||
/>
|
/>
|
||||||
{fieldState.invalid && (
|
{fieldState.invalid && (
|
||||||
<FieldError errors={[fieldState.error]} />
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ function ProductSkus(props: {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const table = useDataTable(action)
|
const table = useDataTable(action)
|
||||||
console.log(table, "table")
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-auto overflow-hidden flex flex-col items-stretch gap-3">
|
<div className="flex-auto overflow-hidden flex flex-col items-stretch gap-3">
|
||||||
@@ -130,15 +129,15 @@ function ProductSkus(props: {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ header: "套餐名称", accessorKey: "name" },
|
{ header: "套餐名称", accessorKey: "name" },
|
||||||
{ header: "单价", accessorFn: row => Number(row.price).toFixed(2) },
|
{ header: "单价", accessorFn: row => Number(row.price) },
|
||||||
{ header: "折扣", accessorFn: row => row.discount?.name ?? "—" },
|
{ header: "折扣", accessorFn: row => row.discount?.name ?? "—" },
|
||||||
{
|
{
|
||||||
header: "最终价格",
|
header: "折后价",
|
||||||
accessorFn: row => {
|
accessorFn: row => {
|
||||||
const value = row.discount
|
const value = row.discount
|
||||||
? (Number(row.price) * Number(row.discount.discount)) / 100
|
? (Number(row.price) * Number(row.discount.discount)) / 100
|
||||||
: Number(row.price)
|
: Number(row.price)
|
||||||
return Number(value.toFixed(2))
|
return Number(value)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ header: "最低价格", accessorKey: "price_min" },
|
{ header: "最低价格", accessorKey: "price_min" },
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ const schema = z.object({
|
|||||||
.refine(
|
.refine(
|
||||||
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
||||||
"请输入有效的正数单价",
|
"请输入有效的正数单价",
|
||||||
)
|
),
|
||||||
.refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"),
|
|
||||||
discount_id: z.string().optional(),
|
discount_id: z.string().optional(),
|
||||||
price_min: z
|
price_min: z
|
||||||
.string()
|
.string()
|
||||||
@@ -52,8 +51,7 @@ const schema = z.object({
|
|||||||
.refine(
|
.refine(
|
||||||
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
v => !Number.isNaN(Number(v)) && Number(v) > 0,
|
||||||
"请输入有效的正数价格",
|
"请输入有效的正数价格",
|
||||||
)
|
),
|
||||||
.refine(val => /^\d+(\.\d{1,2})?$/.test(val), "价格最多只能保留两位小数"),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export function UpdateProductSku(props: {
|
export function UpdateProductSku(props: {
|
||||||
@@ -85,8 +83,6 @@ export function UpdateProductSku(props: {
|
|||||||
}, [open])
|
}, [open])
|
||||||
|
|
||||||
const onSubmit = async (data: z.infer<typeof schema>) => {
|
const onSubmit = async (data: z.infer<typeof schema>) => {
|
||||||
console.log(data, "data")
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await updateProductSku({
|
const resp = await updateProductSku({
|
||||||
id: props.sku.id,
|
id: props.sku.id,
|
||||||
@@ -171,19 +167,19 @@ export function UpdateProductSku(props: {
|
|||||||
placeholder="请输入单价"
|
placeholder="请输入单价"
|
||||||
{...field}
|
{...field}
|
||||||
aria-invalid={fieldState.invalid}
|
aria-invalid={fieldState.invalid}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
let value = e.target.value
|
// let value = e.target.value
|
||||||
value = value.replace(/[^\d.]/g, "")
|
// value = value.replace(/[^\d.]/g, "")
|
||||||
const dotCount = (value.match(/\./g) || []).length
|
// const dotCount = (value.match(/\./g) || []).length
|
||||||
if (dotCount > 1) {
|
// if (dotCount > 1) {
|
||||||
value = value.slice(0, value.lastIndexOf("."))
|
// value = value.slice(0, value.lastIndexOf("."))
|
||||||
}
|
// }
|
||||||
if (value.includes(".")) {
|
// if (value.includes(".")) {
|
||||||
const [int, dec] = value.split(".")
|
// const [int, dec] = value.split(".")
|
||||||
value = `${int}.${dec.slice(0, 2)}`
|
// value = `${int}.${dec.slice(0, 2)}`
|
||||||
}
|
// }
|
||||||
field.onChange(value)
|
// field.onChange(value)
|
||||||
}}
|
// }}
|
||||||
/>
|
/>
|
||||||
{fieldState.invalid && (
|
{fieldState.invalid && (
|
||||||
<FieldError errors={[fieldState.error]} />
|
<FieldError errors={[fieldState.error]} />
|
||||||
@@ -202,19 +198,19 @@ export function UpdateProductSku(props: {
|
|||||||
placeholder="请输入最低价格"
|
placeholder="请输入最低价格"
|
||||||
{...field}
|
{...field}
|
||||||
aria-invalid={fieldState.invalid}
|
aria-invalid={fieldState.invalid}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
let value = e.target.value
|
// let value = e.target.value
|
||||||
value = value.replace(/[^\d.]/g, "")
|
// value = value.replace(/[^\d.]/g, "")
|
||||||
const dotCount = (value.match(/\./g) || []).length
|
// const dotCount = (value.match(/\./g) || []).length
|
||||||
if (dotCount > 1) {
|
// if (dotCount > 1) {
|
||||||
value = value.slice(0, value.lastIndexOf("."))
|
// value = value.slice(0, value.lastIndexOf("."))
|
||||||
}
|
// }
|
||||||
if (value.includes(".")) {
|
// if (value.includes(".")) {
|
||||||
const [int, dec] = value.split(".")
|
// const [int, dec] = value.split(".")
|
||||||
value = `${int}.${dec.slice(0, 2)}`
|
// value = `${int}.${dec.slice(0, 2)}`
|
||||||
}
|
// }
|
||||||
field.onChange(value)
|
// field.onChange(value)
|
||||||
}}
|
// }}
|
||||||
/>
|
/>
|
||||||
{fieldState.invalid && (
|
{fieldState.invalid && (
|
||||||
<FieldError errors={[fieldState.error]} />
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ function ResourceList({ resourceType }: ResourceListProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const table = useDataTable<Resources>(fetchResources)
|
const table = useDataTable<Resources>(fetchResources)
|
||||||
console.log(table, "我的套餐的table")
|
|
||||||
const refreshTable = useCallback(() => {
|
const refreshTable = useCallback(() => {
|
||||||
setFilters(prev => ({ ...prev }))
|
setFilters(prev => ({ ...prev }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default function UserPage() {
|
|||||||
|
|
||||||
const onFilter = handleSubmit(data => {
|
const onFilter = handleSubmit(data => {
|
||||||
const result: FilterValues = {}
|
const result: FilterValues = {}
|
||||||
if (data.phone) result.phone = data.phone
|
if (data.phone?.trim()) result.phone = data.phone.trim()
|
||||||
setFilters(result)
|
setFilters(result)
|
||||||
table.pagination.onPageChange(1)
|
table.pagination.onPageChange(1)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user