Commit 14aa7ff2 authored by 前端-许佳敏's avatar 前端-许佳敏

采购订单

parent 2b56ed04
import React from 'react'
import { ISchemaFieldProps } from '@formily/antd'
import { ISchemaFieldProps, ISchemaFieldComponentProps } from '@formily/antd'
const VirtualChildren = (props) => {
const VirtualChildren = (props: ISchemaFieldComponentProps) => {
// console.log(props)
const { children } = props
const { children } = props.schema.getExtendsComponentProps()
// const componentProps = schema.getExtendsComponentProps()
// const { children } = componentProps
return (
......
......@@ -26,8 +26,11 @@ import { Checkbox, Radio } from '@formily/antd-components';
import DateSelect from './components/DateSelect';
import VirtualChildren from './components/VirtualChildren'
import { useLinkComponentProps } from './linkages/linkComponentProps';
import Loading from '../Loading';
export interface NiceFormProps extends IAntdSchemaFormProps {}
export interface NiceFormProps extends IAntdSchemaFormProps {
loading?: boolean
}
const SchemaFormButtonGroup = createVirtualBox('schemaButtonGroup', FormButtonGroup)
const SchemaButton = createVirtualBox('schemaButton', Button)
......@@ -96,26 +99,30 @@ export const componentExport = {
RadioGroup: Radio.Group
}
const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, effects, expressionScope, ...reset } = props;
const { children, components, effects, expressionScope, loading = false, ...reset } = props;
const defineComponents = Object.assign(componentExport, components);
return (
<SchemaForm
colon={false}
components={defineComponents}
effects={($, ctx) => {
// 自定义联动scope收集器
useLinkComponentProps(expressionScope)
<div style={{width: '100%', position: 'relative'}}>
<SchemaForm
colon={false}
components={defineComponents}
style={{opacity: loading ? 0 : 1, position: loading ? 'absolute' : 'initial'}}
effects={($, ctx) => {
// 自定义联动scope收集器
useLinkComponentProps(expressionScope)
// 组件联动
effects && effects($, ctx)
}}
expressionScope={expressionScope}
{...reset}
>
{children}
</SchemaForm>
// 组件联动
effects && effects($, ctx)
}}
expressionScope={expressionScope}
{...reset}
>
{children}
</SchemaForm>
{ loading && <Loading/> }
</div>
);
};
......
......@@ -377,3 +377,210 @@ export enum OrderModalType {
*/
CHANNEL_SPOT_MANUAL_ORDER,
}
// 采购订单外部工作流状态
export enum PurchaseOrderOutWorkState {
/**
* 取消订单
*/
CANCEL_ORDER = -1,
/**
* 提交订单
*/
SUBMIT_ORDER = 1,
/**
* 确认订单
*/
CONFIRM_ORDER,
/**
* 确认电子合同
*/
CONFIRM_ELECTRONIC,
/**
* 订单支付
*/
PAY_ORDER,
/**
* 确认支付结果
*/
CONFIRM_PAY_RESULT,
/**
* 新增销售发货单
*/
ADD_SALE_INVOICE_ORDER,
/**
* 新增物流单
*/
ADD_LOGISTICS_ORDER,
/**
* 订单发货确认
*/
CONFIRM_DELIVERY_ORDER,
/**
* 新增采购入库单
*/
ADD_PURCHASE_STOCK_ORDER,
/**
* 订单收货确认
*/
CONFIRM_RECEIPT_ORDER,
/**
* 确认回单
*/
CONFIRM_RECEIPT,
/**
* 订单归档供应商
*/
FILING_SUPPLIER_ORDER,
/**
* 订单归档采购商
*/
FILING_BUYER_ORDER,
/**
* 完成订单
*/
FINISH_ORDER,
/**
* 不接受订单
*/
NOT_ACCEPTED_ORDER = 20,
/**
* 确认没到账
*/
CONFIRM_NOT_ARRIVED_ACCOUNT,
/**
* 货品数量还没有全部发货重新发货
*/
PRODUCT_ACOUNT_NOT_SEND
}
// 采购订单内部工作流状态
export enum PurchaseOrderInsideWorkState {
/**
* 取消订单
*/
CANCEL_ORDER = -1,
/**
* 新增采购订单
*/
ADD_PURCHASE_ORDER = 1,
/**
* 一级审核订单
*/
ONE_LEVEL_AUDIT_ORDER,
/**
* 二级审核订单
*/
TWO_LEVEL_AUDIT_ORDER,
/**
* 提交订单
*/
SUBMIT_ORDER,
/**
* 提交订单完成
*/
SUBMIT_FINISH_ORDER,
/**
* 提交一级审核订单不通过
*/
ONE_LEVEL_AUDIT_ORDER_NOT_ALLOWED,
/**
* 提交二级审核订单不通过
*/
TWO_LEVEL_AUDIT_ORDER_NOT_ALLOWED,
/**
* 确认电子合同
*/
CONFIRM_ELECTRONIC,
/**
* 支付成功
*/
PAY_SUCCESS = 10,
/**
* 支付失败
*/
PAY_ERROR,
/**
* 确认收货
*/
CONFIRM_RECEIPT,
/**
* 订单入库
*/
WAREHOUSE_ORDER = 14,
/**
* 订单归档
*/
FILLING_ORDER,
}
// 采购订单外部显示文案
export const PurchaseOrderOutWorkStateTexts = {
"-1": "取消订单",
1: '提交订单',
2: '确认订单',
3: '确认电子合同',
4: '订单支付',
5: '确认支付结果',
6: '新增销售发货单',
7: '新增物流单',
8: '订单发货确认',
9: '新增采购入库单',
10: '订单收货确认',
11: '确认回单',
12: '订单归档供应商',
13: '订单归档采购商',
14: '完成订单',
20: '不接受订单',
21: '确认没到账',
22: '货品未全部发货'
}
export const PurchaseOrderInsideWorkStateTexts = {
"-1": '取消订单',
1: '新增采购订单',
2: '一级审核订单',
3: '二级审核订单',
4: '提交订单',
5: '提交订单完成',
6: '提交一级审核订单不通过',
7: '提交二级审核订单不通过',
8: '确认电子合同',
10: '支付成功',
11: '支付失败',
12: '确认收货',
14: '订单入库',
15: '订单归档'
}
\ No newline at end of file
import React from 'react'
import { Tag } from 'antd'
import { PurchaseOrderInsideWorkStateTexts, PurchaseOrderOutWorkStateTexts, PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState } from '@/constants'
export interface IStatusColor {
[key: string]: {
......@@ -10,7 +11,8 @@ export interface IStatusColor {
// 用于标签状态控制
export interface StatusColorsProps {
status: number
status: number,
type: 'out' | 'inside'
}
export enum ORDER_EXAMINE_ENUM {
......@@ -78,15 +80,20 @@ const matchStatusColor = (status: number): string => {
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_PROCESS]: StatusColorsMaps.submit,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_SUCCESS]: StatusColorsMaps.success
}
const READY_LISTS = [
PurchaseOrderInsideWorkState.CANCEL_ORDER,
PurchaseOrderOutWorkState.CANCEL_ORDER
]
// 默认返回错误的状态颜色
return maps[status] || StatusColorsMaps.error
}
// 订单内部状态显示
const StatusColors:React.FC<StatusColorsProps> = (props) => {
const { status } = props
const { status, type } = props
const statusText = type === 'inside' ? PurchaseOrderInsideWorkStateTexts : PurchaseOrderOutWorkStateTexts
const statusShowColor = matchStatusColor(status)
return (<Tag color={statusShowColor}>{ORDER_EXAMINE_LIST[status]}</Tag>)
return (<Tag color={statusShowColor}>{statusText[status]}</Tag>)
}
StatusColors.defaultProps = {}
......
import React, { useRef, useEffect, useState } from 'react'
import React, { useRef, useEffect, useState, useContext } from 'react'
import { Button, Table } from 'antd'
import { StandardTable } from 'god'
import { formatTimeString } from '@/utils'
import './index.less'
import cx from 'classnames'
import { ReadyAddOrderDetailContext } from '../../context'
import StatusColors from '../StatusColors'
export interface CirculationRecordProps {}
......@@ -29,6 +31,7 @@ const outOrderCols: any[] = [
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='out'/>
// @todo 需传递工作流状态重新render
},
{
......@@ -82,6 +85,7 @@ const sideOrderCols: any[] = [
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='inside'/>
},
{
title: '操作',
......@@ -104,11 +108,20 @@ const sideOrderCols: any[] = [
]
const CirculationRecord:React.FC<CirculationRecordProps> = (props) => {
const colRef = useRef<any[]>(outOrderCols)
const colRef = useRef<any>({
columns: outOrderCols
})
const { detailData } = useContext(ReadyAddOrderDetailContext)
const [orderState, setOrderState] = useState<number>(0)
const [dataSource, setDataSource] = useState<any>([])
useEffect(() => {
colRef.current = orderState === 1 ? outOrderCols : sideOrderCols
}, [colRef, orderState])
if (detailData) {
colRef.current = {
columns: orderState === 1 ? sideOrderCols : outOrderCols
}
setDataSource(orderState === 1 ? detailData.interiorProcurementOrderLogResponses : detailData.externalProcurementOrderLogResponses)
}
}, [colRef, orderState, detailData])
return (
<div>
<div className='com-switch-btn-group' style={{margin: '20px 0'}}>
......@@ -116,8 +129,9 @@ const CirculationRecord:React.FC<CirculationRecordProps> = (props) => {
<div className={cx('switch-btn', orderState === 1 ? 'active' : '')} onClick={() => setOrderState(1)}>内部单据</div>
</div>
<Table
columns={colRef.current}
dataSource={[]}
columns={colRef.current.columns}
dataSource={dataSource}
rowKey="id"
/>
</div>
)
......
......@@ -2,6 +2,7 @@ import React from 'react'
import { formatTimeString } from '@/utils'
import { ORDER_TYPE } from '@/constants'
import StatusColors from '../components/StatusColors'
import EyePreview from '@/components/EyePreview'
export const baseOrderListColumns: any[] = [
......@@ -10,6 +11,12 @@ export const baseOrderListColumns: any[] = [
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
render: (text, record) => {
// 查看订单, 需根据状态显示不同schema
return <EyePreview url={`/memberCenter/tranactionAbility/purchaseOrder/orderDetail?page_type=-1&id=${record.id}&preview=1`}>
{text}
</EyePreview>
}
},
{
title: '订单摘要',
......@@ -48,12 +55,13 @@ export const baseOrderListColumns: any[] = [
align: 'center',
dataIndex: 'externalState',
key: 'externalState',
render: text => <StatusColors status={text} type='out'/>
},
{
title: '内部状态',
align: 'center',
dataIndex: 'interiorState',
key: 'interiorState',
render: (text) => <StatusColors status={text}/>
render: (text) => <StatusColors status={text} type='inside'/>
},
]
\ No newline at end of file
import { createContext } from 'react';
export const readyAddOrderDetailContext = createContext<any>({})
\ No newline at end of file
export const ReadyAddOrderDetailContext = createContext<any>({})
\ No newline at end of file
import React, { useRef } from 'react'
import { history } from 'umi'
import { Card, Button, Space, Dropdown, Menu } from 'antd'
import { Card, Button, Space, Dropdown, Menu, message } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api'
......@@ -13,6 +13,7 @@ import { FORM_FILTER_PATH } from '@/formSchema/const'
import Submit from '@/components/NiceForm/components/Submit'
import { DatePicker } from '@formily/antd-components'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { PurchaseOrderInsideWorkState } from '@/constants'
// 一级待审核订单
......@@ -33,9 +34,17 @@ const FirstApprovedOrder:React.FC<FirstApprovedOrderProps> = (props) => {
} = useSelfTable()
const handleSubmitBatch = async () => {
await PublicApi.postOrderProcurementOrderReviewedAll({
ids: rowSelectionCtl.selectedRowKeys
})
if (rowSelectionCtl.selectRow.length === 0) {
message.error('请先勾选订单')
return ;
}
const canBitch = !rowSelectionCtl.selectRow.some(v => v.interiorState !== PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER)
if (canBitch) {
await PublicApi.postOrderProcurementOrderReviewedAll({ids: rowSelectionCtl.selectedRowKeys})
ref.current.reload()
} else {
message.error('只能批量提交内部状态为审核中的订单')
}
}
return <PageHeaderWrapper>
<Card>
......
......@@ -4,14 +4,17 @@ import { baseOrderListColumns } from '../../constant'
import { history } from 'umi'
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { PurchaseOrderInsideWorkState } from '@/constants'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
const ref = useRef<any>({})
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'id'})
const handleSubmit = async (id) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/orderDetail?id=${id}&preview=1&page_type=1`)
const handleSubmit = async (record) => {
if (record.interiorState === PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER) {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/orderDetail?id=${record.id}&preview=0&page_type=1`)
}
// await PublicApi.postOrderQuotationBeReviewed({id})
// ref.current.reload()
}
......@@ -22,7 +25,10 @@ export const useSelfTable = () => {
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
{
record.interiorState === PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER &&
<Button type='link' onClick={() => handleSubmit(record)}>提交审核</Button>
}
</>
}
])
......
......@@ -6,13 +6,18 @@ import './index.less'
import { PublicApi } from '@/services/api'
export interface InvoiceModalProps {
mode: 'add' | 'edit' | 'default',
mode: 'add' | 'edit' | 'preview' | 'default',
currentRef?: any,
formInitValue?: any,
reload?()
}
const schemaActions = createFormActions()
const modelTitle = {
'add': '新增发票',
'edit': "编辑发票",
'preview': '查看发票'
}
const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
const { mode, formInitValue } = props
......@@ -27,6 +32,10 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
schemaActions.reset({validate: false})
}
const handleConfirm = () => {
if (mode === 'preview') {
props.currentRef.current.setVisible(false)
return ;
}
schemaActions.submit()
}
......@@ -43,10 +52,12 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
}
return (
<ModalForm
modalTitle={mode === 'add' ? '新建发票信息' : '编辑发票信息'}
modalTitle={modelTitle[mode]}
previewPlaceholder=" "
confirm={handleConfirm}
cancel={resetForm}
value={selfInitValue}
editable={mode !== 'preview'}
effects={($, { setFieldState }) => {
$('onFormMount').subscribe(() => {
})
......
......@@ -18,9 +18,19 @@ const EditableContext = React.createContext<any>({});
export const EditableRow: React.FC<any> = (props) => {
const [form] = Form.useForm();
// form.setFieldsValue()
const { options = [] } = props?.children[5]?.props.additionalProps.formItemProps || {}
const [childOptions, setChildOptions] = useState<any[]>([])
const [childOptions, setChildOptions] = useState<any[]>(() => {
const { payWay } = props?.children[5]?.props.record || {}
if (payWay) {
return options.find(v => v.payType === payWay)?.payList.map(v => ({
label: v.way,
value: v.id
})) || []
} else {
return []
}
})
const ctx = {
form,
childOptions,
......@@ -79,6 +89,7 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
onChange={e => {
const result = originOptions.find(v => e === v.payType)
setChildOptions(result.payList.map(v => ({label: v.way, value: v.id})))
form.setFieldsValue({channel: ''})
save(e)
}}
{...rest}
......@@ -103,11 +114,13 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
let childNode = children;
if (editable) {
childNode = (forceEdit) ? (
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
......
......@@ -46,7 +46,6 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
......@@ -71,6 +70,7 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
......
......@@ -9,58 +9,6 @@ import { PublicApi } from '@/services/api'
import InvoiceModal from '../invoiceModal'
import styles from './index.less'
const SelectStyles = styled((props) => <div className='select-list' {...props}></div>)`
.select_style_border {
border: 1px solid #EBECF0;
margin-top: 20px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 14px;
cursor: pointer;
line-height: 28px;
position:relative;
}
.select_style_border.active {
border: 1px solid #00B382;
}
.select_style_border.active::after {
content: '';
position: absolute;
width: 0;
height: 0;
border-bottom: 12px solid #00B37A;
border-left: 12px solid transparent;
bottom: 0;
right: 0;
z-index: 5;
}
`
const MockData = [
{
id: 1,
type: 1,
name: '温州市龙昌皮业有限公司',
userType: 1,
isDefault: 1
},
{
id: 2,
type: 2,
name: '温州市龙昌皮业有限公司',
userType: 1,
isDefault: 0
},
{
id: 3,
type: 2,
name: '温州市龙昌皮业有限公司',
userType: 1,
isDefault: 0
}
]
const transformDefaultData = (data: any[]) => {
if (data.length === 0) return data
......@@ -82,7 +30,7 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
})
const modalRef = useRef<any>({})
const { dataSource, showMore } = state
const { value, mutators, form } = props
const { value, mutators, form, editable } = props
const transformData = transformDefaultData(dataSource)
const showDataSource = showMore ? [...transformData].splice(0, 3) : transformData
const handleAdd = () => {
......@@ -120,11 +68,11 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
}
}
const handleEdit = async (item, e) => {
const handleEdit = async (item, e, mode?) => {
e.stopPropagation()
const { data } = await PublicApi.getSettleAccountsInvoiceMessageDetails({id: item.id})
setFormInitValue({...data, isDefault: item.isDefault})
setMode('edit')
setMode(mode || 'edit')
modalRef.current.setVisible(true)
}
......@@ -136,7 +84,7 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
return (
<div style={{width: '100%'}} className={styles.invoice}>
<Button block onClick={handleAdd} icon={<PlusOutlined/>}>新增发票</Button>
{ editable && <Button block onClick={handleAdd} icon={<PlusOutlined/>}>新增发票</Button> }
<Radio.Group className={styles.raido_group} value={value} onChange={e => handleCheck(e)}>
<div className={styles.invoice_list}>
{
......@@ -156,10 +104,15 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
</div>
{
value === item.id && (
editable ?
<div className={styles.invoice_list_item_btn_group}>
<div className={styles.invoice_list_item_btn} onClick={(e) => handleEdit(item, e)}>编辑</div>
<div className={styles.invoice_list_item_btn} onClick={(e) => handleDelete(item.id, e)}>删除</div>
</div>
:
<div className={styles.invoice_list_item_btn_group}>
<div className={styles.invoice_list_item_btn} onClick={(e) => handleEdit(item, e, 'preview')}>查看</div>
</div>
)
}
</div>
......
import React from 'react'
import { formatTimeString } from '@/utils'
import { Row, Space, Popover } from 'antd'
import { DELIVERY_TYPE, OrderModalType } from '@/constants'
import { DELIVERY_TYPE, OrderModalType, PurchaseOrderOutWorkStateTexts } from '@/constants'
import { EnvironmentOutlined } from '@ant-design/icons'
import { PublicApi } from '@/services/api'
......@@ -170,7 +170,8 @@ export const paymentInformationColumns: any[] = [
title: '外部状态',
dataIndex: 'externalState',
align: 'center',
key: 'externalState'
key: 'externalState',
render: text => PurchaseOrderOutWorkStateTexts[text]
},
{
title: '支付比例',
......@@ -182,7 +183,8 @@ export const paymentInformationColumns: any[] = [
formItemProps: {
addonAfter: '%'
},
width: 200
width: 200,
render: text => text + '%'
},
{
title: '支付金额',
......
import React, { useState, useEffect } from 'react'
import { OrderModalType } from '../constant'
import { OrderModalType } from '@/constants'
import { PublicApi } from '@/services/api'
import { useLocation, history } from 'umi'
import { ISchemaFormActions } from '@formily/antd'
......
......@@ -4,6 +4,7 @@ import { Button, Row, Col } from 'antd';
import { productInfoColumns } from '../constant';
import ProductTableCell, { ProductEditableRow } from '../components/productTableCell';
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['purchaseCount']) || 0
......@@ -25,7 +26,7 @@ const getUnitPriceTotal = (record) => {
export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const productRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
const { pageStatus } = usePageStatus()
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('orderProductRequests')]
// 删除formvalue
......@@ -39,12 +40,17 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
}
const [productColumns, setProductColumns] = useState(() => {
productInfoColumns[productInfoColumns.length - 1].render = (text, record) => {
return <>
<Button type='link' onClick={() => handleDelete(record)}>删除</Button>
<Button type='link'>选择合并订单</Button>
</>
if (pageStatus === PageStatus.ADD) {
productInfoColumns[productInfoColumns.length - 1].render = (text, record) => {
return <>
<Button type='link' onClick={() => handleDelete(record)}>删除</Button>
<Button type='link'>选择合并订单</Button>
</>
}
} else {
return [...productInfoColumns].slice(0, productInfoColumns.length - 1)
}
return productInfoColumns
})
const productAddButton = <Button onClick={() => productRef.current.setVisible(true)} block type='default' style={{margin: '24px auto'}}>选择订单商品</Button>
......
......@@ -395,9 +395,14 @@ const auditRecord: ISchema = {
NO_SUBMIT_LAYOUT_3: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelAlign: 'left',
labelCol: 4,
wrapperCol: 10
},
properties: {
state: {
title: ' ',
title: '是否审核通过',
type: 'radio',
enum: [
{
......@@ -409,6 +414,7 @@ const auditRecord: ISchema = {
value: 0
}
],
editable: true,
default: 1,
"x-linkages": [
{
......@@ -424,7 +430,8 @@ const auditRecord: ISchema = {
required: true,
"x-component-props": {
rows: 3
}
},
editable: true,
}
}
}
......@@ -457,9 +464,9 @@ export const orderDetailSchema: ISchema = {
"x-component": 'tab',
properties: {
basicInfo,
submitInfo,
orderProduct,
payInfo,
submitInfo,
ortherInfo,
transformRecord,
}
......@@ -476,9 +483,9 @@ export const auditOneSchema: ISchema = {
"x-component": 'tab',
properties: {
basicInfo,
submitInfo,
orderProduct,
payInfo,
submitInfo,
ortherInfo,
auditRecord,
transformRecord
......@@ -496,9 +503,9 @@ export const orderAddSchema: ISchema = {
"x-component": 'tab',
properties: {
basicInfo,
submitInfo,
orderProduct,
payInfo,
submitInfo,
ortherInfo,
}
}
......@@ -507,7 +514,11 @@ export const orderAddSchema: ISchema = {
// 根据传入的query参数 判断当前使用哪个schema
export const mergeAllSchemas = {
0: orderDetailSchema,
// 新增订单详情
"-1": orderDetailSchema,
0: orderAddSchema,
// 一级审核详情
1: auditOneSchema
1: auditOneSchema,
// 二级审核详情
2: auditOneSchema,
}
\ No newline at end of file
import React from 'react'
import { history } from 'umi'
import { Card, Button, Space, Dropdown, Menu } from 'antd'
import { Card, Button, Space, Dropdown, Menu, message } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api'
......@@ -13,6 +13,7 @@ import Submit from '@/components/NiceForm/components/Submit'
import { DatePicker } from '@formily/antd-components'
import { useSelfTable } from './model/useReadyAddOrder'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { PurchaseOrderInsideWorkState } from '@/constants'
// 待新增订单
......@@ -28,20 +29,29 @@ const ReadyAddOrder:React.FC<ReadyAddOrderProps> = (props) => {
const { columns, ref } = useSelfTable()
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'id'})
const handleMenuClick = (e) => {
const handleMenuClick = async (e) => {
switch(e.key) {
case '1': {
// 批量删除
const canDelete = !rowSelectionCtl.selectRow.some(v => v.interiorState !== PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER)
if (canDelete) {
await PublicApi.postOrderProcurementOrderDeleteAll({ids: rowSelectionCtl.selectedRowKeys})
} else {
message.error('只能删除内部状态为未审核过的订单')
}
break;
}
}
}
const handleBitchPush = async () => {
await PublicApi.postOrderProcurementOrderSubmitExamineAll({
ids: rowSelectionCtl.selectedRowKeys
})
ref.current.reload()
const canBitch = !rowSelectionCtl.selectRow.some(v => v.interiorState !== PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER)
if (canBitch) {
await PublicApi.postOrderProcurementOrderSubmitExamineAll({ids: rowSelectionCtl.selectedRowKeys})
ref.current.reload()
} else {
message.error('只能删除内部状态为未审核过的订单')
}
}
return <PageHeaderWrapper>
......
import React, { useRef } from 'react'
import { Button } from 'antd'
import { Button, Popconfirm } from 'antd'
import { baseOrderListColumns } from '../../constant'
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { history } from 'umi'
import { PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState } from '@/constants'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
......@@ -10,21 +12,62 @@ export const useSelfTable = () => {
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({customKey: 'id'})
const handleSubmit = async (id) => {
// 状态写死, 默认传-1
// 从待新增订单直接传到一级审核, 状态写死, 默认传-1
await PublicApi.postOrderProcurementOrderSubmitExamine({id, state: -1})
ref.current.reload()
}
const handleDelete = async (id) => {
await PublicApi.postOrderProcurementOrderDelete({id})
ref.current.reload()
}
const handleEdit = (id) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/orderDetail?page_type=0&id=${id}&preview=0`)
}
const handleCancel = async (id) => {
await PublicApi.postOrderPurchaseOrderCancel({id})
ref.current.reload()
}
const secondColumns: any[] = baseOrderListColumns.concat([
{
title: '操作',
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
<Button type='link' onClick={() => {}}>修改订单</Button>
<Button type='link' onClick={() => handleSubmit(record.id)}>取消订单</Button>
</>
render: (text, record) => {
// 当内部状态为待审核状态,审核不通过, 或者外部状态为不接受订单时才可修改订单
const showEditOrCancel = PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER_NOT_ALLOWED ||
PurchaseOrderInsideWorkState.TWO_LEVEL_AUDIT_ORDER_NOT_ALLOWED ||
PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER ||
PurchaseOrderOutWorkState.NOT_ACCEPTED_ORDER
// 待提交审核且从未提交过审核的订单才可删除
const showDeleteOrSubmit = PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER
return <>
{
showDeleteOrSubmit &&
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
}
{
showEditOrCancel && <Button type='link' onClick={() => handleEdit(record.id)}>修改订单</Button>
}
{
showDeleteOrSubmit &&
<Popconfirm title='是否要删除该订单' onConfirm={() => handleDelete(record.id)}>
<Button type='link'>删除订单</Button>
</Popconfirm>
}
{
showEditOrCancel &&
<Popconfirm title='是否要取消该订单' onConfirm={() => handleCancel(record.id)}>
<Button type='link'>取消订单</Button>
</Popconfirm>
}
</>
}
}
])
......
......@@ -2,13 +2,16 @@ import React, { useRef } from 'react'
import { Button } from 'antd'
import { baseOrderListColumns } from '../../constant'
import { PublicApi } from '@/services/api'
import { history } from 'umi'
import { PurchaseOrderInsideWorkState } from '@/constants'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
const ref = useRef<any>({})
const handleSubmit = async (id) => {
await PublicApi.postOrderQuotationBeReviewedTwo({id})
ref.current.reload()
const handleSubmit = async (record) => {
if (record.interiorState === PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER) {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/orderDetail?id=${record.id}&preview=0&page_type=1`)
}
}
const secondColumns: any[] = baseOrderListColumns.concat([
{
......@@ -17,7 +20,7 @@ export const useSelfTable = () => {
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
<Button type='link' onClick={() => handleSubmit(record)}>提交审核</Button>
</>
}
])
......
import { history } from 'umi'
/**
* 根据页面状态切换标题
*/
export const changeRouterTitleByStatus = () => {
const { id, page_type, preview } = history.location.query
if (id) {
if (preview === '1') {
return '查看订单'
}
switch(page_type) {
case '0': return '编辑订单'
case '1': return '订单审核'
case '2': return '订单审核'
}
} else {
// id不存在为新增页面
return '新增订单'
}
}
\ No newline at end of file
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