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

fix: 处理合并下单参数异常问题,处理新增价格策略提交时页面显示异常问题,对订单上级状态审核不通过时禁用审核通过处理

parent d4446fce
......@@ -1051,6 +1051,7 @@ export const PurchaseOrderInsideWorkStateTexts = {
17: '待手工收货',
18: '已确认收货',
19: '已归档',
20: '待确认电子合同',
}
// 销售订单内部显示文案
......
......@@ -101,16 +101,18 @@ const UserSystem: React.FC<{}> = () => {
dataIndex: 'option',
align: 'center',
render: (text:any, record:any) => {
return record.status === 0 && (
return (
<>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => deleteItem(record)}
okText="是"
cancelText="否"
>
<Button type='link'>删除</Button>
</Popconfirm>
{
record.status === 0 && <Popconfirm
title="确定要执行这个操作?"
onConfirm={() => deleteItem(record)}
okText="是"
cancelText="否"
>
<Button type='link'>删除</Button>
</Popconfirm>
}
<Button type='link' onClick={()=>updateItem(record)}>修改</Button>
</>
)
......
......@@ -81,7 +81,6 @@ export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaF
data.map((item, index) => {
let temp: any = {}
let _item_differ = pageStatus === PageStatus.ADD ? item : item["commodityUnitPrice"]
console.log(_item_differ, '_item_differ')
_item_differ.attributeAndValueList.map(_item => {
temp[_item.customerAttribute.name] = {
value: _item.customerAttributeValue.value,
......
......@@ -10,6 +10,7 @@ import { FORM_FILTER_PATH } from '@/formSchema/const'
import ModalSearch from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
import { PageStatus, usePageStatus } from '@/hooks/usePageStatus'
import { clearModalParams } from '@/utils'
export interface MemberModalProps {
type?: 'radio' | 'checkbox',
......@@ -66,6 +67,12 @@ const MemberModal:React.FC<MemberModalProps> = (props) => {
state.dataSource = rowSelectionCtl.selectRow
})
}
clearModalParams()
}
const handleCancelAddMember = () => {
setVisible(false)
clearModalParams()
}
const fetchMemberList = async (params) => {
......@@ -90,7 +97,7 @@ const MemberModal:React.FC<MemberModalProps> = (props) => {
<ModalTable
modalTitle='选择会员'
confirm={handleOkAddMember}
cancel={() => setVisible(false)}
cancel={handleCancelAddMember}
visible={visible}
columns={columnsSetMember}
rowSelection={rowSelection}
......
......@@ -23,7 +23,7 @@ export interface PriceSettingProps {
addSchemaAction: ISchemaFormActions,
schema: ISchema,
onFieldChange?(),
formSubmit?(values)
formSubmit?(values),
}
const PriceSetting:React.FC<PriceSettingProps> = (props) => {
......@@ -59,7 +59,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
}
}, [])
// 删除会员
const handleDeleteMemberTable = (reocrd) => {
const value = addSchemaAction.getFieldValue('commodityMemberList')
......@@ -159,7 +158,7 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
})
ctx.setFieldValue("memberUnitPriceList", priceType === 2 ? tableUnitData.map(item => { delete item["单价"]; return item }) : tableUnitData)
console.log(columsUnit, tableUnitData, source)
// console.log(columsUnit, tableUnitData, source)
// 填充适用会员table
ctx.setFieldState("commodityMemberList", state => {
......@@ -231,36 +230,7 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
$('onFieldValueChange', 'productId').subscribe(async parentState => {
if (parentState.value) {
// const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({
// id: parentState.value,
// })
// if(res.code === 1000) {
// // 填充价格设置table
// const { columsUnit, tableUnitData } = constructTableData(res.data, ctx)
// ctx.setFieldState("memberUnitPriceList", state => {
// state.dataSource = res.data // 存源数据
// columsUnit.push({
// dataIndex: 'ctl',
// title: '操作',
// align: 'center',
// render: (_i, _r) => <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
// })
// state.props["x-component-props"].columns = columsUnit
// })
// ctx.setFieldValue("memberUnitPriceList", tableUnitData)
// console.log(columsUnit, tableUnitData, res.data)
// // 填充适用会员table
// ctx.setFieldState("commodityMemberList", state => {
// memberColumns[memberColumns.length -1].render = (text, record) => {
// return <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleDeleteMemberTable(record)}>删除</Button>
// }
// state.props["x-component-props"].columns = memberColumns
// })
// }
producePriceTableMemerColumn(parentState.value, ctx)
}
})
......@@ -302,4 +272,4 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
PriceSetting.defaultProps = {}
export default PriceSetting
export default React.memo(PriceSetting)
import React, { useEffect, useState } from 'react'
import React, { useCallback, useState } from 'react'
import { Button, message, Card, } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { history } from "umi"
......@@ -12,6 +12,7 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { PublicApi } from '@/services/api'
import { omit } from '@/utils'
import { transformParamsForApi } from '../effect'
import { useHttpRequest } from '@/hooks/useHttpRequest'
const addSchemaAction = createFormActions()
......@@ -25,28 +26,27 @@ const SetStrategy: React.FC<{}> = () => {
const [btnLoading, setBtnLoading] = useState<boolean>(false)
// 整体表单提交
const formSubmit = async (values) => {
const formSubmit = useCallback(async (values) => {
setBtnLoading(true)
// console.log(values, '原始参数', addSchemaAction.getFieldState("shopId").dataSource)
if(!values['commodityMemberList'] && !values['commodityMemberList']?.length) {
message.error('请选择指定适用会员')
} else {
const { params } = transformParamsForApi(values, addSchemaAction)
let _params = {}
if(id) {
_params["id"] = Number(id)
}
await PublicApi.postProductCommoditySaveOrUpdateUnitPriceStrategy({...params, ..._params})
setTimeout(() => {
setBtnLoading(false)
history.goBack(-1)
}, 1000)
let res = await PublicApi.postProductCommoditySaveOrUpdateUnitPriceStrategy({...params, ..._params})
if(res.code === 1000) {
setTimeout(() => {
history.goBack(-1)
}, 1000)
}
setBtnLoading(false)
}
}
}, [])
return (
<PageHeaderWrapper
......@@ -65,7 +65,7 @@ const SetStrategy: React.FC<{}> = () => {
)}
>
<Card>
<PriceSetting addSchemaAction={addSchemaAction} schema={setPriceSchema} formSubmit={formSubmit}/>
<PriceSetting addSchemaAction={addSchemaAction} schema={setPriceSchema} formSubmit={formSubmit} />
</Card>
</PageHeaderWrapper>
)
......
......@@ -104,10 +104,10 @@ export const schema: ISchema = {
label: '价格需要询价',
value: 2,
},
{
label: '积分兑换商品',
value: 3,
}
// {
// label: '积分兑换商品',
// value: 3,
// }
],
'x-component-props': {
placeholder: '商品定价',
......
......@@ -76,6 +76,9 @@ const ApproveSchemaUseContract = {
{ label: '审核不通过', value: 0 },
],
default: 1,
"x-component-props": {
disabled: false,
},
"x-linkages": [
{
type: 'value:visible',
......@@ -135,6 +138,9 @@ const ApproveSchema = {
{ label: '审核不通过', value: 0 },
],
default: 1,
"x-component-props": {
disabled: false,
},
"x-linkages": [
{
type: 'value:visible',
......@@ -184,14 +190,6 @@ const ApprovedOrderModal:React.FC<ApprovedOrderModalProps> = (props) => {
const { data } = useContext(OrderDetailContext)
const [checkedContract, setCheckedContract] = useState<boolean>(false)
// useEffect(() => {
// console.log(data)
// // 上一级审核不通过
// if(data && data.purchaseOrderInteriorState === 6) {
// approvedActions.setFieldValue("state", 0)
// }
// }, [data])
useEffect(() => {
if (currentRef) {
currentRef.current = Object.assign({}, currentRef.current, {actions: approvedActions})
......@@ -220,7 +218,8 @@ const ApprovedOrderModal:React.FC<ApprovedOrderModalProps> = (props) => {
children: <><Checkbox onChange={onChange} />&nbsp;&nbsp;<a href={data.electronicContractUrl} target="blank">{data.electronicContractName}</a></>
}
})
if(data && data.purchaseOrderInteriorState === 6) {
// 上级审核不通过
if(data && (data.purchaseOrderInteriorState === 7 || data.purchaseOrderInteriorState === 8)) {
ctx.setFieldValue("state", 0)
ctx.setFieldState("state", state => {
state.props["x-component-props"] = {
......
......@@ -276,7 +276,7 @@ const OrderDeleveRecord:React.FC<OrderDeleveRecordProps> = (props) => {
<MellowCard style={{marginTop: 24}} bordered={false} id='deleveBox'>
<Tabs defaultActiveKey="2">
{
orderReceivingStatisticsResponses?.length > 0 && <Tabs.TabPane tab='订单收货统计' key="1">
orderReceivingStatisticsResponses?.length > 0 && <Tabs.TabPane tab='订单收货统计' key="1">
<Table
columns={outOrderCols}
dataSource={orderReceivingStatisticsResponses}
......@@ -286,7 +286,7 @@ const OrderDeleveRecord:React.FC<OrderDeleveRecordProps> = (props) => {
</Tabs.TabPane>
}
{
orderDeliveryDetailsResponses?.length > 0 && <Tabs.TabPane tab='订单收货明细' key="2">
orderDeliveryDetailsResponses?.length > 0 && <Tabs.TabPane tab='订单收货明细' key="2">
<NestTable
NestColumns={[sideOrderCols, sideChildrenCols]}
rowKey='id'
......
......@@ -57,10 +57,11 @@ const OrderPayTabs:React.FC<OrderPayTabsProps> = (props) => {
{dataSource.channel !== 0 && '¥'}
{dataSource.payPrice || 0}
{
dataSource.refundPrice &&
<Tooltip title={`本次实际支付金额(¥${data.payPrice})=本次订单待支付金额(¥${data.payPrice+data.refundPrice})-售后待退款金额(¥${data.refundPrice})`}>
<QuestionCircleOutlined />
</Tooltip>
dataSource.refundPrice && <>&nbsp;
<Tooltip title={`本次实际支付金额(¥${dataSource.payPrice})=本次订单待支付金额(¥${dataSource.payPrice+dataSource.refundPrice})-售后待退款金额(¥${dataSource.refundPrice})`}>
<QuestionCircleOutlined />
</Tooltip>
</>
}
</div>
</Col>
......
......@@ -336,7 +336,7 @@ const OrderSaleRecord:React.FC<OrderSaleRecordProps> = (props) => {
<MellowCard style={{marginTop: 24}} bordered={false} id='deleveBox'>
<Tabs defaultActiveKey="2" animated={false}>
{
orderReceivingStatisticsResponses?.length > 0 && <Tabs.TabPane tab='订单发货统计' key="1">
orderReceivingStatisticsResponses?.length > 0 && <Tabs.TabPane tab='订单发货统计' key="1">
<Table
columns={outOrderCols}
dataSource={orderReceivingStatisticsResponses}
......@@ -346,7 +346,7 @@ const OrderSaleRecord:React.FC<OrderSaleRecordProps> = (props) => {
</Tabs.TabPane>
}
{
orderDeliveryDetailsResponses?.length > 0 && <Tabs.TabPane tab='订单发货明细' key="2">
orderDeliveryDetailsResponses?.length > 0 && <Tabs.TabPane tab='订单发货明细' key="2">
<NestTable
NestColumns={[sideOrderCols, sideChildrenCols]}
rowKey='id'
......
import React, { useState, useRef, useContext, useEffect } from 'react'
import { Form, Input, Select } from 'antd';
import { has } from 'lodash';
export interface ProductTableCellProps {
title: React.ReactNode;
......@@ -59,10 +60,15 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
const chooseFormItem = (type, v) => {
switch(type) {
case 'input': {
// 用于判断是否是合并下单
let hasSelectMergeBtn = document.getElementsByClassName("selectMerge")
// 用于合并订单采购数量回显
let keyValue = {}
keyValue[dataIndex] = v
form.setFieldsValue(keyValue)
if(hasSelectMergeBtn.length) {
let keyValue = {}
keyValue[dataIndex] = v
form.setFieldsValue(keyValue)
}
return <Input
style={{width: 140}}
......
......@@ -2,12 +2,13 @@ import React from 'react'
import { formatTimeString } from '@/utils'
import { Row, Space, Popover } from 'antd'
import { DELIVERY_TYPE, OrderModalType, PurchaseOrderOutWorkStateTexts } from '@/constants'
import { EnvironmentOutlined } from '@ant-design/icons'
import { EnvironmentOutlined, MediumOutlined } from '@ant-design/icons'
import { PublicApi } from '@/services/api'
import moment from 'moment'
// 简单控制价格区间的组件
// @todo 后续需要优化, 样式,目录文件等。
const PriceComp = (props) => {
export const PriceComp = (props) => {
const { priceSection = {} } = props
const priceTransKeys = Object.keys(priceSection || {})
// 出现0-0 表示没有单价区间范围
......@@ -233,18 +234,19 @@ export const paymentInformationColumns: any[] = [
// 商品列表
export const productInfoColumns: any[] = [
// to fix: 这里通过commodityId判断询报价手工类型会出错
{
title: 'ID',
dataIndex: 'productId',
align: 'center',
key: 'productId',
render: (t, r) => {
if(r?.commodityId) {
return r.id
} else {
return r.productId
}
}
// render: (t, r) => {
// if(r?.commodityId) {
// return r.id
// } else {
// return r.productId
// }
// }
},
{
title: '商品名称',
......@@ -270,20 +272,20 @@ export const productInfoColumns: any[] = [
align: 'center',
key: 'unit',
},
// 单价回显的时候 需要通过commodityId判断是报价订单(price)还是其他(unitPrice),
// to fix: 这里通过commodityId判断询报价手工类型会出错 之前有commodityId是手工
{
title: '单价(元)',
dataIndex: 'unitPrice',
align: 'left',
key: 'unitPrice',
render: (t, r) => {
// todo 还差需求报价的商品数据字段对比
if(r?.commodityId) {
return <PriceComp priceSection={r.unitPrice}/>
} else {
return <span style={{color: 'red'}}>{r.price}</span>
}
}
// render: (t, r) => {
// // todo 还差需求报价的商品数据字段对比
// if(r?.commodityId) {
// return <PriceComp priceSection={r.unitPrice}/>
// } else {
// return <span style={{color: 'red'}}>¥ {r.price}</span>
// }
// }
},
{
title: '会员折扣',
......@@ -362,6 +364,7 @@ export const mergeParentTableColumns: any[] = [
dataIndex: 'createTime',
align: 'center',
key: 'createTime',
render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '活动时间',
......
......@@ -306,12 +306,12 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
if(pageStatus === PageStatus.EDIT){
if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
ctx.submit((values) => {
// console.log(values, value, path, state, '发票id')
console.log(values, value, path, state, '发票id')
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: value.id || null,
theInvoiceId: value?.id || null,
needTheInvoice: Number(values.needTheInvoice),
deliveryAddresId: values.deliveryAddresId,
id,
......@@ -332,7 +332,7 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
if(pageStatus === PageStatus.EDIT){
if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
ctx.submit((values) => {
// console.log(values, value, path, '发货地址id')
console.log(values, value, path, '发货地址id')
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
......
import React, { useRef, useMemo, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions, createControllerBox, useFormSpy } from '@formily/antd';
import { Button, Row, Col, message } from 'antd';
import { productInfoColumns } from '../constant';
import { PriceComp, productInfoColumns } from '../constant';
import ProductTableCell, { ProductEditableRow } from '../components/productTableCell';
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { OrderModalType } from '@/constants';
const { pageStatus } = usePageStatus()
let orderModel = null;
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export const sortByKey = (params) => {
let keys = Object.keys(params).sort((x,y)=> parseInt(x) - parseInt(y));
......@@ -20,9 +24,13 @@ export const sortByKey = (params) => {
export const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['purchaseCount']) || 0
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
record.unitPrice = record.unitPrice || record.price || 0
// fix 编辑订单取price
record.unitPrice = pageStatus === PageStatus.EDIT ? record.price : record.unitPrice || record.price || 0
if (typeof record.unitPrice === 'number') {
return record.unitPrice * purchaseCount
return record.isMemberPrice ?
Number((record.unitPrice * purchaseCount * record.memberPrice).toFixed(2))
:
Number((record.unitPrice * purchaseCount).toFixed(2))
}
if(record.unitPrice) {
record.unitPrice = sortByKey(record.unitPrice)
......@@ -45,7 +53,6 @@ export const getUnitPriceTotal = (record) => {
}
})
// 考虑会员折扣
// let memberPrice = record.memberPrice !== 1 ? toPoint(record.memberPrice) : 1
let memberPrice = record.memberPrice
if(record.isMemberPrice) {
return Number((unitPrice * purchaseCount * memberPrice).toFixed(2))
......@@ -61,7 +68,8 @@ export const getUnitPriceTotal = (record) => {
export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, mergeRef: any) => {
const productRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
const { pageStatus } = usePageStatus()
orderModel = ctx.getFieldValue('orderModel')
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('orderProductRequests')]
......@@ -95,16 +103,34 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
const [productColumns, setProductColumns] = useState(() => {
if (pageStatus === PageStatus.ADD) {
// 渲染操作
productInfoColumns[productInfoColumns.length - 1].render = (text, record) => {
const orderModel = ctx.getFieldValue('orderModel')
return <>
{
// 合并下单
orderModel === 9 && <Button type='link' onClick={() => clickMergeButton(record)}>选择合并订单</Button>
orderModel === OrderModalType["CONSOLIDATED_ORDER"] && <Button type='link' className="selectMerge" onClick={() => clickMergeButton(record)}>选择合并订单</Button>
}
<Button type='link' onClick={() => handleDelete(record)}>删除</Button>
</>
}
// @todo 可能需要单独考虑合并订单
// 渲染单价
productInfoColumns[5].render = (t, r) => {
if(orderModel === OrderModalType["HAND_ORDER"]) {
return <PriceComp priceSection={r.unitPrice}/>
} else {
return r.price ? <span style={{color: 'red'}}>{r.price}</span> : <PriceComp priceSection={r.unitPrice}/>
}
}
// 渲染商品ID
productInfoColumns[0].render = (t, r) => {
if(orderModel === OrderModalType["HAND_ORDER"]) {
return r.id
} else {
return r.id ? r.id : r.productId
}
}
} else {
return [...productInfoColumns].slice(0, productInfoColumns.length - 1)
}
......@@ -133,7 +159,6 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
if (pageStatus === PageStatus.ADD) {
ctx.setFieldValue('paymentInformationResponses', [])
}
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('orderProductRequests')];
const index = newData.findIndex(item => row.id === item.id);
......
......@@ -62,7 +62,7 @@ export const useSelfTable = () => {
key: 'sumPrice',
render: (t, r) => r.type === 7 || r.type === 8 ? t : '¥' + t
},
{ title: '收货批次', align: 'center', dataIndex: 'shipmentBatch', key: 'shipmentBatch', render: text => text ? `第${text}次` : '' },
{ title: '收货批次', align: 'center', dataIndex: 'shipmentBatch', key: 'shipmentBatch', render: text => text ? `第${text}次` : '' },
// @todo 收货单号跳转
{
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