修改发布数量

This commit is contained in:
筱野
2025-09-26 23:20:29 +08:00
parent 5e7feb7cca
commit 37fa1118f2
3 changed files with 51 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import React from 'react' import React, { useState, useEffect } from 'react'
import { View, Text } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import { InputNumber } from '@nutui/nutui-react-taro' import { InputNumber } from '@nutui/nutui-react-taro'
import { Checkbox } from '@nutui/nutui-react-taro' import { Checkbox } from '@nutui/nutui-react-taro'
@@ -17,7 +17,19 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
min, min,
max max
}) => { }) => {
const { min:minParticipants, max:maxParticipants, organizer_joined } = value || { min: 1, max: 1, organizer_joined: true } const [organizer_joined, setOrganizerJoined] = useState(true);
const [minParticipants, setMinParticipants] = useState(1);
const [maxParticipants, setMaxParticipants] = useState(1);
useEffect(() => {
if (value) {
setOrganizerJoined(value.organizer_joined);
setMinParticipants(value.min);
setMaxParticipants(value.max);
}
console.log(value, 'valuevaluevaluevaluevaluevalue');
}, [value]);
const handleChange = (value: { min: number | string, max: number | string, organizer_joined: boolean }) => { const handleChange = (value: { min: number | string, max: number | string, organizer_joined: boolean }) => {
const toNumber = (v: number | string): number => typeof v === 'string' ? Number(v) : v const toNumber = (v: number | string): number => typeof v === 'string' ? Number(v) : v
const { min, max, organizer_joined } = value; const { min, max, organizer_joined } = value;
@@ -32,7 +44,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
<View className='control-buttons'> <View className='control-buttons'>
<InputNumber <InputNumber
className="format-width" className="format-width"
defaultValue={minParticipants} value={minParticipants}
min={min} min={min}
max={maxParticipants} max={maxParticipants}
onChange={(value) => handleChange({ min: value, max: maxParticipants, organizer_joined: organizer_joined })} onChange={(value) => handleChange({ min: value, max: maxParticipants, organizer_joined: organizer_joined })}
@@ -45,7 +57,7 @@ const NumberInterval: React.FC<NumberIntervalProps> = ({
<View className='control-buttons'> <View className='control-buttons'>
<InputNumber <InputNumber
className="format-width" className="format-width"
defaultValue={maxParticipants} value={maxParticipants}
onChange={(value) => handleChange({ min: minParticipants, max: value, organizer_joined: organizer_joined })} onChange={(value) => handleChange({ min: minParticipants, max: value, organizer_joined: organizer_joined })}
min={minParticipants} min={minParticipants}
max={max} max={max}

View File

@@ -208,6 +208,8 @@
width: 11px; width: 11px;
height: 11px; height: 11px;
:global(.nut-icon-Checked){ :global(.nut-icon-Checked){
width: 11px;
height: 11px;
background: rgba(22, 24, 35, 0.75)!important; background: rgba(22, 24, 35, 0.75)!important;
} }
} }

View File

@@ -390,6 +390,27 @@ const PublishBall: React.FC = () => {
} }
} }
const formatConfig = () => {
const newFormSchema = publishBallFormSchema.reduce((acc, item) => {
if (item.prop === 'wechat') {
return acc
}
if (item.prop === 'image_list') {
if (item.props) {
item.props.source = ['album', 'history']
}
}
if (item.prop === 'players') {
if (item.props) {
item.props.max = 100
}
}
acc.push(item)
return acc
}, [] as FormFieldConfig[])
setOptionsConfig(newFormSchema)
}
const initFormData = () => { const initFormData = () => {
const currentInstance = Taro.getCurrentInstance() const currentInstance = Taro.getCurrentInstance()
const params = currentInstance.router?.params const params = currentInstance.router?.params
@@ -399,24 +420,7 @@ const PublishBall: React.FC = () => {
if (type === 'individual' || type === 'group') { if (type === 'individual' || type === 'group') {
setActivityType(type) setActivityType(type)
if (type === 'group') { if (type === 'group') {
const newFormSchema = publishBallFormSchema.reduce((acc, item) => { formatConfig()
if (item.prop === 'wechat') {
return acc
}
if (item.prop === 'image_list') {
if (item.props) {
item.props.source = ['album', 'history']
}
}
if (item.prop === 'players') {
if (item.props) {
item.props.max = 100
}
}
acc.push(item)
return acc
}, [] as FormFieldConfig[])
setOptionsConfig(newFormSchema)
setFormData([defaultFormData]) setFormData([defaultFormData])
setTitleBar('发布畅打活动') setTitleBar('发布畅打活动')
} else { } else {
@@ -427,21 +431,26 @@ const PublishBall: React.FC = () => {
// 从 Store 注入 AI 生成的表单 JSON // 从 Store 注入 AI 生成的表单 JSON
if (publishAiData) { if (publishAiData && Array.isArray(publishAiData) && publishAiData.length > 0) {
Taro.showToast({ Taro.showToast({
title: '智能识别成功,请完善剩余信息', title: '智能识别成功,请完善剩余信息',
icon: 'none' icon: 'none'
}) })
if (Array.isArray(publishAiData)) { const merged = publishAiData.map(item => mergeWithDefault(item))
const merged = publishAiData.map(item => mergeWithDefault(item)) setFormData(merged.length ? merged : [defaultFormData])
setFormData(merged.length ? merged : [defaultFormData]) if (merged.length === 1) {
setTitleBar('发布')
setActivityType('individual')
} else { } else {
setFormData([mergeWithDefault(publishAiData)]) formatConfig()
setTitleBar('发布畅打活动')
setActivityType('group')
} }
} else { } else {
setFormData([defaultFormData]) setFormData([defaultFormData])
setTitleBar('发布')
setActivityType('individual')
} }
setTitleBar('发布畅打活动')
} }
} }
} }