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

fix:新增交易规则

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