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

Merge branch 'featStrategies' into dev

parents a858d83e 2d143164
......@@ -59,8 +59,8 @@ const SelectChannel:React.FC<IProps> = (props) => {
const [memberTableData, setMemberTableData] = useState<IMemberTableData[]>()
const { ChannelProudctStore } = store
const {
productSelectRowInStore,
const {
productSelectRowInStore,
setSelectedRole,
setSelectChannel,
} = ChannelProudctStore
......@@ -141,7 +141,6 @@ const SelectChannel:React.FC<IProps> = (props) => {
useEffect(() => {
onRef(formMember)
// 获取所有的会员角色
PublicApi.getMemberManageRoleList().then(res => {
const { data } = res
setMemberRoleList(data)
......@@ -238,7 +237,7 @@ const SelectChannel:React.FC<IProps> = (props) => {
<Form
{...layout}
form={formMember}
name="add-channel-merchant"
name="add-channel-merchant"
labelAlign="left"
colon={false}
initialValues={{childMemberRoleId: memberRoleList[0].roleId}}
......@@ -305,7 +304,7 @@ const SelectChannel:React.FC<IProps> = (props) => {
forceRender={true}
formilyProps={
{
ctx: {
ctx: {
schema: {
type: 'object',
properties: {
......@@ -317,7 +316,7 @@ const SelectChannel:React.FC<IProps> = (props) => {
}
}
}
}
}
}
}
}
......@@ -331,4 +330,4 @@ const SelectChannel:React.FC<IProps> = (props) => {
</>)
}
export default observer(SelectChannel)
\ No newline at end of file
export default observer(SelectChannel)
......@@ -390,7 +390,7 @@ const SetPrice:React.FC<IProps> = (props) => {
}
]}
>
<Form.List name="ladderRange" key={Math.random()}>
<Form.List name="ladderRange">
{(fields, { add, remove }) => {
if (!fields.length) {
add()
......@@ -398,86 +398,63 @@ const SetPrice:React.FC<IProps> = (props) => {
return (
<div>
{fields.map(field => (
<Row key={field.key} gutter={[0, 10]}>
<Row key={ field.key } gutter={[0, 10]}>
<Col span={20} style={{ display: 'flex' }}>
<Item
<Form.Item
{...field}
name={[field.name, 'numberRange']}
fieldKey={[field.fieldKey, 'numberRange']}
key={'_' + field.fieldKey}
noStyle
name={[field.name, 'numberRange', 'numberMin']}
fieldKey={[field.fieldKey, 'numberRange', 'numberMin']}
rules={[
{ required: true, message: '阶梯最小数量为必填项' },
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值仅限三位小数',
}
]}
>
<Input placeholder="最小数量" />
</Form.Item>
<Input
style={{
width: 30,
height: 32,
borderLeft: 0,
borderRight: 0,
pointerEvents: 'none',
}}
placeholder="~"
disabled
/>
<Form.Item
{...field}
name={[field.name, 'numberRange', 'numberMax']}
fieldKey={[field.fieldKey, 'numberRange', 'numberMax']}
rules={[
{ required: true, message: '阶梯最大数量为必填项' },
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值仅限三位小数',
}
]}
>
<Input.Group compact>
<Form.Item
name={[field.name, 'numberRange', 'numberMin']}
noStyle
rules={[
{
required: true,
message: '阶梯最小数量为必填项'
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值小数点后仅限三位',
}
]}
>
<InputNumber style={{ width: 100, textAlign: 'center' }} placeholder="最小数量" />
</Form.Item>
<Input
style={{
width: 30,
borderLeft: 0,
borderRight: 0,
pointerEvents: 'none',
}}
placeholder="~"
disabled
/>
<Form.Item
name={[field.name, 'numberRange', 'numberMax']}
noStyle
rules={[
{
required: true,
message: '阶梯最大数量为必填项'
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值小数点后仅限三位',
}
]}
>
<InputNumber
className={styles.siteInputRight}
style={{
width: 100,
textAlign: 'center',
}}
placeholder="最大数量"
/>
</Form.Item>
</Input.Group>
</Item>
<Item
<Input placeholder="最大数量" />
</Form.Item>
<Form.Item
{...field}
name={[field.name, 'numberPrice']}
fieldKey={[field.fieldKey, 'numberPrice']}
key={'__' + field.fieldKey}
noStyle
rules={[
{
required: true,
message: '阶梯单价为必填项'
},
{ required: true, message: '阶梯单价为必填项' },
{
pattern: /^\d+(\.\d{1,4})?$/,
message: '阶梯单价小数点后仅限四位',
message: '阶梯单价仅限四位小数',
}
]}
style={{marginLeft: 20}}
>
<InputNumber style={{ width: '50%', marginLeft: 24 }} placeholder="请输入单价" />
</Item>
<Input placeholder="请输入单价" />
</Form.Item>
</Col>
<Col span={4}>
<Button size="small" onClick={() => add()} style={{ marginLeft: 20, marginRight: 8 }} icon={<PlusOutlined />} />
......
// 选择商品和会员弹框和商品规格的列
// 选择商品和会员弹框的列
export const columnsSetMember: any[] = [
{
title: 'ID',
......@@ -66,3 +66,87 @@ export const columnsSetProduct: any[] = [
key: 'unitName',
},
]
// 和商品规格
export const columnsUnitProduct: any[] = [
{
title: '索引',
dataIndex: '索引',
key: '索引',
align: 'center',
className: 'commonHide'
},
{
dataIndex: 'id',
key: 'id',
title: 'ID',
align: 'center',
className: "commonHide"
},
{
title: '货品ID',
dataIndex: '货品ID',
key: '货品ID',
align: 'center',
className: 'commonHide'
},
{
dataIndex: '商品名称',
key: '商品名称',
align: 'center',
title: '商品名称',
},
// ...,
// {
// dataIndex: 'memberTypeName',
// title: '单价(元)',
// render: (text, record) => {
// if (!text || JSON.stringify(text)==='{}') return null
// return Object.keys(text).map((v, i) => {
// return <><span key={i}>{v==='0-0'?'':`${v}:`} <span style={{color:'red'}}>¥{text[v]}</span></span><br /></>
// })
// }
// },
// {
// dataIndex: 'ctl',
// title: '操作',
// render: (_, record) => <>
// <Button type='link' onClick={() => handleSetProductPrice(record.productId)}>设置价格</Button>
// </>
// }
]
// 适用会员的列
export const memberColumns: any[] = [
{
dataIndex: 'memberId',
title: 'ID',
align: 'center'
},
{
dataIndex: 'name',
align: 'center',
title: '会员名称'
},
{
dataIndex: 'memberTypeName',
title: '会员类型',
align: 'center'
},
{
dataIndex: 'roleName',
title: '角色',
align: 'center'
},
{
dataIndex: 'levelTag',
title: '等级',
align: 'center'
},
{
dataIndex: 'ctl',
title: '操作',
align: 'center',
}
]
import React, { useEffect } from 'react'
import { ISchemaFormActions, FormEffectHooks, IFormActions } from '@formily/antd';
import { ISchemaFormActions, FormEffectHooks, IFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { columnsUnitProduct } from '../constant';
const { onFieldValueChange$ } = FormEffectHooks
export const createAddRepositoryEffect = (context: ISchemaFormActions) => {
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
context.setFieldState('warehouseId', state => {
state.warehouseLists = data
})
return data.map(v => ({
value: v.id,
label: v.name
}))
}
useAsyncSelect('warehouseId', fetchWarehouseAll)
// useWarehouseSelect(context)
}
// 高级筛选schema中用于输入搜索品牌的Effect
export const searchBrandOptionEffect = (context: any, fieldName: string) => {
context.getFieldState(fieldName, state => {
// 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
......@@ -37,11 +22,6 @@ export const searchBrandOptionEffect = (context: any, fieldName: string) => {
export const searchCustomerCategoryOptionEffect = (context: any, fieldName: string) => {
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
// })
// })
PublicApi.getProductCustomerGetCustomerCategoryTree().then(res => {
context.setFieldState(fieldName, state => {
state.props['x-component-props'].dataoption = res.data
......@@ -49,3 +29,74 @@ export const searchCustomerCategoryOptionEffect = (context: any, fieldName: stri
})
})
}
export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
// 预先对阶梯价格排序
data = data.map(item => {
let tempUnit: any = {}
Object.keys(item.unitPrice).sort().forEach(function(key) {
tempUnit[key] = item.unitPrice[key]
})
return {
...item,
unitPrice: tempUnit
}
})
console.log(data, 'structureTableData')
let col: any = [...columnsUnitProduct]
let temp: any = []
data[0].attributeAndValueList.map(_item => {
temp.push({title: _item.customerAttribute.name, dataIndex: [_item.customerAttribute.name, 'value'], key: _item.customerAttribute.name})
})
col.push(
{
title: '对应货品',
dataIndex: '对应货品',
key: '对应货品'
},
...temp,
{
title: '单价',
dataIndex: '单价',
key: '单价',
render: (text, record) => {
if (!text || JSON.stringify(text)==='{}') return null
return Object.keys(text).map((v, i) => {
return <><span key={i}>{v==='0-0'?'':`${v}:`} <span style={{color:'red'}}>{text[v]}</span></span><br /></>
})
}
})
let _tableData: any = []
data.map((item, index) => {
let temp: any = {}
item.attributeAndValueList.map(_item => {
temp[_item.customerAttribute.name] = {value: _item.customerAttributeValue.value, vId: _item.customerAttributeValue.id, id: _item.customerAttribute.id }
})
_tableData.push({
"id": item.id,
"索引": index,
"货品ID": item.goods?.id || '',
"商品名称": ctx.getFieldValue("productName"),
"对应货品": item.goods?.name || '',
...temp,
"单价": item.unitPrice
})
})
return {
columsUnit: col,
tableUnitData: _tableData
}
}
export const transformParamsForApi = () => {
}
import { useState, useEffect } from 'react'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
export const useModalTable = (options?) => {
const [visible, setVisible] = useState(false)
/**f */
const [rowSelection, rowSelectionCtl] = useRowSelectionTable(options)
/**是否阶梯价格 */
const [ladderPrice, setLadderPrice] = useState<boolean>(false)
/**是否批量设置 */
const [isBatchSetting, setIsBatchSetting] = useState<boolean>(false)
/**当前操作行 */
const [curretSetPriceRow, setCurrentSetPriceRow] = useState<any>()
return {
visible,
setVisible,
ladderPrice,
setLadderPrice,
isBatchSetting,
setIsBatchSetting,
curretSetPriceRow,
setCurrentSetPriceRow,
rowSelection,
rowSelectionCtl
}
}
import React, {useEffect} from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useModalTable } from '../../model/useModalTable'
import ModalTable from '@/components/ModalTable'
import { columnsSetMember } from '../../constant'
import { PublicApi } from '@/services/api'
import {formSearch } from '../../schema'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import ModalSearch from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
export interface MemberModalProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
}
const MemberModal:React.FC<MemberModalProps> = (props) => {
const { type = "checkbox", schemaAction, currentRef, ...restProps } = props
const {
visible,
setVisible,
rowSelection,
rowSelectionCtl,
} = useModalTable({type})
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
// 添加会员
const handleOkAddMember = () => {
setVisible(false)
console.log(rowSelectionCtl.selectRow, 'row')
schemaAction.setFieldValue('commodityMemberList', rowSelectionCtl.selectRow)
}
const fetchMemberList = async (params) => {
const excludeIds = await PublicApi.getProductCommodityGetStrategyMemberByCommodityId({commodityId: schemaAction.getFieldValue("productId")}, {ctlType: 'none'})
params.excludeList = excludeIds.data
const res = await PublicApi.postMemberManageLowerConsumerPage(params, {ctlType: 'none'});
return res.data
}
return (
<ModalTable
modalTitle='选择会员'
confirm={handleOkAddMember}
cancel={() => setVisible(false)}
visible={visible}
columns={columnsSetMember}
rowSelection={rowSelection}
fetchTableData={params => fetchMemberList(params)}
formilyProps={
{
ctx: {
schema: formSearch,
components: {
ModalSearch,
Submit,
},
effects: ($, actions) => {
actions.reset()
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
},
}
}
}
resetModal={{
destroyOnClose: true
}}
tableProps={{
rowKey: 'id'
}}
/>
)
}
MemberModal.defaultProps = {}
export default MemberModal
import React, {useState, useEffect, useRef} from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import {
PlusOutlined,
MinusOutlined,
} from '@ant-design/icons'
import { Button, Input, Modal, Form, Table, Checkbox, Row, Col, InputNumber } from 'antd'
import { useModalTable } from '../../model/useModalTable'
const layoutSetPrice = {
labelCol: { span: 24 },
wrapperCol: { span: 24 },
}
export interface PriceModalProps {
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
}
const PriceModal:React.FC<PriceModalProps> = (props) => {
const { schemaAction, currentRef, ...restProps } = props
const [setPriceForm] = Form.useForm()
const {
visible,
setVisible,
ladderPrice,
setLadderPrice,
isBatchSetting,
setIsBatchSetting,
curretSetPriceRow,
setCurrentSetPriceRow
} = useModalTable()
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
ladderPrice,
setLadderPrice,
isBatchSetting,
setIsBatchSetting,
curretSetPriceRow,
setCurrentSetPriceRow
}
}
}, [])
useEffect(() => {
console.log(curretSetPriceRow, 'curretSetPriceRow')
let record = {...curretSetPriceRow}
if(record && JSON.stringify(record)!=="{}" && record.id) {
setVisible(true)
console.log(schemaAction.getFieldState("memberUnitPriceList"))
setIsBatchSetting(false)
setPriceForm.resetFields()
// 0-0为 非阶梯
if(Object.keys(record['单价'])[0] === '0-0') {
setLadderPrice(false)
setPriceForm.setFieldsValue({ladderPrice: false, uniquePrice: Object.values(record['单价'])[0]})
} else if(JSON.stringify(record['单价']) === '{}') { // {} 为新增
setLadderPrice(false)
} else { // 编辑
setLadderPrice(true)
let numberArray = Object.keys(record['单价']).map(item => item.split('-').map(_ => Number(_)))
let priceArray = Object.values(record['单价'])
let tempArr = []
numberArray.map((_item, _index) => {
tempArr.push({ numberPrice: priceArray[_index], numberRange: { numberMin: _item[0], numberMax: _item[1] } })
})
setPriceForm.setFieldsValue({ladderPrice: true, ladderRange: tempArr})
}
}
}, [curretSetPriceRow])
useEffect(() => {
if(isBatchSetting) {
setPriceForm.resetFields()
}
}, [isBatchSetting])
const changeLadderPrice = (e: any) => {
setLadderPrice(e.target.checked)
setPriceForm.setFields([{name: 'ladderPrice', value: e.target.checked}])
}
const handlePriceOk = () => {
setPriceForm.validateFields().then(v => {
setVisible(false)
let memberUnitPriceList = schemaAction.getFieldValue("memberUnitPriceList")
const { ladderPrice, ladderRange } = v
let _priceRange = {}
if(ladderPrice) { // 判断阶梯价格
ladderRange.length>0 && ladderRange.map(item => {
_priceRange[`${item.numberRange.numberMin}-${item.numberRange.numberMax}`] = item.numberPrice
})
} else {
_priceRange['0-0'] = v.uniquePrice
}
let _row = { ...curretSetPriceRow, 单价: _priceRange }
let newTabeData = [...memberUnitPriceList]
if(isBatchSetting) { // 判断是否批量设置价格
newTabeData.map(item => item['单价'] = _priceRange)
} else {
newTabeData[curretSetPriceRow['索引']] = _row
}
schemaAction.setFieldValue("memberUnitPriceList", newTabeData)
})
}
// 校验阶梯范围
const validatorNumberRange = (rule, value, callback) => {
try {
if(Array.isArray(value)){
let range = value.map(item => {
if(item)
return Object.values(item.numberRange)
}).reduce(
function(a, b) {
return a.concat(b);
},
[]
)
let result = range.reduce((a, b) => { if(a<b) return b })
if(!result) throw new Error('请正确输入阶梯数量范围');
callback()
}
} catch (err) {
callback(err)
}
}
return (
<Modal
title="设置价格"
visible={visible}
onOk={handlePriceOk}
onCancel={() => setVisible(false)}
forceRender={true}
{...restProps}
>
<Form
{...layoutSetPrice}
name="settingPrice"
form={setPriceForm}
initialValues={{ladderPrice: false}}
>
<Form.Item
label=""
name="ladderPrice"
valuePropName="checked"
>
<Checkbox onChange={changeLadderPrice}>阶梯价格</Checkbox>
</Form.Item>
{
ladderPrice ? <Form.Item
name="ladderRange"
label=""
shouldUpdate={true}
rules={[
{
required: true,
message: '阶梯范围为必填项'
},
{
validator: validatorNumberRange
}
]}
>
<Form.List name="ladderRange">
{(fields, { add, remove }) => {
if (!fields.length) {
add()
}
return (
<div>
{fields.map(field => (
<Row key={Number(field.key) + 100} gutter={[0, 10]}>
<Col span={20} style={{ display: 'flex' }}>
<Form.Item
{...field}
name={[field.name, 'numberRange', 'numberMin']}
fieldKey={[field.fieldKey, 'numberRange', 'numberMin']}
rules={[
{ required: true, message: '阶梯最小数量为必填项' },
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值仅限三位小数',
}
]}
>
<Input placeholder="最小数量" />
</Form.Item>
<Input
style={{
width: 30,
height: 32,
borderLeft: 0,
borderRight: 0,
pointerEvents: 'none',
}}
placeholder="~"
disabled
/>
<Form.Item
{...field}
name={[field.name, 'numberRange', 'numberMax']}
fieldKey={[field.fieldKey, 'numberRange', 'numberMax']}
rules={[
{ required: true, message: '阶梯最大数量为必填项' },
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '阶梯数值仅限三位小数',
}
]}
>
<Input placeholder="最大数量" />
</Form.Item>
<Form.Item
{...field}
name={[field.name, 'numberPrice']}
fieldKey={[field.fieldKey, 'numberPrice']}
rules={[
{ required: true, message: '阶梯单价为必填项' },
{
pattern: /^\d+(\.\d{1,4})?$/,
message: '阶梯单价仅限四位小数',
}
]}
style={{marginLeft: 20}}
>
<Input placeholder="请输入单价" />
</Form.Item>
</Col>
<Col span={4}>
<Button size="small" onClick={() => add()} style={{ marginLeft: 20, marginRight: 8 }} icon={<PlusOutlined />} />
{field.key > 0 && (<Button size="small" onClick={() => remove(field.name)} icon={<MinusOutlined />} />)}
</Col>
</Row>)
)}
</div>
);
}}
</Form.List>
</Form.Item> : <Form.Item
label="单价"
name="uniquePrice"
rules={[
{
required: true,
type: 'number',
message: '请输入价格'
},
{
pattern: /^\d+(\.\d{1,4})?$/,
message: '小数点后仅限四位',
}
]}
>
<InputNumber min={0} style={{width: '100%'}} placeholder="请输入价格" />
</Form.Item>
}
</Form>
</Modal>
)
}
PriceModal.defaultProps = {}
export default PriceModal
import React, {useState, useEffect, useRef} from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useModalTable } from '../../model/useModalTable'
import ModalTable from '@/components/ModalTable'
import { columnsSetProduct } from '../../constant'
import { GlobalConfig } from '@/global/config'
import { PublicApi } from '@/services/api'
import { formProduct } from '../../schema'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import ModalSearch from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
import SearchSelect from '@/components/NiceForm/components/SearchSelect'
export interface ProductModalProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
}
const ProductModal:React.FC<ProductModalProps> = (props) => {
const { type = "radio" ,schemaAction, currentRef, ...restProps } = props
const {
visible,
setVisible,
rowSelection,
rowSelectionCtl,
} = useModalTable({type})
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
// 指定商品
const fetchProductList = async (params) => {
const shopId = schemaAction.getFieldValue('shopId')
let shopInfo: any = GlobalConfig.web.shopInfo.filter(item => item.id === shopId)
console.log(shopInfo, 'shopInfo')
const res = await PublicApi.getProductCommodityCommonGetCommodityListBySeller({
...params,
shopType: shopInfo[0]["type"],
environment: shopInfo[0].environment,
priceTypeList: [1, 2],
})
return res.data
}
// 商品添加弹窗控制
const handleOkAddProduct = async () => {
setVisible(false)
const selectResult = rowSelectionCtl.selectRow[0]
if (!selectResult) {
return null
}
schemaAction.setFieldValue('productName', selectResult.name)
schemaAction.setFieldValue('productId', selectResult.commodityId)
}
return (
<ModalTable
modalTitle='选择商品'
confirm={handleOkAddProduct}
cancel={() => setVisible(false)}
visible={visible}
columns={columnsSetProduct}
rowSelection={rowSelection}
fetchTableData={params => fetchProductList(params)}
formilyProps={
{
ctx: {
schema: formProduct,
components: {
ModalSearch,
SearchSelect, Submit
},
effects: ($, actions) => {
actions.reset()
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
}
}
}
}
resetModal={{
destroyOnClose: true
}}
tableProps={{
rowKey: 'id',
}}
/>
)
}
ProductModal.defaultProps = {}
export default ProductModal
......@@ -106,6 +106,7 @@ const PriceManage: React.FC<{}> = () => {
handleConfirm={() => handleUpdateState(record)}
record={record}
fieldNames="isEnable"
expectTrueValue={true}
/>
),
filters: [
......
import React, { useState, useEffect, useRef, ReactNode } from 'react'
import { Button, Form, Card, Modal, Checkbox, Row, Col, Input, } from 'antd'
import React, { useState } from 'react'
import { Button, message, Card, } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { history } from "umi"
import ReutrnEle from '@/components/ReturnEle'
......@@ -9,6 +9,8 @@ import { setPriceSchema } from '../schema'
import PriceSetting from './component/PriceSetting'
import './index.less'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { PublicApi } from '@/services/api'
import { omit } from '@/utils'
const addSchemaAction = createFormActions()
......@@ -19,24 +21,41 @@ const SetStrategy: React.FC<{}> = () => {
pageStatus
} = usePageStatus()
const [btnLoading, setBtnLoading] = useState<boolean>(false)
// 整体表单提交
const formSubmit = async (values) => {
console.log(values, 'values')
// const params = omit(values, ['NO_SUBMIT3'])
// if (params['applyMember']) {
// params['applyMember'] = params['applyMember']
// }
// if(!params['isAllMemberShare'] && !params['applyMember']?.length) {
// message.error('请选择指定会员')
// } else {
// addSchemaAction.getFieldState('warehouseId', prevState => {
// params['warehouseName'] = prevState.props.enum.filter((item: any) => item.value === prevState.value)[0]['label']
// })
// await PublicApi.postWarehouseFreightSpaceAdd(params)
// setTimeout(() => {
// history.goBack(-1)
// }, 1000)
// }
const formSubmit = async (params) => {
console.log(params, '原始参数', addSchemaAction.getFieldState("shopId").dataSource)
if(!params['commodityMemberList'] && !params['commodityMemberList']?.length) {
message.error('请选择指定适用会员')
} else {
let _params: any = {}
_params["name"] = params.name
_params["priceType"] = params.priceType
_params["shopName"] = addSchemaAction.getFieldState("shopId").dataSource[0]["name"]
_params["commodity"] = { id: params.productId }
_params["commodityMemberList"] = params.commodityMemberList.map(item => ({
memberId: item.memberId,
memberName: item.name,
memberTypeName: item.memberTypeName,
memberRoleId: item.roleId,
memberRoleName: item.roleName,
}))
_params["memberUnitPriceList"] = params.memberUnitPriceList.map(item => ({
commodityUnitPrice: { id: item.id },
unitPrice: item["单价"]
}))
console.log(_params, '传输参数')
await PublicApi.postProductCommoditySaveOrUpdateUnitPriceStrategy(_params)
setTimeout(() => {
history.goBack(-1)
}, 1000)
}
}
return (
......@@ -49,8 +68,8 @@ const SetStrategy: React.FC<{}> = () => {
extra={(
pageStatus !== PageStatus.PREVIEW
? (
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
<Button key="1" loading={btnLoading} onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
</Button>
)
: null
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { GlobalConfig } from '@/global/config';
import { SHOP_TYPES } from '@/constants';
import { SHOP_TYPE } from '@/constants';
import { PublicApi } from '@/services/api';
// 将获取的商城转化为可用类型
const getShopTypeMap = (() => {
return GlobalConfig.web.shopInfo.reduce((prev, next) => {
const shopTypeEnumValue = SHOP_TYPES.find(v => v.value === next.type)
if (!shopTypeEnumValue) {
return prev
}
if (!prev.find(v => v.value === shopTypeEnumValue.value)) {
prev.push(shopTypeEnumValue)
let a = GlobalConfig.web.shopInfo.reduce((prev, next) => {
// const shopTypeEnumValue = SHOP_TYPES.find(v => v.value === next.id)
// if (!shopTypeEnumValue) {
// return prev
// }
// if (!prev.find(v => v.value === shopTypeEnumValue.value)) {
// prev.push(shopTypeEnumValue)
// }
// return prev
if(next.type === SHOP_TYPE["mall"]) {
prev.push({ label: next["name"], value: next["id"] })
}
return prev
}, [])
console.log(a)
return a
// return GlobalConfig.web.shopInfo.reduce((prev, next) => {
// const shopTypeEnumValue = SHOP_TYPES.find(v => v.value === next.type)
// if (!shopTypeEnumValue) {
// return prev
// }
// if (!prev.find(v => v.value === shopTypeEnumValue.value)) {
// prev.push(shopTypeEnumValue)
// }
// return prev
// }, [])
})()
// 列表高级筛选
......@@ -188,8 +204,8 @@ export const setPriceSchema: ISchema = {
},
]
},
shopType: {
type: 'string',
shopId: {
type: 'number',
enum: getShopTypeMap,
title: '适用商城',
required: true
......@@ -226,18 +242,6 @@ export const setPriceSchema: ISchema = {
],
default: 1
},
// category: {
// type: 'string',
// display: false
// },
// brand: {
// type: 'string',
// display: false
// },
// unit: {
// type: 'string',
// display: false
// },
}
}
}
......@@ -257,17 +261,17 @@ export const setPriceSchema: ISchema = {
labelAlign: 'left'
},
properties: {
applyMember0: {
type: 'array:number',
memberUnitPriceList: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'memberId',
columns: "{{tableProductColumns}}",
prefix: "{{tableAddProductButton}}",
pagination: {
"onChange": "{{paginationChange}}",
"total": "{{membersLength}}"
}
rowKey: 'id',
columns: "{{columnsUnitProduct}}",
prefix: "{{batchPriceButton}}",
// pagination: {
// "onChange": "{{paginationChange}}",
// "total": "{{membersLength}}"
// }
}
}
}
......@@ -289,17 +293,17 @@ export const setPriceSchema: ISchema = {
labelAlign: 'left'
},
properties: {
applyMember1: {
commodityMemberList: {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'memberId',
columns: "{{tableMemberColumns}}",
columns: "{{memberColumns}}",
prefix: "{{tableAddMemberButton}}",
pagination: {
"onChange": "{{paginationChange}}",
"total": "{{membersLength}}"
}
// pagination: {
// "onChange": "{{paginationChange}}",
// "total": "{{membersLength}}"
// }
}
}
}
......@@ -322,6 +326,7 @@ export const setPriceSchema: ISchema = {
'x-component-props': {
placeholder: '请输入会员名字',
align: 'flex-left',
advanced: false,
},
},
[FORM_FILTER_PATH]: {
......@@ -339,41 +344,13 @@ export const setPriceSchema: ISchema = {
},
},
properties: {
memberTypeId: {
type: 'string',
"x-component": 'Select',
"x-component-props": {
options: [],
style: {width: '180px'},
placeholder: '请选择会员类型'
}
},
level: {
type: 'string',
"x-component": 'Select',
"x-component-props": {
options: [],
style: {width: '180px'},
placeholder: '请选择会员等级'
}
},
roleId: {
type: 'string',
"x-component": 'Select',
"x-component-props": {
options: [],
style: {width: '180px'},
placeholder: '请选择会员角色'
}
},
submit: {
"x-component": 'Submit',
"x-mega-props": {
span: 1
},
"x-component-props": {
children: '查询'
children: '查询',
}
}
}
......
......@@ -64,13 +64,11 @@ const Repositories: React.FC<{}> = () => {
{
title: '仓位ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '仓位名称',
dataIndex: 'name',
align: 'center',
key: 'name',
render: (text: any, record: any) => (
<EyePreview
......@@ -82,37 +80,31 @@ const Repositories: React.FC<{}> = () => {
},
{
title: '商品名称',
align: 'center',
dataIndex: 'productName',
key: 'productName',
},
{
title: '品类',
align: 'center',
dataIndex: 'category',
key: 'category',
},
{
title: '品牌',
align: 'center',
dataIndex: 'brand',
key: 'brand',
},
{
title: '单位',
align: 'center',
dataIndex: 'unit',
key: 'unit',
},
{
title: '库存',
align: 'center',
dataIndex: 'inventory',
key: 'inventory',
},
{
title: '仓位状态',
align: 'center',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => (
......@@ -126,7 +118,6 @@ const Repositories: React.FC<{}> = () => {
{
title: '操作',
dataIndex: 'option',
align: 'center',
render: (text: any, record: any) => {
return (
<>
......
......@@ -10,6 +10,7 @@ import { PublicApi } from '@/services/api';
import { filterProductDataById } from '../components/productModalTable'
import { getUnitPriceTotal } from '../model/useProductTable';
import moment from 'moment';
import { OrderModalType } from '@/constants';
let updateFlag = false
......@@ -106,11 +107,12 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
} else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
const orderModel = ctx.getFieldValue('orderModel')
fetchOrderApi.getPayInfoList({
productId: productItem?.commodityId ? productItem.id : productItem.productId,
productId: orderModel === OrderModalType["HAND_ORDER"] ? productItem.id : productItem.productId,
memberId: productItem?.memberId || ctx.getFieldValue('supplyMembersId'),
memberRoleId: productItem?.memberRoleId || ctx.getFieldValue('supplyMembersRoleId'),
orderModel: ctx.getFieldValue('orderModel'),
orderModel: orderModel,
}).then(data => {
ctx.setFieldValue('paymentInformationResponses', data)
}).catch(err => {
......
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