Commit 3f6288f2 authored by GuanHua's avatar GuanHua
parents c3b23dc9 c66800e3
...@@ -337,42 +337,30 @@ const Goods: React.FC<{}> = () => { ...@@ -337,42 +337,30 @@ const Goods: React.FC<{}> = () => {
setFilterParams(obj) setFilterParams(obj)
} }
const handleBrandSearch = (value: any) => { // end value const handleBrandSearch = (value?: any) => { // end value
console.log(value, 'handleBrandSearch') PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => {
if (value) { if (res.code === 1000)
PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => { setBrandData(res.data)
if (res.code === 1000) })
setBrandData(res.data)
})
} else {
setBrandData([])
}
} }
const handleBrandChange = (value: any) => { const handleBrandChange = (value: any) => {
setBrandValue(value) setBrandValue(value)
console.log(value, 'handleBrandChange')
let obj = { ...filterParams, brandId: value } let obj = { ...filterParams, brandId: value }
setFilterParams(obj) setFilterParams(obj)
} }
const handleClassSearch = (value: any) => { const handleClassSearch = (value?: any) => {
console.log(value, 'handleClassSearch') PublicApi.getProductSelectGetSelectCustomerCategory({ name: value }).then(res => {
if (value) { if (res.code === 1000)
PublicApi.getProductSelectGetSelectCustomerCategory({ name: value }).then(res => { setClassData(res.data)
if (res.code === 1000) })
setClassData(res.data)
})
} else {
setClassData([])
}
} }
const handleClassChange = (value: any) => { const handleClassChange = (value: any) => {
setClassValue(value) setClassValue(value)
let obj = { ...filterParams, customerCategoryId: value } let obj = { ...filterParams, customerCategoryId: value }
setFilterParams(obj) setFilterParams(obj)
console.log(value, 'handleClassChange')
} }
const controllerBtns = ( const controllerBtns = (
...@@ -472,6 +460,7 @@ const Goods: React.FC<{}> = () => { ...@@ -472,6 +460,7 @@ const Goods: React.FC<{}> = () => {
filterOption={false} filterOption={false}
onSearch={handleBrandSearch} onSearch={handleBrandSearch}
onChange={handleBrandChange} onChange={handleBrandChange}
onFocus={()=>handleBrandSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{width:'100%'}} style={{width:'100%'}}
> >
...@@ -488,6 +477,7 @@ const Goods: React.FC<{}> = () => { ...@@ -488,6 +477,7 @@ const Goods: React.FC<{}> = () => {
filterOption={false} filterOption={false}
onSearch={handleClassSearch} onSearch={handleClassSearch}
onChange={handleClassChange} onChange={handleClassChange}
onFocus={()=>handleClassSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{width:'100%'}} style={{width:'100%'}}
> >
......
...@@ -79,7 +79,7 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -79,7 +79,7 @@ const AddProducts: React.FC<{}> = (props) => {
}) })
try{ try{
if(productAttributeAndImageParams.length>0){ if(productAttributeAndImageParams.length>0){
console.log(productAttributeAndImageParams,'____') console.log(productAttributeAndImageParams,'____') // 所有属性共用的情况下 item只有第一项有图片
productAttributeAndImageParams.map(_item => { productAttributeAndImageParams.map(_item => {
if(_item.goodsCustomerAttributeList.length>0){ if(_item.goodsCustomerAttributeList.length>0){
_item.goodsCustomerAttributeList.map(__item => { _item.goodsCustomerAttributeList.map(__item => {
...@@ -88,11 +88,13 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -88,11 +88,13 @@ const AddProducts: React.FC<{}> = (props) => {
}) })
} }
if(_item.commodityPic.length>0){ if(_item.commodityPic.length>0){
_item.commodityPic = _item.commodityPic.map(__item => { // 编辑情况下兼顾手动添加图片列表属性
return __item?.response?.data || __item?.url // 编辑情况下兼顾手动添加图片列表属性 _item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url)
})
}else{ }else{
throw new Error('每项请至少上传一张商品图片!') if(isAllAttributePic && productAttributeAndImageParams[0].commodityPic.length>0) //处理所有属性共用
_item.commodityPic = productAttributeAndImageParams[0].commodityPic
else
throw new Error('每项请至少上传一张商品图片!')
} }
}) })
} }
...@@ -114,12 +116,10 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -114,12 +116,10 @@ const AddProducts: React.FC<{}> = (props) => {
commodityRemark: productDescription, commodityRemark: productDescription,
isAllAttributePic: isAllAttributePic, isAllAttributePic: isAllAttributePic,
} }
_params.minOrder = Number(_params.minOrder)
_params.logistics.weight = Number(_params.logistics.weight)
// 处理地址 // 处理地址
let _commodityAreaList:any = [] let _commodityAreaList:any = []
_params.commodityAreaList.length > 0 && _params.commodityAreaList.map(_itme => { _params.commodityAreaList.length > 0 && areaOption.length > 0 && _params.commodityAreaList.map(_itme => {
if(_itme){ if(_itme && _itme.length > 0){
let _temp: any = {} let _temp: any = {}
let pobj = areaOption.filter(_=>_.code===_itme[0])[0] let pobj = areaOption.filter(_=>_.code===_itme[0])[0]
let cobj = pobj.areaResponses.filter(__=>__.code===_itme[1])[0] let cobj = pobj.areaResponses.filter(__=>__.code===_itme[1])[0]
...@@ -134,8 +134,13 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -134,8 +134,13 @@ const AddProducts: React.FC<{}> = (props) => {
} }
}) })
// 增加不限区域字段 // 增加不限区域字段
_commodityAreaList.length > 0 ? _params.isAllArea = false : _params.isAllArea = true if(_commodityAreaList.length > 0){
_params.commodityAreaList = _commodityAreaList _params.isAllArea = false
_params.commodityAreaList = _commodityAreaList
}else{
_params.isAllArea = true
delete _params.commodityAreaList
}
const { id } = history.location.query const { id } = history.location.query
_params.id = id ? id : null _params.id = id ? id : null
console.log(_params,'_params') console.log(_params,'_params')
...@@ -152,7 +157,10 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -152,7 +157,10 @@ const AddProducts: React.FC<{}> = (props) => {
message.error(e.message) message.error(e.message)
}).catch(error => { }).catch(error => {
console.log(error, '_error') console.log(error, '_error')
message.error(error.message) if(error.messge)
message.error(error.message)
else
message.error(error.errorFields[0].errors.toString())
}) })
}catch(e){ }catch(e){
message.error(e.message) message.error(e.message)
......
...@@ -106,16 +106,11 @@ const BasicInfoForm: React.FC<Iprops> = (props) => { ...@@ -106,16 +106,11 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
console.log(values,'原values') console.log(values,'原values')
} }
const handleBrandSearch = (value: any) => { // end value const handleBrandSearch = (value?: any) => { // end value
console.log(value, 'handleBrandSearch') PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => {
if (value) { if (res.code === 1000)
PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => { setBrandData(res.data)
if (res.code === 1000) })
setBrandData(res.data)
})
} else {
setBrandData([])
}
} }
const handleBrandChange = (value: any) => { const handleBrandChange = (value: any) => {
...@@ -210,13 +205,14 @@ const BasicInfoForm: React.FC<Iprops> = (props) => { ...@@ -210,13 +205,14 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
<Select <Select
showSearch={true} showSearch={true}
showArrow={true} showArrow={true}
placeholder="请选择品牌" placeholder="请输入或选择商品品牌"
allowClear allowClear
value={brandValue} value={brandValue}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
filterOption={false} filterOption={false}
onSearch={handleBrandSearch} onSearch={handleBrandSearch}
onChange={handleBrandChange} onChange={handleBrandChange}
onFocus={()=>handleBrandSearch(null)}
style={{ width: '100%' }} style={{ width: '100%' }}
> >
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)} {brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
...@@ -279,7 +275,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => { ...@@ -279,7 +275,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
> >
<Select <Select
mode="tags" mode="tags"
placeholder="请选择或输入商品卖点" placeholder="请输入或选择商品卖点"
maxTagCount={3} maxTagCount={3}
tagRender={tagRender} tagRender={tagRender}
/> />
......
...@@ -74,7 +74,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => { ...@@ -74,7 +74,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
labelAlign="left" labelAlign="left"
ref={logisticsFormRef} ref={logisticsFormRef}
colon={false} colon={false}
initialValues={history.location.query?.id ? productInfoByEdit.logistics : {}} initialValues={history.location.query?.id ? productInfoByEdit.logistics : {deliveryType:1, carriageType:1}}
autoComplete="off" autoComplete="off"
> >
<Form.Item <Form.Item
...@@ -86,7 +86,6 @@ const LogisticsForm: React.FC<Iprops> = (props) => { ...@@ -86,7 +86,6 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
message: '请选择配送方式' message: '请选择配送方式'
}, },
]} ]}
initialValue={1}
> >
<Radio.Group onChange={changeDeliveryType}> <Radio.Group onChange={changeDeliveryType}>
<Radio value={1}>物流(默认)</Radio> <Radio value={1}>物流(默认)</Radio>
...@@ -104,7 +103,6 @@ const LogisticsForm: React.FC<Iprops> = (props) => { ...@@ -104,7 +103,6 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
message: '请选择运费方式' message: '请选择运费方式'
}, },
]} ]}
initialValue={1}
> >
<Radio.Group onChange={(e)=>setCarriageType(e.target.value)}> <Radio.Group onChange={(e)=>setCarriageType(e.target.value)}>
<Radio value={1}>卖家承担运费(默认)</Radio> <Radio value={1}>卖家承担运费(默认)</Radio>
...@@ -112,7 +110,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => { ...@@ -112,7 +110,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="重量" label={<>重量<i style={{color:'red'}}>&nbsp;*</i></>}
style={{position: 'relative'}} style={{position: 'relative'}}
> >
<Form.Item <Form.Item
......
...@@ -80,17 +80,17 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -80,17 +80,17 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
useEffect(()=>{ useEffect(()=>{
constructedCallback() constructedCallback()
console.log('重新构造')
},[productName, selectedGoods, productSelectAttribute, planPrice]) },[productName, selectedGoods, productSelectAttribute, planPrice])
/* 构建表格列和data */ /* 构建表格列和data */
const constructedCallback = () => { const constructedCallback = () => {
console.log(productName,'name')
let _col = []; let _col = [];
let col_productName = { title: '商品名称', dataIndex: '商品名称', key: '商品名称' } let col_productName = { title: '商品名称', dataIndex: '商品名称', key: '商品名称' }
_col.push(col_productName) _col.push(col_productName)
let _priceAttribute = productSelectAttribute.filter(_item=>_item.isPrice) let _priceAttribute = productSelectAttribute.filter(_item=>_item.isPrice)
let len = _priceAttribute.length let len = _priceAttribute.length
console.log(productName, _priceAttribute, len, productSelectAttribute, _tableDataSource, '---construct---')
let _temp_attributeObjArr = [] // 取id备用 let _temp_attributeObjArr = [] // 取id备用
let _temp_attributeValObjArr = [] // 取id备用 let _temp_attributeValObjArr = [] // 取id备用
let _attributeNameArr = [] let _attributeNameArr = []
...@@ -109,7 +109,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -109,7 +109,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_temp_attributeValObjArr.push(_tempObjArr) _temp_attributeValObjArr.push(_tempObjArr)
}) })
} }
console.log(_priceAttribute, _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr, '>>>>>') // ................................... console.log(_priceAttribute, _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr, '---constructimg---') // ..............................
if(selectedGoods.length>0){ if(selectedGoods.length>0){
_col.push({ _col.push({
title: '对应货品', title: '对应货品',
...@@ -163,6 +163,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -163,6 +163,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
) )
} }
}) })
setColumns(_col) setColumns(_col)
// 生成表格data // 生成表格data
...@@ -173,7 +174,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -173,7 +174,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
console.log(combineArray,'combine') console.log(combineArray,'combine')
let _tableData: any[] = [] let _tableData: any[] = []
if(combineArray?.length>0){ // length存在 表示表格的行数 if(combineArray?.length>0){ // length存在 表示表格的行数(有价格属性组合)
combineArray.map((_rowArr: any[], i: any) => { // _rowArr 属性值数组 combineArray.map((_rowArr: any[], i: any) => { // _rowArr 属性值数组
let _tempObj: any = { 索引: i ,商品名称: productName } let _tempObj: any = { 索引: i ,商品名称: productName }
Array.isArray(_rowArr) ? _rowArr.map((__rowArr, index) => { Array.isArray(_rowArr) ? _rowArr.map((__rowArr, index) => {
...@@ -193,16 +194,16 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -193,16 +194,16 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tableData.push(_tempObj) _tableData.push(_tempObj)
}) })
}else{ // length不存在,默认只有商品名称一行 }else{ // length不存在,默认只有商品名称一行(无价格属性组合)只有一行的情况下单价可能有,可能阶梯价,也可能没有
let _tempObj: any = { 索引: 0 ,商品名称: productName } let _tempObj: any = { 索引: 0 ,商品名称: productName }
_tempObj['对应货品'] = selectedGoods.length > 0 ? selectedGoods[0].id : 0 // 编辑情况下 对应货品id和单价 特殊处理 _tempObj['对应货品'] = selectedGoods.length > 0 ? selectedGoods[0].id : 0 // 编辑情况下 对应货品id和单价 特殊处理
_tempObj['单价'] = {} _tempObj['单价'] = productInfoByEdit?.unitPriceAndPicList[0]?.unitPrice || {}
_tableData.push(_tempObj) _tableData.push(_tempObj)
} }
console.log(_tableData, '_tableData') // 只有一项 变动情况下表格数据的key获取不到 console.log(_tableData, '_tableData') // 只有一项 变动情况下表格数据的key获取不到 //..............Bug:再进来这里依旧有数据..................
_tableDataSource = _tableData _tableDataSource = _tableData
setTableDataSource(_tableDataSource) setTableDataSource(productName ? _tableDataSource : []) // 通过商品名称来判断是否显示表格数据
constructedPrarams() constructedPrarams()
} }
...@@ -302,10 +303,15 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -302,10 +303,15 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let _row = { ...curretSetPriceRow, 单价: _priceRange } let _row = { ...curretSetPriceRow, 单价: _priceRange }
let newTabeData = [..._tableDataSource] let newTabeData = [..._tableDataSource]
newTabeData[curretSetPriceRow['索引']] = _row console.log(newTabeData, 'newTableData')
if(isBatchSetting){ // 判断是否批量设置价格
_tableDataSource.map(_item => _item['单价'] = _priceRange)
}else{
newTabeData[curretSetPriceRow['索引']] = _row
}
_tableDataSource = newTabeData _tableDataSource = newTabeData
setTableDataSource(_tableDataSource) setTableDataSource(_tableDataSource)
// console.log(_tableDataSource, curretSetPriceRow, v,'setPriceOk') console.log(_tableDataSource, curretSetPriceRow, v, isBatchSetting, 'setPriceOk')
}) })
} }
...@@ -315,6 +321,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -315,6 +321,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
} }
const clickSetPrice = (record: any) => { const clickSetPrice = (record: any) => {
setIsBatchSetting(false) // 点击行操作批量置为false
setCurrentSetPriceRow(record) setCurrentSetPriceRow(record)
setSetPriceModal(true) setSetPriceModal(true)
console.log(record, 'record') // 通过判断key字符串'0-0' 是否是阶梯价格 注:空对象时候{}为新建状态 console.log(record, 'record') // 通过判断key字符串'0-0' 是否是阶梯价格 注:空对象时候{}为新建状态
...@@ -352,19 +359,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -352,19 +359,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
} }
} }
const handleUnitSearch = (value:any) => { const handleUnitSearch = (value?:any) => {
if (value) { PublicApi.getProductSelectGetSelectCnUnit({name: value}).then(res=>{
PublicApi.getProductSelectGetSelectCnUnit({name: value}).then(res=>{ if(res.code === 1000)
if(res.code === 1000) setUnitData(res.data)
setUnitData(res.data) })
})
} else {
setUnitData([])
}
} }
const handleUnitChange = (value:any, option: any) => { const handleUnitChange = (value:any, option: any) => {
console.log(value, option,'change value')
setUnitValue(value) setUnitValue(value)
priceForm.setFieldsValue({unitName: option.children}) priceForm.setFieldsValue({unitName: option.children})
} }
...@@ -394,7 +396,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -394,7 +396,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const clickBatchSetPrice = () => { const clickBatchSetPrice = () => {
console.log('批量设置价格') console.log('批量设置价格')
setIsBatchSetting(!isBatchSetting) setPriceForm.resetFields() // 先清空
setIsBatchSetting(true) // 点击置为true
setSetPriceModal(true) setSetPriceModal(true)
} }
...@@ -429,12 +432,13 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -429,12 +432,13 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
<Select <Select
showSearch={true} showSearch={true}
showArrow={true} showArrow={true}
placeholder="请输入单位" placeholder="请输入或选择单位"
value={unitValue} value={unitValue}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
filterOption={false} filterOption={false}
onSearch={handleUnitSearch} onSearch={handleUnitSearch}
onChange={(value,option)=>handleUnitChange(value, option)} onChange={(value,option)=>handleUnitChange(value, option)}
onFocus={()=>handleUnitSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{width:'100%'}} style={{width:'100%'}}
> >
...@@ -506,13 +510,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -506,13 +510,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</Form> </Form>
{/* 批量设置按钮 */} {/* 批量设置按钮 */}
{ {
planPrice != 2 && <Button type="text" style={{float: 'right'}} onClick={clickBatchSetPrice}><SettingOutlined />{planPrice === 3 ? '批量设置积分' : '批量设置价格'}</Button> planPrice != 2 && productName && <Button type="text" style={{float: 'right'}} onClick={clickBatchSetPrice}><SettingOutlined />{planPrice === 3 ? '批量设置积分' : '批量设置价格'}</Button>
} }
<Table <Table
rowKey="索引" rowKey="索引"
dataSource={tableDataSource} dataSource={tableDataSource}
columns={planPrice === 2 ? colums.slice(0, colums.length-2) : colums} columns={planPrice === 2 ? colums.slice(0, colums.length-2) : colums}
pagination={false} pagination={false}
locale={{emptyText:<>暂无数据<br />请先完善商品基本信息项!</>}}
style={{clear: 'both'}} style={{clear: 'both'}}
/> />
{/* 设置价格 */} {/* 设置价格 */}
......
...@@ -210,7 +210,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => { ...@@ -210,7 +210,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
</Button> </Button>
</Form.Item> */} </Form.Item> */}
</Form> </Form>
{attributesData?.length === 0 && "请先选择基本信息中商品品类项!"} {attributesData?.length === 0 && "请先完善商品基本信息项!"}
</>) </>)
} }
......
...@@ -52,7 +52,9 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -52,7 +52,9 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
useEffect(()=>{ useEffect(()=>{
let _priceAttributeParams: any = [] let _priceAttributeParams: any = []
if(productInfoByEdit?.id){ // id判断是否新增还是编辑 if(productInfoByEdit?.id){ // id判断是否新增还是编辑
setSetImageType(productInfoByEdit.isAllAttributePic || true) console.log(123456789)
setSetImageType(productInfoByEdit.isAllAttributePic)
setIsAllAttributePic(productInfoByEdit.isAllAttributePic)
let _commodityPicList = productInfoByEdit.unitPriceAndPicList.map(_ => _.commodityPic) let _commodityPicList = productInfoByEdit.unitPriceAndPicList.map(_ => _.commodityPic)
_priceAttributeParams = priceAttributeParams.map((_item, _index) => { _priceAttributeParams = priceAttributeParams.map((_item, _index) => {
// 为图片字符串数组手动添加 uid 和 status // 为图片字符串数组手动添加 uid 和 status
...@@ -75,12 +77,13 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -75,12 +77,13 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
}) })
} }
// console.log('???', _priceAttributeParams) // console.log('???', _priceAttributeParams)
if(_priceAttributeParams?.length>0 && _priceAttributeParams[0]?.goodsCustomerAttributeList?.length!=0){ // if(_priceAttributeParams?.length>0 && _priceAttributeParams[0]?.goodsCustomerAttributeList?.length!=0){
setDefaultChecked(0) setDefaultChecked(0)
}else{ clickItemTab(0)
setDefaultChecked(-1) // }else{
} // setDefaultChecked(-1)
clickItemTab(-1) // clickItemTab(-1)
// }
setPriceAttributeParamsByRender(_priceAttributeParams) setPriceAttributeParamsByRender(_priceAttributeParams)
setProductAttributeAndImageParams(_priceAttributeParams) setProductAttributeAndImageParams(_priceAttributeParams)
console.log(_priceAttributeParams, '_p') console.log(_priceAttributeParams, '_p')
...@@ -158,7 +161,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -158,7 +161,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const handleChange = ({ file, fileList }, index) => { const handleChange = ({ file, fileList }, index) => {
let _priceAttributeParams = [...priceAttributeParamsByRender] let _priceAttributeParams = [...priceAttributeParamsByRender]
console.log(_priceAttributeParams, '图片更改初始数据') console.log(_priceAttributeParams, index, '图片更改初始数据')
// if(index===-1){ // -1表示所有属性共用 也表示表格只有默认的一行 // 无需判断 不管是共用还是不共用都需要逐条写入fileList // if(index===-1){ // -1表示所有属性共用 也表示表格只有默认的一行 // 无需判断 不管是共用还是不共用都需要逐条写入fileList
setCommonImageList(fileList) setCommonImageList(fileList)
// _priceAttributeParams[0].commodityPic = fileList // _priceAttributeParams[0].commodityPic = fileList
...@@ -167,14 +170,15 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -167,14 +170,15 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
// } // }
if(!file?.status && file?.status !== 'done'){ if(!file?.status && file?.status !== 'done'){
// 不符合要求的 移除没有'done'状态的图片 // 不符合要求的 移除没有'done'状态的图片
if(index === -1){ // if(index === -1){
let ttt = _priceAttributeParams[0].commodityPic.filter(_ => _.status === 'done') // let ttt = _priceAttributeParams[0].commodityPic.filter(_ => _.status === 'done')
setCommonImageList(ttt) // setCommonImageList(ttt)
_priceAttributeParams[0].commodityPic = ttt // _priceAttributeParams[0].commodityPic = ttt
}else{ // }else{
let ttt = _priceAttributeParams[index].commodityPic.filter(_ => _.status === 'done') let ttt = _priceAttributeParams[index].commodityPic.filter(_ => _.status === 'done')
_priceAttributeParams[index].commodityPic = ttt _priceAttributeParams[index].commodityPic = ttt
} setCommonImageList(ttt)
// }
} }
console.log(_priceAttributeParams, '图片更改之后数据') console.log(_priceAttributeParams, '图片更改之后数据')
setPriceAttributeParamsByRender(_priceAttributeParams) setPriceAttributeParamsByRender(_priceAttributeParams)
...@@ -184,9 +188,9 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -184,9 +188,9 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const onChangeSetImageType = (e) => { const onChangeSetImageType = (e) => {
setSetImageType(e.target.value) setSetImageType(e.target.value)
setIsAllAttributePic(e.target.value) setIsAllAttributePic(e.target.value)
if(e.target.value) // if(e.target.value)
clickItemTab(-1) // clickItemTab(-1)
else // else
clickItemTab(0) clickItemTab(0)
// 切换 清空图片数组 // 切换 清空图片数组
let _priceAttributeParams = [...priceAttributeParamsByRender] let _priceAttributeParams = [...priceAttributeParamsByRender]
...@@ -211,7 +215,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -211,7 +215,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
<ul> <ul>
{ {
!setImageType ? <span className={styles.tipTitle}>按特定属性添加图片</span> !setImageType ? <span className={styles.tipTitle}>按特定属性添加图片</span>
: <li className={defaultChecked == -1 ? styles.activedLi : ""} onClick={()=>clickItemTab(-1)}> : <li className={defaultChecked == 0 ? styles.activedLi : ""} onClick={()=>clickItemTab(0)}> {/* -1 */}
<span>所有属性共用</span> <span>所有属性共用</span>
</li> </li>
} }
...@@ -233,8 +237,8 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -233,8 +237,8 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
</Col> </Col>
<Col span={20} style={{ padding: 24 }}> <Col span={20} style={{ padding: 24 }}>
{ {
!setImageType && !setImageType ?
priceAttributeParamsByRender?.length>0 && priceAttributeParamsByRender[0]?.goodsCustomerAttributeList?.length!=0 ? priceAttributeParamsByRender.map((item, index) => (priceAttributeParamsByRender?.length>0 && priceAttributeParamsByRender[0]?.goodsCustomerAttributeList?.length!=0 ? priceAttributeParamsByRender.map((item, index) =>
<div key={index+100} style={defaultChecked == index ? {display: 'block'} : {display: 'none'}}> <div key={index+100} style={defaultChecked == index ? {display: 'block'} : {display: 'none'}}>
<div className={styles.pictureCardBox}> <div className={styles.pictureCardBox}>
<div className="clearfix"> <div className="clearfix">
...@@ -256,14 +260,14 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -256,14 +260,14 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
banner banner
showIcon={false} showIcon={false}
message="" message=""
description={<>1. 一次可以选择 6 张图片<br />2. 图片尺寸为 800*800,单张大小不超过 600K,仅支持JPEG/JPG/PNG格式<br />3. 图片质量要清晰,不要虚化,建议主图为白色背景正面图</>} description={<>1. (按属性设置)一次可以选择 6 张图片<br />2. 图片尺寸为 800*800,单张大小不超过 600K,仅支持JPEG/JPG/PNG格式<br />3. 图片质量要清晰,不要虚化,建议主图为白色背景正面图</>}
type="info" type="info"
closable closable
style={{ backgroundColor: '#F0F8FF', color: '#1B9AEE' }} style={{ backgroundColor: '#F0F8FF', color: '#1B9AEE' }}
/> />
</div> </div>
) ) : null)
: <div style={defaultChecked == -1 ? {display: 'block'} : {display: 'none'}}> : <div style={defaultChecked == 0 ? {display: 'block'} : {display: 'none'}}> {/* -1 */}
<div className={styles.pictureCardBox}> <div className={styles.pictureCardBox}>
<div className="clearfix"> <div className="clearfix">
<Upload <Upload
...@@ -273,7 +277,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -273,7 +277,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
fileList={commonImageList} fileList={commonImageList}
beforeUpload={beforeUpload} beforeUpload={beforeUpload}
onPreview={handlePreview} onPreview={handlePreview}
onChange={(files)=>handleChange(files, -1)} onChange={(files)=>handleChange(files, 0)} //-1
data={{fileType: UPLOAD_TYPE}} data={{fileType: UPLOAD_TYPE}}
> >
{commonImageList.length >= 6 ? null : uploadButton} {commonImageList.length >= 6 ? null : uploadButton}
...@@ -284,7 +288,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -284,7 +288,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
banner banner
showIcon={false} showIcon={false}
message="" message=""
description={<>1. 一次可以选择 6 张图片<br />2. 图片尺寸为 800*800,单张大小不超过 600K,仅支持JPEG/JPG/PNG格式<br />3. 图片质量要清晰,不要虚化,建议主图为白色背景正面图</>} description={<>1. (所有属性共用)一次可以选择 6 张图片<br />2. 图片尺寸为 800*800,单张大小不超过 600K,仅支持JPEG/JPG/PNG格式<br />3. 图片质量要清晰,不要虚化,建议主图为白色背景正面图</>}
type="info" type="info"
closable closable
style={{ backgroundColor: '#F0F8FF', color: '#1B9AEE' }} style={{ backgroundColor: '#F0F8FF', color: '#1B9AEE' }}
......
...@@ -4,7 +4,6 @@ import { Button, Form, Card, Modal, Select, Row, Col, Dropdown, Input, Menu, Spa ...@@ -4,7 +4,6 @@ import { Button, Form, Card, Modal, Select, Row, Col, Dropdown, Input, Menu, Spa
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { import {
PlusOutlined, PlusOutlined,
EyeOutlined,
DownOutlined, DownOutlined,
CaretUpOutlined, CaretUpOutlined,
CaretDownOutlined, CaretDownOutlined,
...@@ -24,6 +23,7 @@ import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect' ...@@ -24,6 +23,7 @@ import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect' import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { searchBrandOptionEffect, searchCustomerCategoryOptionEffect } from './effect' import { searchBrandOptionEffect, searchCustomerCategoryOptionEffect } from './effect'
import EyePreview from '@/components/EyePreview'
// 定义选择的行数据的类型 // 定义选择的行数据的类型
interface Item { interface Item {
...@@ -38,59 +38,6 @@ interface Item { ...@@ -38,59 +38,6 @@ interface Item {
status: string; status: string;
} }
const data = [
{
id: '1',
role: '百达翡丽',
type: '小羊皮',
brand: 'YSL',
unit: '寸',
price: '¥400 ~ ¥500',
channelName: '经销商',
origin: '江南皮革厂',
batch: '2015-15-26 12:12:76',
status: '0'
},
{
id: '2',
role: '万宝卡',
type: '小瓜皮',
brand: 'MAC',
unit: '克',
price: '¥400 ~ ¥500',
channelName: '经销商',
origin: '江南皮革厂',
batch: '2015-15-26 12:12:76',
status: '1'
},
{
id: '3',
role: '小宝SOD蜜',
type: '洗护一体',
brand: 'AOC',
unit: '吨',
price: '¥186 ~ ¥536',
channelName: '经销商',
origin: '江南皮革厂',
batch: '2015-15-26 12:12:76',
status: '2'
}
]
// 模拟请求
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.id === params.keywords)
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data
})
}, 1000)
})
}
const formActions = createFormActions(); const formActions = createFormActions();
const DirectChannel: React.FC<{}> = () => { const DirectChannel: React.FC<{}> = () => {
...@@ -101,56 +48,64 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -101,56 +48,64 @@ const DirectChannel: React.FC<{}> = () => {
const [isUp, setIsUp] = useState(1) // 1上0下架状态 const [isUp, setIsUp] = useState(1) // 1上0下架状态
const [upDownModal, setUpDownModal] = useState(false) const [upDownModal, setUpDownModal] = useState(false)
// brand: {id: 33, name: "沙县",…}
// code: "P00002M"
// customerCategory: {id: 49, name: "男装"}
// id: 85
// name: "沙县沙滩裤"
// parentMemberId: null
// parentMemberName: null
// priceType: 1
// source: null
// status: 5
// unitName: "件"
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
align: 'center',
key: 'id', key: 'id',
}, },
{ {
title: '商品名称', title: '商品名称',
dataIndex: 'role', dataIndex: 'name',
align: 'center', key: 'name',
key: 'role',
className: 'commonPickColor', className: 'commonPickColor',
render: (text:any, record:any) => <span className="commonPickColor" onClick={()=>handleSee(record)}>{text}&nbsp;<EyeOutlined /></span> render: (text:any, record:any) => <EyePreview
url={`/memberCenter/commodityAbility/commodity/products/viewDirectChannel?id=${record.key}`}
>
{text}
</EyePreview>
}, },
{ {
title: '品类', title: '品类',
dataIndex: 'type', dataIndex: ['customerCategory', 'name'],
align: 'center', key: 'id',
key: 'type',
}, },
{ {
title: '品牌', title: '品牌',
dataIndex: 'brand', dataIndex: ['brand', 'name'],
align: 'center', key: 'id',
key: 'brand',
}, },
{ {
title: '单位', title: '单位',
dataIndex: 'unit', dataIndex: 'unitName',
align: 'center', key: 'unitName',
key: 'unit',
}, },
{ {
title: '价格', title: '价格',
dataIndex: 'price', dataIndex: 'price',
align: 'center',
key: 'price', key: 'price',
}, },
{ {
title: '渠道会员名称', title: '渠道会员名称',
dataIndex: 'channelName', dataIndex: 'parentMemberName',
align: 'center', key: 'parentMemberName',
key: 'chanelName',
}, },
{ {
title: '商品来源', title: '商品来源',
dataIndex: 'origin', dataIndex: 'source',
align: 'center', key: 'source',
key: 'origin',
}, },
{ {
title: '操作时间', title: '操作时间',
...@@ -165,12 +120,12 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -165,12 +120,12 @@ const DirectChannel: React.FC<{}> = () => {
key: 'status', key: 'status',
render: (text:any, record:any) => { render: (text:any, record:any) => {
let component: ReactNode = null let component: ReactNode = null
if(record.status === '1') if(record.status === 5)
component = (<span style={{color:'#00B37A',padding:'2px 5px',background:'rgba(235,247,242,1)',borderRadius:'4px'}}>已上架</span>) component = (<span style={{color:'#00B37A',padding:'2px 5px',background:'rgba(235,247,242,1)',borderRadius:'4px'}}>已上架</span>)
else if(record.status === '2') else if(record.status === 6)
component = (<span style={{padding:'2px 5px',background:'rgba(244,245,247,1)',borderRadius:'4px'}}>已下架</span>) component = (<span style={{padding:'2px 5px',background:'rgba(244,245,247,1)',borderRadius:'4px'}}>已下架</span>)
else if(record.status === '0') else if(record.status === 4)
component = (<span style={{color:'#E63F3B',padding:'2px 5px',background:'rgba(255,235,230,1)',borderRadius:'4px'}}>未上架</span>) component = (<span style={{color:'#E63F3B',padding:'2px 5px',background:'rgba(255,235,230,1)',borderRadius:'4px'}}>审核通过</span>)
return component return component
} }
}, },
...@@ -181,8 +136,8 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -181,8 +136,8 @@ const DirectChannel: React.FC<{}> = () => {
render: (text:any, record:any) => { render: (text:any, record:any) => {
return ( return (
<> <>
{(record.status==='0'||record.status==='2')?<Button type='link' onClick={()=>clickUp(1)}>上架</Button>:''} {(record.status===6)?<Button type='link' onClick={()=>clickUp(1)}>上架</Button>:''}
{record.status==='1'?<Button type='link' onClick={()=>clickUp(0)}>下架</Button>:''} {record.status===5?<Button type='link' onClick={()=>clickUp(0)}>下架</Button>:''}
<Button type='link'>修改</Button> <Button type='link'>修改</Button>
<Button type='link'>删除</Button> <Button type='link'>删除</Button>
</> </>
...@@ -191,6 +146,17 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -191,6 +146,17 @@ const DirectChannel: React.FC<{}> = () => {
} }
]; ];
const fetchData = (params: any) => {
console.log(params, 'params')
return new Promise((resolve, reject) => {
PublicApi.getProductChannelCommodityGetCommodityList(params).then(res => {
const { data } = res
console.log(data,'data')
resolve(data)
})
})
}
const handleBatchUp = () => { const handleBatchUp = () => {
console.log('批量上架') console.log('批量上架')
setUpDownModal(true) setUpDownModal(true)
...@@ -208,11 +174,6 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -208,11 +174,6 @@ const DirectChannel: React.FC<{}> = () => {
console.log('删除') console.log('删除')
} }
const handleSee = (record:any) => {
console.log('see')
history.push(`/memberCenter/commodityAbility/commodity/products/viewDirectChannel?id=${record.key}`)
}
const confirm = () => { const confirm = () => {
console.log('confirm') console.log('confirm')
} }
...@@ -270,12 +231,6 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -270,12 +231,6 @@ const DirectChannel: React.FC<{}> = () => {
} }
} }
// const fetchSelectBrand = async (params) => {
// const { data } = await PublicApi.getProductSelectGetSelectBrand({ name: params })
// console.log(params, data)
// return data
// }
const menuMore = ( const menuMore = (
<Menu onClick={(param) => handleMenuClick(param)}> <Menu onClick={(param) => handleMenuClick(param)}>
<Menu.Item key="2" icon={<VerticalAlignTopOutlined />}> <Menu.Item key="2" icon={<VerticalAlignTopOutlined />}>
......
...@@ -4,7 +4,6 @@ import { Button, Form, Card, Modal, Result, Progress, Select, Tooltip, Checkbox, ...@@ -4,7 +4,6 @@ import { Button, Form, Card, Modal, Result, Progress, Select, Tooltip, Checkbox,
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { import {
PlusOutlined, PlusOutlined,
EyeOutlined,
MinusOutlined, MinusOutlined,
CaretUpOutlined, CaretUpOutlined,
CaretDownOutlined CaretDownOutlined
...@@ -14,6 +13,7 @@ import { ColumnType } from 'antd/lib/table/interface' ...@@ -14,6 +13,7 @@ import { ColumnType } from 'antd/lib/table/interface'
import moment from 'moment' import moment from 'moment'
import styles from "./index.less" import styles from "./index.less"
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'
const { Option } = Select; const { Option } = Select;
const { Item }:any = Form const { Item }:any = Form
...@@ -41,8 +41,6 @@ interface paramItem { ...@@ -41,8 +41,6 @@ interface paramItem {
status: number; status: number;
} }
let timeChange: any;
const FastModifyPrice: React.FC<{}> = () => { const FastModifyPrice: React.FC<{}> = () => {
const ref = useRef<any>({}) const ref = useRef<any>({})
const [setForm] = Form.useForm() const [setForm] = Form.useForm()
...@@ -57,16 +55,17 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -57,16 +55,17 @@ const FastModifyPrice: React.FC<{}> = () => {
wrapperCol: { span: 24 }, wrapperCol: { span: 24 },
}; };
const [filterParams, setFilterParams] = useState<paramItem>({ // const [filterParams, setFilterParams] = useState<paramItem>({
name: '', // name: '',
code: '', // code: '',
priceType: null, // priceType: null,
min: null, // min: null,
max: null, // max: null,
brandId: 0, // brandId: 0,
customerCategoryId: 0, // customerCategoryId: 0,
status: null, // status: null,
}) // })
const [filterParams, setFilterParams] = useState<any>({})
const [brandData, setBrandData] = useState<any>([]) const [brandData, setBrandData] = useState<any>([])
const [brandValue, setBrandValue] = useState(undefined) const [brandValue, setBrandValue] = useState(undefined)
const [classData, setClassData] = useState<any>([]) const [classData, setClassData] = useState<any>([])
...@@ -84,7 +83,11 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -84,7 +83,11 @@ const FastModifyPrice: React.FC<{}> = () => {
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
className: 'commonPickColor', className: 'commonPickColor',
render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span> render: (text: any, record: any) => <EyePreview
url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.commodityId}`}
>
{text}
</EyePreview>
}, },
{ {
title: '品类', title: '品类',
...@@ -186,11 +189,6 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -186,11 +189,6 @@ const FastModifyPrice: React.FC<{}> = () => {
}) })
} }
const handleSee = (record: any) => {
console.log('see')
history.push(`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.commodityId}`)
}
const handleModify = (record: any) => { const handleModify = (record: any) => {
console.log('点击修改价格', record) console.log('点击修改价格', record)
const { id, unitPrice, priceType } = record const { id, unitPrice, priceType } = record
...@@ -221,53 +219,39 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -221,53 +219,39 @@ const FastModifyPrice: React.FC<{}> = () => {
const handleReset = () => { const handleReset = () => {
let restObj = { name: '', code: '', max: null, min: null, priceType: null, brandId: 0, customerCategoryId: 0, status: null } setFilterParams({})
setFilterParams(restObj)
setBrandValue(undefined) setBrandValue(undefined)
setClassValue(undefined) setClassValue(undefined)
ref.current.reload(restObj) ref.current.reload({})
} }
const handleBrandSearch = (value: any) => { // end value const handleBrandSearch = (value?: any) => { // end value
// console.log(value, 'handleBrandSearch') PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => {
if (value) { if (res.code === 1000)
PublicApi.getProductSelectGetSelectBrand({ name: value }).then(res => { setBrandData(res.data)
if (res.code === 1000) })
setBrandData(res.data)
})
} else {
setBrandData([])
}
} }
const handleBrandChange = (value: any) => { const handleBrandChange = (value: any) => {
setBrandValue(value) setBrandValue(value)
// console.log(value, 'handleBrandChange')
let obj = { ...filterParams, brandId: value } let obj = { ...filterParams, brandId: value }
setFilterParams(obj) setFilterParams(obj)
} }
const handleClassSearch = (value: any) => { const handleClassSearch = (value?: any) => {
// console.log(value, 'handleClassSearch') PublicApi.getProductSelectGetSelectCustomerCategory({ name: value }).then(res => {
if (value) { if (res.code === 1000)
PublicApi.getProductSelectGetSelectCustomerCategory({ name: value }).then(res => { setClassData(res.data)
if (res.code === 1000) })
setClassData(res.data)
})
} else {
setClassData([])
}
} }
const handleClassChange = (value: any) => { const handleClassChange = (value: any) => {
setClassValue(value) setClassValue(value)
let obj = { ...filterParams, customerCategoryId: value } let obj = { ...filterParams, customerCategoryId: value }
setFilterParams(obj) setFilterParams(obj)
// console.log(value, 'handleClassChange')
} }
const handleSearch = (val: string) => { const handleSearch = (val: string) => {
console.log(val)
let obj = { ...filterParams, name: val } let obj = { ...filterParams, name: val }
setFilterParams(obj) setFilterParams(obj)
ref.current.reload(obj) ref.current.reload(obj)
...@@ -276,14 +260,11 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -276,14 +260,11 @@ const FastModifyPrice: React.FC<{}> = () => {
const handleOk = () => { const handleOk = () => {
setForm.validateFields().then(v=>{ setForm.validateFields().then(v=>{
setModifyModal(false) setModifyModal(false)
// console.log(v,'value')
}) })
// console.log('handleOk')
} }
const handleCancel = () => { const handleCancel = () => {
setModifyModal(false) setModifyModal(false)
// console.log('handleCancel')
} }
const changeLadderPrice = (e: any) => { const changeLadderPrice = (e: any) => {
...@@ -369,32 +350,34 @@ const FastModifyPrice: React.FC<{}> = () => { ...@@ -369,32 +350,34 @@ const FastModifyPrice: React.FC<{}> = () => {
</Col> </Col>
<Col span={4}> <Col span={4}>
<Select <Select
showSearch showSearch={true}
showArrow={true}
placeholder="商品品牌" placeholder="商品品牌"
value={brandValue} value={brandValue}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
showArrow={false}
filterOption={false} filterOption={false}
onSearch={handleBrandSearch} onSearch={handleBrandSearch}
onChange={handleBrandChange} onChange={handleBrandChange}
onFocus={()=>handleBrandSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{ width: '100%' }} style={{width:'100%'}}
> >
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)} {brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select> </Select>
</Col> </Col>
<Col span={4}> <Col span={4}>
<Select <Select
showSearch showSearch={true}
showArrow={true}
placeholder="商品品类" placeholder="商品品类"
value={classValue} value={classValue}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
showArrow={false}
filterOption={false} filterOption={false}
onSearch={handleClassSearch} onSearch={handleClassSearch}
onChange={handleClassChange} onChange={handleClassChange}
onFocus={()=>handleClassSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{ width: '100%' }} style={{width:'100%'}}
> >
{classData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)} {classData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select> </Select>
......
...@@ -460,8 +460,10 @@ const Products: React.FC<{}> = () => { ...@@ -460,8 +460,10 @@ const Products: React.FC<{}> = () => {
console.log('复制商品') console.log('复制商品')
const { id } = record; const { id } = record;
if(id){ if(id){
PublicApi.postProductCommodityCopyCommodity({id: id}) PublicApi.postProductCommodityCopyCommodity({id: id}).then(res => {
ref.current.reload() if(res.code === 1000)
ref.current.reload()
})
} }
} }
...@@ -469,8 +471,10 @@ const Products: React.FC<{}> = () => { ...@@ -469,8 +471,10 @@ const Products: React.FC<{}> = () => {
console.log('提交审核') console.log('提交审核')
const { id } = record; const { id } = record;
if(id) if(id)
PublicApi.postProductCommodityApplyCheckCommodity({id: id}) PublicApi.postProductCommodityApplyCheckCommodity({id: id}).then(res => {
ref.current.reload() if(res.code === 1000)
ref.current.reload()
})
} }
const handleMenuClick = (e: any) => { const handleMenuClick = (e: any) => {
...@@ -501,42 +505,30 @@ const Products: React.FC<{}> = () => { ...@@ -501,42 +505,30 @@ const Products: React.FC<{}> = () => {
ref.current.reload(restObj) ref.current.reload(restObj)
} }
const handleBrandSearch = (value:any) => { // end value const handleBrandSearch = (value?:any) => { // end value
console.log(value, 'handleBrandSearch') PublicApi.getProductSelectGetSelectBrand({name: value}).then(res=>{
if (value) { if(res.code === 1000)
PublicApi.getProductSelectGetSelectBrand({name: value}).then(res=>{ setBrandData(res.data)
if(res.code === 1000) })
setBrandData(res.data)
})
} else {
setBrandData([])
}
} }
const handleBrandChange = (value:any) => { const handleBrandChange = (value:any) => {
setBrandValue(value) setBrandValue(value)
console.log(value, 'handleBrandChange')
let obj = {...filterParams, brandId: value} let obj = {...filterParams, brandId: value}
setFilterParams(obj) setFilterParams(obj)
} }
const handleClassSearch = (value:any) => { const handleClassSearch = (value?:any) => {
console.log(value, 'handleClassSearch') PublicApi.getProductSelectGetSelectCustomerCategory({name: value}).then(res=>{
if (value) { if(res.code === 1000)
PublicApi.getProductSelectGetSelectCustomerCategory({name: value}).then(res=>{ setClassData(res.data)
if(res.code === 1000) })
setClassData(res.data)
})
} else {
setClassData([])
}
} }
const handleClassChange = (value:any) => { const handleClassChange = (value:any) => {
setClassValue(value) setClassValue(value)
let obj = {...filterParams, customerCategoryId: value} let obj = {...filterParams, customerCategoryId: value}
setFilterParams(obj) setFilterParams(obj)
console.log(value, 'handleClassChange')
} }
const handleSearch = (val?: string) => { const handleSearch = (val?: string) => {
...@@ -627,7 +619,8 @@ const Products: React.FC<{}> = () => { ...@@ -627,7 +619,8 @@ const Products: React.FC<{}> = () => {
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
filterOption={false} filterOption={false}
onSearch={handleBrandSearch} onSearch={handleBrandSearch}
onChange={handleBrandChange} onChange={handleBrandChange}
onFocus={()=>handleBrandSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{width:'100%'}} style={{width:'100%'}}
> >
...@@ -644,6 +637,7 @@ const Products: React.FC<{}> = () => { ...@@ -644,6 +637,7 @@ const Products: React.FC<{}> = () => {
filterOption={false} filterOption={false}
onSearch={handleClassSearch} onSearch={handleClassSearch}
onChange={handleClassChange} onChange={handleClassChange}
onFocus={()=>handleClassSearch(null)}
notFoundContent={null} notFoundContent={null}
style={{width:'100%'}} style={{width:'100%'}}
> >
......
...@@ -318,7 +318,7 @@ const viewProducts: React.FC<{}> = () => { ...@@ -318,7 +318,7 @@ const viewProducts: React.FC<{}> = () => {
backIcon={<ReutrnEle logoSrc={productDetail?.unitPriceAndPicList[0]?.commodityPic[0]} />} backIcon={<ReutrnEle logoSrc={productDetail?.unitPriceAndPicList[0]?.commodityPic[0]} />}
content={content} content={content}
extra={[ extra={[
<Button icon={<FormOutlined />} key="1" type="primary" disabled={productDetail?.status !== 3} onClick={clickModify}> <Button icon={<FormOutlined />} key="1" type="primary" disabled={productDetail?.status !== 3 && productDetail?.status !== 1 } onClick={clickModify}>
修改 修改
</Button>, </Button>,
]} ]}
...@@ -360,7 +360,7 @@ const viewProducts: React.FC<{}> = () => { ...@@ -360,7 +360,7 @@ const viewProducts: React.FC<{}> = () => {
<Col span={20}> <Col span={20}>
<p> <p>
{ {
productDetail?.commodityAreaList.map(_item => <p>{_item.provinceName+'/'+_item.cityName}</p>) productDetail?.commodityAreaList.map(_item => <p>{_item.provinceName+'/'+(_item.cityName||'')}</p>)
} }
</p> </p>
</Col> </Col>
...@@ -529,7 +529,8 @@ const viewProducts: React.FC<{}> = () => { ...@@ -529,7 +529,8 @@ const viewProducts: React.FC<{}> = () => {
<Space direction="vertical" style={{width:'100%'}}> <Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="商品图片"> <Card headStyle={{borderBottom:'none'}} title="商品图片">
{ {
productDetail?.unitPriceAndPicList[0].attributeAndValueList.length === 0 ? <> // productDetail?.unitPriceAndPicList[0].attributeAndValueList.length === 0 ? <>
productDetail?.isAllAttributePic ? <>
<Row> <Row>
<Col span={3}> <Col span={3}>
<p>设置方式:</p> <p>设置方式:</p>
...@@ -599,7 +600,7 @@ const viewProducts: React.FC<{}> = () => { ...@@ -599,7 +600,7 @@ const viewProducts: React.FC<{}> = () => {
{/* 图片区块 */} {/* 图片区块 */}
<div className={styles.descriptionBox}> <div className={styles.descriptionBox}>
{ {
productDetail?.commodityRemark?.image.length>0 ? productDetail?.commodityRemark?.image.map((_item, _index)=> <div key={_index} className={styles.imgItem}> productDetail?.commodityRemark?.image?.length>0 ? productDetail?.commodityRemark?.image.map((_item, _index)=> <div key={_index} className={styles.imgItem}>
<img src={_item} /> <img src={_item} />
</div>) : <p>暂无数据</p> </div>) : <p>暂无数据</p>
} }
......
...@@ -13,7 +13,7 @@ class ProductStore implements IProductModule { ...@@ -13,7 +13,7 @@ class ProductStore implements IProductModule {
@observable public areaOption: any[] = []; @observable public areaOption: any[] = [];
@observable public productInfoByEdit: GetProductCommodityGetCommodityResponse; @observable public productInfoByEdit: GetProductCommodityGetCommodityResponse;
@observable public productDescription: IDecsParams; @observable public productDescription: IDecsParams;
@observable public isAllAttributePic: boolean = null; // 是否所有属性共用 @observable public isAllAttributePic: boolean = true; // 是否所有属性共用
/** 计算操作 **/ /** 计算操作 **/
// 加工接口返回的数据,用户编辑回显数据 // 加工接口返回的数据,用户编辑回显数据
...@@ -89,6 +89,7 @@ class ProductStore implements IProductModule { ...@@ -89,6 +89,7 @@ class ProductStore implements IProductModule {
@action.bound @action.bound
public setProductSelectAttribute(list: any[]) { public setProductSelectAttribute(list: any[]) {
console.log(list, 'mobx')
this.productSelectAttribute = list; this.productSelectAttribute = list;
} }
...@@ -103,8 +104,13 @@ class ProductStore implements IProductModule { ...@@ -103,8 +104,13 @@ class ProductStore implements IProductModule {
} }
@action.bound @action.bound
public clearData(data: any[]) { public clearData(data?: any[]) {
this.tableDataSource = data; this.tableDataSource = data || [];
//productName, selectedGoods, productSelectAttribute, productInfoByEdit
this.productName = null;
this.selectedGoods = [];
this.productSelectAttribute = [];
this.productInfoByEdit = null;
} }
@action.bound @action.bound
......
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