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

fix:货品品牌非必填,商品阶梯价格起始阶段控制,商品阶梯价格设置切换异常

parent 4714db4d
......@@ -57,7 +57,7 @@ const RowStyleLayout = styled(props => <div {...props} />)`
`
const CardCheckBox = (props) => {
const { dataSource = [] } = props.props['x-component-props']
const { dataSource = [], type = 'checkbox' } = props.props['x-component-props']
const value: number[] = props.value || []
const handleChange = (id) => {
......@@ -69,7 +69,8 @@ const CardCheckBox = (props) => {
const newValue = findItemAndDelete(value, id)
props.mutators.change(newValue)
} else {
props.mutators.change([...value, id])
// 扩展单选模式
type === 'radio' ? props.mutators.change([id]) : props.mutators.change([...value, id])
}
}
......
......@@ -222,12 +222,12 @@ const AddGoods = () => {
<Form.Item
name={['brand', 'id']}
label="品牌"
rules={[
{
required: true,
message: '请填入品牌'
},
]}
// rules={[
// {
// required: true,
// message: '请填入品牌'
// },
// ]}
>
{/* <Input placeholder="最长40个字符、20个汉字" /> */}
<Select
......
......@@ -319,9 +319,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
// console.log('生成传输数据', combineAttributeArray, attributeObjArr, attributeValObjArr, tableDataSource)
Array.isArray(combineAttributeArray) ? combineAttributeArray.map((item, index)=>{ // 非数组情况下默认无组合 从table数据中获取 // 当属性减少的时候 这个combine数组还是之前的 /* code1 */
let _tempArr: any = []
console.log(item, '0')
Array.isArray(item) ? item.map((_item, _index) => { /* code2 */
console.log(item, _item, '1')
let _tempObject: any = {};
_tempObject.customerAttribute = {
......@@ -507,8 +505,9 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
[]
)
let result = range.reduce((a, b) => { if(a<b) return b })
// console.log(result, 'result')
// console.log(result, range, 'result')
if(!result) throw new Error('请正确输入阶梯数量范围');
if(range[0]!==minOrderNumber) throw new Error('阶段的起始值必须为最小起订数');
callback()
}
} catch (err) {
......@@ -521,6 +520,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setPriceForm.resetFields() // 先清空
setIsBatchSetting(true) // 点击置为true
setSetPriceModal(true)
setLadderPrice(false)
}
/**
......
......@@ -25,12 +25,14 @@ const AddRule:React.FC<{}> = (props) => {
// 整体表单提交
const formSubmit = async (values) => {
// const params = omit(values, ['NO_SUBMIT3'])
console.log(values, 'values')
// await PublicApi.postOrderTradingRulesAdd(params)
// setTimeout(() => {
// history.goBack(-1)
// }, 1000)
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)
}, 1000)
}
return (
......
......@@ -20,6 +20,7 @@ import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import Search from '@/components/NiceForm/components/Search'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import Submit from '@/components/NiceForm/components/Submit'
import SelectProcesss from './selectProcesss'
export interface RuleSettingProps {
addSchemaAction: ISchemaFormActions,
......@@ -31,7 +32,7 @@ export interface RuleSettingProps {
const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [productRowSelection, productRowCtl] = useRowSelectionTable({customKey: 'productId'})
const [productRowSelection, productRowCtl] = useRowSelectionTable({customKey: 'id'})
const {
id,
......@@ -43,12 +44,20 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// useUnitPreview(initValue, addSchemaAction)
const fetchProductList = async (params) => {
const tradingRulesId = addSchemaAction.getFieldValue('transactionProcesssId')
const res = await PublicApi.getOrderTradingRulesProductList({
...params,
tradingRulesId,
})
return res.data
const shopIds = addSchemaAction.getFieldValue('shopIds')
if(shopIds.length){
let shopInfo: any = GlobalConfig.web.shopInfo.filter(item => item.id === shopIds[0])
const res = await PublicApi.getProductCommodityCommonGetCommodityDetailList({
...params,
shopType: shopInfo[0].type,
environment: shopInfo[0].environment,
})
return res.data
}else{
message.error('请先选择适用商城!')
return []
}
}
// table删除商品
......@@ -74,35 +83,43 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const tableColumns = [
{
dataIndex: 'productId',
dataIndex: 'id',
title: 'ID',
key: 'productId'
key: 'id'
},
{
dataIndex: 'productName',
dataIndex: 'name',
title: '商品名称',
key: 'productName',
render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.productId}`}>{_}</EyePreview>
key: 'name',
render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview>
},
{
dataIndex: 'category',
dataIndex: 'customerCategoryName',
title: '品类',
key: 'category'
key: 'customerCategoryName'
},
{
dataIndex: 'brand',
dataIndex: 'brandName',
title: '品牌',
key: 'brand'
key: 'brandName'
},
{
dataIndex: 'productPrice',
title: '商品定价',
key: 'productPrice'
dataIndex: 'priceType',
title: '商品定价',
key: 'priceType',
render: (text:any, reocrd:any)=>{
if(text===1)
return '现货价格'
else if(text===2)
return '价格需要询价'
else if(text===3)
return '积分兑换商品'
},
},
{
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.productId)}>删除</Button>
render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button>
}
]
......@@ -123,29 +140,37 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const columnsSetProduct: any[] = [
{
dataIndex: 'productId',
dataIndex: 'id',
title: 'ID',
key: 'productId'
key: 'id'
},
{
dataIndex: 'productName',
dataIndex: 'name',
title: '商品名称',
key: 'productName'
key: 'name'
},
{
dataIndex: 'category',
dataIndex: 'customerCategoryName',
title: '品类',
key: 'category'
key: 'customerCategoryName'
},
{
dataIndex: 'brand',
dataIndex: 'brandName',
title: '品牌',
key: 'brand'
key: 'brandName'
},
{
dataIndex: 'productPrice',
dataIndex: 'priceType',
title: '商品定价',
key: 'productPrice'
key: 'priceType',
render: (text:any, reocrd:any)=>{
if(text===1)
return '现货价格'
else if(text===2)
return '价格需要询价'
else if(text===3)
return '积分兑换商品'
},
},
]
......@@ -153,7 +178,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const formProduct: ISchema = {
type: 'object',
properties: {
productName: {
name: {
type: 'string',
'x-component': 'ModalSearch',
'x-component-props': {
......@@ -176,7 +201,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
},
},
properties: {
categoryId: {
customerCategoryId: {
type: 'string',
"x-component": 'SearchSelect',
"x-component-props": {
......@@ -223,6 +248,9 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
tableColumns,
tableAddButton,
}}
components={{
SelectProcesss,
}}
effects={($, { setFieldState }) => {
FormEffectHooks.onFormInputChange$().subscribe(() => {
onFieldChange()
......@@ -252,12 +280,15 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
{
ctx: {
schema: formProduct,
components: { ModalSearch: Search, SearchSelect, Submit } ,
components: {
ModalSearch: Search,
SearchSelect, Submit,
} ,
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'productName',
'name',
FORM_FILTER_PATH,
);
}
......@@ -265,7 +296,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
}
tableProps={{
rowKey: 'productId'
rowKey: 'id'
}}
/>
......
import React, { useState, useRef, useEffect } from 'react'
import styled from 'styled-components'
import { ISchemaFormProps, ISchemaFieldProps, ISchemaFieldComponentProps, createFormActions, useFieldState } from '@formily/antd'
import { Button, Space, Row, Col, Tag } from 'antd'
import { PlusOutlined, DeleteColumnOutlined, EditOutlined, DeleteOutlined, CaretUpOutlined, CaretDownOutlined, EyeOutlined } from '@ant-design/icons'
import cx from 'classnames'
import { PublicApi } from '@/services/api'
const SelectStyles = styled((props) => <div className='select-list' {...props}></div>)`
.select_style_border {
border: 1px solid #EBECF0;
margin-top: 20px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 14px;
cursor: pointer;
line-height: 28px;
position:relative;
}
.select_style_border.active {
border: 1px solid #00B382;
}
.select_style_border.active::after {
content: '';
position: absolute;
width: 0;
height: 0;
border-bottom: 12px solid #00B37A;
border-left: 12px solid transparent;
bottom: 0;
right: 0;
z-index: 5;
}
`
enum ProcessTagColor {
'red',
'orange',
'purple',
'blue'
}
enum ProcessTagType {
'订单交易流程',
'售后换货流程',
'售后退货流程',
'售后维修流程'
}
const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const [formInitValue, setFormInitValue] = useState<any>(null)
const [state, setFieldState] = useFieldState({
dataSource: [],
showMore: false
})
const { dataSource, showMore } = state
const { value, mutators, editable } = props
useEffect(() => {
PublicApi.getOrderTradingRulesTransactionProcessList().then(res => {
setFieldState({
dataSource: res.data,
showMore
})
})
}, [])
const showDataSource = showMore ? dataSource : [...dataSource].splice(0, 3)
const handleCheck = (id) => {
if (editable) {
mutators.change(id)
}
}
const toogleMore = () => {
setFieldState({
dataSource,
showMore: !showMore
})
}
const renderProcessType = (v: any) => {
return <Tag color={ProcessTagColor[v.type-1]}>
{ProcessTagType[v.type-1]}
</Tag>
}
return (
<div style={{width: '100%'}}>
<SelectStyles>
{
showDataSource.map(v => <div key={v.id} onClick={() => handleCheck(v.id)} className={cx('select_style_border', value === v.id ? 'active' : '')}>
<div>
<Row style={{color: '#172B4D'}}>
<Col>{v.name}</Col>
<Col style={{marginLeft: 6}}>
{
renderProcessType(v)
}
</Col>
</Row>
<div style={{color: '#6B778C'}}>{v.explain}</div>
</div>
</div>)
}
</SelectStyles>
{ dataSource.length > 3 &&
<div onClick={toogleMore} style={{textAlign: 'center', cursor: 'pointer'}}>
显示更多{showMore ? <CaretDownOutlined /> : <CaretUpOutlined/>}
</div>
}
</div>
)
}
SelectProcesss.defaultProps = {}
SelectProcesss.isFieldComponent = true;
export default SelectProcesss
\ No newline at end of file
......@@ -52,13 +52,30 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"transactionProcesssId": {
type: 'string',
title: '流程选择',
required: true,
"x-component": 'SearchSelect',
"x-component": 'SelectProcesss',
"x-mega-props": {
style: {
full: true
}
},
"x-component-props": {
placeholder: '请选择交易流程',
className: 'fixed-ant-selected-down',
fetchSearch: PublicApi.getOrderTradingRulesTransactionProcessList,
dataSource: []
},
"x-rules": [
{
required: true,
message: '请选择收货方式'
}
],
// required: true,
// "x-component": 'SearchSelect',
// "x-component-props": {
// placeholder: '请选择交易流程',
// className: 'fixed-ant-selected-down',
// fetchSearch: PublicApi.getOrderTradingRulesTransactionProcessList,
// },
},
MEGA_LAYOUT1_1: {
type: 'object',
......@@ -110,7 +127,8 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: GlobalConfig.web.shopInfo
dataSource: GlobalConfig.web.shopInfo,
type: 'radio' // CardCheckBox 单选模式
},
"title": "适用商城",
required: true,
......
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