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

fix: 交易规则多批次多支付处理,商品批量上下架,询价报价下单修改

parent f96d8657
......@@ -5,11 +5,13 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
FileExcelOutlined,
EyeOutlined,
QuestionCircleOutlined,
DownOutlined,
DeleteOutlined,
ExclamationCircleOutlined
ExclamationCircleOutlined,
ImportOutlined,
ArrowUpOutlined,
ArrowDownOutlined
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
......@@ -29,6 +31,7 @@ import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable'
import { priceTypeLabel, productStatusLabel } from './constant'
import EyePreview from '@/components/EyePreview'
import UpperProductModalTable from './components/upperProductModalTable'
import { Item } from '@/components/ButtonTabs'
const { Option } = Select;
const { confirm } = Modal;
......@@ -426,8 +429,9 @@ const Products: React.FC<{}> = () => {
icon: <ExclamationCircleOutlined />,
onOk() {
PublicApi.postProductCommodityCopyCommodity({id: id}).then(res => {
if(res.code === 1000)
if(res.code === 1000) {
ref.current.reload()
}
})
},
onCancel() {
......@@ -449,18 +453,46 @@ const Products: React.FC<{}> = () => {
})
}
const handleBatch = (type: string, ids: string[] = []) => {
const fn = type === '3' ? PublicApi.postProductCommodityPublishCommodityBatch : PublicApi.postProductCommodityOffPublishCommodityBatch
if(ids.length) {
confirm({
title: `确定要执行批量${type==='3'?'上架':'下架'}操作?`,
icon: <ExclamationCircleOutlined />,
onOk() {
fn({idList: ids}).then(res => {
if(res.code === 1000) {
ref.current.reload()
}
})
},
okType: type==='3'?'primary':'danger',
onCancel() {
console.log('Cancel');
},
okText: '确定',
cancelText: '取消'
})
} else {
message.error('请选择需要操作的商品')
}
}
const handleMenuClick = (e: any) => {
// 1 批量删除;2 删除导入批次
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架
if(e.key === '1'){
console.log('批量删除')
handleBatchDelete(currentRef.current, true)
}else if(e.key === '2'){
console.log('删除导入批次')
setDeleteBatchModal(true)
} else if(e.key === '0') {
handleUpperCommodity()
} else if(e.key === '3' || e.key === '4') {
handleBatch(e.key, currentRef.current)
}
}
const handleBatchDelete = (ids: string[], param?: boolean) => {
const handleBatchDelete = (ids: string[] = [], param?: boolean) => {
if(ids.length) {
if(param){
confirm({
......@@ -514,12 +546,21 @@ const Products: React.FC<{}> = () => {
const menuMore = (
<Menu onClick={(e) => handleMenuClick(e)}>
<Menu.Item key="1" icon={<DeleteOutlined />}>
批量删除
<Menu.Item key="0" icon={<ImportOutlined />}>
导入上游供应商品
</Menu.Item>
{/* <Menu.Item key="2" icon={<DeleteOutlined />}>
删除导入批次
</Menu.Item> */}
<Menu.Item key="3" icon={<ArrowUpOutlined />}>
批量上架
</Menu.Item>
<Menu.Item key="4" icon={<ArrowDownOutlined />}>
批量下架
</Menu.Item>
<Menu.Item key="1" icon={<DeleteOutlined />}>
批量删除
</Menu.Item>
</Menu>
)
......@@ -532,7 +573,6 @@ const Products: React.FC<{}> = () => {
<PlusOutlined />新建
</Button>
{/* <Button style={{margin:'0 16px'}} onClick={()=>setImportModal(true)}>导入数据</Button> */}
<Button style={{margin:'0 16px'}} onClick={handleUpperCommodity}>导入上游供应商品</Button>
<Dropdown overlay={menuMore} trigger={['click']}>
<Button>
更多 <DownOutlined />
......
......@@ -114,7 +114,7 @@ export const transformParamsForApi = (data: any, ctx: ISchemaFormActions | ISche
_params["priceType"] = data.priceType
let shopInfo = ctx.getFieldState("shopId").dataSource[0]
// _params["shopName"] = ctx.getFieldState("shopId").dataSource[0]["name"]
_params["shopId"] = shopInfo["id"]
_params["type"] = shopInfo["type"]
_params["environment"] = shopInfo["environment"]
_params["commodity"] = { id: data.productId }
......
......@@ -29,10 +29,20 @@ const InquiryModalTable:React.FC<InquiryModalTableProps> = (props) => {
}
}, [])
useEffect(() => {
if(visible) {
const quoteId = schemaAction.getFieldValue('quoteId')
if(quoteId) {
rowSelectionCtl.setSelectedRowKeys([quoteId])
}
}
}, [visible])
const handleConfirm = async () => {
const item = rowSelectionCtl.selectRow[0]
if (item) {
schemaAction.setFieldValue('quoteNo', item.quotationNo)
schemaAction.setFieldValue('quoteId', item.id)
const data = await fetchOrderApi.getProductListByQuotationOrderId({
id: item.inquiryListId
})
......
......@@ -64,7 +64,6 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
}) => {
const formItemRef = useRef<any>();
const { form, childOptions, setChildOptions, originOptions } = useContext(EditableContext);
let _childOptions = null;
if(history.location.query?.id && title === "支付渠道") {
let payList = originOptions.filter(item => item.payType === record.payType) || []
......@@ -149,6 +148,7 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
if (editable) {
// console.log(dataIndex, record)
childNode = (forceEdit) ? (
<Form.Item
style={{ margin: 0 }}
......
......@@ -43,6 +43,9 @@ export const procurmentRenderInit = (initValue: any) => {
deliverDate: initValue.consignee.deliverDate,
theInvoiceId: initValue.invoice?.invoiceId || null,
quoteNo: initValue.quoteNo,
quoteId: initValue.quoteId,
shopId: initValue.shopId,
payments: initValue.payments,
}
}
......@@ -52,6 +55,7 @@ export const procurementRenderField = (data) => {
return _orderProductRequests.map(item => {
return {
...item,
commodityId: item.productId,
productId: item.skuId,
productName: item.name,
logistics: item.deliverType,
......
......@@ -81,12 +81,13 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if (value && value.length > 0 && !state.loading){ // 添加loading判断避免二次调用
// 请求一次并复制给支付信息
const productItem = value[0]
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
// if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
} else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
const shopId = ctx.getFieldValue('shopId')
const products = value.map(item => ({ productId: item.commodityId, skuId: item.productId }))
if(shopId && products?.length)
// } else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
const shopId = ctx.getFieldValue('shopId')
const products = value.map(item => ({ productId: item.commodityId, skuId: item.productId }))
if(shopId && products?.length) {
console.log(value)
fetchOrderApi.getPayInfoList({
products: products,
memberId: productItem?.memberId,
......@@ -102,6 +103,7 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
})
}
// }
}
// 确认后 需根据商品id请求会员折扣接口, 以及配送方式
......
......@@ -69,7 +69,6 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
}, [sum, freePrice])
useEffect(() => {
console.log(data,'ddd')
// 存在商品 并且有选择收货地址,则开始计算运费,此外 收货方式变动也要重新计算
if (data && data.length > 0 && receiverAddressId) {
// 筛选配送方式为物流的商品并且使用了运费模板
......@@ -129,11 +128,12 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
return resultState
})
const [products, setProducts] = useState<any>([])
const [paymentColumns, paymentComponents, paymentSave] = usePaymentInfo(
addSchemaAction,
addSchemaAction.getFieldValue('vendorMemberId'),
addSchemaAction.getFieldValue('vendorRoleId'),
pageStatus === PageStatus.ADD ? addSchemaAction.getFieldValue('products') : initFormValue.products
pageStatus === PageStatus.ADD ? addSchemaAction.getFieldValue('products') : products
)
// 订单商品
const { productAddButton, productRef, productColumns, productComponents, ...sectionProps } = useProductTable(addSchemaAction)
......@@ -148,6 +148,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}).then(res => {
const { data } = res
const _orderProductRequests = procurementRenderField(data)
setProducts(_orderProductRequests)
setInitFormValue(() => procurmentRenderInit(data))
setTimeout(() => {
addSchemaAction.setFieldValue('products', _orderProductRequests)
......
......@@ -4,7 +4,7 @@ import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useEffect, useState, useRef } from 'react'
import { PublicApi } from '@/services/api'
export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, memberId: any, memberRoleId: any, orderProducts: any = []): any => {
export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, memberId: any, memberRoleId: any, products: any = []): any => {
const paywayData = useRef<any>({})
const [columns, setColumns] = useState<any[]>(paymentInformationColumns)
// const { schemaActions, detailData } = useContext(ReadyAddOrderDetailContext)
......@@ -17,10 +17,10 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
useEffect(() => {
// 当选择报价单/会员/商品时有memberId传入时 调用支付方式api
if(memberId) {
if(memberId && products.length) {
getPayLists(memberId, memberRoleId)
}
}, [memberId])
}, [memberId, products])
const initPayWayList = (memberId, memberRoleId) => {
let result = []
......@@ -43,7 +43,7 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
roleId: memberRoleId,
shopId: ctx.getFieldValue('shopId'),
orderMode: ctx.getFieldValue('orderMode'),
products: orderProducts.map(item => ({ productId: item.commodityId, skuId: item.productId }))
products: products.map(item => ({ productId: item.commodityId, skuId: item.productId }))
}, { ctlType: 'none' }).then(res => {
const { code, data } = res
if (code === 1000) {
......
......@@ -66,7 +66,7 @@ const basicInfo: ISchema = {
],
},
shopId: {
type: 'string',
type: 'number',
enum: getShopTypeMap,
title: '适应商城',
required: true,
......@@ -107,6 +107,11 @@ const basicInfo: ISchema = {
}
],
},
quoteId: {
type: 'number',
title: '报价单号ID',
visible: false,
},
vendorMemberName: {
type: 'string',
title: '供应会员',
......
......@@ -55,10 +55,11 @@ const AddRule:React.FC<{}> = (props) => {
if(params?.payments && params.payments.length > 0) {
params.payments = params.payments.map(item => ({
...item,
payRate: Number(item['payRate'])
nodes: item.nodes.map(_item => ({ ..._item, payRate: Number(_item.payRate) }))
}))
// 百分比校验
if(params.payments.reduce((a, b) => a + b.payRate, 0) !== 100) {
const possess = params.payments.reduce((a, b) => a.concat(b['nodes']), [])
if(possess.reduce((a, b) => a + b.payRate, 0) !== 100) {
setIsDisabled(false)
return message.error('支付比例之和100')
}
......
......@@ -7,7 +7,7 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { createAddContractTemplateEffect } from '../effects'
import { PublicApi } from '@/services/api'
import { PlusOutlined } from '@ant-design/icons'
import { Button, message } from 'antd'
import { Button, message, Table } from 'antd'
import NiceForm from '@/components/NiceForm'
import ModalTable from '@/components/ModalTable'
import { GlobalConfig } from '@/global/config'
......@@ -315,6 +315,28 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
})
}
// 自定义支付批次配置组件
const CustomPayments = props => {
const { value } = props
return (<div>
{
value?.length
?
value.map(item => <div key={`out_${item.serialNo}`}>
<p>{`支付批次:${item.serialNo}`}</p>
<Table
components={paymentComponents}
dataSource={item.nodes}
columns={paymentColumns}
pagination={false}
/>
</div>)
:
null
}
</div>)
}
return (
<>
<NiceForm
......@@ -332,6 +354,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}}
components={{
SelectProcesss,
CustomPayments
}}
effects={($, { setFieldState, setFieldValue }) => {
FormEffectHooks.onFormInputChange$().subscribe(() => {
......@@ -370,20 +393,15 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
// 不是多次支付 隐藏支付配置
if(selectedObject && selectedObject['payTimes'] > 0) {
console.log(selectedObject, 'ds')
setFieldState("payments", state => {
state.visible = true
})
// if(pageStatus === PageStatus.ADD) {
let initPayments: any[] = [];
for(let i = 1; i <= selectedObject['payTimes']; i++) {
initPayments.push({
batchNo: i,
payNode: null,
payRate: null
})
}
setFieldValue("payments", initPayments)
// }
setFieldValue("payments", selectedObject['payments'].map(item => ({
...item,
// 冗余批次号到环节里面
nodes: item['nodes'].map(_item => ({ ..._item, serialNo: item['serialNo'] }))
})))
} else {
setFieldState("payments", state => {
state.visible = false
......
......@@ -46,14 +46,18 @@ export const usePaymentTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('payments')];
const index = newData.findIndex(item => row.batchNo === item.batchNo);
const item = newData[index];
newData.splice(index, 1, {
...item,
const paymentIndex = newData.findIndex(item => row.serialNo === item.serialNo )
const nodeItem = newData[paymentIndex]['nodes']
const nodeIndex = nodeItem.findIndex(item => row.batchNo === item.batchNo)
nodeItem.splice(nodeIndex, 1, {
...nodeItem[nodeIndex],
...row,
});
newData[paymentIndex]['nodes'] = nodeItem
ctx.setFieldValue('payments', newData)
resolve({item, newData})
resolve({nodeItem, newData})
})
};
......
......@@ -117,18 +117,25 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
}
}
},
// 处理成多个表格
"payments": {
type: 'array:number',
type: 'array',
title: '支付配置',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'batchNo',
columns: "{{paymentColumns}}",
components: "{{paymentComponents}}",
pagination: false,
},
visible: false
'x-component': 'CustomPayments',
visible: false,
},
// "payments": {
// type: 'array:number',
// title: '支付配置',
// "x-component": 'MultTable',
// "x-component-props": {
// rowKey: 'batchNo',
// columns: "{{paymentColumns}}",
// components: "{{paymentComponents}}",
// pagination: false,
// },
// visible: false
// },
"processType": {
type: 'number',
title: '流程类型',
......
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