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

fix:修改商品物流模块为空

parent fb95bffe
import { GetProductChannelCommodityGetCommodityListResponseDetail } from '@/services';
export interface IChannelProductModule {
productSelectRowInStore: GetProductChannelCommodityGetCommodityListResponseDetail;
priceType: number;
productName: string;
setProductSelectRowInStore(data: GetProductChannelCommodityGetCommodityListResponseDetail): void;
setPriceType(data: number): void;
setProductName(data: string): void;
}
\ No newline at end of file
import React, {useState, useRef, useEffect} from 'react'
import { Button, Form, Radio, Table } from 'antd'
import {
PlusOutlined,
} from '@ant-design/icons'
import { ColumnType } from 'antd/lib/table/interface';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import { createAsyncFormActions, FormEffectHooks } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { addChannelSchema } from '../schema/channelSchema';
import { PublicApi } from '@/services/api';
import ModalTable from '@/components/ModalTable'
import { GetProductChannelCommodityGetCommodityListResponseDetail } from '@/services';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import Search from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
const layout = {
labelCol: {
span: 2,
},
wrapperCol: {
span: 12,
},
}
interface IProps {
onRef: (refs: any) => void;
}
const productFormActions = createAsyncFormActions()
const SelectProduct:React.FC<IProps> = (props) => {
const { onRef } = props
const productRef = useRef<any>({})
const productFormRef = useRef()
const [formProduct] = Form.useForm()
const [source, setSource] = useState(1)
const [visibleAddTabs, setVisibleAddTabs] = useState(false)
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const [selectProduct, setSelectProduct] = useState<GetProductChannelCommodityGetCommodityListResponseDetail[]>()
const { ChannelProudctStore } = store
const { setProductSelectRowInStore, setPriceType, setProductName } = ChannelProudctStore
const productColumns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '商品名称',
dataIndex: 'name',
key: 'name',
},
{
title: '品类',
dataIndex: ['customerCategory', 'name'],
key: 'customerCategory',
},
{
title: '品牌',
dataIndex: ['brand', 'name'],
key: 'brand',
},
{
title: '单位',
dataIndex: 'unitName',
key: 'unitName',
}
]
const productedColumns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '商品名称',
dataIndex: 'name',
key: 'name',
},
{
title: '品类',
dataIndex: ['customerCategory', 'name'],
key: 'customerCategory',
},
{
title: '品牌',
dataIndex: ['brand', 'name'],
key: 'brand',
},
{
title: '单位',
dataIndex: 'unitName',
key: 'unitName',
},
{
title: '操作',
dataIndex: 'option',
render: (text: any, record: any) => {
return (
<>
<Button type='link' onClick={()=>clickDelete(record)}>删除</Button>
</>
)
}
}
]
useEffect(() => {
onRef(productFormRef)
formProduct.setFieldsValue({source: source})
// 获取会员角色列表
PublicApi.getMemberManageChannelLowerRoleList().then(res => {
const { data } = res
console.log(data)
})
}, [])
useEffect(() => {
console.log(productRowCtl.selectRow[0])
if(productRowCtl.selectRow.length>0){
setPriceType(productRowCtl.selectRow[0].priceType)
setProductName(productRowCtl.selectRow[0].name)
setProductSelectRowInStore(productRowCtl.selectRow[0])
}
}, [productRowCtl.selectRow])
useEffect(() => {
if(visibleAddTabs)
productRef?.current?.schemaAction?.setFieldState('parentMemberId', state => {
console.log('parentMemberId')
state.visible = source===1 ? true : false
})
}, [visibleAddTabs])
// 获取渠道商品
const fetchProductData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getProductChannelCommodityGetCommodityList({...params, source: source}).then(res => {
const { data } = res
resolve(data)
})
})
}
// 获取上级渠道下拉列表
const fetchSelectOptions = async () => {
const { data } = await PublicApi.getMemberManageChannelUpperList();
return data.map(v => ({ label: v.name, value: v.memberId }))
}
const handleSourceChange = (v:any) => {
setSource(v.target.value)
setSelectProduct([])
}
const handleOkAddTabs = () => {
setSelectProduct(productRowCtl.selectRow)
setVisibleAddTabs(false)
}
const handleCancelAddTabs = () => {
setVisibleAddTabs(false)
// productRowCtl.setSelectedRowKeys([])
}
const clickDelete = (record: any) => {
setSelectProduct([])
}
return (<>
<Form
{...layout}
form={formProduct}
ref={productFormRef}
name="add-channel-origin"
labelAlign="left"
>
<Form.Item
name="source"
label="选择商品来源"
rules={[{
required: true,
message: '请选择商品来源'
}]}
>
<Radio.Group onChange={handleSourceChange}>
<Radio value={1}>上级渠道商品</Radio>
<Radio value={2}>渠道自有商品</Radio>
</Radio.Group>
</Form.Item>
</Form>
<Button onClick={()=>setVisibleAddTabs(true)} style={{width:'100%', marginTop: 24, marginBottom: 24, backgroundColor: '#fafbfc'}}>
<PlusOutlined /> 新增{source===1?'上级渠道商品':'渠道自有商品'}
</Button>
<Table rowKey="id" dataSource={selectProduct} columns={productedColumns} />
{/* 选择商品 */}
<ModalTable
modalTitle={source===1?'选择上级渠道商品':'选择渠道自有商品'}
confirm={handleOkAddTabs}
cancel={handleCancelAddTabs}
visible={visibleAddTabs}
resetModal={{destroyOnClose: true, forceRender: true}}
columns={productColumns}
rowSelection={productRowSelection}
fetchTableData={(params:any) => fetchProductData(params)}
currentRef={productRef}
tableProps={{
rowKey: 'id',
onRow: (record) => ({
onClick: () => {
productRowCtl.setSelectRow([record]);
productRowCtl.setSelectedRowKeys([record.id]);
},
})
}}
formilyProps={
{
ctx: {
schema: addChannelSchema,
actions: productFormActions,
components: { ModalSearch: Search, SearchSelect, Submit } ,
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
)
useAsyncSelect(
'parentMemberId',
fetchSelectOptions,
)
}
}
}
}
/>
</>)
}
export default observer(SelectProduct)
\ No newline at end of file
......@@ -81,12 +81,22 @@ const AddProducts: React.FC<{}> = (props) => {
delete _itme.customerAttributeId
})
let _bacsicForm = {...values[0]}
if(values.length > 0){
for(let i = 0; i < values.length; i++){
// 过滤出物流form
if(values[i].deliveryType){
_bacsicForm = { ..._bacsicForm, logistics: {...values[i]} }
}else{
_bacsicForm = { ..._bacsicForm, ...values[i] }
}
}
}
_bacsicForm.customerCategoryId = _bacsicForm.customerCategoryId[_bacsicForm.customerCategoryId.length-1]
let _params = {
..._bacsicForm,
...values[2],
logistics: {...values[3]},
...values[4],
// ...values[2],
// logistics: {...values[3]},
// ...values[4],
commodityAttributeList: productSelectAttribute,
// unitPriceAndPicList: productAttributeAndImageParams,
commodityRemark: productDescription,
......@@ -124,10 +134,11 @@ const AddProducts: React.FC<{}> = (props) => {
try{
if(productAttributeAndImageParams.length>0){
productAttributeAndImageParams.map(_item => {
if(_item.goodsCustomerAttributeList.length>0){
console.log(_item, '_item')
if(_item.attributeAndValueList.length>0){
_item.goods = { id: _item.goodsId }
delete _item.goodsId
_item.goodsCustomerAttributeList.map(__item => {
_item.attributeAndValueList.map(__item => {
delete __item.customerAttributeName
// __item.customerAttributeValueId = __item.id
// **** 新字段结构变更
......@@ -138,8 +149,8 @@ const AddProducts: React.FC<{}> = (props) => {
delete __item.customerAttributeId
})
}
_item.attributeAndValueList = _item.goodsCustomerAttributeList
delete _item.goodsCustomerAttributeList
// _item.attributeAndValueList = _item.goodsCustomerAttributeList
// delete _item.goodsCustomerAttributeList
if(_item.commodityPic.length>0){
// 编辑情况下兼顾手动添加图片列表属性
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url)
......
......@@ -231,8 +231,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
id: attributeValObjArr[0][0].id,
value: item.toString()
})
_paramsArray.push({goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0, goodsCustomerAttributeList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/
}) : _paramsArray.push({goodsId: _tableDataSource[0] ? _tableDataSource[0]['对应货品'] : 0, goodsCustomerAttributeList: [], unitPrice: _tableDataSource[0]&&_tableDataSource[0]['单价']}) /*带上货品id 带上单价*/
_paramsArray.push({goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0, attributeAndValueList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/
}) : _paramsArray.push({goodsId: _tableDataSource[0] ? _tableDataSource[0]['对应货品'] : 0, attributeAndValueList: [], unitPrice: _tableDataSource[0]&&_tableDataSource[0]['单价']}) /*带上货品id 带上单价*/
setPriceAttributeParams(_paramsArray)
console.log(_paramsArray,'params')
}
......
......@@ -50,10 +50,10 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
/* 给数据添加图片字段 */
useEffect(()=>{
console.log('图片111', priceAttributeParams)
// console.log('图片111', priceAttributeParams)
let _priceAttributeParams: any = []
if(productInfoByEdit?.id){ // id判断是否新增还是编辑
console.log('图片222', priceAttributeParams)
// console.log('图片222', priceAttributeParams)
setSetImageType(productInfoByEdit.isAllAttributePic)
setIsAllAttributePic(productInfoByEdit.isAllAttributePic)
let _commodityPicList = productInfoByEdit.unitPriceAndPicList.map(_ => _.commodityPic)
......@@ -223,11 +223,11 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
{ !setImageType &&
priceAttributeParamsByRender?.length>0 && priceAttributeParamsByRender.map(
(item, index) => {
return Array.isArray(item.goodsCustomerAttributeList) &&
return Array.isArray(item.attributeAndValueList) &&
<li key={index} className={defaultChecked == index ? styles.activedLi : ""} onClick={()=>clickItemTab(index)}>
<span>
{
item.goodsCustomerAttributeList.map((_item, _index)=>_item.value).join('/')
item.attributeAndValueList.map((_item, _index)=>_item.value).join('/')
}
</span>
</li>
......@@ -239,7 +239,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
<Col span={20} style={{ padding: 24 }}>
{
!setImageType ?
(priceAttributeParamsByRender?.length>0 && priceAttributeParamsByRender[0]?.goodsCustomerAttributeList?.length!=0 ? priceAttributeParamsByRender.map((item, index) =>
(priceAttributeParamsByRender?.length>0 && priceAttributeParamsByRender[0]?.attributeAndValueList?.length!=0 ? priceAttributeParamsByRender.map((item, index) =>
<div key={index+100} style={defaultChecked == index ? {display: 'block'} : {display: 'none'}}>
<div className={styles.pictureCardBox}>
<div className="clearfix">
......
......@@ -94,9 +94,9 @@ const DirectChannel: React.FC<{}> = () => {
render: (text: any, record: any) => <>{record.min} ~ ¥{record.max}</>
},
{
title: '渠道会员名称',
dataIndex: 'parentMemberName',
key: 'parentMemberName',
title: '渠道会员角色',
dataIndex: 'channelMemberRoleName',
key: 'channelMemberRoleName',
},
{
title: '商品来源',
......@@ -298,11 +298,11 @@ const DirectChannel: React.FC<{}> = () => {
>
<PlusOutlined />新建
</Button>
<Dropdown overlay={menuMore} trigger={['click']}>
{/* <Dropdown overlay={menuMore} trigger={['click']}>
<Button>
更多 <DownOutlined />
</Button>
</Dropdown>
</Dropdown> */}
</Space>
);
......
import {action, computed, observable, runInAction} from 'mobx'
import { IChannelProductModule } from '@/module/channelProductModule'; // mobx要用到的数据类型
import { GetProductChannelCommodityGetCommodityListResponseDetail } from '@/services';
/**
* 渠道直采商品
*/
class ChannelProductStore implements IChannelProductModule {
// 选择商品区块
@observable public productSelectRowInStore: GetProductChannelCommodityGetCommodityListResponseDetail = null;
@observable public priceType: number = null
@observable public productName: string = null
// 加工接口返回的数据,用户编辑回显数据
// @computed
// public get getBasicFormParamsByEdit(): IBasicFormParam {
// return {
// commodityAreaList: this.productInfoByEdit?.commodityAreaList.map(item => [item.provinceCode, item.cityCode]),
// }
// }
@action.bound
public setProductSelectRowInStore(data: GetProductChannelCommodityGetCommodityListResponseDetail) {
this.productSelectRowInStore = data;
}
@action.bound
public setPriceType(data: number){
this.priceType = data;
}
@action.bound
public setProductName(data: string){
this.productName = data;
}
}
export default ChannelProductStore
import UserStore from './user'
import ThemeStore from './theme'
import ProductStroe from './product'
import ChannelProudctStore from './channelProduct'
import SiteStore from './site'
import CategoryStore from './category'
import React from 'react';
import { Provider } from 'mobx-react'
import { ILoginModule } from '@/module/userModule';
import { IProductModule } from '@/module/productModule'
import { IChannelProductModule } from '@/module/channelProductModule'
// import { ProductContext } from '@/pages/commodity/products/addProducts';
......@@ -29,12 +31,14 @@ import { IProductModule } from '@/module/productModule'
export interface IStore {
UserStore: ILoginModule;
ProductStore: IProductModule;
ChannelProudctStore: IChannelProductModule;
}
export const store = {
UserStore: new UserStore,
ThemeStore: new ThemeStore,
ProductStore: new ProductStroe,
ChannelProudctStore: new ChannelProudctStore,
SiteStore: new SiteStore,
CategoryStore: new CategoryStore
}
......
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