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

fix: 新增请购单添加选组织机构/会员/物料货品,添加请购单转采购订单页面

parent eb0b3d52
...@@ -6,37 +6,73 @@ ...@@ -6,37 +6,73 @@
export const purchaseRequisitionRoute = [ export const purchaseRequisitionRoute = [
// 采购请购单 // 采购请购单
{ {
path: '/memberCenter/procurementAbility/purchaseRequisition', path: '/memberCenter/procurementAbility/purchaseRequisition',
name: 'purchaseRequisition', name: 'purchaseRequisition',
routes: [ routes: [
// 采购请购单查询 // 采购请购单查询
{ {
path: '/memberCenter/procurementAbility/purchaseRequisition/purchaseRequisitionList', path: '/memberCenter/procurementAbility/purchaseRequisition/purchaseRequisitionList',
name: 'purchaseRequisitionSearch', name: 'purchaseRequisitionSearch',
component: '@/pages/transaction/purchaseRequisition' component: '@/pages/transaction/purchaseRequisition'
}, },
// 采购请购单详情 // 采购请购单详情
{ {
path: '/memberCenter/procurementAbility/purchaseRequisition/purchaseRequisitionList/preview', path: '/memberCenter/procurementAbility/purchaseRequisition/purchaseRequisitionList/preview',
name: 'purchaseRequisitionPreview', name: 'purchaseRequisitionPreview',
hideInMenu: true, hideInMenu: true,
noMargin: true, noMargin: true,
component: '@/pages/transaction/purchaseRequisition/billPreview' component: '@/pages/transaction/purchaseRequisition/billPreview'
}, },
// 待新增请购单 // 待新增请购单
{ {
path: '/memberCenter/procurementAbility/purchaseRequisition/readyAddBill', path: '/memberCenter/procurementAbility/purchaseRequisition/readyAddBill',
name: 'readyAddBill', name: 'readyAddBill',
component: '@/pages/transaction/purchaseRequisition/readyAddBill' component: '@/pages/transaction/purchaseRequisition/readyAddBill'
}, },
// 待新增请购单详情 // 待新增请购单详情
{ {
path: '/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/detail', path: '/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/preview',
name: 'readyAddBillDetail', name: 'readyAddBillPreview',
component: '@/pages/transaction/purchaseRequisition/billPreview', component: '@/pages/transaction/purchaseRequisition/billPreview',
hideInMenu: true, hideInMenu: true,
noMargin: true, noMargin: true,
}, },
] // 待新增请购单-新增请购单
{
path: '/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/add',
name: 'addReadyAddBill',
component: '@/pages/transaction/purchaseRequisition/increaseRequesition',
hideInMenu: true,
},
// 待新增请购单-编辑请购单
{
path: '/memberCenter/tranactionAbility/purchaseRequisition/readyAddBill/edit',
name: 'eidtReadyAddBill',
component: '@/pages/transaction/purchaseRequisition/increaseRequesition',
hideInMenu: true,
},
]
}, },
// 请购单转采购订单
{
path: '/memberCenter/procurementAbility/requisitionOrder',
name: 'requisitionOrder',
routes: [
// 待请购单转采购订单
{
path: '/memberCenter/procurementAbility/requisitionOrder/readyRequisitionOrder',
name: 'readyRequisitionOrder',
component: '@/pages/transaction/purchaseRequisition/requisitionOrder'
},
// 请购单转采购订单详情
{
path: '/memberCenter/procurementAbility/requisitionOrder/readyRequisitionOrder/preview',
name: 'readyRequisitionOrderPreview',
hideInMenu: true,
noMargin: true,
component: '@/pages/transaction/purchaseRequisition/requisitionOrder/detail'
},
]
}
] ]
...@@ -3,7 +3,7 @@ import {StandardTable} from 'god'; ...@@ -3,7 +3,7 @@ import {StandardTable} from 'god';
import NestTable from '@/components/NestTable'; import NestTable from '@/components/NestTable';
import { IStandardTableProps } from 'god/dist/src/standard-table'; import { IStandardTableProps } from 'god/dist/src/standard-table';
import { Row, Col, Modal } from 'antd'; import { Row, Col, Modal } from 'antd';
import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema, logisticsDeliverySearchSchema, addOrderModalSchema , logisticsSelectGoodsSearchSchema, SelectRfqOrderSearchSchema, SelectLogisticsService, contractSchema} from './schema'; import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema, logisticsDeliverySearchSchema, addOrderModalSchema , logisticsSelectGoodsSearchSchema, SelectRfqOrderSearchSchema, SelectLogisticsService, contractSchema, departmentSchema} from './schema';
import Search from '../NiceForm/components/Search'; import Search from '../NiceForm/components/Search';
import SearchSelect from '../NiceForm/components/SearchSelect'; import SearchSelect from '../NiceForm/components/SearchSelect';
import Submit from '../NiceForm/components/Submit'; import Submit from '../NiceForm/components/Submit';
...@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> { ...@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> {
cancel?(), cancel?(),
visible?: boolean, visible?: boolean,
resetModal?: object, resetModal?: object,
modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'logisticsDelivery' | 'addOrderModalSchema' | 'selectGoodsSchema' | 'selectRfqOrder' | 'SelectLogisticsService' | 'contractByDefault' | 'none' , modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'logisticsDelivery' | 'addOrderModalSchema' | 'selectGoodsSchema' | 'selectRfqOrder' | 'SelectLogisticsService' | 'contractByDefault' | 'departmentSchema' | 'none' ,
useNestTable?: boolean, // 是否使用嵌套表格 useNestTable?: boolean, // 是否使用嵌套表格
nestColumns?: any[], nestColumns?: any[],
nestTableProps?: any, nestTableProps?: any,
...@@ -94,6 +94,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => { ...@@ -94,6 +94,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
case 'contractByDefault': { case 'contractByDefault': {
return contractSchema return contractSchema
} }
case 'departmentSchema': {
return departmentSchema
}
case 'none': { case 'none': {
return {} return {}
} }
......
...@@ -1079,3 +1079,54 @@ export const contractSchema: ISchema = { ...@@ -1079,3 +1079,54 @@ export const contractSchema: ISchema = {
} }
} }
} }
/** 选择组织机构弹框筛选 */
export const departmentSchema: ISchema = {
type: 'object',
properties: {
code: {
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: {
title: {
type: 'string',
"x-component-props": {
placeholder: '机构名称',
style: {
width: 160
}
}
},
submit: {
"x-component": 'Submit',
"x-mega-props": {
span: 1
},
"x-component-props": {
children: '查询'
}
}
}
}
}
}
...@@ -4,10 +4,9 @@ import EyePreview from '@/components/EyePreview' ...@@ -4,10 +4,9 @@ import EyePreview from '@/components/EyePreview'
import { history } from 'umi' import { history } from 'umi'
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getSaleOrderAuditPageSelectOption } from '@/pages/transaction/effect'; import { getSaleOrderAuditPageSelectOption } from '@/pages/transaction/effect';
import { ORDER_TYPE_CHANNEL_POINTS, ORDER_TYPE_POINTS } from '@/constants/order'
/** 采购请购单 公共列和查询schmea */ /** 采购 请购单查询 带内部状态schmea */
export const tableListSchema: any = (align?: String, colStyle?: Object) => { export const tableSearchListSchema: any = (align?: String, colStyle?: Object) => {
const res = getSaleOrderAuditPageSelectOption() const res = getSaleOrderAuditPageSelectOption()
if(res) { if(res) {
...@@ -18,38 +17,68 @@ export const tableListSchema: any = (align?: String, colStyle?: Object) => { ...@@ -18,38 +17,68 @@ export const tableListSchema: any = (align?: String, colStyle?: Object) => {
return { return {
type: 'object', type: 'object',
properties: { properties: {
orderNo: { mageLayout: {
type: 'string',
"x-component": 'SearchFilter',
'x-component-props': {
placeholder: '请输入订单编号',
align: align || 'flex-start',
},
},
[FORM_FILTER_PATH]: {
type: 'object', type: 'object',
'x-component': 'flex-layout', 'x-component': 'mega-layout',
'x-component-props': {
inline: true,
colStyle: colStyle || {marginRight: 20}
},
properties: { properties: {
digest: { topLayout: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
},
properties: {
orderNo: {
type: 'string',
"x-component": 'Search',
'x-component-props': {
placeholder: '请输入请购单号',
align: 'flex-end',
},
}
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
},
colStyle: {
marginLeft: 20,
},
},
properties: {
"digest": {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '请输入单摘要', placeholder: '请输入请购单摘要',
} }
}, },
"memberName": { "memberName": {
type: 'string', type: 'string',
"x-component-props": { "x-component-props": {
placeholder: '请输入采购会员名称' placeholder: '请输入供应会员名称'
}
},
"department": {
type: 'string',
"x-component-props": {
placeholder: '请输入请购部门'
}
},
"purpose": {
type: 'string',
"x-component-props": {
placeholder: '请输入请购用途'
} }
}, },
"orderType": { "orderType": {
type: 'string', type: 'string',
"x-component-props": { "x-component-props": {
placeholder: '请选择订单类型' placeholder: '请选择内部状态'
}, },
enum: OrderType.map(item => ({ enum: OrderType.map(item => ({
label: item['text'], label: item['text'],
...@@ -69,20 +98,101 @@ export const tableListSchema: any = (align?: String, colStyle?: Object) => { ...@@ -69,20 +98,101 @@ export const tableListSchema: any = (align?: String, colStyle?: Object) => {
children: '查询', children: '查询',
}, },
}, },
}, },}}
}, },
} }
} }
} }
} }
/** 采购 请购单查询 无内部状态schmea */
export const tableListSchema: any = (align?: String, colStyle?: Object) => {
return {
type: 'object',
properties: {
mageLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
},
properties: {
orderNo: {
type: 'string',
"x-component": 'Search',
'x-component-props': {
placeholder: '请输入请购单号',
align: 'flex-end',
},
}
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
},
colStyle: {
marginLeft: 20,
},
},
properties: {
"digest": {
type: 'string',
'x-component-props': {
placeholder: '请输入请购单摘要',
}
},
"memberName": {
type: 'string',
"x-component-props": {
placeholder: '请输入供应会员名称'
}
},
"department": {
type: 'string',
"x-component-props": {
placeholder: '请输入请购部门'
}
},
"purpose": {
type: 'string',
"x-component-props": {
placeholder: '请输入请购用途'
}
},
"[startDate,endDate]": {
type: 'daterange',
// "x-component": 'DateRangePickerUnix',
'x-component-props': {
placeholder: ['开始时间','结束时间'],
},
},
submit: {
'x-component': 'Submit',
'x-component-props': {
children: '查询',
},
},
},}}
},
}
}
}
/** 采购 请购单 公共列 */
export const baseOrderListColumns: any = () => { export const baseOrderListColumns: any = () => {
return [ return [
{ {
title: '单号', title: '请购单号',
align: 'center', align: 'center',
dataIndex: 'orderNo', dataIndex: 'orderNo',
key: 'orderNo', key: 'orderNo',
...@@ -95,50 +205,54 @@ export const baseOrderListColumns: any = () => { ...@@ -95,50 +205,54 @@ export const baseOrderListColumns: any = () => {
} }
}, },
{ {
title: '单摘要', title: '请购单摘要',
align: 'center', align: 'center',
dataIndex: 'digest', dataIndex: 'digest',
key: 'digest', key: 'digest',
}, },
{ {
title: '采购会员', title: '供应会员',
align: 'center', align: 'center',
dataIndex: 'memberName', dataIndex: 'memberName',
key: 'memberName', key: 'memberName',
render: (t, r) => r.memberName ? t : r.buyerMemberName render: (t, r) => r.memberName ? t : r.buyerMemberName
}, },
{ {
title: '下单时间', title: '交付日期',
align: 'center', align: 'center',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
render: (text) => formatTimeString(text) render: (text) => formatTimeString(text)
}, },
{ {
title: '订单总额', title: '请购部门',
align: 'center', align: 'center',
dataIndex: 'amount', dataIndex: 'digest',
key: 'amount', key: 'digest',
render: (t, r) => (r.orderType === ORDER_TYPE_POINTS || r.orderType === ORDER_TYPE_CHANNEL_POINTS) ? t : `¥${t}`
}, },
{ {
title: '订单类型', title: '请购用途',
align: 'center', align: 'center',
dataIndex: 'orderTypeName', dataIndex: 'digest',
key: 'orderTypeName', key: 'digest',
},
{
title: '请购数量',
align: 'center',
dataIndex: 'amount',
key: 'amount',
}, },
{ {
title: '转单订单号', title: '已转订单数量',
align: 'center', align: 'center',
dataIndex: 'relationNo', dataIndex: 'amount',
key: 'relationNo' key: 'amount',
}, },
{ {
title: '外部状态', title: '单据时间',
align: 'center', align: 'center',
dataIndex: 'outerStatusName', dataIndex: 'orderTypeName',
key: 'outerStatusName', key: 'orderTypeName',
render: (text, record) => <StatusColors status={text} type='out' text={record['outerStatusName']} />,
}, },
{ {
title: '内部状态', title: '内部状态',
......
import { PublicApi } from '@/services/api'
export const fetchOrderApi = {
/** 弹窗获取商品列表 */
async getProductList(params) {
const { data } = await PublicApi.getProductCommodityCommonGetCommodityListByBuyer(params, { useCache: true, ttl: 10 * 1000 })
return data
},
/** 获取下架服务提供者会员列表 */
async getMemberListByMemberName(params) {
const { data } = await PublicApi.postMemberManageLowerProviderPage({...params}, { ctlType: 'none' })
return data
},
/** 请购单物料 获取商品货品列表 */
async getPurchaseRequesitionMaterielList(params) {
const { data } = await PublicApi.getProductGoodsGetGoodsList(params)
return data
},
}
import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { departmentColumns } from '../../constant'
import { PublicApi } from '@/services/api'
export interface DepartmentModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?()
}
// 选择部门弹窗
const DepartmentModalTable:React.FC<DepartmentModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type})
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
const handleConfirm = async () => {
const item = rowSelectionCtl.selectRow[0]
if (item) {
schemaAction.setFieldValue('departmentId', item['id'])
schemaAction.setFieldValue('department', item['title'])
}
confirmModal && confirmModal()
setVisible(false)
}
return (
<ModalTable
modalTitle='选择组织机构'
columns={departmentColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={async (params) => (await PublicApi.getMemberBusinessOrganizationPage({...params}, {useCache: true, ttl: 10 * 1000})).data}
rowSelection={rowSelection}
modalType='departmentSchema'
searchName="code"
tableProps={{
rowKey: 'id'
}}
resetModal={{
destroyOnClose: true,
}}
{...restProps}
/>
)
}
DepartmentModalTable.defaultProps = {}
export default DepartmentModalTable
import React, { useEffect } from 'react'
import { history } from 'umi'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const';
import Search from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit';
import Children from '@/components/NiceForm/components/Children';
import { addRequesitionMaterialSchema } from '../../schema/modal'
import { Button, Tooltip } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
export interface MaterialModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
sectionProps: any,
confirmModal?()
}
export const materialColumns: 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: 'type',
align: 'center',
key: 'type',
},
{
title: '品类',
dataIndex: ['customerCategory', 'name'],
align: 'center',
key: ['customerCategory', 'name'],
},
{
title: '品牌',
dataIndex: ['brand', 'name'],
align: 'center',
key: ['brand', 'name'],
},
{
title: '单位',
dataIndex: 'unitName',
align: 'center',
key: 'unitName'
},
]
const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
const { type = 'checkbox', schemaAction, confirmModal, currentRef, sectionProps, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = sectionProps
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
const addMaterialProcessField = (value, origin) => {
let tempOriginData = [...origin]
if(Array.isArray(value)) {
let processData = value.map(v => {
let temp: any = {};
temp.id = v.id;
temp.code = v.code;
temp.name = v.name;
temp.type = v.type;
temp.category = v.customerCategory.name;
temp.brand = v.brand.name;
temp.unit = v.unitName;
return temp
})
let originIds = tempOriginData.map(item => item.id)
processData.map(item => {
if(!originIds.includes(item.id)) {
tempOriginData.push(item)
}
})
return tempOriginData
}
}
const handleConfirm = async () => {
console.log(rowSelectionCtl, 'rowSelectionCtl')
const materialData = schemaAction.getFieldValue('materials')
schemaAction.setFieldValue('materials', addMaterialProcessField(rowSelectionCtl.selectRow, materialData))
confirmModal && confirmModal()
setVisible(false)
}
const otherHandle = <>
<a className="ant-btn" href="/memberCenter/commodityAbility/commodity/goods/add" target="_blank" style={{marginRight: 16}}>新增货品</a>
<Tooltip title="点击查询,列表可显示新增的货品">
<QuestionCircleOutlined />
</Tooltip>
</>
return (
<ModalTable
modalTitle='选择货品'
width={900}
columns={materialColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={fetchOrderApi.getPurchaseRequesitionMaterielList}
rowSelection={rowSelection}
resetModal={{destroyOnClose: true}}
modalType='none'
tableProps={{
rowKey: 'id',
onRow: (record) => ({
onClick: () => {
rowSelectionCtl.appendSelectRow(record);
rowSelectionCtl.appendSelectRowKeys(record.id);
},
})
}}
formilyProps={{
ctx: {
schema: addRequesitionMaterialSchema,
components: { ModalSearch: Search, Submit, Children },
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'code',
FORM_FILTER_PATH,
);
},
expressionScope: {
otherHandle
}
}
}}
{...restProps}
/>
)
}
MaterialModalTable.defaultProps = {}
export default MaterialModalTable
import React, { useState, useRef, useContext } from 'react'
import { Form, Input, Select, Popover, Row } from 'antd';
import { EnvironmentOutlined } from '@ant-design/icons';
import { PublicApi } from '@/services/api';
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 [showAddress, setShowAddress] = useState<boolean>(false)
// 地址信息
const [receiveInfo, setReceiveInfo] = useState<any>()
const getReceiveInfo = async () => {
const { data: deliveryAddress} = await PublicApi.getLogisticsSelectListMemberShipperAddress({
memberId: record.memberId,
roleId: record.memberRoleId
})
// setReceiveInfo(() => deliveryAddress.filter(item => item.isDefault)[0])
setReceiveInfo(() => deliveryAddress[0])
}
const save = async e => {
try {
const values = await form.validateFields();
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
// select的change
const change = async (va, op, idx) => {
console.log(va, op, idx)
// 自提情况下 显示地址
if(va === 2) {
setShowAddress(true)
getReceiveInfo()
} else {
setShowAddress(false)
}
try {
const values = await form.validateFields();
values[idx] = op['label']
values['logistics'] = op['value']
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
}
const chooseFormItem = (type, v) => {
switch(type) {
// input类型
case 'input': {
return <Input
style={{width: 80}}
type='number'
ref={formItemRef}
onChange={save}
{...formItemProps}
id={dataIndex + record.id}
className="purchase_amount_input"
/>
}
// select选择类型
case 'select': {
return <Select
style={{width: 80}}
ref={formItemRef}
onChange={(value, option) => change(value, option, dataIndex)}
id={dataIndex + record.id}
className="purchase_logistic_select"
options={[{ label: '物流', value: 1 }, { label: '自提', value: 2 }, { label: '无需配送', value: 3 }]}
{...formItemProps}
/>
}
}
}
// 校验最大精度
const validatorNumber = (rule, value, callback) => {
try {
let _value = Number(value)
if(_value > Number.MAX_SAFE_INTEGER) {
throw new Error('数值精度溢出')
}
callback()
} catch (err) {
callback(err)
}
}
let childNode = children;
if (editable) {
childNode =
<>
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={dataIndex === 'quantity' ? [
{
required: true,
message: `${title}必须填写`,
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '采购数量仅限三位小数',
},
{
validator: validatorNumber
},
] : [
{
pattern: /^\d+(\.\d{1,2})?$/,
message: '采购数量仅限两位小数',
},
{
validator: validatorNumber
}
]}
>
{chooseFormItem(formItem, record[dataIndex] || '')}
</Form.Item>
{
showAddress
?
<Popover content={
<Row>
<div>
<h3><EnvironmentOutlined/> 自提地址</h3>
{
receiveInfo && <>
<p>{receiveInfo.shipperName} / {receiveInfo.phone}</p>
<p>{receiveInfo.provinceName + receiveInfo.cityName + receiveInfo.districtName + receiveInfo.address || receiveInfo.fullAddress}</p>
</>
}
</div>
</Row>
}>
<span style={{position: 'absolute', right: 0, top: '42%', }}><EnvironmentOutlined/></span>
</Popover>
:
null
}
</>
}
return <td {...restProps}>{childNode}</td>;
}
MaterialTableCell.defaultProps = {}
export default MaterialTableCell
import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { memberColumns } from '../../constant'
export interface MemberModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?(),
productRef?: any,
}
const MemberModalTable:React.FC<MemberModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type, customKey: 'id'})
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
const handleConfirm = () => {
const rowItem = rowSelectionCtl.selectRow[0]
console.log(rowItem, 'row')
if (rowItem) {
schemaAction.setFieldValue('vendorRoleId', rowItem.roleId)
schemaAction.setFieldValue('vendorMemberId', rowItem.memberId)
schemaAction.setFieldValue('vendorMemberName', rowItem.name)
}
confirmModal && confirmModal()
setVisible(false)
// 清空之前可能存在的商品支付信息数据
schemaAction.setFieldValue('materials', [])
schemaAction.setFieldValue('payments', [])
if(props?.productRef) {
props.productRef.current.rowSelectionCtl.setSelectRow([])
props.productRef.current.rowSelectionCtl.setSelectedRowKeys([])
}
}
return (
<ModalTable
modalTitle='选择供应会员'
columns={memberColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={(params) => fetchOrderApi.getMemberListByMemberName({...params})}
rowSelection={rowSelection}
modalType='memberByDefault'
tableProps={{
rowKey: 'id'
}}
{...restProps}
/>
)
}
MemberModalTable.defaultProps = {}
export default MemberModalTable
import { formatTimeString } from '@/utils'
/** 修改合同下单 初始值转换 */
export const procurmentRenderInit = (initValue: any) => {
return {
...initValue.requirement.detail,
vendorMemberId: initValue.vendorMemberId,
vendorMemberName: initValue.vendorMemberName,
vendorRoleId: initValue.vendorRoleId,
product: initValue.product,
deliveryAddresId: initValue.consignee.consigneeId,
hasInvoice: initValue.hasInvoice,
orderId: initValue.orderId,
orderKind: initValue.orderKind,
orderMode: initValue.orderMode,
orderModeName: initValue.orderModeName,
type: initValue.orderTypeName,
digest: initValue.digest,
deliverDate: initValue.consignee.deliverDate,
theInvoiceId: initValue.invoice?.invoiceId || null,
hasContract: initValue.hasContract,
contractNo: initValue.contract.contractNo,
contract: {...initValue.contract},
}
}
/** 修改采购合同下单 回显商品字段转换 */
export const procurementRenderField = (data) => {
const _orderProductRequests = data.product.products
return _orderProductRequests.map(item => {
return {
...item,
relevanceProductId: item.quotedSkuId,
relevanceProductName: item.quotedName,
relevanceProductBrand: item.quotedBrand,
relevanceProductCategory: item.quotedCategory,
relevanceProductSpec: item.quotedSpec,
logistics: item.deliverType,
id: item.productId,
code: item.productNo,
type: item.spec,
memberId: data.vendorMemberId,
memberRoleId: data.vendorRoleId,
}
})
}
/** 采购合同下单 字段转换 */
export const procurementProcessField = (value) => {
value.products = value.products.map(item => {
return {
...item,
productId: item.id,
productNo: item.code,
// 关联商品信息
// quotedProductId: item.relevanceProductId,
quotedSkuId: item.relevanceProductId,
quotedName: item.relevanceProductName,
quotedSpec: item.relevanceProductType,
quotedCategory: item.relevanceProductCategory,
quotedBrand: item.relevanceProductBrand,
}
})
return value
}
// 会员列
export const memberColumns: any[] = [
{
title: '会员ID',
dataIndex: 'memberId',
align: 'center',
key: 'memberId',
},
{
title: '会员名称',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '公司类型',
dataIndex: 'memberTypeName',
align: 'center',
key: 'memberTypeName',
},
{
title: '公司角色',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '公司等级',
dataIndex: 'levelTag',
align: 'center',
key: 'levelTag',
},
]
//组织机构部门列
export const departmentColumns: any[] = [
{
title: 'Id',
dataIndex: 'id',
key: 'id',
className: 'commonHide'
},
{
title: '机构代码',
dataIndex: 'code',
key: 'code',
},
{
title: '机构名称',
dataIndex: 'title',
key: 'title',
},
]
// 合同下单 物料列表
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: 'type',
align: 'center',
key: 'type',
},
{
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: 'left',
key: 'price',
formItem: 'input',
editable: true,
// render: (t) => `¥${t.toFixed(2)}`
},
{
title: '数量',
dataIndex: 'quantity',
align: 'center',
key: 'quantity',
formItem: 'input',
editable: true,
},
{
title: '预估金额(元)',
dataIndex: 'amount',
align: 'center',
key: 'amount',
// render: (t, r) => t ? `${Number(t).toFixed(2)}` : null
},
{
title: '操作',
dataIndex: 'ctl',
align: 'center',
key: 'ctl',
},
]
import { FormEffectHooks, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { PublicApi } from '@/services/api';
export const useEditHideField = () => {
const { pageStatus } = usePageStatus()
const utils = useLinkageUtils()
FormEffectHooks.onFormInit$().subscribe(() => {
if (pageStatus === PageStatus.ADD) {
utils.hide('orderNo')
utils.hide('createTime')
}
})
}
export const useMaterialTableChangeForAmount = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => {
FormEffectHooks.onFieldValueChange$('materials').subscribe(state => {
// 强制渲染一次, 用于触发金额总数
update()
})
}
// 高级筛选schema中用于输入搜索商品品类的Effect
/**
* @param ctx 外部表单action
* @param mctx 模态框表单action
* @param fieldName 字段名称
*/
export const searchCustomerCategoryOptionEffect = (ctx: any, mctx: any, fieldName: string) => {
const params: any = {}
params['memberId'] = ctx.getFieldValue('supplyMembersId')
params['memberRoleId'] = ctx.getFieldValue('supplyMembersRoleId')
mctx.getFieldState(fieldName, state => {
PublicApi.getProductCustomerGetMemberCustomerCategoryTree(params).then(res => {
mctx.setFieldState(fieldName, state => {
state.props['x-component-props'].dataoption = res.data
})
})
})
}
import React, { useRef, useState, useEffect } from 'react'
import { history } from 'umi'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ReutrnEle from '@/components/ReturnEle'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { Button, Card, Col, message, Row } from 'antd'
import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd'
import { SaveOutlined, LinkOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { increaseSchema } from './schema'
import { useEditHideField, useMaterialTableChangeForAmount } from './effects'
import { procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant'
import { useUpdate } from '@umijs/hooks'
import { PublicApi } from '@/services/api'
import { changeRouterTitleByStatus } from '../../_public/order/utils'
import { help } from '../../common'
import { useMaterialTable } from './model/useMaterialTable'
import MaterialModalTable from './components/materialModalTable'
import DepartmentModalTable from './components/departmentModalTable'
import MemberModalTable from './components/memberModalTable'
import styled from 'styled-components'
const addSchemaAction = createFormActions()
const RowStyle = styled(props => <Row style={{marginTop: 12}} justify='end' {...props}>
{props.children}
</Row>)`
.ant-col {
text-align: center
}
.ant-col div {
margin-bottom: 12px;
}
`
// 总计金额联动框
export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
const { form } = useFormSpy({ selector: [['onFieldValueChange', 'materials']], reducer: v => v })
const data = form.getFieldValue('materials')
const sum = data.reduce((prev, next) => (prev*1000 + (next.amount || 0)*1000)/1000, 0)
const total = data.reduce((prev, next) => (prev*1000 + (next.quantity || 0)*1000)/1000, 0)
// useEffect(() => {
// if (sum + freePrice) {
// form.notify('sumPrice', sum + freePrice)
// }
// }, [sum, freePrice])
return <RowStyle>
<Col span={2}>
<div>数量合计</div>
<div>{total.toFixed(2)}</div>
</Col>
<Col span={2}>
<div>金额总计</div>
<div>{`¥${(sum).toFixed(2)}`}</div>
</Col>
</RowStyle>
})
/** 采购请购单 新增 */
const IncreaseRequesition:React.FC<{}> = () => {
const departmentRef = useRef<any>({}) // 选部门
const memberRef = useRef<any>({})
const [formLoading, setFormLoading] = useState(false)
const [btnLoading, setBtnLoading] = useState(false)
const update = useUpdate()
const { pageStatus, id } = usePageStatus()
const [initFormValue, setInitFormValue] = useState<any>({})
// 请购单物料
const { materialAddButton, materialRef, materialColumns, materialComponents, ...surplusProps } = useMaterialTable(addSchemaAction)
useEffect(() => {
if (id) {
setFormLoading(true)
PublicApi.getOrderBuyerCreateDetail({ orderId: id }).then(res => {
const { data } = res
const _orderProductRequests = procurementRenderField(data)
setInitFormValue(() => procurmentRenderInit(data))
setTimeout(() => {
addSchemaAction.setFieldValue('materials', _orderProductRequests)
addSchemaAction.setFieldValue('contract', {...data.contract})
}, 1000)
setFormLoading(false)
})
}
}, [])
const handleSubmit = async (value) => {
try {
let fnResult = null
// 新增订单/编辑订单
const params = { ...value }
console.log(value)
// 校验采购数量
const judgementByCount = params.materials?.length && params.materials.map(item => {
if(item.quantity){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error('请填写商品采购数量')
}
// 使用发票即校验发票id
if(params.hasInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
setBtnLoading(true)
/** 字段转换 */
// 合同下单 取供应商默认的发货地址
const { data: deliveryAddress} = await PublicApi.getLogisticsSelectListMemberShipperAddress({
memberId: params.vendorMemberId,
roleId: params.vendorRoleId
})
params.materials = params.materials.map(item => {
const address = deliveryAddress[0]
return {
...item,
spec: item.type,
quotedSpec: item.relevanceProductType,
deliveryType: item.logistics,
addressId: address?.id || null,
address: address?.fullAddress || null,
receiver: address?.shipperName || null,
phone: address?.phone || null,
}
})
const _params = procurementProcessField(params)
console.log(_params)
if(id) {
fnResult = await PublicApi.postOrderBuyerCreateSrmUpdate({..._params, orderId: id})
} else {
fnResult = await PublicApi.postOrderBuyerCreateSrm(_params)
}
if (fnResult.code === 1000) {
setTimeout(() => {
history.push("/memberCenter/tranactionAbility/purchaseOrder/readyAddSrmOrder")
}, 1000)
} else {
setBtnLoading(false)
}
} catch (error) {
setBtnLoading(false)
error?.message && message.error(error.message)
console.log(error)
}
}
// 选择会员弹窗
const handleOrderMember = () => {
memberRef.current.setVisible(true)
}
const memberBtn = pageStatus === PageStatus.ADD && <div className='connectBtn' onClick={handleOrderMember}><LinkOutlined style={{marginRight: 4}}/>选择</div>
// 选择合同
const handleDepartment = () => {
departmentRef.current.setVisible(true)
}
const departmentBtn = pageStatus === PageStatus.ADD && <div className='connectBtn' onClick={handleDepartment}><LinkOutlined style={{marginRight: 4}}/>选择</div>
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title={changeRouterTitleByStatus()}
extra={[
<Button key="1" onClick={() => addSchemaAction.submit()} loading={btnLoading} type="primary" icon={<SaveOutlined />}>
保存
</Button>,
]}
>
<Card>
<NiceForm
loading={formLoading}
previewPlaceholder=' '
// editable={pageStatus !== PageStatus.PREVIEW}
value={initFormValue}
actions={addSchemaAction}
schema={increaseSchema}
onSubmit={handleSubmit}
effects={($, ctx) => {
$('onFormMount').subscribe(() => {
// if (id || modelType) {
// ctx.setFieldState('orderMode', state => {
// state.editable = false
// })
// }
})
useEditHideField()
// 物料信息的改动 渲染总额
useMaterialTableChangeForAmount(ctx, update)
}}
expressionScope={{
memberBtn,
departmentBtn,
materialColumns,
materialAddButton,
materialComponents,
help,
}}
/>
</Card>
{/* 选择部门 */}
<DepartmentModalTable currentRef={departmentRef} schemaAction={addSchemaAction}/>
{/* 选择采购物料 */}
<MaterialModalTable currentRef={materialRef} schemaAction={addSchemaAction} sectionProps={surplusProps} />
{/* 选择供应会员 */}
<MemberModalTable currentRef={memberRef} schemaAction={addSchemaAction}/>
</PageHeaderWrapper>
)
}
IncreaseRequesition.defaultProps = {}
export default IncreaseRequesition
import React, { useState, useEffect } from 'react'
import { OrderModalType } from '@/constants/order'
import { PublicApi } from '@/services/api'
import { useLocation, history } from 'umi'
import { ISchemaFormActions } from '@formily/antd'
interface DetailOrderLocationState {
// 进货单商品列表
productList?: any[],
// 下单模式
modelType?: OrderModalType
}
interface DetailOptionsProps {
addSchemaAction: ISchemaFormActions
}
export const useDetailOrder = (options: DetailOptionsProps) => {
const { addSchemaAction } = options
const locationState = useLocation<DetailOrderLocationState>().state || {}
const { productList } = locationState
const { modelType } = history.location.query
// 是否显示选择商品按钮
const [showProBtn, setShowProBtn] = useState(false)
// 是否显示供应会员字段
const [showMemberType, setShowMemberType] = useState(false)
const [visibleMember, setVisibleMember] = useState(false)
// 商品列表, 如果路由state中 带有productList, 说明是进货单下单, 需要回显进货单商品数据
const [proList, setProList] = useState<any[]>(() => productList || [])
// 回显数据写在这
useEffect(() => {
// 页面中有传入下单模式, 需要手动回显数据
if (modelType) {
addSchemaAction.setFieldValue('orderMode', parseInt(modelType))
}
// 在有传入商品列表时 需手动回显
if (proList.length > 0) {
addSchemaAction.setFieldValue('orderProductRequests', proList)
addSchemaAction.setFieldValue('orderThe', proList[0].name)
}
}, [modelType, productList])
// 唤起新增订单
const fetchAddOrder = async (params) => {
await PublicApi.postOrderProcurementOrderAdd(params)
}
return {
showProBtn,
setShowProBtn,
showMemberType,
setShowMemberType,
fetchAddOrder,
proList,
modelType,
visibleMember,
setVisibleMember
}
}
import React, { useRef, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button } from 'antd';
import { materialInfoColumns } from '../constant';
import MaterialTableCell, { MaterialEditableRow } from '../components/materialTableCell';
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
// 对象按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['quantity']) || 0
return Number(((record.price || 0) * purchaseCount).toFixed(2))
}
/**
* @param ctx schemaAction
*/
export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const materialRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('materials')]
// 删除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('materials', newData)
}
const [materialColumns, setMaterialColumns] = useState(() => {
const { pageStatus } = usePageStatus()
if (pageStatus === PageStatus.ADD) {
// 渲染操作
materialInfoColumns[materialInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>删除</Button>
// 渲染预估金额
materialInfoColumns[materialInfoColumns.length - 2].render = (t, r) => r.amount && <span style={{color: 'red'}}>{Number(r.amount).toFixed(2)}</span>
} else {
// 渲染预估金额
materialInfoColumns[materialInfoColumns.length - 2].render = (t, r) => r.amount && <span style={{color: 'red'}}>{Number(r.amount).toFixed(2)}</span>
materialInfoColumns.pop()
}
return materialInfoColumns
})
const handleShowMaterial = () => {
const materials = ctx.getFieldValue('materials')
materialRef.current.setVisible(true)
if(materials && materials.length) {
materialRef.current.rowSelectionCtl.setSelectedRowKeys(() => materials.map(item => item.id))
}
}
const materialAddButton = <Button onClick={handleShowMaterial} block type='default' style={{margin: '24px auto'}}>选择采购物料</Button>
const materialComponents = {
body: {
row: MaterialEditableRow,
cell: MaterialTableCell
}
}
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('materials')];
const index = newData.findIndex(item => row.id === item.id);
const item = newData[index];
// 算单行价格
row['amount'] = getUnitPriceTotal(row)
newData.splice(index, 1, {
...item,
...row,
});
ctx.setFieldValue('materials', 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
}
}
import { useState } from 'react'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
export const useModalTable = (options?) => {
const [visible, setVisible] = useState(false)
const [rowSelection, rowSelectionCtl] = useRowSelectionTable(options)
return {
visible,
setVisible,
rowSelection,
rowSelectionCtl
}
}
\ No newline at end of file
import { ISchema } from '@formily/antd';
import moment from 'moment'
// 基本信息
const basicInfo: ISchema = {
"x-index": 0,
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
tab: '基本信息',
className: 'useConnectBtnWrapper'
},
properties: {
NO_SUBMIT_LAYOUT: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left',
wrapperCol: 10
},
properties: {
orderNo: {
type: 'string',
title: '请购单号',
"x-component": 'text',
visible: false
},
digest: {
type: 'string',
title: '订单摘要',
"x-rules": [
{
required: true,
message: '请输入订单摘要'
},
{
limitByte: true,
maxByte: 60
}
]
},
deliverDate: {
type: 'string',
"x-component": 'date',
title: '预交日期',
required: true,
"x-component-props": {
showTime: true,
format: 'YYYY-MM-DD HH:mm',
disabledDate: current => {
return current && current < moment().startOf('day')
},
style: { width: '100%' }
}
},
department: {
type: 'string',
title: '请购部门',
"x-component-props": {
disabled: true,
addonAfter: "{{departmentBtn}}"
},
},
departmentId: {
type: 'string',
title: '请购部门ID',
visible: false,
},
purpose: {
type: 'string',
title: '请购用途',
"x-rules": [
{
required: true,
message: '请输入请购用途'
},
{
limitByte: true,
maxByte: 100
}
]
},
vendorMemberName: {
type: 'string',
title: '供应会员',
"x-component-props": {
disabled: true,
addonAfter: "{{memberBtn}}"
},
required: true,
},
vendorMemberId: {
type: 'string',
display: false
},
vendorRoleId: {
type: 'string',
display: false
},
createTime: {
type: 'string',
title: '单据时间',
visible: false
},
interiorState: {
type: 'string',
title: '内部状态',
visible: false
},
}
},
}
}
// 请购单物料
export const material: ISchema = {
"x-index": 2,
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
tab: '订单物料'
},
properties: {
materials: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'materialId',
columns: "{{materialColumns}}",
components: "{{materialComponents}}",
prefix: "{{materialAddButton}}",
},
},
NO_SUBMIT_SPY: {
type: 'object',
"x-component": "moneyTotalBox"
}
}
}
// 新增请购单
export const increaseSchema: ISchema = {
type: 'object',
properties: {
NO_SUBMIT_TABS: {
type: 'object',
"x-component": 'tab',
properties: {
basicInfo,
material,
}
}
}
}
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getPurchaseOrderReadyAddPageSelectOption } from '@/pages/transaction/effect'; import { ISchema } from '@formily/antd';
export const tableListSchema: any = () => {
const res = getPurchaseOrderReadyAddPageSelectOption()
if(res) {
const {
orderTypes: OrderType,
} = res
return { /**
* 新增采购请购单 选择物料的筛选
*/
export const addRequesitionMaterialSchema: ISchema = {
type: 'object',
properties: {
code: {
type: 'string',
'x-component': 'ModalSearch',
'x-component-props': {
placeholder: '请输入物料编号',
align: 'flex-start',
},
},
[FORM_FILTER_PATH]: {
type: 'object', type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
style: {
marginRight: 0,
}
},
colStyle: {
marginTop: 20,
},
},
properties: { properties: {
orderNo: { name: {
type: 'string', type: 'string',
"x-component": 'SearchFilter',
'x-component-props': { 'x-component-props': {
placeholder: '请输入订单编号', placeholder: '物料名称',
align: 'flex-end',
}, },
}, },
[FORM_FILTER_PATH]: { type: {
type: 'object', type: 'string',
'x-component': 'flex-layout', "x-component-props": {
'x-component-props': { placeholder: '规格型号',
inline: true, }
colStyle: { },
marginLeft: 20 submit: {
}, "x-component": 'Submit',
}, "x-mega-props": {
properties: { span: 1
"digest": {
type: 'string',
'x-component-props': {
placeholder: '请输入订单摘要',
}
},
"memberName": {
type: 'string',
"x-component-props": {
placeholder: '请输入供应会员名称'
}
},
"orderType": {
type: 'string',
"x-component-props": {
placeholder: '请选择订单类型'
},
enum: OrderType.map(item => ({
label: item['text'],
value: item['id'],
}))
},
"[startDate,endDate]": {
type: 'daterange',
// "x-component": 'DateRangePickerUnix',
'x-component-props': {
placeholder: ['开始时间','结束时间'],
},
},
submit: {
'x-component': 'Submit',
'x-component-props': {
children: '查询',
},
},
}, },
"x-component-props": {
children: '查询'
}
}, },
submit1: {
"x-component": 'Children',
"x-component-props": {
children: '{{otherHandle}}'
}
}
} }
} }
} }
......
...@@ -3,8 +3,7 @@ import { Card } from 'antd' ...@@ -3,8 +3,7 @@ import { Card } from 'antd'
import { StandardTable } from 'god' import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { baseOrderListColumns } from './constant' import { baseOrderListColumns, tableSearchListSchema } from './constant'
import { saleTableListSchema as tableListSchema } from '../_public/order/constant'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix' import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
...@@ -112,9 +111,6 @@ const RequestBill: React.FC<RequestBillProps> = () => { ...@@ -112,9 +111,6 @@ const RequestBill: React.FC<RequestBillProps> = () => {
} }
} }
return <PageHeaderWrapper> return <PageHeaderWrapper>
<Card> <Card>
<StandardTable <StandardTable
...@@ -134,7 +130,7 @@ const RequestBill: React.FC<RequestBillProps> = () => { ...@@ -134,7 +130,7 @@ const RequestBill: React.FC<RequestBillProps> = () => {
FORM_FILTER_PATH, FORM_FILTER_PATH,
) )
}} }}
schema={tableListSchema()} schema={tableSearchListSchema()}
components={{ components={{
DateRangePickerUnix, DateRangePickerUnix,
Submit Submit
......
import React, { useRef } from 'react' import React from 'react'
import { history } from 'umi' import { history } from 'umi'
import { Card, Button, Space } from 'antd' import { Card, Button, Space } from 'antd'
import { StandardTable } from 'god' import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { PlusCircleOutlined } from '@ant-design/icons' import { PlusCircleOutlined } from '@ant-design/icons'
import { tableListSchema } from './schema'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import Submit from '@/components/NiceForm/components/Submit' import Submit from '@/components/NiceForm/components/Submit'
import { useSelfTable } from './model/useReadyAddBill' import { useSelfTable } from './model/useReadyAddBill'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix' import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
import '../index.less' import '../index.less'
import { tableListSchema } from '../constant'
// 待新增请购单 // 待新增请购单
...@@ -23,11 +23,10 @@ const fetchTableData = async (params) => { ...@@ -23,11 +23,10 @@ const fetchTableData = async (params) => {
} }
const ReadyAddBill:React.FC<ReadyAddBillProps> = () => { const ReadyAddBill:React.FC<ReadyAddBillProps> = () => {
const currentRef = useRef<any>({})
const { columns, ref } = useSelfTable() const { columns, ref } = useSelfTable()
const clickAdd = () => { const clickAdd = () => {
currentRef.current.setVisible(true) history.push(`/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/add`)
} }
return <PageHeaderWrapper> return <PageHeaderWrapper>
......
import React, { useRef } from 'react'
import { history } from 'umi'
import { Card, Button, Space } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api'
import { PlusCircleOutlined } from '@ant-design/icons'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import Submit from '@/components/NiceForm/components/Submit'
import '../index.less'
import { tableListSchema } from '../../constant'
import { useSelfTable } from '../model/useRequesitionOrder'
// 请购单转订单 详情
export interface RequesitionOrderDetailProps {}
const fetchTableData = async (params) => {
const { data } = await PublicApi.getOrderBuyerCreatePage(params)
return data
}
const RequesitionOrderDetail:React.FC<RequesitionOrderDetailProps> = () => {
const { columns, ref } = useSelfTable()
const clickAdd = () => {
history.push(`/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/add`)
}
return <PageHeaderWrapper>
<Card>
<StandardTable
fetchTableData={params => fetchTableData(params)}
columns={columns}
currentRef={ref}
rowKey="orderId"
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
ctx: {
inline: false,
schema: tableListSchema(),
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'orderNo',
FORM_FILTER_PATH,
);
},
components: {
Submit
}
},
layouts: {
order: 2,
span: 16
}
}}
formilyChilds={{
children: <Space>
<Button
icon={<PlusCircleOutlined/>}
type='primary'
onClick={clickAdd}
>
新建
</Button>
</Space>,
layouts: {
span: 8
}
}}
/>
</Card>
</PageHeaderWrapper>
}
RequesitionOrderDetail.defaultProps = {}
export default RequesitionOrderDetail
import React, { useRef } from 'react'
import { history } from 'umi'
import { Card, Button, Space } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api'
import { PlusCircleOutlined } from '@ant-design/icons'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import Submit from '@/components/NiceForm/components/Submit'
import { useSelfTable } from './model/useRequesitionOrder'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
import '../index.less'
import { tableListSchema } from '../constant'
// 请购单转订单
export interface RequesitionOrderProps {}
const fetchTableData = async (params) => {
const { data } = await PublicApi.getOrderBuyerCreatePage(params)
return data
}
const RequesitionOrder:React.FC<RequesitionOrderProps> = () => {
const { columns, ref } = useSelfTable()
const clickAdd = () => {
history.push(`/memberCenter/procurementAbility/purchaseRequisition/readyAddBill/add`)
}
return <PageHeaderWrapper>
<Card>
<StandardTable
fetchTableData={params => fetchTableData(params)}
columns={columns}
currentRef={ref}
rowKey="orderId"
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
ctx: {
inline: false,
schema: tableListSchema(),
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'orderNo',
FORM_FILTER_PATH,
);
},
components: {
DateRangePickerUnix,
Submit
}
},
layouts: {
order: 2,
span: 16
}
}}
formilyChilds={{
children: <Space>
<Button
icon={<PlusCircleOutlined/>}
type='primary'
onClick={clickAdd}
>
新建
</Button>
</Space>,
layouts: {
span: 8
}
}}
/>
</Card>
</PageHeaderWrapper>
}
RequesitionOrder.defaultProps = {}
export default RequesitionOrder
import React, { useRef } from 'react'
import { baseOrderListColumns } from '../../constant'
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { history } from 'umi'
import TableOperation from '@/components/TableOperation'
// 请购单转订单 Hook
export const useSelfTable = () => {
const ref = useRef<any>({})
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'orderId'})
const handleSubmit = async (id) => {
await PublicApi.postOrderBuyerCreateSubmit({orderId: id})
ref.current.reload()
}
const handleDelete = async (id) => {
await PublicApi.postOrderBuyerCreateDelete({orderId: id})
ref.current.reload()
}
const handleEdit = (record: any) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/edit?id=${record.orderId}`)
}
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const buttonGroup = { '提交': true, '修改': record.showUpdate, '删除': true }
const operationHandler = {
'提交': () => handleSubmit(record.orderId),
'修改': () => handleEdit(record),
'删除': () => handleDelete(record.orderId),
}
return (
<TableOperation
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
/>
)
}
const secondColumns = () => {
const alreadyColumns = baseOrderListColumns()
if(alreadyColumns) {
return alreadyColumns.concat([
{
title: '操作',
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
render: (text: any, record: any) => renderOptionButton(record)
}
])
}
}
return {
columns: secondColumns(),
ref,
rowSelection,
rowSelectionCtl
}
}
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