🎈 perf(优化所有输入框):
This commit is contained in:
parent
d06f4137c6
commit
812971f6b2
@ -1,61 +1,67 @@
|
|||||||
|
import { Input, Text, Textarea, View } from '@tarojs/components'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
import { Input, Text, Textarea, View } from "@tarojs/components"
|
interface ListParams {
|
||||||
import { memo } from "react"
|
label: string //左边label
|
||||||
import "./index.scss"
|
onInput?: (ev: Object) => void // 输入框输入
|
||||||
|
onClick?: () => any //点击列表
|
||||||
interface ListParams{
|
placeholder?: string // 提示文本
|
||||||
label: string, //左边label
|
children?: any // 插槽
|
||||||
onInput?: (ev:Object)=>void, // 输入框输入
|
|
||||||
onClick?:()=>any, //点击列表
|
|
||||||
placeholder?:string, // 提示文本
|
|
||||||
children?: any, // 插槽
|
|
||||||
type?: string // 类型:1.input,2.textarea,3.select,
|
type?: string // 类型:1.input,2.textarea,3.select,
|
||||||
primordialType?: 'text'|'number'|'idcard'|'digit'
|
primordialType?: 'text' | 'number' | 'idcard' | 'digit'
|
||||||
value?: any,
|
value?: any
|
||||||
style?: object, //整行样式
|
style?: object //整行样式
|
||||||
labelStyle?: object, // label样式
|
labelStyle?: object // label样式
|
||||||
contentStyle?: object,
|
contentStyle?: object
|
||||||
required?: boolean
|
required?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单列表
|
// 表单列表
|
||||||
const FromList = memo((props:ListParams)=>{
|
const FromList = memo((props: ListParams) => {
|
||||||
const {type="input",value="",style={},labelStyle={},contentStyle={},required=false} = props;
|
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={style} className="form-list">
|
<View style={style} className='form-list'>
|
||||||
<View style={labelStyle} className={`form-list-label ${required&&"form-list-label-required"}`}>{props.label}</View>
|
<View style={labelStyle} className={`form-list-label ${required && 'form-list-label-required'}`}>
|
||||||
<View onClick={props?.onClick} className="form-list-right">
|
{props.label}
|
||||||
{
|
</View>
|
||||||
props.children??
|
<View onClick={props?.onClick} className='form-list-right'>
|
||||||
<View style={contentStyle} onClick={props?.onClick} className="form-list-right-meet">
|
{props.children ?? (
|
||||||
{
|
<View style={contentStyle} onClick={props?.onClick} className='form-list-right-meet'>
|
||||||
type=="input"?
|
{type == 'input' ? (
|
||||||
<View className="form-list-input">
|
<View className='form-list-input'>
|
||||||
<Input value={value} placeholder-class="phcolor" type={props.primordialType||'text'} onInput={props?.onInput} placeholder={props.placeholder} />
|
<Input
|
||||||
{value&&
|
alwaysEmbed={true}
|
||||||
<View><Text onClick={()=>props.onInput&&props.onInput({detail: {value: ""}})} className="iconfont icon-qingkong"/></View>
|
cursorSpacing={150}
|
||||||
}
|
value={value}
|
||||||
</View>:
|
placeholder-class='phcolor'
|
||||||
type=="textarea"?<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />:
|
type={props.primordialType || 'text'}
|
||||||
|
onInput={props?.onInput}
|
||||||
|
placeholder={props.placeholder}
|
||||||
|
/>
|
||||||
|
{value && (
|
||||||
|
<View>
|
||||||
|
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
) : type == 'textarea' ? (
|
||||||
|
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
||||||
|
) : (
|
||||||
<>
|
<>
|
||||||
{
|
{props.value ? <View>{value}</View> : <View className='form-list-right-placeholder'>{props.placeholder}</View>}
|
||||||
props.value?<View>{value}</View>:
|
<View className='form-list-right-enter'>
|
||||||
<View className="form-list-right-placeholder">
|
<Text className='iconfont icon-a-moreback'></Text>
|
||||||
{props.placeholder}
|
|
||||||
</View>
|
</View>
|
||||||
}
|
|
||||||
<View className="form-list-right-enter"><Text className="iconfont icon-a-moreback"></Text></View>
|
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
</View>
|
</View>
|
||||||
}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const A = ()=>{
|
const A = () => {}
|
||||||
|
export default FromList
|
||||||
}
|
|
||||||
export default FromList;
|
|
||||||
|
@ -1,63 +1,64 @@
|
|||||||
|
import { Input, Text, Textarea, View } from '@tarojs/components'
|
||||||
|
import { memo } from 'react'
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
import { Input, Text, Textarea, View } from "@tarojs/components"
|
interface ListParams {
|
||||||
import { memo } from "react"
|
label: string //左边label
|
||||||
import "./index.scss"
|
onInput?: (ev: Object) => void // 输入框输入
|
||||||
|
onClick?: () => any //点击列表
|
||||||
interface ListParams{
|
placeholder?: string // 提示文本
|
||||||
label: string, //左边label
|
children?: any // 插槽
|
||||||
onInput?: (ev:Object)=>void, // 输入框输入
|
|
||||||
onClick?:()=>any, //点击列表
|
|
||||||
placeholder?:string, // 提示文本
|
|
||||||
children?: any, // 插槽
|
|
||||||
type?: string // 类型:1.input,2.textarea,3.select
|
type?: string // 类型:1.input,2.textarea,3.select
|
||||||
value?: any,
|
value?: any
|
||||||
style?: object, //整行样式
|
style?: object //整行样式
|
||||||
labelStyle?: object, // label样式
|
labelStyle?: object // label样式
|
||||||
contentStyle?: object,
|
contentStyle?: object
|
||||||
required?: boolean,
|
required?: boolean
|
||||||
showIcon?: boolean, // 是否显示右边的箭头,type=select
|
showIcon?: boolean // 是否显示右边的箭头,type=select
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单列表
|
// 表单列表
|
||||||
const FromList = memo((props:ListParams)=>{
|
const FromList = memo((props: ListParams) => {
|
||||||
const {type="input",value="",style={},labelStyle={},contentStyle={},required=false,showIcon=true} = props;
|
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={style} className="From-list-certification">
|
<View style={style} className='From-list-certification'>
|
||||||
<View style={labelStyle} className={`From-list-certification-label ${required&&"From-list-certification-label-required"}`}>{props.label}</View>
|
<View style={labelStyle} className={`From-list-certification-label ${required && 'From-list-certification-label-required'}`}>
|
||||||
<View onClick={props?.onClick} className="From-list-certification-right">
|
{props.label}
|
||||||
{
|
</View>
|
||||||
props.children??
|
<View onClick={props?.onClick} className='From-list-certification-right'>
|
||||||
<View style={contentStyle} onClick={props?.onClick} className="From-list-certification-right-meet">
|
{props.children ?? (
|
||||||
{
|
<View style={contentStyle} onClick={props?.onClick} className='From-list-certification-right-meet'>
|
||||||
type=="input"?
|
{type == 'input' ? (
|
||||||
<View className="From-list-certification-input">
|
<View className='From-list-certification-input'>
|
||||||
<Input value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
|
<Input
|
||||||
{value&&
|
alwaysEmbed={true}
|
||||||
<View><Text onClick={()=>props.onInput&&props.onInput({detail: {value: ""}})} className="iconfont icon-qingkong"/></View>
|
cursorSpacing={150}
|
||||||
}
|
value={value}
|
||||||
</View>:
|
placeholder-class='phcolor'
|
||||||
type=="textarea"?<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />:
|
onInput={props?.onInput}
|
||||||
|
placeholder={props.placeholder}
|
||||||
|
/>
|
||||||
|
{value && (
|
||||||
|
<View>
|
||||||
|
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
) : type == 'textarea' ? (
|
||||||
|
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
||||||
|
) : (
|
||||||
<>
|
<>
|
||||||
{
|
{props.value ? <View>{value}</View> : <View className='From-list-certification-right-placeholder'>{props.placeholder}</View>}
|
||||||
props.value?<View>{value}</View>:
|
<View className='From-list-certification-right-enter'>{showIcon && <Text className='iconfont icon-a-moreback'></Text>}</View>
|
||||||
<View className="From-list-certification-right-placeholder">
|
|
||||||
{props.placeholder}
|
|
||||||
</View>
|
|
||||||
}
|
|
||||||
<View className="From-list-certification-right-enter">
|
|
||||||
{showIcon&&<Text className="iconfont icon-a-moreback"></Text>}
|
|
||||||
</View>
|
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
</View>
|
</View>
|
||||||
}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const A = ()=>{
|
const A = () => {}
|
||||||
|
export default FromList
|
||||||
}
|
|
||||||
export default FromList;
|
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
import { Input, View } from "@tarojs/components"
|
import { Input, View } from '@tarojs/components'
|
||||||
import { useEffect, useMemo, useRef, useState } from "react"
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
import styles from "./index.module.scss"
|
import styles from './index.module.scss'
|
||||||
type params = {
|
type params = {
|
||||||
minNum?: number, //最小值
|
minNum?: number //最小值
|
||||||
maxNum?: number, //最大值
|
maxNum?: number //最大值
|
||||||
step?: number, //步长
|
step?: number //步长
|
||||||
defaultNum?: number, //默认值
|
defaultNum?: number //默认值
|
||||||
digits?: number //多少位小数
|
digits?: number //多少位小数
|
||||||
onChange?:(val:number) => void,
|
onChange?: (val: number) => void
|
||||||
onBlue?:(val:number) => void, //失去焦点触发
|
onBlue?: (val: number) => void //失去焦点触发
|
||||||
onClickBtn?:(val:number) => void,
|
onClickBtn?: (val: number) => void
|
||||||
unit?: string,
|
unit?: string
|
||||||
disable?: true|false, //是否禁用
|
disable?: true | false //是否禁用
|
||||||
}
|
}
|
||||||
export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false}: params) => {
|
export default ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false }: params) => {
|
||||||
const [value, setValue] = useState<any>({count:defaultNum})
|
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||||
|
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
if(disable) return false
|
if (disable) return false
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum?maxNum:num_res
|
num_res = num_res >= maxNum ? maxNum : num_res
|
||||||
num_res = formatDigits(num_res)
|
num_res = formatDigits(num_res)
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res))
|
onChange?.(parseFloat(num_res))
|
||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
if(disable) return false
|
if (disable) return false
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum?minNum:num_res
|
num_res = num_res < minNum ? minNum : num_res
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res))
|
onChange?.(parseFloat(num_res))
|
||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
@ -40,8 +40,8 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
//保留小数
|
//保留小数
|
||||||
const formatDigits = (num) => {
|
const formatDigits = (num) => {
|
||||||
num = num + ''
|
num = num + ''
|
||||||
if(num.includes('.')&&digits > 0) {
|
if (num.includes('.') && digits > 0) {
|
||||||
console.log('num::',num.includes('.'))
|
console.log('num::', num.includes('.'))
|
||||||
let res = num.split('.')
|
let res = num.split('.')
|
||||||
let last_num = res[1].substr(0, digits)
|
let last_num = res[1].substr(0, digits)
|
||||||
return res[0] + '.' + last_num
|
return res[0] + '.' + last_num
|
||||||
@ -52,64 +52,59 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
//检查数据
|
//检查数据
|
||||||
const checkData = (val) => {
|
const checkData = (val) => {
|
||||||
let num = parseFloat(val)
|
let num = parseFloat(val)
|
||||||
if(num > maxNum) return maxNum
|
if (num > maxNum) return maxNum
|
||||||
if(num < minNum) return minNum
|
if (num < minNum) return minNum
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onInputEven = (e) => {
|
const onInputEven = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
if(res === '') {
|
if (res === '') {
|
||||||
setValue({...value, count:minNum})
|
setValue({ ...value, count: minNum })
|
||||||
onChange?.(minNum)
|
onChange?.(minNum)
|
||||||
}
|
} else if (!isNaN(Number(res))) {
|
||||||
else if(!isNaN(Number(res))) {
|
|
||||||
let count = formatDigits(res)
|
let count = formatDigits(res)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(parseFloat(count as string))
|
onChange?.(parseFloat(count as string))
|
||||||
} else {
|
} else {
|
||||||
let num = parseFloat(res)
|
let num = parseFloat(res)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(count as number)
|
onChange?.(count as number)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onChange?.(defaultNum)
|
onChange?.(defaultNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBluerEven = () => {
|
const onBluerEven = () => {
|
||||||
let num = parseFloat(value.count)
|
let num = parseFloat(value.count)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onBlue?.(count as number)
|
onBlue?.(count as number)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onBlue?.(defaultNum)
|
onBlue?.(defaultNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.reduce} onClick={() => minus()}>-</View>
|
<View className={styles.reduce} onClick={() => minus()}>
|
||||||
|
-
|
||||||
|
</View>
|
||||||
<View className={styles.input}>
|
<View className={styles.input}>
|
||||||
<Input
|
<Input value={String(value.count)} onInput={onInputEven} onBlur={onBluerEven} type='digit' disabled={disable} alwaysEmbed={true} cursorSpacing={150} />
|
||||||
value={String(value.count)}
|
|
||||||
onInput={onInputEven}
|
|
||||||
onBlur={onBluerEven}
|
|
||||||
type='digit'
|
|
||||||
disabled={disable}
|
|
||||||
/>
|
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.plus} onClick={() => onPlus()}>+</View>
|
<View className={styles.plus} onClick={() => onPlus()}>
|
||||||
|
+
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,35 +1,35 @@
|
|||||||
import { Input, View } from "@tarojs/components"
|
import { Input, View } from '@tarojs/components'
|
||||||
import { useEffect, useMemo, useRef, useState } from "react"
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
import styles from "./index.module.scss"
|
import styles from './index.module.scss'
|
||||||
type params = {
|
type params = {
|
||||||
minNum?: number, //最小值
|
minNum?: number //最小值
|
||||||
maxNum?: number, //最大值
|
maxNum?: number //最大值
|
||||||
step?: number, //步长
|
step?: number //步长
|
||||||
defaultNum?: number, //默认值
|
defaultNum?: number //默认值
|
||||||
digits?: number //多少位小数
|
digits?: number //多少位小数
|
||||||
onChange?:(val:number) => void,
|
onChange?: (val: number) => void
|
||||||
onBlue?:(val:number) => void, //失去焦点触发
|
onBlue?: (val: number) => void //失去焦点触发
|
||||||
onClickBtn?:(val:number) => void,
|
onClickBtn?: (val: number) => void
|
||||||
unit?: string
|
unit?: string
|
||||||
}
|
}
|
||||||
export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = ''}: params) => {
|
export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '' }: params) => {
|
||||||
const [value, setValue] = useState<any>({count:defaultNum})
|
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||||
|
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum?maxNum:num_res
|
num_res = num_res >= maxNum ? maxNum : num_res
|
||||||
num_res = formatDigits(num_res)
|
num_res = formatDigits(num_res)
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res))
|
onChange?.(parseFloat(num_res))
|
||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum?0:num_res
|
num_res = num_res < minNum ? 0 : num_res
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res))
|
onChange?.(parseFloat(num_res))
|
||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
@ -37,8 +37,8 @@ export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, o
|
|||||||
//保留小数
|
//保留小数
|
||||||
const formatDigits = (num) => {
|
const formatDigits = (num) => {
|
||||||
num = num + ''
|
num = num + ''
|
||||||
if(num.includes('.')&&digits > 0) {
|
if (num.includes('.') && digits > 0) {
|
||||||
console.log('num::',num.includes('.'))
|
console.log('num::', num.includes('.'))
|
||||||
let res = num.split('.')
|
let res = num.split('.')
|
||||||
let last_num = res[1].substr(0, digits)
|
let last_num = res[1].substr(0, digits)
|
||||||
return res[0] + '.' + last_num
|
return res[0] + '.' + last_num
|
||||||
@ -49,63 +49,59 @@ export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, o
|
|||||||
//检查数据
|
//检查数据
|
||||||
const checkData = (val) => {
|
const checkData = (val) => {
|
||||||
let num = parseFloat(val)
|
let num = parseFloat(val)
|
||||||
if(num > maxNum) return maxNum
|
if (num > maxNum) return maxNum
|
||||||
if(num < minNum) return minNum
|
if (num < minNum) return minNum
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onInputEven = (e) => {
|
const onInputEven = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
if(res === '') {
|
if (res === '') {
|
||||||
setValue({...value, count:minNum})
|
setValue({ ...value, count: minNum })
|
||||||
onChange?.(minNum)
|
onChange?.(minNum)
|
||||||
}
|
} else if (!isNaN(Number(res))) {
|
||||||
else if(!isNaN(Number(res))) {
|
|
||||||
let count = formatDigits(res)
|
let count = formatDigits(res)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(parseFloat(count as string))
|
onChange?.(parseFloat(count as string))
|
||||||
} else {
|
} else {
|
||||||
let num = parseFloat(res)
|
let num = parseFloat(res)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(count as number)
|
onChange?.(count as number)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onChange?.(defaultNum)
|
onChange?.(defaultNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBluerEven = () => {
|
const onBluerEven = () => {
|
||||||
let num = parseFloat(value.count)
|
let num = parseFloat(value.count)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onBlue?.(count as number)
|
onBlue?.(count as number)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onBlue?.(defaultNum)
|
onBlue?.(defaultNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.reduce} onClick={() => minus()}>-</View>
|
<View className={styles.reduce} onClick={() => minus()}>
|
||||||
|
-
|
||||||
|
</View>
|
||||||
<View className={styles.input}>
|
<View className={styles.input}>
|
||||||
<Input
|
<Input value={String(value.count)} onInput={onInputEven} onBlur={onBluerEven} type='digit' alwaysEmbed={true} cursorSpacing={150} />
|
||||||
value={String(value.count)}
|
|
||||||
onInput={onInputEven}
|
|
||||||
onBlur={onBluerEven}
|
|
||||||
type='digit'
|
|
||||||
/>
|
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.plus} onClick={() => onPlus()}>+</View>
|
<View className={styles.plus} onClick={() => onPlus()}>
|
||||||
|
+
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,17 +1,16 @@
|
|||||||
import { GetProductKindListApi } from "@/api/material";
|
import { GetProductKindListApi } from '@/api/material'
|
||||||
import Popup, {Params as PopuParams} from "@/components/popup"
|
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||||
import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import { useDidShow } from "@tarojs/taro";
|
import { useDidShow } from '@tarojs/taro'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { memo, useEffect, useRef, useState } from "react";
|
import { memo, useEffect, useRef, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val:object) => void //确定搜索
|
onFiltr?: (val: object) => void //确定搜索
|
||||||
onRest?: (val:Object) => void //重置
|
onRest?: (val: Object) => void //重置
|
||||||
} & PopuParams
|
} & PopuParams
|
||||||
export default memo(({onClose, onFiltr, show = false, onRest}:params) => {
|
export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||||
|
|
||||||
//搜索条件
|
//搜索条件
|
||||||
const [filterObj, setFilterObj] = useState({
|
const [filterObj, setFilterObj] = useState({
|
||||||
seriesName: '',
|
seriesName: '',
|
||||||
@ -21,23 +20,23 @@ export default memo(({onClose, onFiltr, show = false, onRest}:params) => {
|
|||||||
element: '',
|
element: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectFieldValue = useRef({width:'幅宽', weight:'克重', element:'成分', seriesName:'系列'})
|
const selectFieldValue = useRef({ width: '幅宽', weight: '克重', element: '成分', seriesName: '系列' })
|
||||||
|
|
||||||
//获取系列
|
//获取系列
|
||||||
const {fetchData: kindFetchData} = GetProductKindListApi()
|
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||||
const [kindList, setKindList] = useState<any[]>([])
|
const [kindList, setKindList] = useState<any[]>([])
|
||||||
const getCategoryList = async () => {
|
const getCategoryList = async () => {
|
||||||
let {data} = await kindFetchData()
|
let { data } = await kindFetchData()
|
||||||
setKindList(data.list)
|
setKindList(data.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
show&&getCategoryList()
|
show && getCategoryList()
|
||||||
}, [show])
|
}, [show])
|
||||||
|
|
||||||
//切换系列
|
//切换系列
|
||||||
const changeKind = (e) => {
|
const changeKind = (e) => {
|
||||||
setFilterObj({...filterObj, seriesId:e.id, seriesName: e.name})
|
setFilterObj({ ...filterObj, seriesId: e.id, seriesName: e.name })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseEven = () => {
|
const onCloseEven = () => {
|
||||||
@ -60,18 +59,18 @@ export default memo(({onClose, onFiltr, show = false, onRest}:params) => {
|
|||||||
|
|
||||||
//提交搜索
|
//提交搜索
|
||||||
const onVerify = () => {
|
const onVerify = () => {
|
||||||
onFiltr?.({data:filterObj, field: selectFieldValue.current})
|
onFiltr?.({ data: filterObj, field: selectFieldValue.current })
|
||||||
onClose?.()
|
onClose?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取幅宽或克重输入值或成分
|
//获取幅宽或克重输入值或成分
|
||||||
const setFieldData = (e, field) => {
|
const setFieldData = (e, field) => {
|
||||||
filterObj[field] = e.detail.value
|
filterObj[field] = e.detail.value
|
||||||
setFilterObj({...filterObj})
|
setFilterObj({ ...filterObj })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
<ScrollView scrollY className={styles.scroll}>
|
<ScrollView scrollY className={styles.scroll}>
|
||||||
@ -79,37 +78,66 @@ export default memo(({onClose, onFiltr, show = false, onRest}:params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>系列</View>
|
<View className={styles.title}>系列</View>
|
||||||
<View className={styles.btn_list}>
|
<View className={styles.btn_list}>
|
||||||
{kindList.map(item => <View key={item.id} onClick={() => changeKind(item)} className={classnames(styles.btn_item, (filterObj.seriesId == item.id)&&styles.select_btn_item)}>{item.name}</View>)}
|
{kindList.map((item) => (
|
||||||
|
<View
|
||||||
|
key={item.id}
|
||||||
|
onClick={() => changeKind(item)}
|
||||||
|
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
||||||
|
{item.name}
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>幅宽</View>
|
<View className={styles.title}>幅宽</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.width} onBlur={(e) => setFieldData(e,'width')} placeholder="请输入幅宽" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.width}
|
||||||
|
onBlur={(e) => setFieldData(e, 'width')}
|
||||||
|
placeholder='请输入幅宽'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>克重</View>
|
<View className={styles.title}>克重</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.weight} onBlur={(e) => setFieldData(e,'weight')} placeholder="请输入克重" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
value={filterObj.weight}
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
onBlur={(e) => setFieldData(e, 'weight')}
|
||||||
|
placeholder='请输入克重'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>kg</View>
|
<View className={styles.unit}>kg</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={(e) => setFieldData(e, 'element')}/>
|
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setFieldData(e, 'element')} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="common_safe_area_y"></View>
|
<View className='common_safe_area_y'></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
<View className={styles.btns_two}>
|
<View className={styles.btns_two}>
|
||||||
<View className={styles.rest_btn} onClick={() => onRestEven()}>重置</View>
|
<View className={styles.rest_btn} onClick={() => onRestEven()}>
|
||||||
<View className={styles.verify_btn } onClick={() => onVerify()}>确认</View>
|
重置
|
||||||
|
</View>
|
||||||
|
<View className={styles.verify_btn} onClick={() => onVerify()}>
|
||||||
|
确认
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
import { GetProductKindListApi } from "@/api/material";
|
import { GetProductKindListApi } from '@/api/material'
|
||||||
import Popup, {Params as PopuParams} from "@/components/popup"
|
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||||
import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import { useDidShow } from "@tarojs/taro";
|
import { useDidShow } from '@tarojs/taro'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val:object) => void
|
onFiltr?: (val: object) => void
|
||||||
} & PopuParams
|
} & PopuParams
|
||||||
export default ({onClose, onFiltr, show = false}:params) => {
|
export default ({ onClose, onFiltr, show = false }: params) => {
|
||||||
|
|
||||||
//搜索条件
|
//搜索条件
|
||||||
const [filterObj, setFilterObj] = useState({
|
const [filterObj, setFilterObj] = useState({
|
||||||
seriesId: '',
|
seriesId: '',
|
||||||
@ -18,24 +17,24 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
//获取系列
|
//获取系列
|
||||||
const {fetchData: kindFetchData} = GetProductKindListApi()
|
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||||
const [kindList, setKindList] = useState<any[]>([])
|
const [kindList, setKindList] = useState<any[]>([])
|
||||||
const getCategoryList = async () => {
|
const getCategoryList = async () => {
|
||||||
let {data} = await kindFetchData()
|
let { data } = await kindFetchData()
|
||||||
setKindList(data.list)
|
setKindList(data.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
show&&getCategoryList()
|
show && getCategoryList()
|
||||||
}, [show])
|
}, [show])
|
||||||
|
|
||||||
//切换系列
|
//切换系列
|
||||||
const changeKind = (e) => {
|
const changeKind = (e) => {
|
||||||
setFilterObj({...filterObj, seriesId:e.id})
|
setFilterObj({ ...filterObj, seriesId: e.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseEven = () => {
|
const onCloseEven = () => {
|
||||||
@ -49,7 +48,7 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -64,21 +63,20 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
const setNumber = (e, field) => {
|
const setNumber = (e, field) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
let num = parseFloat(e.detail.value)
|
let num = parseFloat(e.detail.value)
|
||||||
if(isNaN(num)) {
|
if (isNaN(num)) {
|
||||||
filterObj[field] = null
|
filterObj[field] = null
|
||||||
} else {
|
} else {
|
||||||
filterObj[field] = parseFloat(num.toFixed(2))
|
filterObj[field] = parseFloat(num.toFixed(2))
|
||||||
}
|
}
|
||||||
setFilterObj({...filterObj})
|
setFilterObj({ ...filterObj })
|
||||||
}
|
}
|
||||||
|
|
||||||
const setElement = (e) => {
|
const setElement = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
setFilterObj({...filterObj, element:res})
|
setFilterObj({ ...filterObj, element: res })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
<ScrollView scrollY className={styles.scroll}>
|
<ScrollView scrollY className={styles.scroll}>
|
||||||
@ -86,43 +84,83 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>系列</View>
|
<View className={styles.title}>系列</View>
|
||||||
<View className={styles.btn_list}>
|
<View className={styles.btn_list}>
|
||||||
{kindList.map(item => <View key={item.id} onClick={() => changeKind(item)} className={classnames(styles.btn_item, (filterObj.seriesId == item.id)&&styles.select_btn_item)}>{item.name}</View>)}
|
{kindList.map((item) => (
|
||||||
|
<View
|
||||||
|
key={item.id}
|
||||||
|
onClick={() => changeKind(item)}
|
||||||
|
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
||||||
|
{item.name}
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>幅宽</View>
|
<View className={styles.title}>幅宽</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.minWidth} type="digit" onBlur={(e) => setNumber(e,'minWidth')} placeholder="请输入幅宽" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.minWidth}
|
||||||
|
type='digit'
|
||||||
|
onBlur={(e) => setNumber(e, 'minWidth')}
|
||||||
|
placeholder='请输入幅宽'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>克重</View>
|
<View className={styles.title}>克重</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.minWeight} onBlur={(e) => setNumber(e,'minWeight')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.minWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'minWeight')}
|
||||||
|
placeholder='自定义最低值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.maxWeight} onBlur={(e) => setNumber(e,'maxWeight')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.maxWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'maxWeight')}
|
||||||
|
placeholder='自定义最高值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>g</View>
|
<View className={styles.unit}>g</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)}/>
|
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="common_safe_area_y"></View>
|
<View className='common_safe_area_y'></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
<View className={styles.btns_two}>
|
<View className={styles.btns_two}>
|
||||||
<View className={styles.rest_btn} onClick={() => onRest()}>重置</View>
|
<View className={styles.rest_btn} onClick={() => onRest()}>
|
||||||
<View className={styles.verify_btn } onClick={() => onVerify()}>确认</View>
|
重置
|
||||||
|
</View>
|
||||||
|
<View className={styles.verify_btn} onClick={() => onVerify()}>
|
||||||
|
确认
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,26 +1,29 @@
|
|||||||
import { Input, View } from "@tarojs/components";
|
import { Input, View } from '@tarojs/components'
|
||||||
import styles from "./index.module.scss"
|
import styles from './index.module.scss'
|
||||||
import CloseBtn from "@/components/closeBtn"
|
import CloseBtn from '@/components/closeBtn'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { debounce } from "@/common/util";
|
import { debounce } from '@/common/util'
|
||||||
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from "react";
|
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
clickOnSearch?: (val: string) => void
|
clickOnSearch?: (val: string) => void
|
||||||
disabled?: false|true,
|
disabled?: false | true
|
||||||
placeholder?: string,
|
placeholder?: string
|
||||||
changeOnSearch?:(any) => void,
|
changeOnSearch?: (any) => void
|
||||||
showIcon?: false|true,
|
showIcon?: false | true
|
||||||
placeIcon?: 'out'|'inner',
|
placeIcon?: 'out' | 'inner'
|
||||||
style?: Object,
|
style?: Object
|
||||||
showBtn?: false|true,
|
showBtn?: false | true
|
||||||
btnStyle?: Object,
|
btnStyle?: Object
|
||||||
btnTitle?: string,
|
btnTitle?: string
|
||||||
debounceTime?: number //防抖时间,不设默认为零
|
debounceTime?: number //防抖时间,不设默认为零
|
||||||
defaultValue?: string
|
defaultValue?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(forwardRef(({
|
export default memo(
|
||||||
|
forwardRef(
|
||||||
|
(
|
||||||
|
{
|
||||||
clickOnSearch, //点击筛选按钮触发
|
clickOnSearch, //点击筛选按钮触发
|
||||||
changeOnSearch, //输入文字触发
|
changeOnSearch, //输入文字触发
|
||||||
disabled = false, //是否禁用
|
disabled = false, //是否禁用
|
||||||
@ -31,9 +34,11 @@ export default memo(forwardRef(({
|
|||||||
placeIcon = 'inner', //搜索图标位置:inner在里面,out在外面
|
placeIcon = 'inner', //搜索图标位置:inner在里面,out在外面
|
||||||
btnTitle = '搜索', //搜索文字
|
btnTitle = '搜索', //搜索文字
|
||||||
debounceTime = 0, //防抖时间,不设默认为零
|
debounceTime = 0, //防抖时间,不设默认为零
|
||||||
defaultValue = '' //默认值
|
defaultValue = '', //默认值
|
||||||
}:Params, ref) => {
|
}: Params,
|
||||||
const [inputCon , setInputCon] = useState('')
|
ref,
|
||||||
|
) => {
|
||||||
|
const [inputCon, setInputCon] = useState('')
|
||||||
const debounceTimeRef = useRef(0)
|
const debounceTimeRef = useRef(0)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInputCon(defaultValue)
|
setInputCon(defaultValue)
|
||||||
@ -49,7 +54,7 @@ export default memo(forwardRef(({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
clearInput
|
clearInput,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const clearInput = () => {
|
const clearInput = () => {
|
||||||
@ -68,16 +73,41 @@ export default memo(forwardRef(({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={styles.search_main} >
|
<View className={styles.search_main}>
|
||||||
<View className={styles.search_con}>
|
<View className={styles.search_con}>
|
||||||
{showIcon&&<View className={classnames('iconfont', 'icon-sousuo', styles.icon_a_sousuo1_self, placeIcon=='inner'?styles.icon_inner:styles.icon_out)}></View>}
|
{showIcon && (
|
||||||
<Input placeholderStyle='color:#ABABAB; font-size:26rpx' onConfirm={onSearch} className={classnames(placeIcon=='out'&&styles.input_out)} disabled={disabled} value={inputCon} placeholder={placeholder} onInput={(e) => onInputEven(e)}></Input>
|
<View
|
||||||
{!!inputCon&&<View className={styles.search_closeBtn}>
|
className={classnames(
|
||||||
<CloseBtn onClose={() => clearInput()} styleObj={{width: '20rpx', height:'20rpx', backgroundColor:'#fff', border:'0'}}/>
|
'iconfont',
|
||||||
</View>}
|
'icon-sousuo',
|
||||||
|
styles.icon_a_sousuo1_self,
|
||||||
|
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||||
|
)}></View>
|
||||||
|
)}
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
placeholderStyle='color:#ABABAB; font-size:26rpx'
|
||||||
|
onConfirm={onSearch}
|
||||||
|
className={classnames(placeIcon == 'out' && styles.input_out)}
|
||||||
|
disabled={disabled}
|
||||||
|
value={inputCon}
|
||||||
|
placeholder={placeholder}
|
||||||
|
onInput={(e) => onInputEven(e)}></Input>
|
||||||
|
{!!inputCon && (
|
||||||
|
<View className={styles.search_closeBtn}>
|
||||||
|
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||||
</View>
|
</View>
|
||||||
{showBtn&&<View style={btnStyle} className={styles.btn} onClick = {onSearch}>{btnTitle}</View>}
|
)}
|
||||||
|
</View>
|
||||||
|
{showBtn && (
|
||||||
|
<View style={btnStyle} className={styles.btn} onClick={onSearch}>
|
||||||
|
{btnTitle}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}))
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import { Input, View } from "@tarojs/components";
|
import { Input, View } from '@tarojs/components'
|
||||||
import { memo, ReactHTMLElement, ReactNode, useDebugValue, useMemo } from "react";
|
import { memo, ReactHTMLElement, ReactNode, useDebugValue, useMemo } from 'react'
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
showIcon?: false|true,
|
showIcon?: false | true
|
||||||
disabled?: false|true,
|
disabled?: false | true
|
||||||
placeholder?: string,
|
placeholder?: string
|
||||||
title?: string,
|
title?: string
|
||||||
showTitle?: false|true,
|
showTitle?: false | true
|
||||||
showBorder?: false|true,
|
showBorder?: false | true
|
||||||
changeOnInput?: (string) => void,
|
changeOnInput?: (string) => void
|
||||||
clickOnInput?: () => void,
|
clickOnInput?: () => void
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
height?: string,
|
height?: string
|
||||||
titleStyle?: Object,
|
titleStyle?: Object
|
||||||
styleObj?: Object
|
styleObj?: Object
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo((props: Params) => {
|
export default memo((props: Params) => {
|
||||||
@ -29,24 +28,35 @@ export default memo((props: Params) => {
|
|||||||
changeOnInput,
|
changeOnInput,
|
||||||
clickOnInput,
|
clickOnInput,
|
||||||
height = '80rpx',
|
height = '80rpx',
|
||||||
titleStyle = {}
|
titleStyle = {},
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
let stylen = useMemo(() => {
|
let stylen = useMemo(() => {
|
||||||
if(!showBorder) {
|
if (!showBorder) {
|
||||||
return { borderBottom: 0 }
|
return { borderBottom: 0 }
|
||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
}, [showBorder])
|
}, [showBorder])
|
||||||
return (
|
return (
|
||||||
<View className={styles.searchInput_main} style={{height: height, ...stylen}}>
|
<View className={styles.searchInput_main} style={{ height: height, ...stylen }}>
|
||||||
{showTitle&&<View className={styles.searchInput_title} style={titleStyle}>{title}</View>}
|
{showTitle && (
|
||||||
<View className={styles.searchInput_con}>
|
<View className={styles.searchInput_title} style={titleStyle}>
|
||||||
{!props.children&&<Input disabled={disabled} placeholder={placeholder} onClick={() => clickOnInput?.()} onInput={(e) => changeOnInput?.(e.detail.value)}/>
|
{title}
|
||||||
||<>{props.children}</>
|
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
{showIcon&&<View className={`iconfont icon-jiantou ${styles.icon_more_self}`}></View>}
|
)}
|
||||||
|
<View className={styles.searchInput_con}>
|
||||||
|
{(!props.children && (
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
disabled={disabled}
|
||||||
|
placeholder={placeholder}
|
||||||
|
onClick={() => clickOnInput?.()}
|
||||||
|
onInput={(e) => changeOnInput?.(e.detail.value)}
|
||||||
|
/>
|
||||||
|
)) || <>{props.children}</>}
|
||||||
|
</View>
|
||||||
|
{showIcon && <View className={`iconfont icon-jiantou ${styles.icon_more_self}`}></View>}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
@ -1,15 +1,15 @@
|
|||||||
import { Image, Input, Text, View } from '@tarojs/components'
|
import { Image, Input, Text, View } from '@tarojs/components'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import useLogin from '@/use/useLogin'
|
import useLogin from '@/use/useLogin'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { formatImgUrl } from '@/common/fotmat'
|
import { formatImgUrl } from '@/common/fotmat'
|
||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { alert } from '@/common/common';
|
import { alert } from '@/common/common'
|
||||||
import CloseBtn from '@/components/closeBtn';
|
import CloseBtn from '@/components/closeBtn'
|
||||||
import SuccessBind from './component/successBind';
|
import SuccessBind from './component/successBind'
|
||||||
import Taro, { useDidShow } from "@tarojs/taro";
|
import Taro, { useDidShow } from '@tarojs/taro'
|
||||||
import { BindInvitationInfoApi, GetInvitationInfoApi } from '@/api/user';
|
import { BindInvitationInfoApi, GetInvitationInfoApi } from '@/api/user'
|
||||||
import { debounce, getFilterData, throttle } from '@/common/util';
|
import { debounce, getFilterData, throttle } from '@/common/util'
|
||||||
export default () => {
|
export default () => {
|
||||||
useLogin()
|
useLogin()
|
||||||
|
|
||||||
@ -22,79 +22,92 @@ export default () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//获取业务员信息
|
//获取业务员信息
|
||||||
type Param = {invitation_code: string, name: string, phone: string}
|
type Param = { invitation_code: string; name: string; phone: string }
|
||||||
const [salesMan, setSalesMan] = useState<Param|null>(null)
|
const [salesMan, setSalesMan] = useState<Param | null>(null)
|
||||||
const {fetchData: GetInvitationInfoFetchData} = GetInvitationInfoApi()
|
const { fetchData: GetInvitationInfoFetchData } = GetInvitationInfoApi()
|
||||||
const getInvitationInfo = async () => {
|
const getInvitationInfo = async () => {
|
||||||
let res = await GetInvitationInfoFetchData(getFilterData({...submitData}))
|
let res = await GetInvitationInfoFetchData(getFilterData({ ...submitData }))
|
||||||
res.success?setSalesMan(res.data):setSalesMan(null)
|
res.success ? setSalesMan(res.data) : setSalesMan(null)
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(submitData.invitation_code.length === 4)
|
if (submitData.invitation_code.length === 4) getInvitationInfo()
|
||||||
getInvitationInfo()
|
|
||||||
}, [submitData])
|
}, [submitData])
|
||||||
|
|
||||||
const onInputCode = (e) => {
|
const onInputCode = (e) => {
|
||||||
const value = e.detail.value.replace(/[\W]/g, "")
|
const value = e.detail.value.replace(/[\W]/g, '')
|
||||||
setSubmitData((val) => ({...val, invitation_code:value}))
|
setSubmitData((val) => ({ ...val, invitation_code: value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const oncloseEven = () => {
|
const oncloseEven = () => {
|
||||||
setSubmitData((val) => ({...val, invitation_code:''}))
|
setSubmitData((val) => ({ ...val, invitation_code: '' }))
|
||||||
setSalesMan(null)
|
setSalesMan(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
//绑定业务员
|
//绑定业务员
|
||||||
const [bindShow, setBindShow] = useState(false)
|
const [bindShow, setBindShow] = useState(false)
|
||||||
const {fetchData: bindInvitationInfoFetchData} = BindInvitationInfoApi()
|
const { fetchData: bindInvitationInfoFetchData } = BindInvitationInfoApi()
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
if(!submitData.invitation_code) return alert.error('请输入邀请码')
|
if (!submitData.invitation_code) return alert.error('请输入邀请码')
|
||||||
let res = await bindInvitationInfoFetchData({...submitData})
|
let res = await bindInvitationInfoFetchData({ ...submitData })
|
||||||
if(res.success) setBindShow(() => true)
|
if (res.success) setBindShow(() => true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onScanCode = () => {
|
const onScanCode = () => {
|
||||||
Taro.scanCode({
|
Taro.scanCode({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
setSubmitData(() => ({invitation_code: res.result}))
|
setSubmitData(() => ({ invitation_code: res.result }))
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取粘贴版内容
|
//获取粘贴版内容
|
||||||
const onClipboardData = () => {
|
const onClipboardData = () => {
|
||||||
Taro.getClipboardData({
|
Taro.getClipboardData({
|
||||||
success: function (res){
|
success: function (res) {
|
||||||
let val = res.data.match(/InviteCode:([a-zA-Z0-9]{4})/)
|
let val = res.data.match(/InviteCode:([a-zA-Z0-9]{4})/)
|
||||||
if(val) setSubmitData((e) => ({...e, invitation_code: val?val[1]:''}))
|
if (val) setSubmitData((e) => ({ ...e, invitation_code: val ? val[1] : '' }))
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.bindSalesmanPage_main}>
|
<View className={styles.bindSalesmanPage_main}>
|
||||||
<View className={styles.header_image}>
|
<View className={styles.header_image}>
|
||||||
<Image src={formatImgUrl('/mall/invite_code_bg.png')} mode="aspectFill"/>
|
<Image src={formatImgUrl('/mall/invite_code_bg.png')} mode='aspectFill' />
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.inputCode}>
|
<View className={styles.inputCode}>
|
||||||
<Input maxlength={4} value={submitData.invitation_code} placeholder='请输入邀请码' onInput={onInputCode} type="text" />
|
<Input
|
||||||
<View className={styles.close_btn} >
|
alwaysEmbed={true}
|
||||||
{submitData.invitation_code&&<CloseBtn styleObj={{backgroundColor: '#ccc', color: '#fff'}} onClose={oncloseEven}/>}
|
cursorSpacing={150}
|
||||||
|
maxlength={4}
|
||||||
|
value={submitData.invitation_code}
|
||||||
|
placeholder='请输入邀请码'
|
||||||
|
onInput={onInputCode}
|
||||||
|
type='text'
|
||||||
|
/>
|
||||||
|
<View className={styles.close_btn}>
|
||||||
|
{submitData.invitation_code && <CloseBtn styleObj={{ backgroundColor: '#ccc', color: '#fff' }} onClose={oncloseEven} />}
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.scan_code} onClick={() => onScanCode()}>
|
<View className={styles.scan_code} onClick={() => onScanCode()}>
|
||||||
<Text className={classnames('iconfont icon-saomazhifu', styles.miconfont)}></Text>
|
<Text className={classnames('iconfont icon-saomazhifu', styles.miconfont)}></Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{salesMan&&<View className={styles.salesman_name}><Text>邀请人:</Text><Text>{`${salesMan.name} (${salesMan.phone})`}</Text></View>}
|
{salesMan && (
|
||||||
<View className={classnames(styles.btns, salesMan&&styles.select_btns)} onClick={onSubmit}>提交</View>
|
<View className={styles.salesman_name}>
|
||||||
|
<Text>邀请人:</Text>
|
||||||
|
<Text>{`${salesMan.name} (${salesMan.phone})`}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<View className={classnames(styles.btns, salesMan && styles.select_btns)} onClick={onSubmit}>
|
||||||
|
提交
|
||||||
|
</View>
|
||||||
<View className={styles.message}>
|
<View className={styles.message}>
|
||||||
<Text>温馨提示</Text>
|
<Text>温馨提示</Text>
|
||||||
<Text>1. 新用户授权手机号码后,7天内可以输入邀请码,超过时间不能输入。</Text>
|
<Text>1. 新用户授权手机号码后,7天内可以输入邀请码,超过时间不能输入。</Text>
|
||||||
<Text>2. 一个手机只能输入一次邀请码。输入邀请码。</Text>
|
<Text>2. 一个手机只能输入一次邀请码。输入邀请码。</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className='common_safe_area_y'></View>
|
<View className='common_safe_area_y'></View>
|
||||||
<SuccessBind show={bindShow} onClose={() => setBindShow(false)} saleMan={salesMan?.name}/>
|
<SuccessBind show={bindShow} onClose={() => setBindShow(false)} saleMan={salesMan?.name} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import Popup, {Params as PopuParams} from "@/components/popup"
|
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||||
import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val:object) => void
|
onFiltr?: (val: object) => void
|
||||||
} & PopuParams
|
} & PopuParams
|
||||||
export default ({onClose, onFiltr, show = false}:params) => {
|
export default ({ onClose, onFiltr, show = false }: params) => {
|
||||||
const [filterObj, setFilterObj] = useState({
|
const [filterObj, setFilterObj] = useState({
|
||||||
series: '',
|
series: '',
|
||||||
minWidth: '',
|
minWidth: '',
|
||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
|
|
||||||
})
|
})
|
||||||
const onCloseEven = () => {
|
const onCloseEven = () => {
|
||||||
onClose?.()
|
onClose?.()
|
||||||
@ -28,7 +27,7 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -43,21 +42,20 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
const setNumber = (e, field) => {
|
const setNumber = (e, field) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
let num = parseFloat(e.detail.value)
|
let num = parseFloat(e.detail.value)
|
||||||
if(isNaN(num)) {
|
if (isNaN(num)) {
|
||||||
filterObj[field] = null
|
filterObj[field] = null
|
||||||
} else {
|
} else {
|
||||||
filterObj[field] = parseFloat(num.toFixed(2))
|
filterObj[field] = parseFloat(num.toFixed(2))
|
||||||
}
|
}
|
||||||
setFilterObj({...filterObj})
|
setFilterObj({ ...filterObj })
|
||||||
}
|
}
|
||||||
|
|
||||||
const setElement = (e) => {
|
const setElement = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
setFilterObj({...filterObj, element:res})
|
setFilterObj({ ...filterObj, element: res })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
|
|
||||||
@ -77,39 +75,82 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>幅宽</View>
|
<View className={styles.title}>幅宽</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.minWidth} type="digit" onBlur={(e) => setNumber(e,'minWidth')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.minWidth}
|
||||||
|
type='digit'
|
||||||
|
onBlur={(e) => setNumber(e, 'minWidth')}
|
||||||
|
placeholder='自定义最低值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.maxWidth} type="digit" onBlur={(e) => setNumber(e,'maxWidth')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.maxWidth}
|
||||||
|
type='digit'
|
||||||
|
onBlur={(e) => setNumber(e, 'maxWidth')}
|
||||||
|
placeholder='自定义最高值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>克重</View>
|
<View className={styles.title}>克重</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.minWeight} onBlur={(e) => setNumber(e,'minWeight')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.minWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'minWeight')}
|
||||||
|
placeholder='自定义最低值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.maxWeight} onBlur={(e) => setNumber(e,'maxWeight')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.maxWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'maxWeight')}
|
||||||
|
placeholder='自定义最高值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>g</View>
|
<View className={styles.unit}>g</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)}/>
|
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="common_safe_area_y"></View>
|
<View className='common_safe_area_y'></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
<View className={styles.btns_two}>
|
<View className={styles.btns_two}>
|
||||||
<View className={styles.rest_btn} onClick={() => onRest()}>重置</View>
|
<View className={styles.rest_btn} onClick={() => onRest()}>
|
||||||
<View className={styles.verify_btn } onClick={() => onVerify()}>确认</View>
|
重置
|
||||||
|
</View>
|
||||||
|
<View className={styles.verify_btn} onClick={() => onVerify()}>
|
||||||
|
确认
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -48,7 +48,6 @@ export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonI
|
|||||||
placeholder='请输入文件夹名称'
|
placeholder='请输入文件夹名称'
|
||||||
className={styles.input}
|
className={styles.input}
|
||||||
alwaysEmbed={true}
|
alwaysEmbed={true}
|
||||||
// adjustPosition={true}
|
|
||||||
cursorSpacing={100}
|
cursorSpacing={100}
|
||||||
onInput={changeInput}
|
onInput={changeInput}
|
||||||
value={defaultValue?.name}
|
value={defaultValue?.name}
|
||||||
|
@ -1,37 +1,36 @@
|
|||||||
import { Input, View } from "@tarojs/components"
|
import { Input, View } from '@tarojs/components'
|
||||||
import { useEffect, useMemo, useRef, useState } from "react"
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
import styles from "./index.module.scss"
|
import styles from './index.module.scss'
|
||||||
type params = {
|
type params = {
|
||||||
minNum?: number, //最小值
|
minNum?: number //最小值
|
||||||
maxNum?: number, //最大值
|
maxNum?: number //最大值
|
||||||
step?: number, //步长
|
step?: number //步长
|
||||||
defaultNum?: number, //默认值
|
defaultNum?: number //默认值
|
||||||
digits?: number //多少位小数
|
digits?: number //多少位小数
|
||||||
onChange?:(val: number, obj?: any) => void,
|
onChange?: (val: number, obj?: any) => void
|
||||||
onBlue?:(val:number, obj?: any) => void, //失去焦点触发
|
onBlue?: (val: number, obj?: any) => void //失去焦点触发
|
||||||
onClickBtn?:(val:number, obj?: any) => void,
|
onClickBtn?: (val: number, obj?: any) => void
|
||||||
unit?: string,
|
unit?: string
|
||||||
otherData?: any
|
otherData?: any
|
||||||
}
|
}
|
||||||
export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData}: params) => {
|
export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData }: params) => {
|
||||||
const [value, setValue] = useState<any>({count:defaultNum})
|
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||||
|
|
||||||
|
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum?maxNum:num_res
|
num_res = num_res >= maxNum ? maxNum : num_res
|
||||||
num_res = formatDigits(num_res)
|
num_res = formatDigits(num_res)
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res), otherData)
|
onChange?.(parseFloat(num_res), otherData)
|
||||||
onClickBtn?.(parseFloat(num_res), otherData)
|
onClickBtn?.(parseFloat(num_res), otherData)
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
let {count} = value
|
let { count } = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum?0:num_res
|
num_res = num_res < minNum ? 0 : num_res
|
||||||
setValue({...value, count:num_res})
|
setValue({ ...value, count: num_res })
|
||||||
onChange?.(parseFloat(num_res), otherData)
|
onChange?.(parseFloat(num_res), otherData)
|
||||||
onClickBtn?.(parseFloat(num_res), otherData)
|
onClickBtn?.(parseFloat(num_res), otherData)
|
||||||
}
|
}
|
||||||
@ -39,8 +38,8 @@ export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, o
|
|||||||
//保留小数
|
//保留小数
|
||||||
const formatDigits = (num) => {
|
const formatDigits = (num) => {
|
||||||
num = num + ''
|
num = num + ''
|
||||||
if(num.includes('.')&&digits > 0) {
|
if (num.includes('.') && digits > 0) {
|
||||||
console.log('num::',num.includes('.'))
|
console.log('num::', num.includes('.'))
|
||||||
let res = num.split('.')
|
let res = num.split('.')
|
||||||
let last_num = res[1].substr(0, digits)
|
let last_num = res[1].substr(0, digits)
|
||||||
return res[0] + '.' + last_num
|
return res[0] + '.' + last_num
|
||||||
@ -51,63 +50,59 @@ export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, o
|
|||||||
//检查数据
|
//检查数据
|
||||||
const checkData = (val) => {
|
const checkData = (val) => {
|
||||||
let num = parseFloat(val)
|
let num = parseFloat(val)
|
||||||
if(num > maxNum) return maxNum
|
if (num > maxNum) return maxNum
|
||||||
if(num < minNum) return minNum
|
if (num < minNum) return minNum
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onInputEven = (e) => {
|
const onInputEven = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
if(res === '') {
|
if (res === '') {
|
||||||
setValue({...value, count:minNum})
|
setValue({ ...value, count: minNum })
|
||||||
onChange?.(minNum, otherData)
|
onChange?.(minNum, otherData)
|
||||||
}
|
} else if (!isNaN(Number(res))) {
|
||||||
else if(!isNaN(Number(res))) {
|
|
||||||
let count = formatDigits(res)
|
let count = formatDigits(res)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(parseFloat(count as string), otherData)
|
onChange?.(parseFloat(count as string), otherData)
|
||||||
} else {
|
} else {
|
||||||
let num = parseFloat(res)
|
let num = parseFloat(res)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onChange?.(count as number, otherData)
|
onChange?.(count as number, otherData)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onChange?.(defaultNum, otherData)
|
onChange?.(defaultNum, otherData)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBluerEven = () => {
|
const onBluerEven = () => {
|
||||||
let num = parseFloat(value.count)
|
let num = parseFloat(value.count)
|
||||||
if(!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({...value, count})
|
setValue({ ...value, count })
|
||||||
onBlue?.(count as number, otherData)
|
onBlue?.(count as number, otherData)
|
||||||
} else {
|
} else {
|
||||||
setValue({...value, count:defaultNum})
|
setValue({ ...value, count: defaultNum })
|
||||||
onBlue?.(defaultNum, otherData)
|
onBlue?.(defaultNum, otherData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.reduce} onClick={() => minus()}>-</View>
|
<View className={styles.reduce} onClick={() => minus()}>
|
||||||
|
-
|
||||||
|
</View>
|
||||||
<View className={styles.input}>
|
<View className={styles.input}>
|
||||||
<Input
|
<Input value={String(value.count)} onInput={onInputEven} onBlur={onBluerEven} type='digit' alwaysEmbed={true} cursorSpacing={150} />
|
||||||
value={String(value.count)}
|
|
||||||
onInput={onInputEven}
|
|
||||||
onBlur={onBluerEven}
|
|
||||||
type='digit'
|
|
||||||
/>
|
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.plus} onClick={() => onPlus()}>+</View>
|
<View className={styles.plus} onClick={() => onPlus()}>
|
||||||
|
+
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,21 +1,20 @@
|
|||||||
import Popup, {Params as PopuParams} from "@/components/popup"
|
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||||
import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val:object) => void
|
onFiltr?: (val: object) => void
|
||||||
} & PopuParams
|
} & PopuParams
|
||||||
export default ({onClose, onFiltr, show = false}:params) => {
|
export default ({ onClose, onFiltr, show = false }: params) => {
|
||||||
const [filterObj, setFilterObj] = useState({
|
const [filterObj, setFilterObj] = useState({
|
||||||
series: '',
|
series: '',
|
||||||
minWidth: '',
|
minWidth: '',
|
||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
|
|
||||||
})
|
})
|
||||||
const onCloseEven = () => {
|
const onCloseEven = () => {
|
||||||
onClose?.()
|
onClose?.()
|
||||||
@ -28,7 +27,7 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
minWeight: '',
|
minWeight: '',
|
||||||
maxWeight: '',
|
maxWeight: '',
|
||||||
element: ''
|
element: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -43,21 +42,20 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
const setNumber = (e, field) => {
|
const setNumber = (e, field) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
let num = parseFloat(e.detail.value)
|
let num = parseFloat(e.detail.value)
|
||||||
if(isNaN(num)) {
|
if (isNaN(num)) {
|
||||||
filterObj[field] = null
|
filterObj[field] = null
|
||||||
} else {
|
} else {
|
||||||
filterObj[field] = parseFloat(num.toFixed(2))
|
filterObj[field] = parseFloat(num.toFixed(2))
|
||||||
}
|
}
|
||||||
setFilterObj({...filterObj})
|
setFilterObj({ ...filterObj })
|
||||||
}
|
}
|
||||||
|
|
||||||
const setElement = (e) => {
|
const setElement = (e) => {
|
||||||
let res = e.detail.value
|
let res = e.detail.value
|
||||||
setFilterObj({...filterObj, element:res})
|
setFilterObj({ ...filterObj, element: res })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
|
|
||||||
@ -77,39 +75,82 @@ export default ({onClose, onFiltr, show = false}:params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>幅宽</View>
|
<View className={styles.title}>幅宽</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.minWidth} type="digit" onBlur={(e) => setNumber(e,'minWidth')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.minWidth}
|
||||||
|
type='digit'
|
||||||
|
onBlur={(e) => setNumber(e, 'minWidth')}
|
||||||
|
placeholder='自定义最低值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}><Input value={filterObj.maxWidth} type="digit" onBlur={(e) => setNumber(e,'maxWidth')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
value={filterObj.maxWidth}
|
||||||
|
type='digit'
|
||||||
|
onBlur={(e) => setNumber(e, 'maxWidth')}
|
||||||
|
placeholder='自定义最高值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>克重</View>
|
<View className={styles.title}>克重</View>
|
||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.minWeight} onBlur={(e) => setNumber(e,'minWeight')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.minWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'minWeight')}
|
||||||
|
placeholder='自定义最低值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}><Input type="digit" value={filterObj.maxWeight} onBlur={(e) => setNumber(e,'maxWeight')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/></View>
|
<View className={styles.btn_width}>
|
||||||
|
<Input
|
||||||
|
alwaysEmbed={true}
|
||||||
|
cursorSpacing={150}
|
||||||
|
type='digit'
|
||||||
|
value={filterObj.maxWeight}
|
||||||
|
onBlur={(e) => setNumber(e, 'maxWeight')}
|
||||||
|
placeholder='自定义最高值'
|
||||||
|
placeholderStyle='font-size: 26rpx'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<View className={styles.unit}>g</View>
|
<View className={styles.unit}>g</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)}/>
|
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="common_safe_area_y"></View>
|
<View className='common_safe_area_y'></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
<View className={styles.btns_two}>
|
<View className={styles.btns_two}>
|
||||||
<View className={styles.rest_btn} onClick={() => onRest()}>重置</View>
|
<View className={styles.rest_btn} onClick={() => onRest()}>
|
||||||
<View className={styles.verify_btn } onClick={() => onVerify()}>确认</View>
|
重置
|
||||||
|
</View>
|
||||||
|
<View className={styles.verify_btn} onClick={() => onVerify()}>
|
||||||
|
确认
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,28 +1,27 @@
|
|||||||
|
import FromList from '@/components/FromList'
|
||||||
|
import { Button, Input, Text, Textarea, View } from '@tarojs/components'
|
||||||
|
import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro'
|
||||||
|
import { weightAddApi, weightDetailApi, weightEditApi } from '@/api/weightList'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { alert, retrieval } from '@/common/common'
|
||||||
|
import './index.scss'
|
||||||
|
import useLogin from '@/use/useLogin'
|
||||||
|
|
||||||
import FromList from "@/components/FromList"
|
export default () => {
|
||||||
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
|
|
||||||
import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro"
|
|
||||||
import {weightAddApi, weightDetailApi,weightEditApi} from "@/api/weightList"
|
|
||||||
import { useEffect, useState } from "react"
|
|
||||||
import { alert, retrieval } from "@/common/common"
|
|
||||||
import "./index.scss"
|
|
||||||
import useLogin from "@/use/useLogin"
|
|
||||||
|
|
||||||
export default ()=>{
|
|
||||||
useLogin()
|
useLogin()
|
||||||
const {type,id} = useRouter().params;
|
const { type, id } = useRouter().params
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
if(type=="add"){
|
if (type == 'add') {
|
||||||
setNavigationBarTitle({title:"添加码单信息"})
|
setNavigationBarTitle({ title: '添加码单信息' })
|
||||||
}else{
|
} else {
|
||||||
initalFormData();
|
initalFormData()
|
||||||
setNavigationBarTitle({title:"修改码单信息"})
|
setNavigationBarTitle({ title: '修改码单信息' })
|
||||||
}
|
}
|
||||||
},[]);
|
}, [])
|
||||||
// 获取编辑码单信息
|
// 获取编辑码单信息
|
||||||
const {fetchData: getFromData} = weightDetailApi()
|
const { fetchData: getFromData } = weightDetailApi()
|
||||||
const initalFormData = async ()=>{
|
const initalFormData = async () => {
|
||||||
const detail = await getFromData({id});
|
const detail = await getFromData({ id })
|
||||||
setFormData({
|
setFormData({
|
||||||
title: detail.data.title,
|
title: detail.data.title,
|
||||||
purchaser_name: detail.data.purchaser_name,
|
purchaser_name: detail.data.purchaser_name,
|
||||||
@ -33,74 +32,108 @@ export default ()=>{
|
|||||||
}
|
}
|
||||||
// 保存
|
// 保存
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
title: "",
|
title: '',
|
||||||
purchaser_name: "",
|
purchaser_name: '',
|
||||||
phone: "",
|
phone: '',
|
||||||
is_default: false,
|
is_default: false,
|
||||||
id: 0
|
id: 0,
|
||||||
})
|
})
|
||||||
const rules = {
|
const rules = {
|
||||||
title: [{
|
title: [
|
||||||
message: "请输入抬头"
|
{
|
||||||
}],
|
message: '请输入抬头',
|
||||||
purchaser_name: [{
|
},
|
||||||
message: "请输入客户名称"
|
],
|
||||||
}],
|
purchaser_name: [
|
||||||
phone: [{
|
{
|
||||||
message: "请输入正确的电话号码", regex: /^1[3|5|6|9|2|8|7]\d{9}$/
|
message: '请输入客户名称',
|
||||||
}]
|
},
|
||||||
|
],
|
||||||
|
phone: [
|
||||||
|
{
|
||||||
|
message: '请输入正确的电话号码',
|
||||||
|
regex: /^1[3|5|6|9|2|8|7]\d{9}$/,
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
const {fetchData} = weightAddApi()
|
const { fetchData } = weightAddApi()
|
||||||
const {fetchData: editFetch} = weightEditApi()
|
const { fetchData: editFetch } = weightEditApi()
|
||||||
const handleSave = ()=>{
|
const handleSave = () => {
|
||||||
retrieval(formData, rules).then(async ()=>{
|
retrieval(formData, rules)
|
||||||
const result = type=="add"?await fetchData({
|
.then(async () => {
|
||||||
|
const result =
|
||||||
|
type == 'add'
|
||||||
|
? await fetchData({
|
||||||
title: formData.title,
|
title: formData.title,
|
||||||
purchaser_name: formData.purchaser_name,
|
purchaser_name: formData.purchaser_name,
|
||||||
phone: formData.phone,
|
phone: formData.phone,
|
||||||
is_default: formData.is_default,
|
is_default: formData.is_default,
|
||||||
}):await editFetch({
|
})
|
||||||
|
: await editFetch({
|
||||||
title: formData.title,
|
title: formData.title,
|
||||||
purchaser_name: formData.purchaser_name,
|
purchaser_name: formData.purchaser_name,
|
||||||
phone: formData.phone,
|
phone: formData.phone,
|
||||||
is_default: formData.is_default,
|
is_default: formData.is_default,
|
||||||
id: formData.id
|
id: formData.id,
|
||||||
});
|
})
|
||||||
if(result.success){
|
if (result.success) {
|
||||||
Taro.eventCenter.trigger("weightList:refresh");
|
Taro.eventCenter.trigger('weightList:refresh')
|
||||||
Taro.navigateBack();
|
Taro.navigateBack()
|
||||||
alert.success("保存成功");
|
alert.success('保存成功')
|
||||||
}else{
|
} else {
|
||||||
alert.error(result.msg);
|
alert.error(result.msg)
|
||||||
}
|
}
|
||||||
}).catch((message)=>{
|
})
|
||||||
|
.catch((message) => {
|
||||||
alert.none(message)
|
alert.none(message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 监听表单完善
|
// 监听表单完善
|
||||||
const [hozon, setHozon] = useState(false);
|
const [hozon, setHozon] = useState(false)
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
if(retrieval){
|
if (retrieval) {
|
||||||
retrieval(formData).then(()=>setHozon(true)).catch(()=>setHozon(false))
|
retrieval(formData)
|
||||||
|
.then(() => setHozon(true))
|
||||||
|
.catch(() => setHozon(false))
|
||||||
}
|
}
|
||||||
},[formData])
|
}, [formData])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="add-address">
|
<View className='add-address'>
|
||||||
<FromList onInput={(ev:any)=>setFormData({...formData,title:ev.detail.value})} value={formData["title"]} label="抬头" placeholder="请输入码单显示抬头信息"/>
|
<FromList
|
||||||
<FromList onInput={(ev:any)=>setFormData({...formData,purchaser_name:ev.detail.value})} value={formData["purchaser_name"]} label="客户" placeholder="请输入码单显示客户名称"/>
|
onInput={(ev: any) => setFormData({ ...formData, title: ev.detail.value })}
|
||||||
<FromList onInput={(ev:any)=>setFormData({...formData,phone:ev.detail.value})} value={formData["phone"]} label="联系方式" placeholder="请输入码单显示联系号码"/>
|
value={formData['title']}
|
||||||
<View className="add-address-default">
|
label='抬头'
|
||||||
|
placeholder='请输入码单显示抬头信息'
|
||||||
|
/>
|
||||||
|
<FromList
|
||||||
|
onInput={(ev: any) => setFormData({ ...formData, purchaser_name: ev.detail.value })}
|
||||||
|
value={formData['purchaser_name']}
|
||||||
|
label='客户'
|
||||||
|
placeholder='请输入码单显示客户名称'
|
||||||
|
/>
|
||||||
|
<FromList
|
||||||
|
onInput={(ev: any) => setFormData({ ...formData, phone: ev.detail.value })}
|
||||||
|
value={formData['phone']}
|
||||||
|
label='联系方式'
|
||||||
|
placeholder='请输入码单显示联系号码'
|
||||||
|
/>
|
||||||
|
<View className='add-address-default'>
|
||||||
<Text>设为默认地址</Text>
|
<Text>设为默认地址</Text>
|
||||||
<View onClick={()=>setFormData({...formData ,is_default: !formData.is_default})}>
|
<View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}>
|
||||||
{
|
{formData.is_default ? (
|
||||||
formData.is_default?<View className="add-address-default-active"><Text className="iconfont icon-tick"/></View>
|
<View className='add-address-default-active'>
|
||||||
:<View className="add-address-default-noactive"></View>
|
<Text className='iconfont icon-tick' />
|
||||||
}
|
</View>
|
||||||
|
) : (
|
||||||
|
<View className='add-address-default-noactive'></View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Button style={{"background": hozon?'#007aff':''}} hoverClass="none" className="add-address-save" onClick={handleSave}>保存</Button>
|
<Button style={{ background: hozon ? '#007aff' : '' }} hoverClass='none' className='add-address-save' onClick={handleSave}>
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user