Commit a853d466 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:

parent e4def9b4
import React, { useState } from 'react';
import { Input, Space, Select, Button } from 'antd';
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons';
import { useFieldState, FormPath, FormEffectHooks } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PublicApi } from '@/services/api';
const { Option } = Select
// export interface SearchProps {
// value: string;
// mutators: any;
// props: any;
// }
const CustomInputSearch = props => {
console.log(props);
// const [state, setState] = useFieldState({
// filterSearch: false,
// });
const justifyAlign = props.props['x-component-props'].align || 'flex-end';
// const changeFilterVisible = () => {
// if (state.filterSearch) {
// props.form.reset({
// // 清除FILTER_PARAMS下所有字段
// selector: `*.${FORM_FILTER_PATH}.*`,
// });
// }
// setState({
// filterSearch: !state.filterSearch,
// });
// };
const [brandData, setBrandData] = useState<any>([])
const [brandValue, setBrandValue] = useState(undefined)
const handleBrandSearch = (value: any) => { // end value
console.log(value, 'handleBrandSearch')
if (value) {
PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => {
if (res.code === 1000)
setBrandData(res.data)
})
} else {
setBrandData([])
}
}
return (
<Space size={20} style={{ justifyContent: justifyAlign, width: '100%' }}>
<Select
showSearch={true}
showArrow={true}
placeholder="品牌"
value={brandValue}
defaultActiveFirstOption={false}
filterOption={false}
onSearch={value => handleBrandSearch(value)}
onChange={v => props.mutators.change(v)}
notFoundContent={null}
style={{ width: '174px', lineHeight: '32px' }}
{...props.props['x-component-props']}
>
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
{/* <Input.Search
value={props.value || ''}
onChange={e => props.mutators.change(e.target.value)}
onSearch={(_, e) => {
e.preventDefault();
props.form.submit();
}}
{...props.props['x-component-props']}
/> */}
</Space>
);
};
CustomInputSearch.defaultProps = {};
CustomInputSearch.isFieldComponent = true;
export default CustomInputSearch;
......@@ -9,6 +9,7 @@ import CustomStatus from './components/CustomStatus';
import CustomAddArray from './components/CustomAddArray';
import CustomSlider from './components/CustomSlider';
import Search from './components/Search';
import CustomInputSearch from './components/CustomInputSearch'
import Submit from './components/Submit';
import Text from './components/Text';
import CardCheckBox from './components/CardCheckBox';
......@@ -82,6 +83,7 @@ const NiceForm: React.FC<NiceFormProps> = props => {
CustomAddArray,
CustomSlider,
Search,
CustomInputSearch,
Submit,
Text,
CardCheckBox,
......
......@@ -108,7 +108,10 @@ const AddGoods = () => {
}
const onFinish = (values:any) => {
PublicApi.postProductGoodsSaveOrUpdateGoods({...values})
PublicApi.postProductGoodsSaveOrUpdateGoods({...values}).then(res => {
if(res.code === 1000)
history.goBack()
})
};
return (<PageHeaderWrapper
......
......@@ -314,9 +314,9 @@ const Goods: React.FC<{}> = () => {
console.log('取消删除')
}
const handleSearch = (val: string) => {
const handleSearch = (val?: string) => {
console.log(val)
let obj = { ...filterParams, name: val }
let obj = val ? { ...filterParams, name: val } : { ...filterParams }
setFilterParams(obj)
//@ts-ignore
ref.current.reload(obj)
......@@ -402,6 +402,28 @@ const Goods: React.FC<{}> = () => {
tableProps={{ rowKey: "id" }}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
// <NiceForm
// actions={formActions}
// onSubmit={values => ref.current.reload(values)}
// expressionScope={{
// controllerBtns,
// }}
// effects={($, actions) => {
// useStateFilterSearchLinkageEffect(
// $,
// actions,
// 'name',
// FORM_FILTER_PATH,
// );
// // useAsyncInitSelect(
// // ['memberType', 'roleId', 'level', 'source'],
// // fetchSearchItems,
// // );
// }}
// schema={goodsSchema}
// />
<Row>
<Col span={24}>
<Row gutter={[16,16]} justify="space-between" style={{marginBottom:0}}>
......@@ -475,6 +497,9 @@ const Goods: React.FC<{}> = () => {
<Col span={4}>
<Input name="batch" value={filterParams.batch} onChange={(e)=>setFilterParams({...filterParams, batch: e.target.value})} placeholder="导入批次"></Input>
</Col>
<Col>
<Button type="primary" onClick={()=>handleSearch()}>查询</Button>
</Col>
</Col>
</Row>
</Col>
......
......@@ -51,15 +51,9 @@ export const goodsSchema: ISchema = {
},
brandId: {
type: 'string',
enum: [],
'x-component': 'CustomInputSearch',
'x-component-props': {
placeholder: '品牌',
showSearch: true,
showArrow: true,
filterOption: false,
defaultActiveFirstOption: false,
notFoundContent: false,
style: { width: '100%' },
},
},
customerCategoryId: {
......
......@@ -128,10 +128,12 @@ const AddProducts: React.FC<{}> = (props) => {
_params.id = id ? id : null
console.log(_params,'_params')
PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => {
console.log(res, 'res')
setIsEnableCheck(false)
//@ts-ignore
setReponseId(res.data)
if(res.code === 1000){
setIsEnableCheck(false)
//@ts-ignore
setReponseId(res.data)
history.goBack()
}
})
}).catch(error => {
message.error("请完善表单必填项!")
......
......@@ -8,17 +8,16 @@
padding: 0;
li{
padding-left: 24px;
height: 32px;
line-height: 32px;
// height: 32px;
// line-height: 32px;
color: #172B4D;
display: flex;
justify-content: space-between;
margin: 8px 0;
cursor: pointer;
// span{
// padding-top: 12px;
// padding-bottom: 12px;
// }
span{
padding-right: 16px;
}
a{
color: #97A0AF;
float: right;
......
......@@ -48,6 +48,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const [attributeObjArr, setAttributeObjArr] = useState<any[]>([])
const [attributeValObjArr, setAttributeValObjArr] = useState<any[]>([])
const [validatorArray, setValidatorArray] = useState<any>([])
const [colums, setColumns] = useState<ColumnType<any>[]>()
const { ProductStore } = store
const {
......@@ -339,6 +341,19 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
priceForm.setFieldsValue({unitName: option.children})
}
// 校验数值范围
const validatorNumberRange = (rule, value, callback) => {
try {
setValidatorArray([...validatorArray, value])
console.log(value, [...validatorArray, value], 'rule')
if(value.numberMin >= value.numberMax){
throw new Error('请正确输入数值范围')
}
} catch (err) {
// callback(err)
}
}
return (<>
<Form
{...layout}
......@@ -347,7 +362,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
labelAlign="left"
ref={priceFormRef}
colon={false}
initialValues={productInfoByEdit?.id ? getPriceAttributeFormParamsByEdit : {}}
initialValues={productInfoByEdit?.id ? getPriceAttributeFormParamsByEdit : {isMemberPrice: false}}
autoComplete="off"
>
<Form.Item
......@@ -407,7 +422,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
transform: (value) => Number(value)
}]}
>
<Input placeholder="请输入最小起订数" />
<InputNumber style={{width: '100%'}} min={0} placeholder="请输入最小起订数" />
</Form.Item>
<Form.Item
name="priceType"
......@@ -441,10 +456,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</Tooltip>
</span>
}
rules={[{
required: true,
message: '请选择会员折扣'
}]}
// rules={[{
// required: true,
// message: '请选择会员折扣'
// }]}
valuePropName="checked"
>
<Checkbox>允许使用会员折扣价购买</Checkbox>
......@@ -499,10 +514,24 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
fieldKey={[field.fieldKey, 'numberRange']}
key={'_' + field.fieldKey}
noStyle
// rules={[
// {
// validator: validatorNumberRange
// }
// ]}
>
<Input.Group compact>
<Form.Item name={[field.name, 'numberRange', 'numberMin']} noStyle>
<Input style={{ width: 100, textAlign: 'center' }} placeholder="最小数量" />
<Form.Item
name={[field.name, 'numberRange', 'numberMin']}
noStyle
rules={[
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '小数点后仅限三位',
}
]}
>
<InputNumber style={{ width: 100, textAlign: 'center' }} placeholder="最小数量" />
</Form.Item>
<Input
style={{
......@@ -514,8 +543,17 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
placeholder="~"
disabled
/>
<Form.Item name={[field.name, 'numberRange', 'numberMax']} noStyle>
<Input
<Form.Item
name={[field.name, 'numberRange', 'numberMax']}
noStyle
rules={[
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '小数点后仅限三位',
}
]}
>
<InputNumber
className={styles.siteInputRight}
style={{
width: 100,
......@@ -532,8 +570,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
fieldKey={[field.fieldKey, 'numberPrice']}
key={'__' + field.fieldKey}
noStyle
rules={[
{
pattern: /^\d+(\.\d{1,4})?$/,
message: '小数点后仅限四位',
}
]}
>
<Input style={{ width: '50%', marginLeft: 24 }} placeholder="请输入单价" />
<InputNumber style={{ width: '50%', marginLeft: 24 }} placeholder="请输入单价" />
</Item>
</Col>
<Col span={4}>
......@@ -549,9 +593,18 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</Form.Item> : <Form.Item
label={planPrice===3?"所需积分":"单价"}
name="uniquePrice"
rules={[{ required: true, message: planPrice===3?'请输入积分!':'请输入价格!' }]}
rules={[
{
required: true,
message: planPrice===3?'请输入积分!':'请输入价格!'
},
{
pattern: planPrice!==3 && /^\d+(\.\d{1,4})?$/,
message: planPrice!==3 && '小数点后仅限四位',
}
]}
>
<Input placeholder={planPrice===3?"请输入积分":"请输入价格"} />
<InputNumber style={{width: '100%'}} placeholder={planPrice===3?"请输入积分":"请输入价格"} />
</Form.Item>
}
</Form>
......
......@@ -109,16 +109,39 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
}
const beforeUpload = (file: UploadFile) => {
console.log(file,'file')
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg';
if (!isJpgOrPng) {
message.error('仅支持上传JPEG/JPG/PNG文件!')
}
const isLt2M = file.size / 1024 / 1024 < 2;
const isLt2M = file.size / 1024 < 600;
if (!isLt2M) {
message.error('上传图片不超过2MB!');
}
return isJpgOrPng && isLt2M;
return isJpgOrPng && isLt2M && isSize(file, 800, 800);
}
//检测尺寸
const isSize = (file, w, h) => {
return new Promise((resolve, reject) => {
let width = w;
let height = h;
let _URL = window.URL || window.webkitURL;
let img = new Image();
img.onload = function() {
let valid = img.width < width && img.height < height;
valid ? resolve() : reject();
};
img.src = _URL.createObjectURL(file);
}).then(
() => {
return file;
},
() => {
message.error(file.name + "图片尺寸不符合要求,请修改后重新上传!");
return Promise.reject();
}
);
};
const handlePreview = async file => {
if (!file.url && !file.preview) {
......
......@@ -126,7 +126,7 @@ const FastModifyPrice: React.FC<{}> = () => {
else if (record.status === 3)
component = (<><span className="commonStatusValid"></span>审核通过</>)
else if (record.status === 4)
component = (<><span className="commonStatusInvalid">审核不通过</span></>)
component = (<><span className="commonStatusInvalid"></span>审核不通过</>)
else if (record.status === 5)
component = (<span style={{ color: '#00B37A', padding: '2px 5px', background: 'rgba(235,247,242,1)', borderRadius: '4px' }}>已上架</span>)
else if (record.status === 6)
......
......@@ -524,9 +524,9 @@ const Products: React.FC<{}> = () => {
console.log(value, 'handleClassChange')
}
const handleSearch = (val: string) => {
const handleSearch = (val?: string) => {
console.log(val)
let obj = {...filterParams, name: val}
let obj = val ? {...filterParams, name: val} : { ...filterParams }
setFilterParams(obj)
//@ts-ignore
ref.current.reload(obj)
......@@ -682,6 +682,9 @@ const Products: React.FC<{}> = () => {
/>
</Input.Group>
</Col>
<Col>
<Button type="primary" onClick={()=>handleSearch()}>查询</Button>
</Col>
</Col>
</Row>
</Col>
......
......@@ -202,7 +202,7 @@ const viewProducts: React.FC<{}> = () => {
const content = <>
<Descriptions colon={true} style={{paddingLeft:128}}>
<Descriptions.Item label="商品品牌">{productDetail?.brand?.name}</Descriptions.Item>
<Descriptions.Item label="商品品类">{productDetail?.customerCategoryFullName}</Descriptions.Item>
<Descriptions.Item label="商品品类">{productDetail?.customerCategory?.fullName}</Descriptions.Item>
<Descriptions.Item label="上架商城">
{
productDetail?.commodityShopList?.length>0 && productDetail.commodityShopList.map((item, index)=><span key={index}>{item.name}&nbsp;</span>)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment