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

fix:

parent f35a5cb6
......@@ -87,6 +87,22 @@ export const getSaleOrderAuditPageSelectOption = () => {
return state
}
/** (采购订单-待新增订单)获取前端页面下拉框列表 */
export const getPurchaseOrderReadyAddPageSelectOption = () => {
const [state, setstate] = useState<any>()
useEffect(() => {
PublicApi.getOrderBuyerCreatePageItems({}).then(res => {
const { code, data } = res
if(code === 1000) {
setstate(data)
}
})
}, [])
return state
}
// **以下*即将弃用*** //
......
......@@ -3,88 +3,71 @@ import { history } from 'umi'
import { formatTimeString } from '@/utils'
import StatusColors from '../components/StatusColors'
import EyePreview from '@/components/EyePreview'
import { getPurchaseOrderSelectOption } from '../../effect'
export const baseOrderListColumns: any = () => {
// const res = getPurchaseOrderSelectOption()
// if(res) {
// const {
// orderTypes: OrderType,
// innerStatus: PurchaseOrderInsideWorkStateTexts,
// outerStatus: PurchaseOrderOutWorkStateTexts
// } = res
return [
{
title: '订单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
render: (text, record) => {
// 查看订单, 需根据状态显示不同schema
return (
<EyePreview url={`${history.location.pathname}/preview?id=${record.orderId}`}>
{text}
</EyePreview>
)
},
ellipsis: true,
},
{
title: '订单摘要',
align: 'center',
dataIndex: 'digest',
key: 'digest',
ellipsis: true,
},
{
title: '供应会员',
align: 'center',
dataIndex: 'vendorMemberName',
key: 'vendorMemberName',
ellipsis: true,
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
render: (text) => formatTimeString(text)
},
{
title: '订单总额',
align: 'center',
dataIndex: 'amount',
key: 'amount',
ellipsis: true,
},
{
title: '订单类型',
align: 'center',
dataIndex: 'orderTypeName',
key: 'orderTypeName',
// filters: OrderType.map((e, i) => ({ text: e['text'], value: Number(e['id']) })),
// onFilter: (value, record) => value === record.orderType,
},
{
title: '外部状态',
align: 'center',
dataIndex: 'outerStatusName',
key: 'outerStatusName',
render: (text, record) => <StatusColors status={text} type='out' text={record['outerStatusName']} />,
// filters: PurchaseOrderOutWorkStateTexts.map((e, i) => ({ text: e['text'], value: Number(e['id']) })),
// onFilter: (value, record) => value === record.outerStatus,
return [
{
title: '订单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
render: (text, record) => {
return (
<EyePreview url={`${history.location.pathname}/preview?id=${record.orderId}`}>
{text}
</EyePreview>
)
},
{
title: '内部状态',
align: 'center',
dataIndex: 'innerStatusName',
key: 'innerStatusName',
render: (text, record) => <StatusColors status={text} type='inside' text={record['innerStatusName']} />,
// filters: PurchaseOrderInsideWorkStateTexts.map((e, i) => ({ text: e['text'], value: Number(e['id']) })),
// onFilter: (value, record) => value === record.innerStatus,
}
]
// }
ellipsis: true,
},
{
title: '订单摘要',
align: 'center',
dataIndex: 'digest',
key: 'digest',
ellipsis: true,
},
{
title: '供应会员',
align: 'center',
dataIndex: 'vendorMemberName',
key: 'vendorMemberName',
ellipsis: true,
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
render: (text) => formatTimeString(text)
},
{
title: '订单总额',
align: 'center',
dataIndex: 'amount',
key: 'amount',
ellipsis: true,
},
{
title: '订单类型',
align: 'center',
dataIndex: 'orderTypeName',
key: 'orderTypeName',
},
{
title: '外部状态',
align: 'center',
dataIndex: 'outerStatusName',
key: 'outerStatusName',
render: (text, record) => <StatusColors status={text} type='out' text={record['outerStatusName']} />,
},
{
title: '内部状态',
align: 'center',
dataIndex: 'innerStatusName',
key: 'innerStatusName',
render: (text, record) => <StatusColors status={text} type='inside' text={record['innerStatusName']} />,
}
]
}
......@@ -58,7 +58,6 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
schemaAction.setFieldValue('sourceType', item.sourceType)
schemaAction.setFieldValue('purchaseType', 1)
const { data } = await fetchOrderApi.getContractPurchaseMaterielList({
shopId: schemaAction.getFieldValue('shopId'),
contractId: item.id,
current: 1,
pageSize: 999,
......@@ -83,7 +82,6 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
temp.category = v.category;
temp.brand = v.brand;
temp.unit = v.unit;
// temp.relevanceGoods = v.associatedGoods;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductNo = v.associatedMaterielNo;
......@@ -91,9 +89,8 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
temp.price = v.price;
temp.inventory = v.bidCount;
// temp.purchaseCount = v.purchaseCount;
temp.taxInclusive = v.isHasTax;
temp.stock = v.bidCount;
temp.tax = v.isHasTax;
temp.taxRate = v.taxRate;
// @ 配送方式 默认物流
temp.logistics = 1
......@@ -104,12 +101,11 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
return temp
})
// 把地址信息冗余给商品字段render
// schemaAction.setFieldValue('orderProductRequests', await filterProductDataById([], data))
schemaAction.setFieldValue('orderProductRequests', newData)
schemaAction.setFieldValue('supplyMembersName', item.partyBName)
schemaAction.setFieldValue('supplyMembersId', item.partyBMemberId)
schemaAction.setFieldValue('supplyMembersRoleId', item.partyBRoleId)
schemaAction.setFieldValue('orderThe', item.contractAbstract)
schemaAction.setFieldValue('products', newData)
schemaAction.setFieldValue('vendorMemberName', item.partyBName)
schemaAction.setFieldValue('vendorMemberId', item.partyBMemberId)
schemaAction.setFieldValue('vendorRoleId', item.partyBRoleId)
schemaAction.setFieldValue('digest', item.contractAbstract)
schemaAction.setFieldValue('contractId', item.id)
}
confirmModal && confirmModal()
......
......@@ -103,8 +103,8 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
temp.price = v.price;
temp.inventory = v.bidCount;
temp.taxInclusive = v.isHasTax;
temp.stock = v.bidCount;
temp.tax = v.isHasTax;
temp.taxRate = v.taxRate;
// @ 配送方式 默认物流
temp.logistics = 1
......@@ -116,7 +116,6 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
tempOriginData.push(item)
}
})
console.log(tempOriginData, 'tempOriginData')
return tempOriginData
}
}
......@@ -126,15 +125,15 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
console.log(rowSelectionCtl, 'rowSelectionCtl')
// @ts-ignore
const res = await PublicApi.postOrderIsWorkFlow({
memberId: schemaAction.getFieldValue('supplyMembersId'),
memberRoleId: schemaAction.getFieldValue('supplyMembersRoleId'),
memberId: schemaAction.getFieldValue('vendorMemberId'),
memberRoleId: schemaAction.getFieldValue('vendorRoleId'),
productIds: rowSelectionCtl.selectRow.map(item => item.associatedDataId),
orderModel: schemaAction.getFieldValue('orderModel')
}, { ctlType: 'none' })
if (res.code === 1000) {
const productData = schemaAction.getFieldValue('orderProductRequests')
schemaAction.setFieldValue('orderProductRequests', addMaterialProcessField(rowSelectionCtl.selectRow, productData))
const productData = schemaAction.getFieldValue('products')
schemaAction.setFieldValue('products', addMaterialProcessField(rowSelectionCtl.selectRow, productData))
confirmModal && confirmModal()
setVisible(false)
}
......
......@@ -34,6 +34,7 @@ export const procurementRenderField = (_orderProductRequests) => {
relevanceProductName: item.productName,
relevanceProductBrand: item.brand,
relevanceProductCategory: item.category,
relevanceProductSpec: item.spec,
logistics: item.logistics.deliveryType,
// id: item.materialId,
code: item.materialCode,
......@@ -47,25 +48,21 @@ export const procurementRenderField = (_orderProductRequests) => {
/** 采购合同下单 字段转换 */
export const procurementProcessField = (value) => {
value.orderProductRequests = value.orderProductRequests.map(item => {
// @todo 查询商品对应的最小起订数
// const { data, code } = await PublicApi.getProductCommodityGetCommodity({id: item.relevanceProductId})
// delete item.id
value.products = value.products.map(item => {
return {
...item,
productId: item.relevanceProductId,
productName: item.relevanceProductName,
brand: item.relevanceProductBrand,
category: item.relevanceProductCategory,
productId: item.quotedSkuId,
productName: item.quotedName,
brand: item.quotedBrand,
category: item.quotedCategory,
unit: item.unit,
price: item.unitPrice,
price: item.price,
deliveryType: item.logistics.deliveryType,
// @todo 后端暂无返回 写死1
minOrder: 1,
// 物料信息
// materialId: item.id,
materialCode: item.code,
materialId: item.productId,
materialCode: item.productNo,
materialName: item.name,
materialSpec: item.spec,
materialType: item.type,
materialCategory: item.category,
materialBrand: item.brand,
......@@ -268,182 +265,6 @@ export const contractColumns: any[] = [
}
]
export const paymentInformationColumns: any[] = [
{
title: '支付次数',
dataIndex: 'payCount',
// align: 'center',
key: 'payCount'
},
{
title: '支付环节',
dataIndex: 'payNode',
// align: 'center',
key: 'payNode'
},
{
title: '外部状态',
dataIndex: 'externalState',
// align: 'center',
key: 'externalState',
render: text => PurchaseOrderOutWorkStateTexts[text]
},
{
title: '支付比例',
dataIndex: 'payRatio',
key: 'payRatio',
editable: true,
forceEdit: true,
formItem: 'input',
formItemProps: {
addonAfter: '%'
},
width: 200,
render: text => text + '%'
},
{
title: '支付金额',
dataIndex: 'payPrice',
// align: 'center',
key: 'payPrice'
},
{
title: '支付方式',
dataIndex: 'payWay',
key: 'payWay',
formItem: 'select',
editable: true,
forceEdit: true,
formItemProps: {
options: []
},
width: 200
},
{
title: '支付渠道',
dataIndex: 'channel',
key: 'channel',
formItem: 'select',
editable: true,
forceEdit: true,
width: 200
},
]
// 商品列表
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
// }
// }
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
key: 'productName',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
key: 'category',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
key: 'brand',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
key: 'unit',
},
// 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>
// }
// }
},
{
title: '会员折扣',
dataIndex: 'memberPrice',
align: 'center',
key: 'memberPrice',
render: (text, record) => record.isMemberPrice && text ? text * 100 + '%' : null
},
{
title: '采购数量',
dataIndex: 'purchaseCount',
align: 'center',
key: 'purchaseCount',
formItem: 'input',
editable: true,
width: 140
},
{
title: '含税',
dataIndex: 'taxInclusive',
align: 'center',
key: 'taxInclusive',
render: (t, r) => r.taxRate ? '是' : '否'
},
{
title: '税率',
dataIndex: 'taxRate',
align: 'center',
key: 'taxRate',
render: (t, r) => t ? `${t}%` : null
},
{
title: '金额',
dataIndex: 'money',
align: 'center',
key: 'money',
},
// 接口调用
{
title: '配送方式',
dataIndex: 'logistics',
align: 'center',
key: 'logistics',
render: (t, r) => {
if(r.logistics?.deliveryType === 1)
return "物流(默认)"
else if(r.logistics?.deliveryType === 2)
return <AddressPop pickInfo={t}>{DELIVERY_TYPE[t.deliveryType]}</AddressPop>
else if(r.logistics?.deliveryType === 3)
return "无需配送"
}
},
{
title: '操作',
dataIndex: 'ctl',
align: 'center',
key: 'ctl',
},
]
// 合同下单 物料列表
export const materialInfoColumns: any[] = [
{
......@@ -496,7 +317,7 @@ export const materialInfoColumns: any[] = [
dataIndex: 'relevanceProductId',
align: 'center',
key: 'relevanceProductId',
render: (t, r) => `${t}/${r.relevanceProductName || ''}/${r.relevanceProductCategory || ''}/${r.relevanceProductBrand || ''}`
render: (t, r) => `${t}/${r.relevanceProductName || ''}/${r.relevanceProductSpec || ''}/${r.relevanceProductCategory || ''}/${r.relevanceProductBrand || ''}`
},
{
title: '单价(元)',
......@@ -506,24 +327,24 @@ export const materialInfoColumns: any[] = [
},
{
title: '供方库存',
dataIndex: 'inventory',
dataIndex: 'stock',
align: 'center',
key: 'inventory',
key: 'stock',
},
{
title: '采购数量',
dataIndex: 'purchaseCount',
dataIndex: 'quantity',
align: 'center',
key: 'purchaseCount',
key: 'quantity',
formItem: 'input',
editable: true,
// width: 80
},
{
title: '含税',
dataIndex: 'taxInclusive',
dataIndex: 'tax',
align: 'center',
key: 'taxInclusive',
key: 'tax',
render: (t, r) => t ? '是' : '否'
},
{
......@@ -547,15 +368,6 @@ export const materialInfoColumns: any[] = [
key: 'logistics',
formItem: 'select',
editable: true,
// width: 80
// render: (t, r) => {
// if(r.logistics?.deliveryType === 1)
// return "物流(默认)"
// else if(r.logistics?.deliveryType === 2)
// return "自提"
// else if(r.logistics?.deliveryType === 3)
// return "无需配送"
// }
},
{
title: '操作',
......@@ -564,99 +376,3 @@ export const materialInfoColumns: any[] = [
key: 'ctl',
},
]
// 合并订单父级表格列
export const mergeParentTableColumns: any[] = [
{
title: '订单号',
dataIndex: 'orderNo',
align: 'center',
key: 'orderNo',
// @todo 此时以采购商的角色查看供应商的订单详情,合理性有待商榷
render: (t, r) => <a target="blank" href={`/memberCenter/tranactionAbility/purchaseOrder/orderList/preview?id=${r.id}`}>{t}</a>
},
{
title: '订单摘要',
dataIndex: 'orderThe',
align: 'center',
key: 'orderThe',
},
{
title: '采购商名称',
dataIndex: 'memberName',
align: 'center',
key: 'memberName',
},
{
title: '下单时间',
dataIndex: 'createTime',
align: 'center',
key: 'createTime',
render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '活动时间',
dataIndex: 'none',
align: 'center',
key: 'none',
},
{
title: '活动名称',
dataIndex: 'none',
align: 'center',
key: 'none',
}
]
// 合并订单子级表格列
export const mergeChildrenTableColumns: any[] = [
{
title: 'ID',
dataIndex: 'productId',
align: 'center',
key: 'productId',
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
key: 'productName',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
key: 'category',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
key: 'brand',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
key: 'unit',
},
{
title: '单价',
dataIndex: 'price',
align: 'center',
key: 'price',
},
{
title: '原订单数量',
dataIndex: 'purchaseCount',
align: 'center',
key: 'purchaseCount',
},
{
title: '原订单金额',
dataIndex: 'id',
align: 'center',
key: 'id',
render: (t, r) => `¥${(r.purchaseCount*100) * (r.price*100) / 10000}`
}
]
......@@ -67,6 +67,14 @@ export const useInvoiceList = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
})
}
export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => {
FormEffectHooks.onFieldValueChange$('products').subscribe(state => {
const { value } = state
// 强制渲染一次, 用于触发金额总数
update()
})
}
// 编辑订单 地址和发票变动 触发订单更新
export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
......
......@@ -8,12 +8,11 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd
import { SaveOutlined, LinkOutlined, PlusOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { mergeAllSchemas } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useOrderUpdateChangeOther } from './effects'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useOrderUpdateChangeOther, useProductTableChangeForPay } from './effects'
import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField } from './constant'
import CirculationRecord from '../components/circulationRecord'
import SelectAddress from './components/selectAddress'
import TheInvoiceList from './components/theInvoiceList'
import moment from 'moment'
import styled from 'styled-components'
import { useUpdate } from '@umijs/hooks'
import { PublicApi } from '@/services/api'
......@@ -44,8 +43,8 @@ const addSchemaAction = createFormActions()
// 总计金额联动框
export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
const { form } = useFormSpy({ selector: [['onFieldValueChange', 'orderProductRequests']], reducer: v => v })
const data = form.getFieldValue('orderProductRequests')
const { form } = useFormSpy({ selector: [['onFieldValueChange', 'products']], reducer: v => v })
const data = form.getFieldValue('products')
const sum = data.reduce((prev, next) => (prev*100 + (next.money || 0)*100)/100, 0)
const [freePrice, setFreePrice] = useState<number>(0)
......@@ -105,7 +104,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
deliveryTime: formatTimeString(data.deliveryTime)
})
setTimeout(() => {
addSchemaAction.setFieldValue('orderProductRequests', _orderProductRequests)
addSchemaAction.setFieldValue('products', _orderProductRequests)
}, 1000)
setFormLoading(false)
})
......@@ -121,89 +120,33 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}, [])
const handleSubmit = async (value) => {
const _orderProductRequests = JSON.parse(JSON.stringify(value.orderProductRequests))
try {
let fnResult = null
switch (page_type) {
case '0': {
// 新增订单/编辑订单
const params = {
...value,
deliveryTime: moment(value.deliveryTime).valueOf(),
// 没用的字段
orderProductRequests: _orderProductRequests.map(v => {
v.price = v.money / v.purchaseCount / v.memberPrice
v.isMemberPrice = Number(v.isMemberPrice) || 0
v.memberPrice = v.memberPrice
v.imgUrl = v.mainPic ? v.mainPic : v.imgUrl
v.minOrder = v.minOrder
v.channelProductId = v?.channelProductId || v?.commodityUnitPriceAndPicId
return v
}),
needTheInvoice: value.needTheInvoice ? 1 : 0,
// 冗余交付信息
deliveryAddresId: value.deliveryAddresId.id || value.deliveryAddresId,
...omit(value.deliveryAddresId, ['id']),
// 冗余发票信息
theInvoiceId: value.theInvoiceId ? value.theInvoiceId.id : undefined,
}
// 合同下单 取供应商默认的发货地址
const { data: deliveryAddress} = await PublicApi.getLogisticsSelectListMemberShipperAddress({
memberId: params.supplyMembersId,
roleId: params.supplyMembersRoleId
})
params.orderProductRequests = params.orderProductRequests.map(item => {
const address = deliveryAddress[0]
const logistics: any = {
deliveryType: item.logistics,
sendAddress: address.id,
render: address
}
return {
...item,
logistics
}
})
// 校验采购数量
const judgementByCount = params.orderProductRequests?.length && params.orderProductRequests.map(item => {
if(item.purchaseCount){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error('请填写商品采购数量')
}
// 使用发票即校验发票id
if(params.needTheInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
// logistics render字段字符串化
params.orderProductRequests = params.orderProductRequests.map(item => {
const logistics: any = {
...item.logistics,
render: JSON.stringify(typeof item.logistics.render === "object" ? item.logistics.render : (item.logistics?.render ? item.logistics.render.replace(/\"/g, '') : {}))
};
return {
...item,
logistics
}
})
setBtnLoading(true)
delete params.type
// 新增订单/编辑订单
const params = { ...value }
if(id) {
fnResult = await PublicApi.postOrderProcurementOrderUpdate({...params, id})
} else {
const _params = procurementProcessField(params)
const _ = _params.quotationNo
_params.quotationNo = _params.contractNo
_params.contractNo = _
fnResult = await PublicApi.postOrderPurchaseContractAdd(_params)
}
break;
// 校验采购数量
const judgementByCount = params.products?.length && params.products.map(item => {
if(item.quantity){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error('请填写商品采购数量')
}
// 使用发票即校验发票id
if(params.needInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
setBtnLoading(true)
if(id) {
fnResult = await PublicApi.postOrderProcurementOrderUpdate({...params, id})
} else {
const _params = procurementProcessField(params)
fnResult = await PublicApi.postOrderPurchaseContractAdd(_params)
}
if (fnResult.code === 1000) {
setTimeout(() => {
......@@ -289,20 +232,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
})
}
})
// 监听商品总价的变更, 此处逻辑需优化
$('sumPrice').subscribe(payload => {
const payment = addSchemaAction.getFieldValue('paymentInformationResponses')
const oldData = payment ? [...payment] : [];
if (oldData && oldData.length > 0) {
const newData = oldData.map(v => {
v.payPrice = (v.payRatio / 100 * payload).toFixed(2)
return v
})
addSchemaAction.setFieldValue('paymentInformationResponses', newData)
}
// setProductSumPrice(payload)
productSumPriceRef.current = payload
})
useOrderFormInitEffect(ctx)
useModelTypeChange(state => {
const { value } = state
......@@ -311,6 +240,9 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
// 编辑 地址和发票信息变动 触发订单更新
useOrderUpdateChangeOther(ctx)
......
......@@ -22,18 +22,8 @@ export const sortByKey = (params) => {
}
export const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['purchaseCount']) || 0
record.unitPrice = pageStatus === PageStatus.EDIT ? record.price : record.unitPrice || record.price || 0
if (typeof record.unitPrice === 'number') {
return Number((record.unitPrice * purchaseCount).toFixed(2))
}
if(record.unitPrice) {
record.unitPrice = sortByKey(record.unitPrice)
}
// fix 当没有传递unitPrice字段时 但有price字段时 补全unitPrice字段
if(record.price && JSON.stringify(record.unitPrice) === "{}") {
record.unitPrice = {'0-0': record.price}
}
const purchaseCount = Number(record['quantity']) || 0
return Number((record.price * purchaseCount).toFixed(2))
}
/**
......@@ -46,7 +36,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
orderModel = ctx.getFieldValue('orderModel')
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('orderProductRequests')]
const newData = [...ctx.getFieldValue('products')]
// 删除formvalue
const colIndex = newData.findIndex(v => v.id === record.id)
newData.splice(colIndex, 1)
......@@ -54,7 +44,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
// 删除选中的项
rowSelectionCtl.setSelectRow(newData)
rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.id))
ctx.setFieldValue('orderProductRequests', newData)
ctx.setFieldValue('products', newData)
}
......@@ -65,37 +55,22 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
// 渲染操作
materialInfoColumns[materialInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>删除</Button>
// 渲染单价
materialInfoColumns[8].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
materialInfoColumns[0].render = (t, r) => {
if(orderModel === OrderModalType["HAND_ORDER"]) {
return r.id
} else {
return r.id ? r.id : r.productId
}
}
materialInfoColumns[8].render = (t, r) => <span style={{color: 'red'}}>{r.price}</span>
} else {
// 渲染单价
materialInfoColumns[8].render = (t, r) => <span style={{color: 'red'}}>{r.price}</span>
// 渲染商品ID
materialInfoColumns[0].render = (t, r) => r.productId
materialInfoColumns[materialInfoColumns.length - 1].render = (t, r) => null
}
return materialInfoColumns
})
const handleShowMaterial = () => {
const supplyMembersId = ctx.getFieldValue('supplyMembersId')
const supplyMembersId = ctx.getFieldValue('vendorMemberId')
const products = ctx.getFieldValue('products')
if (supplyMembersId) {
materialRef.current.setVisible(true)
materialRef.current.rowSelectionCtl.setSelectedRowKeys(() => products.map(item => item.id))
} else {
message.error('请先选择采购询价合同')
}
......@@ -113,22 +88,16 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
const { pageStatus } = usePageStatus()
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('orderProductRequests')];
const newData = [...ctx.getFieldValue('products')];
const index = newData.findIndex(item => row.id === item.id);
const item = newData[index];
// 算单行价格
row['money'] = getUnitPriceTotal(row)
// 通过下单模式判断 是否是手工或者渠道手工下单
let addModel = ctx.getFieldValue("orderModel")
row['productId'] = (
addModel === OrderModalType["HAND_ORDER"] ||
addModel === OrderModalType["CHANNEL_DIRECT_MINING_ORDER"] ||
addModel === OrderModalType["CHANNEL_SPOT_MANUAL_ORDER"]
) && (pageStatus === PageStatus.ADD) ? row.id : row.productId
newData.splice(index, 1, {
...item,
...row,
});
ctx.setFieldValue('orderProductRequests', newData)
ctx.setFieldValue('products', newData)
resolve({item, newData})
})
};
......
......@@ -13,7 +13,6 @@ const getShopTypeMap = (() => {
}))
})()
// 基本信息
const basicInfo: ISchema = {
"x-index": 0,
......@@ -66,14 +65,7 @@ const basicInfo: ISchema = {
},
],
},
shopId: {
type: 'string',
enum: getShopTypeMap,
title: '适应商城',
required: true,
visible: false,
},
orderThe: {
digest: {
type: 'string',
title: '订单摘要',
"x-rules": [
......@@ -97,7 +89,7 @@ const basicInfo: ISchema = {
"x-linkages": [
{
type: 'value:schema',
target: "supplyMembersName",
target: "vendorMemberName",
condition: `{{$self.editable && !!$value}}`,
schema: {
"x-component-props": {
......@@ -108,7 +100,7 @@ const basicInfo: ISchema = {
}
],
},
supplyMembersName: {
vendorMemberName: {
type: 'string',
title: '供应会员',
"x-component-props": {
......@@ -116,11 +108,11 @@ const basicInfo: ISchema = {
},
required: true,
},
supplyMembersId: {
vendorMemberId: {
type: 'string',
display: false
},
supplyMembersRoleId: {
vendorRoleId: {
type: 'string',
display: false
},
......@@ -194,11 +186,11 @@ export const orderMaterial: ISchema = {
tab: '订单物料'
},
properties: {
orderProductRequests: {
products: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'id',
rowKey: 'materialId',
columns: "{{materialColumns}}",
components: "{{materialComponents}}",
prefix: "{{materialAddButton}}",
......
......@@ -25,7 +25,8 @@ const approvedActions = createFormActions()
export interface ReadyAddOrderProps {}
const fetchTableData = async (params) => {
const { data } = await PublicApi.getOrderProcurementStayAddList(params)
const { data } = await PublicApi.getOrderBuyerCreatePage(params)
// const { data } = await PublicApi.getOrderProcurementStayAddList(params)
return data
}
......
import React, { useRef } from 'react'
import { Button, Popconfirm } from 'antd'
import { Button, Dropdown, Menu } from 'antd'
import { baseOrderListColumns } from '../../constant'
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { history } from 'umi'
import { PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState } from '@/constants/order'
import TableOperation from '@/components/TableOperation'
import { CaretDownOutlined } from '@ant-design/icons'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
const ref = useRef<any>({})
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'id', extendsSelection: {
getCheckboxProps: record => ({
// 不等于可提交审核的 都无法通过批量提交
disabled: record.interiorState !== PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER,
interiorState: record.interiorState,
})
}})
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'id'})
const handleSubmit = async (id) => {
// 从待新增订单直接传到一级审核, 状态写死, 默认传-1
await PublicApi.postOrderProcurementOrderSubmitExamine({id, state: -1})
await PublicApi.postOrderBuyerCreateSubmit({orderId: id})
ref.current.reload()
}
const handleDelete = async (id) => {
await PublicApi.postOrderProcurementOrderDelete({id})
await PublicApi.postOrderBuyerCreateDelete({orderId: id})
ref.current.reload()
}
const handleEdit = (record: any) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/edit?id=${record.id}${record.type === 4 ? '&type=4' : ''}`)
}
const handleCancel = async (id) => {
await PublicApi.postOrderPurchaseOrderCancel({id})
ref.current.reload()
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/srm/edit?id=${record.orderId}${record.type === 4 ? '&type=4' : ''}`)
// history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/edit?id=${record.id}${record.type === 4 ? '&type=4' : ''}`)
}
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'5': ['提交审核', '修改', '删除'],
'6': ['修改'],
}
const buttonGroup = { '提交': true, '修改': true, '删除': true }
const operationHandler = {
'提交审核': () => handleSubmit(record.id),
'提交': () => handleSubmit(record.orderId),
'修改': () => handleEdit(record),
'删除': () => handleDelete(record.id),
'删除': () => handleDelete(record.orderId),
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
operationHandler={operationHandler}
priorityOperationName='提交审核'
/>
)
const keyNames = Object.keys(buttonGroup)
return (<>
{
Object.values(buttonGroup).filter(Boolean).length > 2
?
<>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Dropdown overlay={
<Menu>
{
keyNames.slice(1, keyNames.length).map((e, i) => (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
</Menu.Item>
))
}
</Menu>
}>
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
更多 <CaretDownOutlined />
</a>
</Dropdown>
</>
:
keyNames.map((e, i) => (buttonGroup[e] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button> : null))
}
</>)
}
const secondColumns = () => {
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getPurchaseOrderSelectOption } from '@/pages/transaction/effect';
import { getPurchaseOrderReadyAddPageSelectOption } from '@/pages/transaction/effect';
export const tableListSchema: any = () => {
const res = getPurchaseOrderSelectOption()
const res = getPurchaseOrderReadyAddPageSelectOption()
if(res) {
const {
orderTypes: OrderType,
......@@ -31,19 +31,19 @@ export const tableListSchema: any = () => {
},
},
properties: {
orderThe: {
"digest": {
type: 'string',
'x-component-props': {
placeholder: '请输入订单摘要',
}
},
"supplyMembersName": {
"memberName": {
type: 'string',
"x-component-props": {
placeholder: '请输入供应会员名称'
}
},
"type": {
"orderType": {
type: 'string',
"x-component-props": {
placeholder: '请选择订单类型'
......@@ -53,7 +53,7 @@ export const tableListSchema: any = () => {
value: item['id'],
}))
},
"[startCreateTime,endCreateTime]": {
"[startDate,endDate]": {
type: 'daterange',
// "x-component": 'DateRangePickerUnix',
'x-component-props': {
......
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