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

fix: 订单部分table操作变更为接口字段控制

parent 6957c03a
......@@ -4,6 +4,8 @@ import { CaretDownOutlined } from '@ant-design/icons'
export interface TableOperationProps {
record: any,
/** 自定义状态字段, 默认'status' */
customField?: string,
/** 所有状态和操作名称的映射 */
statusOperationMap: any,
/** 所有的操作句柄函数 */
......@@ -14,18 +16,18 @@ export interface TableOperationProps {
const TableOperation:React.FC<TableOperationProps> = (props) => {
const { record, statusOperationMap, operationHandler, priorityOperationName } = props
const { record, statusOperationMap, operationHandler, priorityOperationName, customField = 'status' } = props
const [operationName, setOperationName] = useState<string[]>([])
useEffect(() => {
let maps = statusOperationMap[record.status]
let maps = record[customField] ? statusOperationMap[record[customField]] : []
if(maps.length > 2 && priorityOperationName && maps.includes(priorityOperationName)){
let temp = maps.filter(_ => _ != priorityOperationName)
temp.unshift(priorityOperationName)
setOperationName(temp)
}else{
setOperationName(() => statusOperationMap[record.status])
setOperationName(() => record[customField] ? statusOperationMap[record[customField]] : [])
}
}, [record])
......@@ -38,9 +40,9 @@ const TableOperation:React.FC<TableOperationProps> = (props) => {
<Dropdown overlay={
<Menu>
{
operationName.slice(1, operationName.length).map(_ => (
<Menu.Item>
<Button type='link' onClick={operationHandler[_]}>{ _ }</Button>
operationName.slice(1, operationName.length).map((e, i) => (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
</Menu.Item>
))
}
......@@ -52,7 +54,7 @@ const TableOperation:React.FC<TableOperationProps> = (props) => {
</Dropdown>
</>
:
operationName.map(_ => (<Button type='link' onClick={operationHandler[_]}>{ _ }</Button>))
operationName.map((e, i) => (<Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button>))
}
</>
)
......
......@@ -29,12 +29,7 @@ export const useSelfTable = () => {
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
{
record.interiorState === PurchaseOrderInsideWorkState.ONE_LEVEL_AUDIT_ORDER &&
<Button type='link' onClick={() => handleSubmit(record)}>提交审核</Button>
}
</>
render: (text, record) => <Button type='link' onClick={() => handleSubmit(record)}>提交审核</Button>
}
])
......
import React, { useState, useRef } from 'react'
import React, { useState, useRef, useCallback } from 'react'
import { Card, Button, Modal, Row, Col, message } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
......@@ -15,6 +15,9 @@ import NiceForm from '@/components/NiceForm'
import { createFormActions } from '@formily/antd'
import styled from 'styled-components'
import cx from 'classnames'
import TableOperation from '@/components/TableOperation'
import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest'
const SelectStyles = styled((props) => <div className='select-list' {...props}></div>)`
.select_style_border {
......@@ -51,12 +54,12 @@ const SelectStyles = styled((props) => <div className='select-list' {...props}><
export interface PurchaseOrderProps { }
const fetchTableData = async (params) => {
console.log(params,'params')
const { data } = await PublicApi.getOrderProcurementOrderList(params)
return data
}
const formActions = createFormActions();
const destroyActions = createFormActions()
const showDataSource = [
{ id: 1, name: "换货"},
......@@ -64,14 +67,15 @@ const showDataSource = [
{ id: 3, name: "维修"},
]
// 最后一步开始调试 TODO
const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
const [saleVisible, setSaleVisible] = useState<any>(false)
const [checkedId, setCheckedId] = useState<any>()
const [recordId, setRecordId] = useState<any>()
const ref = useRef<any>({})
const destoryRef = useRef<any>({})
const { run, loading } = useHttpRequest(PublicApi.postPurchaseInviteTenderDiscardInviteTender)
// 售后唤起弹窗 @todo
// 售后唤起弹窗
const handleSaleAfter = (id) => {
setSaleVisible(true)
setRecordId(id)
......@@ -95,22 +99,65 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
}
}
// 提交取消
const handleSubmit = useCallback(() => {
destroyActions.submit().then(async ({values}: any) => {
const result = await run(values)
if (result.code === 1000) {
destoryRef.current.setVisible(false)
setTimeout(() => {
ref.current.reload()
}, 800)
}
})
}, [])
const handleEvaluate = (id) => {
history.push(`/memberCenter/tranactionAbility/purchaserEvaluation/unevaluated`)
}
const handleCancel = async (id) => {
destoryRef.current.setVisible(true)
// await PublicApi.postOrderPurchaseOrderCancel({id})
// ref.current.reload()
}
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'2': ['取消订单'],
'3': ['售后'],
'4': ['售后', '评价'],
}
const operationHandler = {
// @todo 取消订单
'取消订单': () => handleCancel(record.id),
'售后': () => handleSaleAfter(record.id),
'评价': () => handleEvaluate(record.id),
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
operationHandler={operationHandler}
/>
)
}
const secondColumns: any[] = baseOrderListColumns().concat([
{
title: '操作',
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{
(record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER) && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
}
</>
render: (text: any, record: any) => renderOptionButton(record)
// render: (text, record) => <>
// { record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
// {
// (record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER) && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
// }
// </>
}
])
......@@ -174,6 +221,50 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
</SelectStyles>
</div>
</Modal>
<ModalForm
modalTitle='取消原因'
currentRef={destoryRef}
confirm={handleSubmit}
actions={destroyActions}
schema={{
type: 'object',
properties: {
NO_SUBMIT: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelAlign: 'top',
},
properties: {
id: {
type: 'number',
title: '当前id',
visible: false,
},
disabledRemark: {
type: 'textarea',
"x-component-props": {
rows: 4,
placeholder: '在此输入你的原因, 最多50个汉字'
},
title: '取消原因',
"x-rules": [
{
required: true,
message: '请输入取消原因'
},
{
limitByte: true,
maxByte: 100
}
]
}
}
}
}
}}
modalProps={{confirmLoading: loading}}
/>
</PageHeaderWrapper>
}
......
......@@ -5,6 +5,7 @@ import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { history } from 'umi'
import { PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState } from '@/constants/order'
import TableOperation from '@/components/TableOperation'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
......@@ -37,43 +38,66 @@ export const useSelfTable = () => {
ref.current.reload()
}
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'5': ['提交审核', '修改', '删除'],
'6': ['修改'],
}
const operationHandler = {
'提交审核': () => handleSubmit(record.id),
'修改': () => handleEdit(record),
'删除': () => handleDelete(record.id),
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
operationHandler={operationHandler}
priorityOperationName='提交审核'
/>
)
}
const secondColumns: any[] = baseOrderListColumns().concat([
{
title: '操作',
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
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
render: (text: any, record: any) => renderOptionButton(record)
// 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 = record.interiorState === PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER
return <>
{
showDeleteOrSubmit &&
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
}
{
showEditOrCancel && <Button type='link' onClick={() => handleEdit(record)}>修改订单</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>
}
</>
}
// // 待提交审核且从未提交过审核的订单才可删除
// const showDeleteOrSubmit = record.interiorState === PurchaseOrderInsideWorkState.ADD_PURCHASE_ORDER
// return <>
// {
// showDeleteOrSubmit &&
// <Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
// }
// {
// showEditOrCancel && <Button type='link' onClick={() => handleEdit(record)}>修改订单</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>
// }
// </>
// }
}
])
......
......@@ -165,7 +165,7 @@ export const useSelfTable = () => {
) &&
<Link to={`/memberCenter/tranactionAbility/purchaseOrder/readyPayOrder/detail?id=${record.id}`}>去支付</Link>
}
{
{/* {
(
record.externalState === PurchaseOrderOutWorkState.PAY_ORDER &&
!record.signatureLogId ||
......@@ -180,7 +180,7 @@ export const useSelfTable = () => {
>
<Button type='link'>取消订单</Button>
</Popconfirm>
}
} */}
</>
}
]
......
......@@ -19,26 +19,14 @@ export const useSelfTable = () => {
await PublicApi.postOrderPurchaseOrderCancel({id})
ref.current.reload()
}
const secondColumns: any[] = baseOrderListColumns().concat([
{
title: '操作',
align: 'center',
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => {
const canSubmit = record.externalState === PurchaseOrderOutWorkState.SUBMIT_ORDER && record.interiorState === PurchaseOrderInsideWorkState.SUBMIT_ORDER
// 外部状态: 待提交订单 可以取消订单
const showEditOrCancel = record.externalState === PurchaseOrderOutWorkState.SUBMIT_ORDER
return <>
{ canSubmit && <Button type='link' onClick={() => handleSubmit(record.id)}>提交订单</Button>}
{
showEditOrCancel &&
<Popconfirm title='是否要取消该订单' onConfirm={() => handleCancel(record.id)}>
<Button type='link'>取消订单</Button>
</Popconfirm>
}
</>
}
render: (text, record) => <Button type='link' onClick={() => handleSubmit(record.id)}>提交订单</Button>
}
])
......
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