网关取消删除添加启用和停用功能 & 产品页套餐添加sort 排序和 count_min 最低购买数量字段
This commit is contained in:
@@ -46,6 +46,7 @@ const schema = z
|
||||
"请输入有效的正数单价",
|
||||
),
|
||||
discount_id: z.string().optional(),
|
||||
count_min: z.string().min(1, "请输入最低购买数量"),
|
||||
price_min: z
|
||||
.string()
|
||||
.min(1, "请输入最低价格")
|
||||
@@ -177,19 +178,6 @@ export function CreateProductSku(props: {
|
||||
placeholder="请输入单价"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// 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 && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
@@ -208,19 +196,6 @@ export function CreateProductSku(props: {
|
||||
placeholder="请输入最低价格"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// 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 && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
@@ -228,7 +203,26 @@ export function CreateProductSku(props: {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="count_min"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field>
|
||||
<FieldLabel htmlFor="sku-create-price">
|
||||
最低购买数量
|
||||
</FieldLabel>
|
||||
<Input
|
||||
id="sku-create-price"
|
||||
placeholder="请输入最低购买数量"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="discount_id"
|
||||
|
||||
@@ -141,6 +141,7 @@ function ProductSkus(props: {
|
||||
},
|
||||
},
|
||||
{ header: "最低价格", accessorKey: "price_min" },
|
||||
{ header: "最低购买数量", accessorKey: "count_min" },
|
||||
{
|
||||
header: "创建时间",
|
||||
accessorFn: row => format(row.created_at, "yyyy-MM-dd HH:mm"),
|
||||
|
||||
@@ -46,6 +46,16 @@ const schema = z
|
||||
"请输入有效的正数单价",
|
||||
),
|
||||
discount_id: z.string().optional(),
|
||||
count_min: z
|
||||
.string()
|
||||
.min(1, "请输入最低购买数量")
|
||||
.refine(
|
||||
v =>
|
||||
!Number.isNaN(Number(v)) &&
|
||||
Number.isInteger(Number(v)) &&
|
||||
Number(v) > 0,
|
||||
"请输入有效的正整数",
|
||||
),
|
||||
price_min: z
|
||||
.string()
|
||||
.min(1, "请输入最低价格")
|
||||
@@ -82,6 +92,7 @@ export function UpdateProductSku(props: {
|
||||
price: props.sku.price,
|
||||
discount_id: props.sku.discount ? String(props.sku.discount.id) : "",
|
||||
price_min: props.sku.price_min ?? "",
|
||||
count_min: String(props.sku.count_min),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -107,7 +118,9 @@ export function UpdateProductSku(props: {
|
||||
? Number(data.discount_id)
|
||||
: null,
|
||||
price_min: data.price_min,
|
||||
count_min: Number(data.count_min),
|
||||
})
|
||||
console.log(resp, "resp")
|
||||
|
||||
if (resp.success) {
|
||||
toast.success("套餐修改成功")
|
||||
@@ -130,6 +143,7 @@ export function UpdateProductSku(props: {
|
||||
price: props.sku.price,
|
||||
discount_id: props.sku.discount ? String(props.sku.discount.id) : "",
|
||||
price_min: props.sku.price_min ?? "",
|
||||
count_min: props.sku.count_min ? String(props.sku.count_min) : "",
|
||||
})
|
||||
}
|
||||
setOpen(value)
|
||||
@@ -180,19 +194,6 @@ export function UpdateProductSku(props: {
|
||||
placeholder="请输入单价"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// 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 && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
@@ -205,25 +206,34 @@ export function UpdateProductSku(props: {
|
||||
name="price_min"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field>
|
||||
<FieldLabel htmlFor="sku-create-price">最低价格</FieldLabel>
|
||||
<FieldLabel htmlFor="sku-update-price-min">
|
||||
最低价格
|
||||
</FieldLabel>
|
||||
<Input
|
||||
id="sku-create-price"
|
||||
id="sku-update-price-min"
|
||||
placeholder="请输入最低价格"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
// onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// 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 && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="count_min"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field>
|
||||
<FieldLabel htmlFor="sku-update-count-min">
|
||||
最低购买数量
|
||||
</FieldLabel>
|
||||
<Input
|
||||
id="sku-update-count-min"
|
||||
placeholder="请输入最低购买数量"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
/>
|
||||
{fieldState.invalid && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
|
||||
Reference in New Issue
Block a user