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

fix:新增交易规则

parent d2ce1e22
...@@ -259,6 +259,7 @@ const SetPrice:React.FC<IProps> = (props) => { ...@@ -259,6 +259,7 @@ const SetPrice:React.FC<IProps> = (props) => {
let _data = selectData.map(item => { let _data = selectData.map(item => {
let price = priceTableData.filter(_i => _i.id === item.id)[0]['单价'] let price = priceTableData.filter(_i => _i.id === item.id)[0]['单价']
delete item.id
return {...item, unitPrice: price} return {...item, unitPrice: price}
}) })
......
...@@ -125,7 +125,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => { ...@@ -125,7 +125,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
} }
const handleBrandSearch = (value?: any) => { // end value const handleBrandSearch = (value?: any) => { // end value
PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => { PublicApi.getProductSelectGetSelectBrand({ name: value||'' }).then(res => {
if (res.code === 1000) if (res.code === 1000)
setBrandData(res.data) setBrandData(res.data)
}) })
......
...@@ -166,6 +166,20 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => { ...@@ -166,6 +166,20 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
_isDisabled = _isPrice && !_isUpdateAttribute _isDisabled = _isPrice && !_isUpdateAttribute
} }
// 校验字节
const validatorByte = (rule, value, callback) => {
try {
let str = value
str = str.replace(/[\u4e00-\u9fa5]/g, 'OO')
if(str.length > 60)
throw new Error('最多输入60个字符,30个汉字');
else
callback()
} catch (err) {
callback(err)
}
}
return ( return (
<> <>
{ {
...@@ -238,13 +252,15 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => { ...@@ -238,13 +252,15 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
rules={attrItem.isEmpty && [{ rules={attrItem.isEmpty && [{
required: true, required: true,
message: '此项为必填项' message: '此项为必填项'
},{
validator: validatorByte
}]} }]}
> >
<TextArea <TextArea
disabled={_isDisabled} disabled={_isDisabled}
onChange={(v)=>onChange(v, attrItem)} onChange={(v)=>onChange(v, attrItem)}
maxLength={50} maxLength={60}
placeholder="最多输入50个字符" placeholder="最多输入60个字符,30个汉字"
rows={4} rows={4}
/> />
</Form.Item> </Form.Item>
......
...@@ -244,12 +244,12 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -244,12 +244,12 @@ const DirectChannel: React.FC<{}> = () => {
// 判断所选商品 priceType, source, status一致 // 判断所选商品 priceType, source, status一致
const judgeType = () => { const judgeType = () => {
let sourceArr = Array.from(new Set(selectRow.map((item:any) => item.channelCommodity.source))) // let sourceArr = Array.from(new Set(selectRow.map((item:any) => item.channelCommodity.source)))
let priceTypeArr = Array.from(new Set(selectRow.map((item:any) => item.channelCommodity.commodity.priceType))) let priceTypeArr = Array.from(new Set(selectRow.map((item:any) => item.channelCommodity.commodity.priceType)))
let statusArr = Array.from(new Set(selectRow.map((item:any) => item.status))) let statusArr = Array.from(new Set(selectRow.map((item:any) => item.status)))
return { return {
isPassJudge: sourceArr.length === 1 && priceTypeArr.length === 1 && statusArr.length ===1, isPassJudge: priceTypeArr.length === 1 && statusArr.length ===1,
source: sourceArr, // source: sourceArr,
priceType: priceTypeArr priceType: priceTypeArr
} }
} }
...@@ -262,7 +262,7 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -262,7 +262,7 @@ const DirectChannel: React.FC<{}> = () => {
if(_judge.isPassJudge){ if(_judge.isPassJudge){
setUpDownModal(true) setUpDownModal(true)
// 获取渠道商品批量上架商城 // 获取渠道商品批量上架商城
PublicApi.getProductChannelCommodityGetShopBatch({priceType: _judge.priceType[0], source: _judge.source[0]}).then(res => { PublicApi.getProductChannelCommodityGetShopBatch({priceType: _judge.priceType[0]}).then(res => {
const { data } = res const { data } = res
setShopsBatchOption(data) setShopsBatchOption(data)
setCheckedValues([]) setCheckedValues([])
......
...@@ -55,6 +55,7 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -55,6 +55,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
const [ladderPrice, setLadderPrice] = useState(false) const [ladderPrice, setLadderPrice] = useState(false)
const [submitParams, setSubmitParams] = useState<any>() const [submitParams, setSubmitParams] = useState<any>()
const flagRef = useRef(false) // 价格数据是否被模态框替换
useEffect(() => { useEffect(() => {
...@@ -87,7 +88,7 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -87,7 +88,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
// 获取商品规格列表 // 获取商品规格列表
const fetchSpecData = () => { const fetchSpecData = () => {
PublicApi.getProductChannelCommodityGetCommodityUnitPriceByChannel({id: history.location.query.commodityId}).then(res => { PublicApi.getProductChannelCommodityGetCommodityUnitPriceByChannel({id: history.location.query.id}).then(res => {
const { data } = res const { data } = res
setOriginTableData(data) setOriginTableData(data)
if(data.length > 0) if(data.length > 0)
...@@ -186,7 +187,7 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -186,7 +187,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
return ( return (
<> <>
<Button type='link' onClick={()=>clickSetPrice(record)}>{priceType===3?'设置积分':'设置价格'}</Button> <Button type='link' onClick={()=>clickSetPrice(record)}>{priceType===3?'设置积分':'设置价格'}</Button>
<Button type='link' onClick={()=>clickDelete(record)}>删除</Button> { channelDetails.status !== 6 && <Button type='link' onClick={()=>clickDelete(record)}>删除</Button> }
</> </>
) )
} }
...@@ -195,12 +196,13 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -195,12 +196,13 @@ const ModifyDirectChannel:React.FC<{}> = () => {
if(!noModal){ if(!noModal){
setPriceTableData(selectSpecRow) setPriceTableData(selectSpecRow)
setVisibleAddSpec(false) setVisibleAddSpec(false)
flagRef.current = true
} }
} }
const handleCancelAddSpec = () => { const handleCancelAddSpec = () => {
setVisibleAddSpec(false) setVisibleAddSpec(false)
setSelectedSpecRowKeys([]) // setSelectedSpecRowKeys([])
} }
const clickSetPrice = (record: any) => { const clickSetPrice = (record: any) => {
...@@ -268,6 +270,7 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -268,6 +270,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
let _temp: any = {} let _temp: any = {}
_temp.unitPrice = item['单价'] _temp.unitPrice = item['单价']
_temp.goods = { id: item['goodsId'] } _temp.goods = { id: item['goodsId'] }
_temp.id = item['id']
// 移除item行数据的多余字段 余下属性 // 移除item行数据的多余字段 余下属性
delete item.goodsId delete item.goodsId
delete item['索引'] delete item['索引']
...@@ -290,12 +293,15 @@ const ModifyDirectChannel:React.FC<{}> = () => { ...@@ -290,12 +293,15 @@ const ModifyDirectChannel:React.FC<{}> = () => {
}) })
setSubmitParams(_data) setSubmitParams(_data)
console.log(priceTableData, _priceTableData, _data, 'params') // console.log(priceTableData, _priceTableData, _data, 'params')
} }
const clickDelete = (record: any) => { const clickDelete = (record: any) => {
setPriceTableData(priceTableData => [...priceTableData].filter(item => item.id != record.id)) setPriceTableData(priceTableData => [...priceTableData].filter(item => item.id != record.id))
setSelectedSpecRowKeys(selectedSpecRowKeys => [...selectedSpecRowKeys].filter(item => item != record.id)) setSelectedSpecRowKeys(selectedSpecRowKeys => [...selectedSpecRowKeys].filter(item => item != record.id))
if(!flagRef.current){
PublicApi.postProductChannelCommodityDeleteChannelCommodityPrice({id: record.id})
}
} }
const changeLadderPrice = (e: any) => { const changeLadderPrice = (e: any) => {
......
...@@ -28,7 +28,6 @@ const AddRule:React.FC<{}> = (props) => { ...@@ -28,7 +28,6 @@ const AddRule:React.FC<{}> = (props) => {
values.products = values.products.map(item => ({ productId: item.id, productName: item.name, category: item.customerCategoryName, productPrice: item.priceType, brand: item.brandName })) values.products = values.products.map(item => ({ productId: item.id, productName: item.name, category: item.customerCategoryName, productPrice: item.priceType, brand: item.brandName }))
values.isElectronicContract = values.isElectronicContract ? 1 : 0 values.isElectronicContract = values.isElectronicContract ? 1 : 0
const params = omit(values, ['state']) // 移除不需要的字段 const params = omit(values, ['state']) // 移除不需要的字段
console.log(values, params, 'values')
await PublicApi.postOrderTradingRulesAdd(params) await PublicApi.postOrderTradingRulesAdd(params)
setTimeout(() => { setTimeout(() => {
history.goBack(-1) history.goBack(-1)
......
...@@ -41,7 +41,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -41,7 +41,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
} = usePageStatus() } = usePageStatus()
const initValue = useInitValue(PublicApi.getOrderTradingRulesDetails) const initValue = useInitValue(PublicApi.getOrderTradingRulesDetails)
// useUnitPreview(initValue, addSchemaAction) useUnitPreview(initValue, addSchemaAction)
const fetchProductList = async (params) => { const fetchProductList = async (params) => {
const shopIds = addSchemaAction.getFieldValue('shopIds') const shopIds = addSchemaAction.getFieldValue('shopIds')
......
...@@ -21,14 +21,16 @@ export const createAddContractTemplateEffect = (context: ISchemaFormActions) => ...@@ -21,14 +21,16 @@ export const createAddContractTemplateEffect = (context: ISchemaFormActions) =>
export const useUnitPreview = (initValue, context) => { export const useUnitPreview = (initValue, context) => {
useEffect(() => { useEffect(() => {
if (initValue) { context.setFieldValue('isElectronicContract', initValue?.isElectronicContract ? true : false)
context.setFieldState('inventory', state => { // console.log(initValue, 'init')
if (!state.props['x-props']) { // if (initValue) {
state.props['x-props'] = {} // context.setFieldState('inventory', state => {
} // if (!state.props['x-props']) {
state.props['x-props'].addonAfter = <div style={{marginLeft: 4}}>{initValue.unit}</div> // state.props['x-props'] = {}
}) // }
context.setFieldValue('itemNo', initValue.itemNo) // state.props['x-props'].addonAfter = <div style={{marginLeft: 4}}>{initValue.unit}</div>
} // })
// context.setFieldValue('itemNo', initValue.itemNo)
// }
}, [initValue]) }, [initValue])
} }
\ No newline at end of file
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