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

fix: 新增订单添加选择合同弹框,表单动态变更

parent 07c0156a
......@@ -3,7 +3,7 @@ import {StandardTable} from 'god';
import NestTable from '@/components/NestTable';
import { IStandardTableProps } from 'god/dist/src/standard-table';
import { Row, Col, Modal } from 'antd';
import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema, logisticsDeliverySearchSchema, addOrderModalSchema , logisticsSelectGoodsSearchSchema, SelectRfqOrderSearchSchema, SelectLogisticsService} from './schema';
import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema, logisticsDeliverySearchSchema, addOrderModalSchema , logisticsSelectGoodsSearchSchema, SelectRfqOrderSearchSchema, SelectLogisticsService, contractSchema} from './schema';
import Search from '../NiceForm/components/Search';
import SearchSelect from '../NiceForm/components/SearchSelect';
import Submit from '../NiceForm/components/Submit';
......@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> {
cancel?(),
visible?: boolean,
resetModal?: object,
modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'logisticsDelivery' | 'addOrderModalSchema' | 'selectGoodsSchema' | 'selectRfqOrder' | 'SelectLogisticsService' | 'none' ,
modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'logisticsDelivery' | 'addOrderModalSchema' | 'selectGoodsSchema' | 'selectRfqOrder' | 'SelectLogisticsService' | 'contractByDefault' | 'none' ,
useNestTable?: boolean, // 是否使用嵌套表格
nestColumns?: any[],
nestTableProps?: any,
......@@ -91,6 +91,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
case 'SelectLogisticsService': {
return SelectLogisticsService
}
case 'contractByDefault': {
return contractSchema
}
case 'none': {
return {}
}
......
......@@ -945,3 +945,69 @@ export const SelectLogisticsService: ISchema = {
}
}
}
/** 选择采购合同弹框筛选 */
export const contractSchema: ISchema = {
type: 'object',
properties: {
contractNo: {
type: 'string',
'x-component': 'ModalSearch',
'x-component-props': {
placeholder: '合同编号',
align: 'flex-left',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
style: {
marginRight: 0
}
},
colStyle: {
marginTop: 20,
},
},
properties: {
contractAbstract: {
type: 'string',
"x-component-props": {
placeholder: '合同摘要',
style: {
width: 160
}
}
},
partyBName: {
type: 'string',
'x-component-props': {
placeholder: '合同乙方',
style: {
width: 160
}
},
},
"[startTime,endTime]": {
type: 'string',
"x-component": "dateSelect",
"x-component-props": {
placeholder: '合同有效时间',
}
},
submit: {
"x-component": 'Submit',
"x-mega-props": {
span: 1
},
"x-component-props": {
children: '查询'
}
}
}
}
}
}
......@@ -21,7 +21,7 @@ export const fetchOrderApi = {
// 根据询价报价id查询商品列表
async getProductListByQuotationOrderId(params) {
const { data } = await PublicApi.getOrderEnquiryProductAll(params)
const { data } = await PublicApi.getTransactionEnquiryProductAll(params)
return data
},
......
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 { contractColumns } from '../../constant'
import { PublicApi } from '@/services/api'
import { filterProductDataById } from '../productModalTable'
import { OrderModalType } from '@/constants'
export interface ContractModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?()
}
// 选择采购合同弹窗
const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type})
const [originType, setOriginType] = useState<number>()
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
useEffect(() => {
if(visible) {
/** 这里分 询价 竞价 招标 三种采购合同类型 */
let sourceType = null;
switch (schemaAction.getFieldValue('orderModel')) {
case OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER:
sourceType = 3;
break;
case OrderModalType.PURCHASE_ENQUIRY_CONTRACT_ORDER:
sourceType = 1;
break;
case OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER:
sourceType = 2;
break;
}
setOriginType(sourceType)
}
}, [visible])
const handleConfirm = async () => {
const item = rowSelectionCtl.selectRow[0]
if (item) {
schemaAction.setFieldValue('quotationNo', item.contractNo)
const { data } = await fetchOrderApi.getProductListByQuotationOrderId({
id: item.sourceId
})
console.log(data, '合同关联单据商品')
// // 判断所选择的商品是否属于同一个工作流
// const res = await PublicApi.postOrderIsWorkFlow({
// memberId: data[0].memberId,
// memberRoleId: data[0].memberRoleId,
// productIds: data.map(item => item.productId),
// orderModel: schemaAction.getFieldValue('orderModel')
// }, { ctlType: 'none' })
// 将询价报价单的id字段 冗余给商品列表
// schemaAction.setFieldValue('orderProductRequests', data.map((v: any) => {
// v.memberId = item.offerMemberId
// v.memberRoleId = item.offerMemberRoleId
// return v
// }))
// let newData = data.map((v: any) => {
// v.memberId = item.offerMemberId
// v.memberRoleId = item.offerMemberRoleId
// return v
// })
// 把地址信息冗余给商品字段render
schemaAction.setFieldValue('orderProductRequests', await filterProductDataById([], data))
schemaAction.setFieldValue('supplyMembersName', data[0].memberName)
schemaAction.setFieldValue('supplyMembersId', data[0].memberId)
schemaAction.setFieldValue('supplyMembersRoleId', data[0].memberRoleId)
// 询价单回显订单明细
schemaAction.setFieldValue('orderThe', item.contractAbstract)
}
// confirmModal && confirmModal()
// setVisible(false)
}
return (
<ModalTable
modalTitle='选择采购合同'
columns={contractColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={async (params) => (await PublicApi.getContractManagePageCompleteList({...params, sourceType: originType}, {useCache: true, ttl: 10 * 1000})).data}
rowSelection={rowSelection}
modalType='contractByDefault'
searchName="contractNo"
tableProps={{
rowKey: 'id'
}}
{...restProps}
/>
)
}
ContractModalTable.defaultProps = {}
export default ContractModalTable
import React, { useState, useRef, useContext, useEffect } from 'react'
import { Form, Input, Select } from 'antd';
export interface MaterialTableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: string;
record: any;
handleSave: (record: any) => Promise<any>;
forceEdit: boolean,
formItem: string,
formItemProps: any
}
const EditableContext = React.createContext<any>({});
export const MaterialEditableRow: React.FC<any> = ({...props }) => {
const [form] = Form.useForm();
const ctx = {
form
}
return (
<Form form={form} component={false}>
<EditableContext.Provider value={ctx}>
<tr {...props} />
</EditableContext.Provider>
</Form>
);
};
export const MaterialTableCell:React.FC<MaterialTableCellProps> = ({
title,
editable,
children,
dataIndex,
record,
handleSave,
forceEdit,
formItem,
formItemProps={},
...restProps
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
values.purchaseCount = Number(values.purchaseCount) || 0
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
const chooseFormItem = (type, v) => {
switch(type) {
case 'input': {
// // 用于判断是否是合并下单
// let hasSelectMergeBtn = document.getElementsByClassName("selectMerge")
// // 用于合并订单采购数量回显
// if(hasSelectMergeBtn.length) {
// let keyValue = {}
// keyValue[dataIndex] = v
// form.setFieldsValue(keyValue)
// }
return <Input
style={{width: 140}}
type='number'
ref={formItemRef}
onChange={save}
{...formItemProps}
id={dataIndex + record.id}
className="purchase_amount_input"
/>
}
}
}
// 校验最小起订
const validatorNumber = (rule, value, callback) => {
try {
let _value = Number(value)
if(isNaN(_value) || _value < Number(record["minOrder"])) {
throw new Error(`数量不小于最小起订数${record["minOrder"]}`)
}
callback()
} catch (err) {
callback(err)
}
}
let childNode = children;
if (editable) {
childNode =
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
message: `${title}必须填写`,
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '采购数量仅限三位小数',
},
{
validator: validatorNumber
}
]}
>
{chooseFormItem(formItem, record[dataIndex] || '')}
</Form.Item>
}
return <td {...restProps}>{childNode}</td>;
}
MaterialTableCell.defaultProps = {}
export default MaterialTableCell
......@@ -208,6 +208,61 @@ export const inquiryColumns: any[] = [
}
]
// 采购合同下单选合同列
export const contractColumns: any[] = [
{
title: 'Id',
dataIndex: 'id',
key: 'id',
className: 'commonHide'
},
{
title: '合同编号',
dataIndex: 'contractNo',
key: 'contractNo',
},
{
title: '合同摘要',
dataIndex: 'contractAbstract',
key: 'contractAbstract',
},
{
title: '合同生效时间',
dataIndex: 'startTime',
key: 'startTime',
},
{
title: '合同失效时间',
dataIndex: 'endTime',
key: 'endTime',
},
{
title: '合同乙方',
dataIndex: 'partyBName',
key: 'partyBName',
},
{
title: '合同剩余金额',
dataIndex: 'deadLine',
key: 'deadLine',
},
{
title: '寻源类型',
dataIndex: 'sourceType',
key: 'sourceType',
render: (t, r) => {
if(t === 1) return '采购询价'
if(t === 2) return '采购招标'
if(t === 3) return '采购竞价'
}
},
{
title: '对应单据',
dataIndex: 'sourceNo',
key: 'sourceNo',
}
]
export const paymentInformationColumns: any[] = [
{
title: '支付次数',
......@@ -377,6 +432,114 @@ export const productInfoColumns: any[] = [
},
]
// 合同下单 物料列表
export const materialInfoColumns: any[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
className: 'commonHide'
},
{
title: '物料编号',
dataIndex: 'code',
align: 'center',
key: 'code',
},
{
title: '物料名称/规格',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
key: 'category',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
key: 'brand',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
key: 'unit',
},
{
title: '关联报价商品ID/名称/规格/品类/品牌',
dataIndex: 'unit',
align: 'center',
key: 'unit',
},
{
title: '单价(元)',
dataIndex: 'unitPrice',
align: 'left',
key: 'unitPrice',
},
{
title: '供方库存',
dataIndex: 'memberPrice',
align: 'center',
key: 'memberPrice',
},
{
title: '采购数量',
dataIndex: 'purchaseCount',
align: 'center',
key: 'purchaseCount',
formItem: 'input',
editable: true,
width: 140
},
{
title: '含税',
dataIndex: 'tax',
align: 'center',
key: 'tax',
render: () => '是'
},
{
title: '税率',
dataIndex: 'rate',
align: 'center',
key: 'rate',
},
{
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 "自提"
else if(r.logistics?.deliveryType === 3)
return "无需配送"
}
},
{
title: '操作',
dataIndex: 'ctl',
align: 'center',
key: 'ctl',
},
]
// 合并订单父级表格列
export const mergeParentTableColumns: any[] = [
{
......
......@@ -7,7 +7,7 @@ import { Button, Card, Row, Col, Drawer, message, Tooltip } from 'antd'
import { createFormActions, registerVirtualBox, useFormSpy, createAsyncFormActions } from '@formily/antd'
import { SaveOutlined, LinkOutlined, PlusOutlined, CodeSandboxCircleFilled, QuestionCircleOutlined, FilePdfOutlined, FilePdfFilled } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas, payInfo, orderMaterial, orderProduct } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay, useOrderUpdateChangeOther } from './effects'
import { orderTypeLabel, orderCombination, orderTypeLabelMap } from './constant'
import { OrderModalType } from '@/constants'
......@@ -34,6 +34,8 @@ import styles from './index.less'
import SimpleElectronModal from './components/simpleElectronModal'
import { fetchOrderApi } from './apis'
import MergeOrderModalTable from './components/mergeOrderModalTable'
import { useMaterialTable } from './model/useMaterialTable'
import ContractModalTable from './components/contractModalTable'
export interface PurchaseOrderDetailProps {}
......@@ -128,12 +130,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
const demandRef = useRef<any>({})
const contractRef = useRef<any>({})
const mergeRef = useRef<any>({})
const contractOrderRef = useRef<any>({}) // 合同下单选采购合同
const [formLoading, setFormLoading] = useState(false)
const [btnLoading, setBtnLoading] = useState(false)
const update = useUpdate()
const [productSumPrice, setProductSumPrice] = useState<number>(0)
const { pageStatus, id, page_type = '0', modelType, spam_id, lastTypeParams } = usePageStatus()
const [initFormSchema, setInitFormSchema] = useState<any>(mergeAllSchemas[page_type])
const [initFormValue, setInitFormValue] = useState<any>(() => {
let resultState = {}
if (modelType) {
......@@ -156,7 +159,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
addSchemaAction.getFieldValue('supplyMembersRoleId'),
pageStatus === PageStatus.ADD ? addSchemaAction.getFieldValue('orderProductRequests') : initFormValue.orderProductRequests
)
// 订单商品
const { productAddButton, productRef, productColumns, productComponents, ...sectionProps } = useProductTable(addSchemaAction, mergeRef)
// 订单物料
const { materialAddButton, materialRef, materialColumns, materialComponents, ...restProps } = useMaterialTable(addSchemaAction)
let timerSignature = null
// 页面进入时, 当前所处的下单模式
......@@ -379,7 +385,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 选择合同
const handleOrderContract = () => {
console.log('选择合同列表')
contractOrderRef.current.setVisible(true)
}
const orderNoPrice = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleOrderNo}><LinkOutlined style={{marginRight: 4}}/>选择</div>
......@@ -469,7 +475,8 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// editable={pageStatus !== PageStatus.PREVIEW}
value={initFormValue}
actions={addSchemaAction}
schema={mergeAllSchemas[page_type]}
// schema={mergeAllSchemas[page_type]}
schema={initFormSchema}
onSubmit={handleSubmit}
components={{
SelectAddress,
......@@ -529,8 +536,14 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
state.props.title = orderTypeLabelMap[value]
state.visible = true
})
ctx.setFieldState('payInfo', state => {
state.visible = false
// 移除支付信息栏 订单商品栏 添加订单物料
console.log(initFormSchema)
setInitFormSchema(() => {
let origin = {...initFormSchema}
delete origin.properties.NO_SUBMIT_TABS.properties.payInfo
delete origin.properties.NO_SUBMIT_TABS.properties.orderProduct
origin.properties.NO_SUBMIT_TABS.properties.orderMaterial = orderMaterial
return origin
})
} else {
ctx.setFieldState('quotationNo', state => {
......@@ -539,6 +552,14 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
ctx.setFieldState('payInfo', state => {
state.visible = true
})
// 移除订单物料 添加支付信息栏 订单商品栏
setInitFormSchema(() => {
let origin = {...initFormSchema}
origin.properties.NO_SUBMIT_TABS.properties.payInfo = payInfo
origin.properties.NO_SUBMIT_TABS.properties.orderProduct = orderProduct
delete origin.properties.NO_SUBMIT_TABS.properties.orderMaterial
return origin
})
}
}
......@@ -641,6 +662,9 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
productColumns,
productAddButton,
productComponents,
materialColumns,
materialAddButton,
materialComponents,
// productAfter: afterFix,
couponAddButton,
orderCombination,
......@@ -668,9 +692,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
currentRef={mergeRef}
schemaAction={addSchemaAction}
handleUpdate={update}
// confirmModal
/>
{/* 选择合同下单 */}
<ContractModalTable currentRef={contractOrderRef} schemaAction={addSchemaAction}/>
{/* @todo 选择采购物料 */}
</ReadyAddOrderDetailContext.Provider>
</PageHeaderWrapper>
)
......
import React, { useRef, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button, message } from 'antd';
import { PriceComp, materialInfoColumns } from '../constant';
import MaterialTableCell, { MaterialEditableRow } from '../components/materialTableCell';
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { OrderModalType } from '@/constants';
import { history } from "umi";
const { pageStatus } = usePageStatus()
let orderModel = null;
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export const sortByKey = (params) => {
let keys = Object.keys(params).sort((x,y)=> parseInt(x) - parseInt(y));
let newParams = {};
keys.forEach((key) => {
newParams[key] = params[key];
});
return newParams;
}
export const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['purchaseCount']) || 0
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
// fix 编辑订单取price
record.unitPrice = pageStatus === PageStatus.EDIT ? record.price : record.unitPrice || record.price || 0
if (typeof record.unitPrice === 'number') {
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)
}
// fix 当没有传递unitPrice字段时 但有price字段时 补全unitPrice字段
if(record.price && JSON.stringify(record.unitPrice) === "{}") {
record.unitPrice = {'0-0': record.price}
}
let unitPrice = 0
Object.entries(record.unitPrice).forEach(([key, value]) => {
const [min, max] = key.split('-').map(v => Number(v))
if (min === 0 && max === 0) {
unitPrice = Number(value)
return false
}
if ((purchaseCount >= min && purchaseCount <= max) || (purchaseCount > max)) {
// 处于该区间或者大于该区间
unitPrice = Number(value)
return false
}
})
// 考虑会员折扣
let memberPrice = record.memberPrice
if(record.isMemberPrice) {
return Number((unitPrice * purchaseCount * memberPrice).toFixed(2))
} else {
return Number((unitPrice * purchaseCount).toFixed(2))
}
}
/**
* @param ctx schemaAction
*/
export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const materialRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
orderModel = ctx.getFieldValue('orderModel')
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('orderProductRequests')]
// 删除formvalue
const colIndex = newData.findIndex(v => v.id === record.id)
newData.splice(colIndex, 1)
// 删除选中的项
rowSelectionCtl.setSelectRow(newData)
rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.id))
ctx.setFieldValue('orderProductRequests', newData)
}
const [materialColumns, setMaterialColumns] = useState(() => {
if (pageStatus === PageStatus.ADD) {
// 渲染操作
materialInfoColumns[materialInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>删除</Button>
// 渲染单价
materialInfoColumns[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
materialInfoColumns[0].render = (t, r) => {
if(orderModel === OrderModalType["HAND_ORDER"]) {
return r.id
} else {
return r.id ? r.id : r.productId
}
}
} else {
// 渲染单价
materialInfoColumns[5].render = (t, r) => <span style={{color: 'red'}}>{r.price}</span>
// 渲染商品ID
materialInfoColumns[0].render = (t, r) => r.productId
}
return materialInfoColumns
})
const handleShowMaterial = () => {
const supplyMembersId = ctx.getFieldValue('supplyMembersId')
if (supplyMembersId) {
materialRef.current.setVisible(true)
} else {
message.error('请先选择供应会员')
}
}
const materialAddButton = <Button onClick={handleShowMaterial} block type='default' style={{margin: '24px auto'}}>选择采购物料</Button>
const materialComponents = {
body: {
row: MaterialEditableRow,
cell: MaterialTableCell
}
}
const handleSave = row => {
// 商品采购数量变动 清空之前的支付信息
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);
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"]
) ? row.id : row.productId
newData.splice(index, 1, {
...item,
...row,
});
ctx.setFieldValue('orderProductRequests', newData)
resolve({item, newData})
})
};
const materialMergeColumns = materialColumns.map(col => {
if (!col.editable) {
return col;
}
return {
...col,
onCell: record => ({
record,
editable: ctx.getFormState().editable === false ? false : col.editable,
dataIndex: col.dataIndex,
title: col.title,
formItem: col.formItem,
formItemProps: col.formItemProps,
handleSave
}),
};
})
return {
materialRef,
materialAddButton,
materialColumns: materialMergeColumns,
materialComponents,
visible,
setVisible,
rowSelection,
rowSelectionCtl
}
}
......@@ -102,30 +102,11 @@ const basicInfo: ISchema = {
{
type: "value:schema",
"target": "quotationNo",
condition: `{{!!$value && orderCombination.showQuotationNoOrderBtn.includes($value)}}`,
condition: `{{!!$value && orderCombination.showQuotationNoOrderBtn.includes($value) || orderCombination.showPurchaseContract.includes($value)}}`,
schema: {
"x-component-props": {
disabled: true,
addonAfter: "{{orderNoPrice}}"
}
},
otherwise: {
visible: true,
"x-component-props": {
disabled: true,
addonAfter: ""
}
}
},
// 联动显示选择采购合同按钮
{
type: "value:schema",
"target": "quotationNo",
condition: `{{!!$value && orderCombination.showPurchaseContract.includes($value)}}`,
schema: {
"x-component-props": {
disabled: true,
addonAfter: "{{orderContract}}"
addonAfter: "{{orderCombination.showQuotationNoOrderBtn.includes($value) ? orderNoPrice : orderContract}}"
}
},
otherwise: {
......@@ -256,7 +237,7 @@ const basicInfo: ISchema = {
}
}
// 订单商品
const orderProduct: ISchema = {
export const orderProduct: ISchema = {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
......@@ -284,8 +265,39 @@ const orderProduct: ISchema = {
}
}
}
// 合同下单 订单物料
export const orderMaterial: ISchema = {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
tab: '订单物料'
},
properties: {
orderProductRequests: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'id',
columns: "{{materialColumns}}",
components: "{{materialComponents}}",
},
},
// 仅合同下单时备用参数数据
ordeProducts: {
type: 'array',
title: '合同下单记录',
visible: false
},
NO_SUBMIT_SPY: {
type: 'object',
"x-component": "moneyTotalBox"
}
}
}
// 支付信息
const payInfo: ISchema = {
export const payInfo: ISchema = {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
......@@ -310,6 +322,8 @@ const payInfo: ISchema = {
}
}
}
// 交付信息
const submitInfo: ISchema = {
type: 'object',
......
......@@ -14,6 +14,7 @@ import * as ReportApi from './ReportApi';
import * as PurchaseApi from './PurchaseApi';
import * as ContractApi from './ContractApi';
import * as PurchaseV2Api from './PurchaseV2Api';
import * as TransactionV2Api from './TransactionV2Api';
/**
* 可在这里写入自定义的接口
......@@ -40,4 +41,5 @@ export const PublicApi = {
...PurchaseApi,
...ContractApi,
...PurchaseV2Api,
...TransactionV2Api,
}
......@@ -16,6 +16,7 @@ const tokenList = [
// { name: 'Purchase', token: 'a09e2b66e00079df9881fc660eb17db0265e33362c13f03f2003ba81d26f49d8', categoryIds: [0], }, // 采购服务
{ name: 'Purchase', token: 'a09e2b66e00079df9881fc660eb17db0265e33362c13f03f2003ba81d26f49d8', categoryIds: [0], }, // 采购服务
{ name: 'PurchaseV2', token: '84c81ef877863ad4e2c0ebb2c3b3e80f9539420f2fc0828ef33f5159e8423b2c', categoryIds: [0] }, // 采购服务V2
{ name: 'TransactionV2', token: '3ad04435494d01c359b9f07948338e019133a3e6c0fccdbe1bc3adc19cf1e0b1', categoryIds: [0] }, // 交易服务V2
]
const getConfigMap = (tokens) => tokens.map(v => ({
......
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