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

fix:处理采购订单编辑时发票和地址更新异常,处理销售订单列表售后评价显示异常,处理商品编辑无货品情况下价格设置处理异常

parent c88227a2
......@@ -95,10 +95,10 @@ const AddProducts: React.FC<{}> = (props) => {
setAttributeLists(attributeRes.data?.customerAttributeList)
// 预先设置选择货品
let unitPicList = data.unitPriceAndPicList.map(item => item.goods)
let selectGoods = Object.values(unitPicList.reduce((item, next)=>{
let selectGoods = unitPicList.indexOf(null) === -1 ? Object.values(unitPicList.reduce((item, next)=>{
item[next?.id] = next;
return item
},{}))
},{})) : []
setSelectedGoods(selectGoods)
}
makeRequest()
......
......@@ -256,8 +256,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let { _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr } = needObject
// console.log(_priceAttribute, _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr, selectedGoods, '---constructimg---') // 编辑直接进入价格设置 都为空数组
if(selectedGoods.length>0){ // 编辑情况下 select货品列表可能会采用接口数据
_col.push({
title: '对应货品',
......@@ -368,7 +366,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tempObj['单价'] = {}
}
// selectedGoods数据是前面表格选择的数组
// console.log(_tableDataSource , selectedGoods, '构建表格单价数据', `是否初次构建|${updateFlag.current}`, clearPrice.current)
_tableData.push(_tempObj)
})
}else{ // length不存在,默认只有商品名称一行(无价格属性组合)只有一行的情况下单价可能有,可能阶梯价,也可能没有
......@@ -410,7 +407,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/* 生成传输数据 */
const constructedPrarams = () => {
let _paramsArray: any[] = [];
// console.log('生成传输数据', combineAttributeArray, attributeObjArr, attributeValObjArr, tableDataSource)
Array.isArray(combineAttributeArray) ? combineAttributeArray.map((item, index)=>{ // 非数组情况下默认无组合 从table数据中获取 // 当属性减少的时候 这个combine数组还是之前的 /* code1 */
let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index) => { /* code2 */
......@@ -452,7 +448,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}) /*带上货品id 带上单价*/ /* code1 end */
setPriceAttributeParams(_paramsArray)
// console.log(_paramsArray,'params')
}
/**
......
......@@ -70,12 +70,10 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleProduct, setVisibleProduct] = useState(false)
const [visibleUnitProduct, setVisibleUnitProduct] = useState(false)
const [modifyModal, setModifyModal] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const [productUnitRowSelection, productUnitRowCtl] = useRowSelectionTable()
const {
id,
preview,
......@@ -91,7 +89,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const [ladderPrice, setLadderPrice] = useState(false)
const [priceType, setPriceTyle] = useState()
useEffect(() => {
// 拿到所有的角色等级, 根据shopType, 商品的类容重新拿
async function getMemberLevel() {
......@@ -166,9 +163,8 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
// 指定规格商品列表
const fetchProductUnitList = async (params) => {
const productId = addSchemaAction.getFieldValue('productId')
const res = await PublicApi.getProductChannelCommodityGetCommodityUnitPrice({
const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({
id: productId,
source: "1",
})
return res.data
}
......@@ -197,20 +193,11 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
setVisibleChannelMember(true)
}
const handleDeleteProductTable = (id) => {
const value = addSchemaAction.getFieldValue('applyMember')
const res = value.filter((item) => item.memberId != id);
addSchemaAction.setFieldValue('applyMember', res)
}
const handleAddProductUnitBtn = () => {
const productId = addSchemaAction.getFieldValue('productId')
if (!productId) {
message.error('请先选择商品')
return false
}
setVisibleUnitProduct(true)
}
// const handleDeleteProductTable = (id) => {
// const value = addSchemaAction.getFieldValue('applyMember')
// const res = value.filter((item) => item.memberId != id);
// addSchemaAction.setFieldValue('applyMember', res)
// }
const handleSetProductPrice = (id: any) => {
......@@ -254,7 +241,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
// ?
<>
<Button type="text" style={{marginBottom: 12, float: "right"}}><SettingOutlined /> 批量设置价格</Button>
<Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddProductUnitBtn} type='dashed'>选择商品规格</Button>
</>
// : null
......@@ -290,7 +276,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <>
<Button type='link' onClick={() => handleDeleteProductTable(record.productId)}>删除</Button>
<Button type='link' onClick={() => handleSetProductPrice(record.productId)}>设置价格</Button>
</>
}
......@@ -366,15 +351,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
setVisibleProduct(false)
}
// 规格商品添加弹窗控制
const handleOkAddSpec = () => {
}
const handleCancelAddSpec = () => {
setVisibleUnitProduct(false)
}
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingMember({id, current: page.toString(), pageSize: size.toString()});
......@@ -557,18 +533,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
})
}}
/>
<ModalTable
modalTitle="选择商品规格"
visible={visibleUnitProduct}
confirm={handleOkAddSpec}
cancel={handleCancelAddSpec}
resetModal={{
destroyOnClose: true
}}
columns={tableProductColumns.slice(0, 4)}
rowSelection={productUnitRowSelection}
fetchTableData={params => fetchProductUnitList(params)}
/>
{/* 设置价格 */}
<Modal
title="设置价格"
......
......@@ -109,7 +109,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{
record.receivingTimes >= 1 || PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
}
</>
}
......
......@@ -30,13 +30,13 @@ const addressSchema: ISchema = {
}
],
default: 1,
"x-linkages": [
{
type: 'value:visible',
target: 'taxNo',
condition: "{{$value === 1}}"
}
]
// "x-linkages": [
// {
// type: 'value:visible',
// target: 'taxNo',
// condition: "{{$value === 1}}"
// }
// ]
},
kind: {
type: 'radio',
......
......@@ -9,6 +9,9 @@ import { useUpdate } from '@umijs/hooks';
import { PublicApi } from '@/services/api';
import { filterProductDataById } from '../components/productModalTable'
import { getUnitPriceTotal } from '../model/useProductTable';
import moment from 'moment';
let updateFlag = false
// 异步填充表格字段
const asyncPadDataForProduct = async (ctx: ISchemaFormActions | ISchemaFormAsyncActions, productValue: any) => {
......@@ -275,3 +278,31 @@ export const useElectronicContract = (ctx: ISchemaFormActions | ISchemaFormAsync
})
}
}
// 编辑订单 地址和发票变动 触发订单更新
export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const { pageStatus, id } = usePageStatus()
FormEffectHooks.onFieldValueChange$('NO_SUBMIT_TABS.*.*.*(theInvoiceId, needTheInvoice, deliveryAddresId)').subscribe(state => {
const { value, path } = state
if(pageStatus === PageStatus.EDIT){
if(state.loading) {
ctx.submit((values) => {
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: value.id,
needTheInvoice: Number(values.needTheInvoice),
deliveryAddresId: value.id,
id,
}, { ctlType: "none" })
}
})
} else {
ctx.setFieldState(path, _state => _state.loading = true)
}
}
})
}
......@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy, createAsyncFormActio
import { SaveOutlined, LinkOutlined, PlusOutlined, CodeSandboxCircleFilled, QuestionCircleOutlined, FilePdfOutlined, FilePdfFilled } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay } from './effects'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay, useOrderUpdateChangeOther } from './effects'
import { orderTypeLabel, orderCombination } from './constant'
import { OrderModalType } from '@/constants'
import ProductModalTable from './components/productModalTable'
......@@ -105,16 +105,16 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
return <RowStyle>
<Col span={2}>
<div>合计金额</div>
<div>{sum}</div>
<div>{sum.toFixed(2)}</div>
</Col>
<Col span={2}>
<div>运费</div>
{/* 缺乏字段 @todo */}
<div>{freePrice}</div>
<div>{freePrice.toFixed(2)}</div>
</Col>
<Col span={2}>
<div>总计金额</div>
<div>{sum + freePrice}</div>
<div>{(sum + freePrice).toFixed(2)}</div>
</Col>
</RowStyle>
})
......@@ -315,9 +315,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
if(params.needTheInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
// logistics render字段字符串化
// logistics render字段字符串化 @to fix bug
params.orderProductRequests = params.orderProductRequests.map(item => {
let logistics: any = { ...item.logistics, render: item.logistics?.render ? JSON.stringify(item.logistics.render) : '' };
let logistics: any = {
...item.logistics,
// render: item.logistics?.render ? JSON.stringify(item.logistics.render.replace(/\"/g, '')) : null
render: JSON.stringify(typeof item.logistics.render === "object" ? item.logistics.render : item.logistics.render.replace(/\"/g, ''))
};
return {
...item,
logistics
......@@ -533,23 +537,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabel[value - 4]) // -4 获得对应的数组下标, 由于id是固定的
// 需要发票变动或者发票id变动,调用订单更新接口传入发票id
$('onFieldInputChange', 'theInvoiceId, needTheInvoice').subscribe(state => {
if(pageStatus === PageStatus.EDIT) {
addSchemaAction.submit((values) => PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: state.value.id,
needTheInvoice: Number(values.needTheInvoice),
id,
}, { ctlType: "none" }))
}
})
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
//编辑 地址和发票信息变动 触发订单更新
useOrderUpdateChangeOther(ctx)
}}
expressionScope={{
orderNoPrice,
......
......@@ -343,18 +343,6 @@ const ortherInfo: ISchema = {
wrapperCol: 10
},
properties: {
// usingElectronicContracts: {
// type: "number",
// title: "{{help('电子合同','勾选则表示同意签署电子合同,电子合同和纸质合同一样具备同等法律效力')}}",
// "x-component-props": {
// // disabled: true,
// contract: {},
// },
// "x-component": "selectContract",
// // default: true,
// required: true,
// visible: false,
// },
needTheInvoice: {
type: 'number',
"x-component": 'CheckboxSingle',
......
......@@ -47,7 +47,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{/* todo */}
{/* <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button> */}
</>
......
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