Commit a8b47c8f authored by XieZhiXiong's avatar XieZhiXiong

Merge branch 'v2-220518-order' into 'v2-220518'

feat: 新增合同采购订单静态 See merge request linkseeks-design/pro-platform!600
parents 5c4c1ecc 98205ade
......@@ -43,7 +43,7 @@ const config: any = {
// layout: {},
esbuild: {},
// 打开msfu会导致样式异常, 无法获得正常的样式变量
mfsu: {},
// mfsu: {},
antd: {},
locale: {
default: 'zh-CN',
......
......@@ -45,8 +45,8 @@ const srmPurchaserHomeRoute = {
};
// isDev ? [ homeRoute, OrderRoute ] :
// const routes = asyncRoutes;
const routes = isDev ? [ homeRoute, AuthConfigRoute ] : asyncRoutes;
const routes = asyncRoutes;
// const routes = isDev ? [ homeRoute, AuthConfigRoute ] : asyncRoutes;
const memberCenterRoute = {
path: '/memberCenter',
......
......@@ -188,7 +188,7 @@ export enum OrderModalType {
/**
* 采购竞价合同下单
*/
PURCHASE_BIDDING_CONTRACT_ORDER = 13,
PURCHASE_BIDDING_CONTRACT_ORDER = 13,
/**
* 采购招标合同下单
......@@ -198,7 +198,7 @@ export enum OrderModalType {
/**
* 请购单采购下单
*/
PURCHASE_REQUISITION_ORDER = 15,
PURCHASE_REQUISITION_ORDER = 16,
}
// 订单种类 *NEW @可能还需要补充 现货采购 渠道直采 渠道现货
......@@ -207,12 +207,12 @@ export enum OrderKindType {
/**
* 采购订单
*/
PURCHASE_ORDER = 1,
PURCHASE_ORDER = 1,
/**
* SRM订单
*/
SRM_ORDER = 2,
SRM_ORDER = 2,
/**
* B2B订单
......@@ -227,7 +227,7 @@ export enum OrderKindType {
/**
* 积分兑换订单
*/
CREDITS_ORDER = 5,
CREDITS_ORDER = 5,
/**
* 代客下单订单
......
......@@ -103,6 +103,7 @@ export default {
'purchaseOrder.orderCollect.button2': 'Select a coupon',
'purchaseOrder.orderCollect.button3': 'Add a new delivery address',
'purchaseOrder.orderCollect.schema.title1': 'Basic Information',
'purchaseOrder.orderCollect.schema.paymentInfo': 'Payment Info',
'purchaseOrder.orderCollect.schema.orderMode': 'Order Mode',
'purchaseOrder.orderCollect.schema.quoteNo': 'Quotation number',
'purchaseOrder.orderCollect.schema.digest': 'Order Summary',
......@@ -134,6 +135,7 @@ export default {
'purchaseOrder.orderCollect.constant.orderTypeLabel2': 'Purchase inquiry contract',
'purchaseOrder.orderCollect.constant.orderTypeLabel3': 'Purchase bidding contract',
'purchaseOrder.orderCollect.constant.orderTypeLabel4': 'Purchase Bidding Contract',
'purchaseOrder.orderCollect.constant.orderTypeLabel5': 'Purchase Requisition Contract',
'purchaseOrder.orderCollect.constant.memberId': 'Member ID',
'purchaseOrder.orderCollect.constant.name': 'Member Name',
'purchaseOrder.orderCollect.constant.memberTypeName': 'Company Type',
......@@ -281,6 +283,7 @@ export default {
'purchaseOrder.orderCollect.contractColumns.sourceType1': 'Purchase inquiry',
'purchaseOrder.orderCollect.contractColumns.sourceType2': 'Purchase bidding',
'purchaseOrder.orderCollect.contractColumns.sourceType3': 'Purchase bidding',
'purchaseOrder.orderCollect.contractColumns.sourceType4': 'Requisitions',
'purchaseOrder.orderCollect.contractColumns.sourceNo': 'Corresponding documents',
'purchaseOrder.orderCollect.contractColumns.contractFreeCount': 'Contract Remaining',
'purchaseOrder.qingshurudingdanOrderNo': 'Please enter the order number',
......
......@@ -103,6 +103,7 @@ export default {
'purchaseOrder.orderCollect.button2': '쿠폰 선택',
'purchaseOrder.orderCollect.button3': '새 배송 주소',
'purchaseOrder.orderCollect.schema.title1': '기본 정보',
'purchaseOrder.orderCollect.schema.paymentInfo': '결제 정보',
'purchaseOrder.orderCollect.schema.orderMode': '주문 모드',
'purchaseOrder.orderCollect.schema.quoteNo': '해당 견적 번호',
'purchaseOrder.orderCollect.schema.digest': '주문 요약',
......@@ -134,6 +135,7 @@ export default {
'purchaseOrder.orderCollect.constant.orderTypeLabel2': '구매 문의 계약',
'purchaseOrder.orderCollect.constant.orderTypeLabel3': '구매 경쟁 계약',
'purchaseOrder.orderCollect.constant.orderTypeLabel4': '구매 입찰 계약',
'purchaseOrder.orderCollect.constant.orderTypeLabel5': '구매 요청 계약',
'purchaseOrder.orderCollect.constant.memberId': '회원 ID',
'purchaseOrder.orderCollect.constant.name': '회원명',
'purchaseOrder.orderCollect.constant.memberTypeName': '회사 유형',
......@@ -281,6 +283,7 @@ export default {
'purchaseOrder.orderCollect.contractColumns.sourceType1': '구매 문의',
'purchaseOrder.orderCollect.contractColumns.sourceType2': '구매 입찰 공고',
'purchaseOrder.orderCollect.contractColumns.sourceType3': '구매 경쟁 가격',
'purchaseOrder.orderCollect.contractColumns.sourceType4': '요청',
'purchaseOrder.orderCollect.contractColumns.sourceNo': '대응 증빙서류',
'purchaseOrder.orderCollect.contractColumns.contractFreeCount': '계약 잉여',
'purchaseOrder.qingshurudingdanOrderNo': '주문 번호를 입력하십시오.',
......
......@@ -103,6 +103,7 @@ export default {
'purchaseOrder.orderCollect.button2': '选择优惠券',
'purchaseOrder.orderCollect.button3': '新增收货地址',
'purchaseOrder.orderCollect.schema.title1': '基本信息',
'purchaseOrder.orderCollect.schema.paymentInfo': '付款信息',
'purchaseOrder.orderCollect.schema.orderMode': '下单模式',
'purchaseOrder.orderCollect.schema.quoteNo': '对应报价单号',
'purchaseOrder.orderCollect.schema.digest': '订单摘要',
......@@ -134,6 +135,7 @@ export default {
'purchaseOrder.orderCollect.constant.orderTypeLabel2': '采购询价合同',
'purchaseOrder.orderCollect.constant.orderTypeLabel3': '采购竞价合同',
'purchaseOrder.orderCollect.constant.orderTypeLabel4': '采购招标合同',
'purchaseOrder.orderCollect.constant.orderTypeLabel5': '请购单合同',
'purchaseOrder.orderCollect.constant.memberId': '会员ID',
'purchaseOrder.orderCollect.constant.name': '会员名称',
'purchaseOrder.orderCollect.constant.memberTypeName': '公司类型',
......@@ -281,6 +283,7 @@ export default {
'purchaseOrder.orderCollect.contractColumns.sourceType1': '采购询价',
'purchaseOrder.orderCollect.contractColumns.sourceType2': '采购招标',
'purchaseOrder.orderCollect.contractColumns.sourceType3': '采购竞价',
'purchaseOrder.orderCollect.contractColumns.sourceType4': '请购单',
'purchaseOrder.orderCollect.contractColumns.sourceNo': '对应单据',
'purchaseOrder.orderCollect.contractColumns.contractFreeCount': '合同剩余',
'purchaseOrder.qingshurudingdanOrderNo': '请输入订单编号',
......
......@@ -34,7 +34,7 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
useEffect(() => {
if(visible) {
/** 这里分 询价 竞价 招标 种采购合同类型 */
/** 这里分 询价 竞价 招标 请购单 四种采购合同类型 */
let sourceType = null;
const contract = schemaAction.getFieldValue('contract')
switch (schemaAction.getFieldValue('orderMode')) {
......@@ -47,6 +47,9 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
case OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER:
sourceType = 2;
break;
case OrderModalType.PURCHASE_REQUISITION_ORDER:
sourceType = 4;
break;
}
if(contract) {
rowSelectionCtl.setSelectedRowKeys([contract['id'] || contract['contractId']])
......@@ -55,57 +58,61 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
}
}, [visible])
const handleConfirm = async () => {
const handleConfirm = () => {
const item = rowSelectionCtl.selectRow[0]
if (item) {
schemaAction.setFieldValue('products', [])
schemaAction.setFieldValue('contractNo', item.contractNo)
schemaAction.setFieldValue('contract', item)
const { data } = await fetchOrderApi.getContractPurchaseMaterielList({
contractId: item?.id || item?.contractId,
current: 1,
pageSize: 999,
})
if(!data) { return false; }
// 字段转换
let newData = data.map((v: any) => {
let temp: any = {};
temp.id = v.id;
// temp.materialId = v.materialId;
temp.code = v.materielNo;
temp.name = v.materielName;
temp.type = v.type;
temp.category = v.category;
temp.brand = v.brand;
temp.unit = v.unit;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductType = v.associatedType;
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
temp.price = v.price;
temp.stock = v.supplierInventory;
temp.tax = v.isHasTax;
temp.taxRate = v.taxRate;
// @ 配送方式 默认物流
temp.logistics = 1
// 会员信息冗余
temp.memberId = item.partyBMemberId
temp.memberRoleId = item.partyBRoleId
return temp
})
schemaAction.setFieldValue('products', newData)
schemaAction.setFieldValue('vendorMemberName', item.partyBName)
schemaAction.setFieldValue('vendorMemberId', item.partyBMemberId)
schemaAction.setFieldValue('vendorRoleId', item.partyBRoleId)
schemaAction.setFieldValue('digest', item.contractAbstract)
// fillProductsOfContractIntoTable(item)
}
confirmModal && confirmModal()
setVisible(false)
}
/** 把合同下的物料填入到订单物料表格 */
const fillProductsOfContractIntoTable = async (item: any) => {
const { data } = await fetchOrderApi.getContractPurchaseMaterielList({
contractId: item?.id || item?.contractId,
current: 1,
pageSize: 999,
})
if(!data) { return false; }
// 字段转换
let newData = data.map((v: any) => {
let temp: any = {};
temp.id = v.id;
// temp.materialId = v.materialId;
temp.code = v.materielNo;
temp.name = v.materielName;
temp.type = v.type;
temp.category = v.category;
temp.brand = v.brand;
temp.unit = v.unit;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductType = v.associatedType;
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
temp.price = v.price;
temp.stock = v.supplierInventory;
temp.tax = v.isHasTax;
temp.taxRate = v.taxRate;
// @ 配送方式 默认物流
temp.logistics = 1
// 会员信息冗余
temp.memberId = item.partyBMemberId
temp.memberRoleId = item.partyBRoleId
return temp
})
schemaAction.setFieldValue('products', newData)
}
return (
<ModalTable
modalTitle={intl.formatMessage({id: 'purchaseOrder.orderCollect.requisition.button2'})}
......
......@@ -8,6 +8,8 @@ import { addContractOrderModalSchema } from '@/components/ModalTable/schema'
import Search from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit';
import { getIntl } from 'umi'
import { Input, TableColumnProps } from 'antd'
import { OrderModalType } from '@/constants/order'
export interface MaterialModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
......@@ -17,7 +19,7 @@ export interface MaterialModalTableProps extends ModalTableProps {
confirmModal?()
}
export const materialColumns: any[] = [
export const materialColumns: TableColumnProps<any>[] = [
{
title: 'ID',
dataIndex: 'id',
......@@ -68,10 +70,88 @@ export const materialColumns: any[] = [
},
]
export const materialColumnsByRequisition: TableColumnProps<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.productNo'}),
dataIndex: 'materielNo',
key: 'materielNo',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.spec'}),
dataIndex: 'type',
key: 'type',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.name'}),
dataIndex: 'materielName',
key: 'materielName',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.category'}),
dataIndex: 'category',
key: 'category',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.brand'}),
dataIndex: 'brand',
key: 'brand',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.materialColumns.unit'}),
dataIndex: 'unit',
key: 'unit'
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.contractColumns.contractFreeCount'}),
dataIndex: 'contractFreeCount',
key: 'contractFreeCount'
},
{
title: '关联请购单',
dataIndex: 'value1',
align: 'center',
key: 'value1',
},
{
title: '请购单剩余',
dataIndex: 'value2',
align: 'center',
key: 'value2',
},
{
title: '下单数量',
dataIndex: 'value3',
align: 'center',
key: 'value3',
width: 80,
render: (text, record) => (
<Input
type="number"
onClick={ e => e.stopPropagation() }
/>
)
},
]
const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
const { type = 'checkbox', schemaAction, confirmModal, currentRef, sectionProps, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = sectionProps
const isPurchaseRequisition = schemaAction.getFieldValue('orderMode') === OrderModalType.PURCHASE_REQUISITION_ORDER
useEffect(() => {
if (currentRef) {
currentRef.current = {
......@@ -142,10 +222,14 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
return (
<ModalTable
modalTitle={getIntl().formatMessage({id: 'purchaseOrder.orderCollect.requisition.button'})}
modalTitle={getIntl().formatMessage({id: 'purchaseOrder.orderCollect.requisition.button'})}
width={900}
columns={materialColumns}
visible={visible}
columns={materialColumns}
// useNestTable={isPurchaseRequisition}
// nestProps={{
// NestColumns: [tableColumn, childTableColumn],
// }}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={fetchMaterialList}
......@@ -162,18 +246,18 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
})
}}
formilyProps={{
ctx: {
schema: addContractOrderModalSchema,
components: { ModalSearch: Search, Submit },
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'productNo',
FORM_FILTER_PATH,
);
}
ctx: {
schema: addContractOrderModalSchema,
components: { ModalSearch: Search, Submit },
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'productNo',
FORM_FILTER_PATH,
);
}
}
}}
{...restProps}
/>
......
import React, { useEffect, useState } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { requisitionColumns } from '../../constant'
import { OrderModalType } from '@/constants/order'
import { getContractManagePageCompleteList } from '@/services/ContractV2Api'
import { useIntl } from 'umi'
export interface ContractModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?()
}
// 关联请购单弹窗
const RequisitionModalTable:React.FC<ContractModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({ type })
const intl = useIntl()
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
return (
<ModalTable
modalTitle={ '关联请购单' }
columns={requisitionColumns}
visible={visible}
fetchTableData={ () => {} }
rowSelection={rowSelection}
modalType='contractByDefault'
searchName="contractNo"
tableProps={{
rowKey: 'id',
scroll: { x: true }
}}
resetModal={{
destroyOnClose: true,
}}
{...restProps}
/>
)
}
RequisitionModalTable.defaultProps = {}
export default RequisitionModalTable
......@@ -104,13 +104,15 @@ export const orderCombination = {
showPurchaseContractField: [
OrderModalType.PURCHASE_ENQUIRY_CONTRACT_ORDER,
OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER,
OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER
OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER,
OrderModalType.PURCHASE_REQUISITION_ORDER
],
// 是否显示选择采购合同按钮
showPurchaseContractBtn: [
OrderModalType.PURCHASE_ENQUIRY_CONTRACT_ORDER,
OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER,
OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER
OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER,
OrderModalType.PURCHASE_REQUISITION_ORDER
],
}
......@@ -120,6 +122,7 @@ export const orderTypeLabelMap = {
'12': getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.orderTypeLabel2'}),
'13': getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.orderTypeLabel3'}),
'14': getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.orderTypeLabel4'}),
'16': getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.orderTypeLabel5'}),
}
......@@ -233,6 +236,7 @@ export const contractColumns: any[] = [
if(t === 1) return getIntl().formatMessage({id: 'purchaseOrder.orderCollect.contractColumns.sourceType1'})
if(t === 2) return getIntl().formatMessage({id: 'purchaseOrder.orderCollect.contractColumns.sourceType2'})
if(t === 3) return getIntl().formatMessage({id: 'purchaseOrder.orderCollect.contractColumns.sourceType3'})
if(t === 4) return getIntl().formatMessage({id: 'purchaseOrder.orderCollect.contractColumns.sourceType4'})
}
},
{
......@@ -342,3 +346,126 @@ export const materialInfoColumns: any[] = [
key: 'ctl',
},
]
// 合同下单 物料列表(请购单合同情况下)
export const materialInfoColumnsByRequisition: any[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
className: 'commonHide'
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.code'}),
dataIndex: 'code',
align: 'center',
key: 'code',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.name1'}),
dataIndex: 'name',
align: 'center',
key: 'name',
render: (t, r) => `${t}/${r.type}`
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.category'}),
dataIndex: 'category',
align: 'center',
key: 'category',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.brand'}),
dataIndex: 'brand',
align: 'center',
key: 'brand',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.unit'}),
dataIndex: 'unit',
align: 'center',
key: 'unit',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.relevanceProductId'}),
dataIndex: 'relevanceProductId',
align: 'center',
key: 'relevanceProductId',
render: (t, r) => t ? `${t}/${r.relevanceProductName || ''}/${r.relevanceProductType || ''}/${r.relevanceProductCategory || ''}/${r.relevanceProductBrand || ''}` : ''
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.price'}),
dataIndex: 'price',
align: 'left',
key: 'price',
render: (t) => `${getIntl().formatMessage({ id: 'commodity.products.directChannel.columns.currency'})}${t.toFixed(2)}`
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.quantity'}),
dataIndex: 'quantity',
align: 'center',
key: 'quantity',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.taxInclusive'}),
dataIndex: 'tax',
align: 'center',
key: 'tax',
render: (t, r) => t ? getIntl().formatMessage({id: 'purchaseOrder.yes'}) : getIntl().formatMessage({id: 'purchaseOrder.no'})
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.taxRate'}),
dataIndex: 'taxRate',
align: 'center',
key: 'taxRate',
render: (t, r) => t ? `${t}%` : null
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.readyAddOrder.productInfoColumns.price'}),
dataIndex: 'amount',
align: 'center',
key: 'amount',
render: (t, r) => t ? `${Number(t).toFixed(2)}` : null
},
// 接口调用
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.constant.logistics'}),
dataIndex: 'logistics',
align: 'center',
key: 'logistics',
formItem: 'select',
editable: true,
},
{
title: '关联单据',
dataIndex: 'relative',
align: 'center',
key: 'relative',
},
{
title: '备注',
dataIndex: 'remark',
align: 'center',
key: 'remark',
formItem: 'input',
editable: true,
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.operation'}),
dataIndex: 'ctl',
align: 'center',
key: 'ctl',
},
]
// 关联请购单 列表
export const requisitionColumns: any[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
className: 'commonHide'
},
]
......@@ -12,6 +12,14 @@ export const useModelTypeChange = (callback) => {
})
}
export const useContractChange = (callback) => {
const utils = useLinkageUtils()
// 选择的合同发生改变时
FormEffectHooks.onFieldValueChange$('contract').subscribe(state => {
callback(state)
})
}
export const useEditHideField = () => {
const { pageStatus } = usePageStatus()
const utils = useLinkageUtils()
......
......@@ -6,7 +6,7 @@ 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, useProductTableChangeForPay } from './effects'
import { useModelTypeChange, useContractChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay } from './effects'
import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant'
import CirculationRecord from '../components/circulationRecord'
import SelectAddress from './components/selectAddress'
......@@ -18,14 +18,16 @@ import styles from './index.less'
import { useMaterialTable } from './model/useMaterialTable'
import ContractModalTable from './components/contractModalTable'
import MaterialModalTable from './components/materialModalTable'
import RequisitionModalTable from './components/requisitionModalTable'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { OrderModalType } from '@/constants/order'
import { FormDetailContext } from '@/formSchema/context'
import FormDetailHeader from '@/components/FormDetailHeader'
import FormDetailWrapper from '@/components/FormDetailWrapper'
import { useFormDetail } from '@/formSchema/effects/useFormDetail'
import { getOrderBuyerCreateDetail, getOrderBuyerCreatePageItems, postOrderBuyerCreateSrm, postOrderBuyerCreateSrmUpdate } from '@/services/OrderNewV2Api'
import { getOrderBuyerCreateDetail, getOrderBuyerCreatePageItems, postOrderBuyerCreateSrm, postOrderBuyerCreateSrmUpdate, getOrderBuyerPaymentTypeAll } from '@/services/OrderNewV2Api'
import { getLogisticsReceiverAddressGet, getLogisticsSelectListMemberShipperAddress } from '@/services/LogisticsV2Api'
import { getContractSelectCurrencyList } from '@/services/ContractV2Api'
import AuthButton from '@/components/AuthButton'
export interface PurchaseOrderDetailProps { }
......@@ -50,6 +52,18 @@ const fetchOrderMode = async () => {
return orderModes.filter(item => item.id !== OrderModalType.INQUIRY_QUOTATION_ORDER)
}
// 获取币别类型
const fetchCurrencyType = async () => {
const { data } = await getContractSelectCurrencyList()
return data
}
// 获取付款方式
const fetchPaymentType = async () => {
const { data } = await getOrderBuyerPaymentTypeAll()
return data
}
// 总计金额联动框
export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
const { form } = useFormSpy({ selector: [['onFieldValueChange', 'products']], reducer: v => v })
......@@ -81,6 +95,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
const shopDataRef = useRef<any>({})
const intl = useIntl()
const contractOrderRef = useRef<any>({}) // 合同下单选采购合同
const requisitionRef = useRef<any>({}) // 关联请购单
const [formLoading, setFormLoading] = useState(false)
const [btnLoading, setBtnLoading] = useState(false)
const update = useUpdate()
......@@ -100,6 +115,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 订单物料
const { materialAddButton, materialRef, materialColumns, materialComponents, ...surplusProps } = useMaterialTable(addSchemaAction)
const { materialColumns: materialColumnsByRequisition } = useMaterialTable(addSchemaAction, OrderModalType.PURCHASE_REQUISITION_ORDER)
let timerSignature = null
useEffect(() => {
......@@ -284,66 +300,82 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
]}
/>
<FormDetailWrapper>
<NiceForm
loading={formLoading}
previewPlaceholder=' '
value={initFormValue}
actions={addSchemaAction}
schema={initFormSchema}
onSubmit={handleSubmit}
components={{
SelectAddress,
TheInvoiceList,
}}
effects={($, ctx) => {
useAsyncSelect('orderMode', fetchOrderMode, ['text', 'id'])
$('onFormMount').subscribe(() => {
if (id || modelType) {
ctx.setFieldState('orderMode', state => {
state.editable = false
})
}
})
useOrderFormInitEffect(ctx)
useModelTypeChange(state => {
const { value, editable } = state
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabelMap[value])
addSchemaAction.setFieldState('products', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: editable && pageStatus === PageStatus.ADD ? materialAddButton : '',
}
<NiceForm
loading={formLoading}
previewPlaceholder=' '
value={initFormValue}
actions={addSchemaAction}
schema={initFormSchema}
onSubmit={handleSubmit}
components={{
SelectAddress,
TheInvoiceList,
}}
effects={($, ctx) => {
useAsyncSelect('orderMode', fetchOrderMode, ['text', 'id'])
useAsyncSelect('currencyType', fetchCurrencyType, ['text', 'id'])
useAsyncSelect('paymentType', fetchPaymentType, ['text', 'id'])
$('onFormMount').subscribe(() => {
if (id || modelType) {
ctx.setFieldState('orderMode', state => {
state.editable = false
})
}
})
useOrderFormInitEffect(ctx)
useModelTypeChange(state => {
const { value, editable } = state
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabelMap[value])
addSchemaAction.setFieldState('products', productState => {
productState.value = [] // 切换下单模式时,清空“订单物料”原有数据
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
columns: value === OrderModalType.PURCHASE_REQUISITION_ORDER
? materialColumnsByRequisition
: materialColumns,
prefix: editable && pageStatus === PageStatus.ADD ? materialAddButton : '',
}
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
// 注入表单完成进度
formContext.useAttachmentChangeForContext(ctx)
// 注入锚点标题数量同步
formContext.useAnchorCountChangeForContext(ctx, ['products'])
}}
expressionScope={{
orderContract,
materialColumns,
materialAddButton,
materialComponents,
orderCombination,
addNewAddress,
CirculationRecord: <CirculationRecord/>,
help,
}}
/>
</FormDetailWrapper>
</FormDetailContext.Provider>
{/* 选择合同下单 */}
<ContractModalTable currentRef={contractOrderRef} schemaAction={addSchemaAction}/>
{/* 选择采购物料 */}
<MaterialModalTable currentRef={materialRef} schemaAction={addSchemaAction} sectionProps={surplusProps} />
})
// 选择完对应合同
useContractChange(({ value }) => {
if (value?.CurrencyType) {
// 若合同有币别,默认填入到 付款信息
ctx.setFieldValue('currencyType', value.CurrencyType)
}
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
// 注入表单完成进度
formContext.useAttachmentChangeForContext(ctx)
// 注入锚点标题数量同步
formContext.useAnchorCountChangeForContext(ctx, ['products'])
}}
expressionScope={{
orderContract,
materialColumns,
materialColumnsByRequisition,
materialAddButton,
materialComponents,
orderCombination,
addNewAddress,
CirculationRecord: <CirculationRecord/>,
help,
}}
/>
</FormDetailWrapper>
</FormDetailContext.Provider>
{/* 选择合同下单 */}
<ContractModalTable currentRef={contractOrderRef} schemaAction={addSchemaAction}/>
{/* 选择采购物料 */}
<MaterialModalTable currentRef={materialRef} schemaAction={addSchemaAction} sectionProps={surplusProps} />
{/* 查看关联请购单 */}
<RequisitionModalTable currentRef={requisitionRef} schemaAction={addSchemaAction} />
</div>)
}
......
import React, { useRef, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button, message } from 'antd';
import { materialInfoColumns } from '../constant';
import { materialInfoColumns, materialInfoColumnsByRequisition } from '../constant';
import MaterialTableCell, { MaterialEditableRow } from '../components/materialTableCell';
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useIntl } from 'umi';
let orderMode = null;
import { OrderModalType } from '@/constants/order';
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export const sortByKey = (params) => {
......@@ -27,13 +26,11 @@ export const getUnitPriceTotal = (record) => {
/**
* @param ctx schemaAction
*/
export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, orderMode = ctx.getFieldValue('orderMode')) => {
const materialRef = useRef<any>({})
const intl = useIntl()
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
orderMode = ctx.getFieldValue('orderMode')
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('products')]
// 删除formvalue
......@@ -50,12 +47,28 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
const [materialColumns, setMaterialColumns] = useState(() => {
const { pageStatus } = usePageStatus()
const tempColumn = [...materialInfoColumns]
const tempColumn = [...(
orderMode === OrderModalType.PURCHASE_REQUISITION_ORDER
? materialInfoColumnsByRequisition
: materialInfoColumns
)]
if (pageStatus === PageStatus.ADD) {
// 渲染操作
tempColumn[tempColumn.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({id: 'purchaseOrder.delete'})}</Button>
// 渲染单价
tempColumn[7].render = (t, r) => <span style={{color: 'red'}}>{intl.formatMessage({ id: 'commodity.products.directChannel.columns.currency'})} {Number(r.price).toFixed(2)}</span>
// 渲染关联单据
const associatedIndex = tempColumn.findIndex(column => column.title === '关联单据')
if (tempColumn[associatedIndex]) {
tempColumn[associatedIndex].render = (text, record) => (
<Button
type="link"
onClick={ () => alert(JSON.stringify(record)) }
>
关联请购单
</Button>
)
}
} else {
// 渲染单价
tempColumn[7].render = (t, r) => <span style={{color: 'red'}}>{intl.formatMessage({ id: 'commodity.products.directChannel.columns.currency'})} {Number(r.price).toFixed(2)}</span>
......
......@@ -161,47 +161,55 @@ const basicInfo: ISchema = {
}
}
// 合同下单 订单物料
export const orderMaterials: ISchema = {
"x-index": 2,
// 付款信息
const paymentInfo: ISchema = {
"x-index": 1,
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.requisition.requisitionMaterial'}),
id: 'orderMaterials',
showTotal: true,
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.schema.paymentInfo'}),
id: 'paymentInfo'
},
properties: {
products: {
type: 'array',
"x-component": 'MultTable',
'x-rules': [{
required: true,
message: getIntl().formatMessage({id: 'common.bitian'}),
}],
NO_SUBMIT_LAYOUT: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
rowKey: 'materialId',
columns: "{{materialColumns}}",
components: "{{materialComponents}}",
prefix: "{{materialAddButton}}",
labelCol: 6,
wrapperCol: 18,
labelAlign: "left",
grid: true,
full: true,
autoRow: true,
columns: 2,
},
properties: {
currencyType: {
type: 'string',
'x-rules': [{
required: true,
message: getIntl().formatMessage({id: 'common.bitian'}),
}],
enum: [],
title: '币别',
},
paymentType: {
type: 'string',
'x-rules': [{
required: true,
message: getIntl().formatMessage({id: 'common.bitian'}),
}],
enum: [],
title: '付款方式',
},
}
},
// 仅合同下单时备用参数数据
ordeProducts: {
type: 'array',
title: '合同下单记录',
visible: false
},
NO_SUBMIT_SPY: {
type: 'object',
"x-component": "moneyTotalBox"
}
}
}
// 送货信息
const submitInfo: ISchema = {
"x-index": 1,
"x-index": 2,
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
......@@ -279,9 +287,47 @@ const submitInfo: ISchema = {
}
}
// 合同下单 订单物料
export const orderMaterials: ISchema = {
"x-index": 3,
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.requisition.requisitionMaterial'}),
id: 'orderMaterials',
showTotal: true,
},
properties: {
products: {
type: 'array',
"x-component": 'MultTable',
'x-rules': [{
required: true,
message: getIntl().formatMessage({id: 'common.bitian'}),
}],
"x-component-props": {
rowKey: 'materialId',
columns: "{{materialColumns}}",
components: "{{materialComponents}}",
prefix: "{{materialAddButton}}",
},
},
// 仅合同下单时备用参数数据
ordeProducts: {
type: 'array',
title: '合同下单记录',
visible: false
},
NO_SUBMIT_SPY: {
type: 'object',
"x-component": "moneyTotalBox"
}
}
}
// 发票信息
const invoiceInfo: ISchema = {
"x-index": 3,
"x-index": 4,
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
......@@ -346,7 +392,7 @@ const invoiceInfo: ISchema = {
// 其他信息
const ortherInfo: ISchema = {
"x-index": 4,
"x-index": 5,
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
......@@ -406,12 +452,13 @@ const ortherInfo: ISchema = {
export const orderAddSchema: ISchema = {
type: 'object',
properties: {
basicInfo,
submitInfo,
orderMaterials,
invoiceInfo,
ortherInfo,
}
basicInfo,
paymentInfo,
submitInfo,
orderMaterials,
invoiceInfo,
ortherInfo,
}
}
......
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