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

fix:新增渠道

parent 708f4af7
......@@ -36,7 +36,7 @@
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
"copy-to-clipboard": "^3.3.1",
"god": "^0.1.20",
"god": "^0.1.23",
"lingxi-design-ui": "^1.0.6",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
......
......@@ -8,11 +8,12 @@ export interface ModalTableProps extends IStandardTableProps<any> {
modalTitle?: ReactText,
confirm?(),
cancel?(),
visible?: boolean
visible?: boolean,
resetModal?: object
}
const ModalTable:React.FC<ModalTableProps> = (props) => {
const { width = 704,modalTitle, confirm, cancel, visible, currentRef, ...resetTable } = props
const { width = 704,modalTitle, confirm, cancel, visible, currentRef, resetModal, ...resetTable } = props
const selfRef = currentRef || useRef<any>({})
useEffect(() => {
if (!visible) {
......@@ -28,7 +29,7 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
onOk={confirm}
onCancel={cancel}
visible={visible}
destroyOnClose
{...resetModal}
>
<StandardTable
tableType='small'
......
......@@ -22,7 +22,7 @@ const { Option } = Select
const CustomInputSearch = props => {
const { form } = props
const justifyAlign = props.props['x-component-props'].align || 'flex-end'
const option = props.props['x-component-props'].dataOption
const option = props.props['x-component-props'].dataoption
const [dataOption, setDataOption] = useState<any>([])
......
export interface MemberType {
id: number;
typeName: string;
}
export interface BusinessType {
id: number;
typeName: string;
}
export interface UseType {
memberType: MemberType[];
businessType: BusinessType[];
url: string;
method: string;
}
export interface UserRegister {
......
import React, {useState, useRef, useEffect} from 'react'
import { history } from 'umi';
import { Button, Form, Card, Tabs, Input, Radio, Modal, Select, Table, Checkbox, Row, Col } from 'antd'
import { Button, Form, Card, Tabs, Input, Radio, Modal, Select, Table, Checkbox, Row, Col, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
......@@ -104,6 +104,8 @@ const dataSetMember = [
const productFormActions = createFormActions()
const AddDirectChannel:React.FC<{}> = (props) => {
const productRef = useRef<any>({})
const specRef = useRef<any>({})
const ref = useRef<any>({})
const [form] = Form.useForm()
const [setForm] = Form.useForm()
......@@ -118,6 +120,8 @@ const AddDirectChannel:React.FC<{}> = (props) => {
const [visibleAddSpec, setVisibleAddSpec] = useState(false)
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const [selectProduct, setSelectProduct] = useState<GetProductChannelCommodityGetCommodityListResponse[]>()
const [specRowSelection, specRowCtl] = useRowSelectionTable()
const [selectSpec, setSelectSpec] = useState<GetProductChannelCommodityGetCommodityListResponse[]>()
const productColumns: ColumnType<any>[] = [
......@@ -134,81 +138,46 @@ const AddDirectChannel:React.FC<{}> = (props) => {
{
title: '品类',
dataIndex: ['customerCategory', 'id'],
key: 'id',
key: 'customerCategory',
},
{
title: '品牌',
dataIndex: ['brand', 'name'],
key: 'id',
key: 'brand',
},
{
title: '单位',
dataIndex: 'unitName',
key: 'unitName',
},
];
const search: IFormFilter[] = [
]
const specColumns: ColumnType<any>[] = [
{
type: 'Input',
value: 'keywords',
col: 6,
label: '商品名称',
placeHolder: '商品名称'
title: 'ID',
dataIndex: 'key',
key: 'key',
},
{
type: 'Select',
value: 'class',
col: 6,
placeHolder: '商品品类',
statusList: [{
type: 'Select',
label:'还不错',
value:'1'
},{
type: 'Select',
label:'还可以',
value:'2'
}]
title: '商品名称',
dataIndex: 'name',
key: 'name',
},
{
type: 'Select',
value: 'brand',
col: 6,
placeHolder: '商品品牌',
statusList: [{
type: 'Select',
label:'还不错',
value:'1'
},{
type: 'Select',
label:'还可以',
value:'2'
}]
title: '品类',
dataIndex: ['customerCategory', 'id'],
key: 'customerCategory',
},
{
type: 'Select',
value: 'parent',
col: 6,
placeHolder: '上级渠道',
statusList: [{
type: 'Select',
label:'AAAAA',
value:'1'
},{
type: 'Select',
label: 'BBBBB',
value:'2'
}]
title: '品牌',
dataIndex: ['brand', 'name'],
key: 'brand',
},
]
const searchBarActions: IButtonFilter[] = [
{
text: '查询',
handler: () => {
console.log('查询')
}
}
title: '单位',
dataIndex: 'unitName',
key: 'unitName',
},
]
const columnsSetPrice: ColumnType<any>[] = [
......@@ -308,24 +277,31 @@ const AddDirectChannel:React.FC<{}> = (props) => {
}
}
]
// 获取渠道商品
const fetchProductData = (params: any) => {
return new Promise((resolve, reject) => {
//@ts-ignore
PublicApi.getProductChannelCommodityGetCommodityList({...params, source: origin}).then(res => {
console.log(res, 'res')
const { data } = res
resolve(data)
})
})
}
// 获取商品规格列表
const fetchSpecData = (params: any) => {
console.log(params, '1234568')
return new Promise((resolve, reject) => {
PublicApi.getProductChannelCommodityGetCommodityUnitPrice({...params, id: 104}).then(res => {
const { data } = res
resolve(data)
})
})
}
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
//@ts-ignore
PublicApi.getProductChannelCommodityGetCommodityList(params).then(res => {
console.log(res, 'res')
const { data } = res
......@@ -391,7 +367,11 @@ const AddDirectChannel:React.FC<{}> = (props) => {
}
const handleAddSpecificationButton = () => {
setVisibleAddSpec(true)
// if(productRowCtl.selectedRowKeys[0]){
setVisibleAddSpec(true)
// }else{
// message.error('请先选择渠道商品!')
// }
}
const handleModify = (record: object) => {
......@@ -526,9 +506,11 @@ const AddDirectChannel:React.FC<{}> = (props) => {
confirm={handleOkAddTabs}
cancel={handleCancelAddTabs}
visible={visibleAddTabs}
resetModal={{destroyOnClose: true}}
columns={productColumns}
rowSelection={productRowSelection}
fetchTableData={(params:any) => fetchProductData(params)}
currentRef={productRef}
tableProps={{
rowKey: 'id',
onRow: (record) => ({
......@@ -541,7 +523,7 @@ const AddDirectChannel:React.FC<{}> = (props) => {
controlRender={
<NiceForm
actions={productFormActions}
onSubmit={values =>ref.current.reload(values)}
onSubmit={values =>productRef.current.reload(values)}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
......@@ -555,11 +537,12 @@ const AddDirectChannel:React.FC<{}> = (props) => {
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
}}
}}
schema={addChannelSchema}
/>
}
/>
<Modal
title="设置价格"
visible={modifyModal}
......@@ -657,21 +640,28 @@ const AddDirectChannel:React.FC<{}> = (props) => {
}
</Form>
</Modal>
<Modal
title="选择商品规格"
<ModalTable
modalTitle="选择商品规格"
confirm={handleOkAddSpec}
cancel={handleCancelAddSpec}
visible={visibleAddSpec}
onOk={handleOkAddSpec}
onCancel={handleCancelAddSpec}
>
<StandardTable
columns={productColumns}
rowSelection={rowSelection}
currentRef={ref}
fetchTableData={(params:any) => fetchData(params)}
formFilters={search}
buttonFilters={searchBarActions}
/>
</Modal>
resetModal={{destroyOnClose: true}}
columns={specColumns}
rowSelection={specRowSelection}
fetchTableData={(params: any) => fetchSpecData(params)}
currentRef={specRef}
tableProps={{
rowKey: 'id',
onRow: (record) => ({
onClick: () => {
specRowCtl.setSelectRow([record]);
specRowCtl.setSelectedRowKeys([record.id]);
},
})
}}
/>
<Modal
title="选择渠道会员"
visible={visibleChannelMember}
......@@ -683,8 +673,6 @@ const AddDirectChannel:React.FC<{}> = (props) => {
rowSelection={rowSelection}
currentRef={ref}
fetchTableData={(params:any) => fetchData(params)}
formFilters={search}
buttonFilters={searchBarActions}
/>
</Modal>
</Card>
......
......@@ -11,7 +11,7 @@ export const searchBrandOptionEffect = (context: any, fieldName: string) => {
// console.log(state.props['x-component-props'].searchValue, 'pagesearchvalue') // 此处可以实时获取到输入并暂存在schema props的值
PublicApi.getProductSelectGetSelectBrand({ name: state.props['x-component-props'].searchValue }).then(res => {
context.setFieldState(fieldName, state => {
state.props['x-component-props'].dataOption = res.data
state.props['x-component-props'].dataoption = res.data
})
})
})
......@@ -23,7 +23,7 @@ export const searchCustomerCategoryOptionEffect = (context: any, fieldName: stri
context.getFieldState(fieldName, state => {
PublicApi.getProductSelectGetSelectCustomerCategory({ name: state.props['x-component-props'].searchValue }).then(res => {
context.setFieldState(fieldName, state => {
state.props['x-component-props'].dataOption = res.data
state.props['x-component-props'].dataoption = res.data
})
})
})
......
......@@ -63,7 +63,7 @@ export const channelSchema: ISchema = {
notFoundContent: null,
style: { width: '174px', lineHeight: '32px' },
searchValue: null,
dataOption: [],
dataoption: [],
},
},
customerCategoryId: {
......@@ -78,7 +78,7 @@ export const channelSchema: ISchema = {
notFoundContent: null,
style: { width: '174px', lineHeight: '32px' },
searchValue: null,
dataOption: []
dataoption: []
},
},
status: {
......@@ -241,7 +241,7 @@ export const addChannelSchema: ISchema = {
filterOption: false,
notFoundContent: null,
searchValue: null,
dataOption: [],
dataoption: [],
},
},
customerCategoryId: {
......@@ -255,7 +255,7 @@ export const addChannelSchema: ISchema = {
filterOption: false,
notFoundContent: null,
searchValue: null,
dataOption: []
dataoption: []
},
},
parentMemberId: {
......
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