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

fix:待新增物流单添加修改物流单跳转,补齐内外部流转记录0为订单完成状态,处理商品阶梯价格间间距为最小起订数的最小精度

parent 65cb3ab4
......@@ -978,6 +978,7 @@ export enum DeliverySideState {
// 订单外部显示文案
export const PurchaseOrderOutWorkStateTexts = {
"-1": "取消订单",
0: '订单完成',
1: '待提交订单',
2: '待确认订单',
3: '待确认电子合同',
......@@ -1051,6 +1052,7 @@ export const SaleOrderInsideWorkStateTexts = {
// 订单流转记录外部状态
export const OrderTransformOutWorkStateTexts = {
"-1": '取消订单',
0: '订单完成',
1: '待确认',
2: '待确认电子合同',
3: '待支付',
......@@ -1074,6 +1076,7 @@ export const OrderTransformOutWorkStateTexts = {
// 采购订单流转记录内部状态
export const PurchaseOrderTransformInsideWorkStateTexts = {
"-1": '取消订单',
0: '订单完成',
1: '待提交审核',
2: '提交审核通过',
3: '审核通过',
......
......@@ -33,7 +33,7 @@ const { Option } = Select
let _tableDataSource: any = []
const PriceAttributeForm: React.FC<Iprops> = (props) => {
const PriceAttributeForm: React.FC<Iprops> = (props) => {
const { onRef } = props
const priceFormRef = useRef()
const updateFlag = useRef(true) // 是否第一次构建
......@@ -58,15 +58,15 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const [colums, setColumns] = useState<ColumnType<any>[]>()
const { ProductStore } = store
const {
productName,
selectedGoods,
productSelectAttribute,
setProductSelectAttribute,
tableDataSource,
setTableDataSource,
clearData,
setPriceAttributeParams,
const {
productName,
selectedGoods,
productSelectAttribute,
setProductSelectAttribute,
tableDataSource,
setTableDataSource,
clearData,
setPriceAttributeParams,
productInfoByEdit,
getPriceAttributeFormParamsByEdit,
selectCategoryId,
......@@ -136,7 +136,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
useEffect(() => {
// 品类 变动清空form和属性组合
if(history.location.query?.id && !flagRef.current) {
flagRef.current = true
flagRef.current = true
} else {
// setProductSelectAttribute([])
priceForm.resetFields()
......@@ -147,7 +147,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/**
* 添加clearPrice.current依赖,处理在未渲染价格属性前已经变动了价格属性组合,此时需要清空价格数据
* bug: 在不改变那价格属性组合情况下修改价格可以保留,当属性组合变动之后,修改价格再做其他修改时会清空价格(原因:clearPrice.current始终为true)
* 添加 tabClickItem
* 添加 tabClickItem
* 价格属性变动引发的构建,清空价格(仅清空一次)之后置为false
*/
useEffect(()=>{
......@@ -170,7 +170,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
if(hasAttribute.length){ // 提取价格属性 属性名数组 属性值SKU数组 /*编辑情况下直接进入此页面length为空 此时需获取调用接口返回的数据生成*/
hasAttribute.map(_item=>{
_attributeNameArr.push(_item.attributeName) // 用于列header
_temp_attributeObjArr.push({attributeName: _item.attributeName, customerAttributeId: _item.customerAttributeId})
_temp_attributeObjArr.push({attributeName: _item.attributeName, customerAttributeId: _item.customerAttributeId})
let _tempArr = []
let _tempObjArr = [] // 取id备用 //....若为日期属性,此处应获取日期段的每一天 进行特殊处理....//
// if(_item.isDate){
......@@ -273,14 +273,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
if(_attributeNameArr?.length>0){
_attributeNameArr.map( _attr => {
_col.push({
title: _attr,
dataIndex: _attr,
title: _attr,
dataIndex: _attr,
key: _attr
})
})
}
_col.push({
title: planPrice===3?'所需积分':'单价(元)',
title: planPrice===3?'所需积分':'单价(元)',
dataIndex: '单价',
key: '单价',
width: 200,
......@@ -389,21 +389,21 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index) => { /* code2 */
let _tempObject: any = {};
_tempObject.customerAttribute = {
id: attributeObjArr[_index].customerAttributeId,
id: attributeObjArr[_index].customerAttributeId,
name: attributeObjArr[_index].attributeName
}
_tempObject.customerAttributeValue = {
id: attributeValObjArr.map(__item => __item.find(_ => _.value===_item)).filter(__ => __)[0].id,
id: attributeValObjArr.map(__item => __item.find(_ => _.value===_item)).filter(__ => __)[0].id,
value: item[_index]
}
_tempArr.push(_tempObject)
}) : ( /* code3 */
// ** 可能是单一多选 attributeValObjArr可能为多个
_tempArr.push({
_tempArr.push({
customerAttribute: {
id: attributeObjArr[0].customerAttributeId,
id: attributeObjArr[0].customerAttributeId,
name: attributeObjArr[0].attributeName
},
customerAttributeValue: {
......@@ -414,7 +414,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
) /* code3 end */ /* code2 end */
_paramsArray.push({
goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0,
attributeAndValueList: _tempArr,
attributeAndValueList: _tempArr,
unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价'],
id: _tableDataSource[index]&&_tableDataSource[index]['规格ID'],
}) /*带上货品id 带上单价*/
......@@ -432,7 +432,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/**
* @description table选择货品改变对应的data数据
* @param v modal数据对象
* @param record table行记录
* @param record table行记录
*/
const tableSelelctChange = (v: number, record: any) => {
let _row = { ...record, 对应货品: v }
......@@ -526,12 +526,12 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
if(numberArray[0][0] === minOrder){
let tempArr = [];
numberArray.map((_item, _index) => {
tempArr.push({ numberPrice: priceArray[_index], numberRange: { numberMin: _item[0], numberMax: _item[1] } })
tempArr.push({ numberPrice: priceArray[_index], numberRange: { numberMin: _item[0], numberMax: _item[1] } })
})
setPriceForm.setFieldsValue({ladderPrice: true, ladderRange: tempArr})
}else{
let tempArr = [];
tempArr.push({ numberPrice: null, numberRange: { numberMin: minOrder, numberMax: null } })
tempArr.push({ numberPrice: null, numberRange: { numberMin: minOrder, numberMax: null } })
setPriceForm.setFieldsValue({ladderPrice: true, ladderRange: tempArr})
}
}
......@@ -558,6 +558,25 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
// 校验阶梯范围
const validatorNumberRange = (rule, value, callback) => {
let minOrder = Number(minOrderNumber)
let precision;
if(Number.isInteger(minOrder)) { // 整数取1
precision = 1
} else { // 小数取最小精度(最多三位)
switch(minOrderNumber.toString().split(".")[1].length) {
case 1:
precision = 0.1
break;
case 2:
precision = 0.01
break;
case 3:
precision = 0.001
break;
default:
precision = 1
}
}
try {
if(Array.isArray(value)){
let range = value.map(item => {
......@@ -565,6 +584,12 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
return Object.values(item.numberRange)
}).reduce(
function(a, b) {
// 判断首位数是否满足精度
if(a.length && b.length) {
if((Number(b[0])*1000 - Number(a[a.length-1])*1000)/1000 !== precision) {
throw new Error('请正确输入阶梯数量范围');
}
}
return a.concat(b);
},
[]
......@@ -589,8 +614,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/**
* 按属性归类
* @param objectArray
* @param {string} property
* @param objectArray
* @param {string} property
*/
const groupBy = (objectArray, property) => {
......@@ -615,7 +640,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
// initialValues={productInfoByEdit?.id ? getPriceAttributeFormParamsByEdit : {isMemberPrice: false, priceType: planPrice}}
autoComplete="off"
>
<Form.Item
<Form.Item
name="unitId"
label={
<span>
......@@ -725,10 +750,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
{
planPrice != 2 && productName && <Button type="text" style={{float: 'right'}} onClick={clickBatchSetPrice}><SettingOutlined />{planPrice === 3 ? '批量设置积分' : '批量设置价格'}</Button>
}
<Table
rowKey="索引"
dataSource={tableDataSource}
columns={planPrice === 2 ? colums.slice(0, colums.length-2) : colums}
<Table
rowKey="索引"
dataSource={tableDataSource}
columns={planPrice === 2 ? colums.slice(0, colums.length-2) : colums}
pagination={false}
locale={{emptyText:<>暂无数据<br />请先完善商品基本信息项!</>}}
style={{clear: 'both'}}
......@@ -750,7 +775,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
initialValues={{ladderPrice: false}}
autoComplete="off"
>
{
{
planPrice!==3 &&
<Form.Item
label=""
......@@ -874,4 +899,4 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</>)
}
export default observer(PriceAttributeForm)
\ No newline at end of file
export default observer(PriceAttributeForm)
......@@ -197,7 +197,7 @@ const FastModifyPrice: React.FC<{}> = () => {
let priceArray = Object.values(data)
let tempArr = [];
numberArray.map((_item, _index) => {
tempArr.push({ numberPrice: priceArray[_index], numberRange: { numberMin: _item[0], numberMax: _item[1] } })
tempArr.push({ numberPrice: priceArray[_index], numberRange: { numberMin: _item[0], numberMax: _item[1] } })
})
setForm.setFieldsValue({ladderPrice: true, ladderRange: tempArr})
}
......@@ -237,6 +237,25 @@ const FastModifyPrice: React.FC<{}> = () => {
// 校验阶梯范围
const validatorNumberRange = (rule, value, callback) => {
let minOrder = Number(currentRow.minOrder)
let precision;
if(Number.isInteger(minOrder)) { // 整数取1
precision = 1
} else { // 小数取最小精度(最多三位)
switch(minOrder.toString().split(".")[1].length) {
case 1:
precision = 0.1
break;
case 2:
precision = 0.01
break;
case 3:
precision = 0.001
break;
default:
precision = 1
}
}
try {
if(Array.isArray(value)){
let range = value.map(item => {
......@@ -244,6 +263,12 @@ const FastModifyPrice: React.FC<{}> = () => {
return Object.values(item.numberRange)
}).reduce(
function(a, b) {
// 判断首位数是否满足精度
if(a.length && b.length) {
if((Number(b[0])*1000 - Number(a[1])*1000)/1000 !== precision) {
throw new Error('请正确输入阶梯数量范围');
}
}
return a.concat(b);
},
[]
......@@ -283,7 +308,7 @@ const FastModifyPrice: React.FC<{}> = () => {
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
}}
}}
schema={fastSchema}
/>
}
......@@ -406,9 +431,9 @@ const FastModifyPrice: React.FC<{}> = () => {
label={priceType===3 ? "积分" : "单价"}
name="uniquePrice"
rules={[
{
{
required: true,
message: priceType===3 ? '请输入积分!' : '请输入单价!'
message: priceType===3 ? '请输入积分!' : '请输入单价!'
},
{
pattern: priceType!==3 ? /^\d+(\.\d{1,4})?$/ : /^[1-9]\d*$/,
......@@ -425,4 +450,4 @@ const FastModifyPrice: React.FC<{}> = () => {
)
}
export default FastModifyPrice
\ No newline at end of file
export default FastModifyPrice
......@@ -9,7 +9,7 @@ import { message } from 'antd'
export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, memberId: any, memberRoleId: any, orderProducts: any): any => {
const paywayData = useRef<any>({})
const [columns, setColumns] = useState<any[]>(paymentInformationColumns)
const { productSumPrice } = useContext(ReadyAddOrderDetailContext)
// const { schemaActions, detailData } = useContext(ReadyAddOrderDetailContext)
const components = {
body: {
row: EditableRow,
......@@ -68,6 +68,7 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
// })
// }, [])
useEffect(() => {
// 当选择报价单/会员/商品时有memberId传入时 调用支付方式api
if(memberId) {
......@@ -75,28 +76,36 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
}
}, [memberId])
// useEffect(() => {
// // 当有商品数据传入的时 判断商品只有是物流的才能使用到付
// if(orderProducts?.length) {
// const newColumns = [...columns]
// let options = newColumns[5].formItemProps.options
// if(orderProducts.filter(item => item.deliveryType === 1).length !== orderProducts.length) {
// if(options.filter(_item => _item.payType === 4).length) {
// options.filter(_item => _item.payType === 4)[0].disabled = true
// }
// } else {
// if(options.filter(_item => _item.payType === 4).length) {
// options.filter(_item => _item.payType === 4)[0].disabled = false
// }
// }
// // 多次支付也要禁用到付
// if(ctx.getFieldValue('paymentInformationResponses').length > 1) {
// if(options.filter(_item => _item.payType === 4).length)
// options.filter(_item => _item.payType === 4)[0].disabled = true
// } else {
// if(options.filter(_item => _item.payType === 4).length)
// options.filter(_item => _item.payType === 4)[0].disabled = false
// }
// }
// }, [orderProducts, columns])
useEffect(() => {
// 当有商品数据传入的时 判断商品只有是物流的才能使用到付
if(orderProducts?.length) {
const newColumns = [...columns]
let options = newColumns[5].formItemProps.options
if(orderProducts.filter(item => item.deliveryType === 1).length !== orderProducts.length) {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = true
} else {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = false
}
// 多次支付也要禁用到付
if(ctx.getFieldValue('paymentInformationResponses').length > 1) {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = true
} else {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = false
}
restrictArrivalPay(columns, orderProducts)
}
}, [orderProducts, columns])
}, [orderProducts])
const getPayLists = (memberId, memberRoleId) => {
PublicApi.getPayPayWayList({memberId, memberRoleId}).then(res => {
......@@ -105,7 +114,7 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
const newColumns = [...columns]
newColumns[5].formItemProps.options = initPayWayList(data)
paywayData.current = data
restrictArrivalPay(newColumns, orderProducts)
setColumns(newColumns)
} else {
message.error(res.message)
......@@ -113,6 +122,39 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
})
}
// 限制使用到付(多次支付和商品仅有物流)
const restrictArrivalPay = (cols, pros) => {
if(pros?.length) {
// const newColumns = [...columns]
const newColumns = [...cols]
let options = newColumns[5].formItemProps.options
if(pros.filter(item => item.deliveryType === 1).length !== pros.length) {
if(options.filter(_item => _item.payType === 4).length) {
options.filter(_item => _item.payType === 4)[0].disabled = true
}
} else {
if(options.filter(_item => _item.payType === 4).length) {
options.filter(_item => _item.payType === 4)[0].disabled = false
}
}
setTimeout(() => {
let payment = ctx.getFieldValue('paymentInformationResponses')
// 多次支付也要禁用到付
if(payment?.length > 1) {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = true
}
else {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = false
}
} , 1000)
setColumns(newColumns)
}
}
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('paymentInformationResponses')];
......
......@@ -95,6 +95,9 @@ export const useSelfTable = () => {
{ record.purchaseOrderInteriorState === SaleOrderInsideWorkState.DELIVERY_APPROVED_SUCCESS &&
<Button type='link' onClick={() => handlePreview(record)}>查看物流单</Button>
}
{ record.purchaseOrderInteriorState === SaleOrderInsideWorkState.NOT_ACCEPTED_DELIVERY &&
<Button type='link' onClick={() => handleModify(record)}>修改物流单</Button>
}
</>
}
]
......@@ -115,6 +118,11 @@ export const useSelfTable = () => {
history.push(`/memberCenter/logisticsAbility/logisticsSubmit/orderSubmitSearchList/detail?id=${logisticsId}&invoicesTypeId=2`)
}
const handleModify = async (record) => {
const logisticsId = record.logisticsId
history.push(`/memberCenter/logisticsAbility/logisticsSubmit/toOrderSumitList/edit?id=${logisticsId}`)
}
return {
columns: customOrderColumns
}
......
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