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

fix: 处理statusColor大小写

parent abb201b4
import React, { useRef, useEffect, useState, useContext } from 'react' import React, { useRef, useEffect, useState, useContext } from 'react'
import { Button, Table } from 'antd' import { Button, Table } from 'antd'
import { StandardTable } from 'god' import { StandardTable } from 'god'
import { formatTimeString } from '@/utils' import { formatTimeString } from '@/utils'
import './index.less' import './index.less'
import cx from 'classnames' import cx from 'classnames'
import { ReadyAddOrderDetailContext } from '../../context' import { ReadyAddOrderDetailContext } from '../../context'
import StatusColors from '../StatusColors' import StatusColors from '../statusColors'
export interface CirculationRecordProps {} export interface CirculationRecordProps {}
/** /**
* 流转记录控制 * 流转记录控制
*/ */
const outOrderCols: any[] = [ const outOrderCols: any[] = [
{ {
title: '流转顺序号', title: '流转顺序号',
dataIndex: 'no', dataIndex: 'no',
align: 'center', align: 'center',
key: 'no', key: 'no',
render: (_, __, index: number) => index + 1 render: (_, __, index: number) => index + 1
}, },
{ {
title: '操作角色', title: '操作角色',
dataIndex: 'roleName', dataIndex: 'roleName',
align: 'center', align: 'center',
key: 'roleName', key: 'roleName',
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
align: 'center', align: 'center',
key: 'state', key: 'state',
render: text => <StatusColors status={text} type='out'/> render: text => <StatusColors status={text} type='out'/>
// @todo 需传递工作流状态重新render // @todo 需传递工作流状态重新render
}, },
{ {
title: '操作', title: '操作',
dataIndex: 'operation', dataIndex: 'operation',
align: 'center', align: 'center',
key: 'operation', key: 'operation',
}, },
{ {
title: '操作时间', title: '操作时间',
dataIndex: 'operationTime', dataIndex: 'operationTime',
align: 'center', align: 'center',
key: 'operationTime', key: 'operationTime',
render: time => formatTimeString(time) render: time => formatTimeString(time)
}, },
{ {
title: '审核意见', title: '审核意见',
dataIndex: 'auditOpinion', dataIndex: 'auditOpinion',
align: 'center', align: 'center',
key: 'auditOpinion', key: 'auditOpinion',
}, },
] ]
const sideOrderCols: any[] = [ const sideOrderCols: any[] = [
{ {
title: '流转记录', title: '流转记录',
dataIndex: 'no', dataIndex: 'no',
align: 'center', align: 'center',
key: 'no', key: 'no',
render: (_, __, index: number) => index + 1 render: (_, __, index: number) => index + 1
}, },
{ {
title: '操作人', title: '操作人',
dataIndex: 'roleName', dataIndex: 'roleName',
align: 'center', align: 'center',
key: 'roleName', key: 'roleName',
}, },
{ {
title: '部门', title: '部门',
dataIndex: 'department', dataIndex: 'department',
align: 'center', align: 'center',
key: 'department', key: 'department',
}, },
{ {
title: '职位', title: '职位',
dataIndex: 'position', dataIndex: 'position',
align: 'center', align: 'center',
key: 'position', key: 'position',
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
align: 'center', align: 'center',
key: 'state', key: 'state',
render: text => <StatusColors status={text} type='inside'/> render: text => <StatusColors status={text} type='inside'/>
}, },
{ {
title: '操作', title: '操作',
dataIndex: 'operation', dataIndex: 'operation',
align: 'center', align: 'center',
key: 'operation', key: 'operation',
}, },
{ {
title: '操作时间', title: '操作时间',
dataIndex: 'operationTime', dataIndex: 'operationTime',
align: 'center', align: 'center',
key: 'operationTime', key: 'operationTime',
}, },
{ {
title: '审核意见', title: '审核意见',
dataIndex: 'auditOpinion', dataIndex: 'auditOpinion',
align: 'center', align: 'center',
key: 'auditOpinion', key: 'auditOpinion',
}, },
] ]
const CirculationRecord:React.FC<CirculationRecordProps> = (props) => { const CirculationRecord:React.FC<CirculationRecordProps> = (props) => {
const colRef = useRef<any>({ const colRef = useRef<any>({
columns: outOrderCols columns: outOrderCols
}) })
const { detailData } = useContext(ReadyAddOrderDetailContext) const { detailData } = useContext(ReadyAddOrderDetailContext)
const [orderState, setOrderState] = useState<number>(0) const [orderState, setOrderState] = useState<number>(0)
const [dataSource, setDataSource] = useState<any>([]) const [dataSource, setDataSource] = useState<any>([])
useEffect(() => { useEffect(() => {
if (detailData) { if (detailData) {
colRef.current = { colRef.current = {
columns: orderState === 1 ? sideOrderCols : outOrderCols columns: orderState === 1 ? sideOrderCols : outOrderCols
} }
setDataSource(orderState === 1 ? detailData.interiorProcurementOrderLogResponses : detailData.externalProcurementOrderLogResponses) setDataSource(orderState === 1 ? detailData.interiorProcurementOrderLogResponses : detailData.externalProcurementOrderLogResponses)
} }
}, [colRef, orderState, detailData]) }, [colRef, orderState, detailData])
return ( return (
<div> <div>
<div className='com-switch-btn-group' style={{margin: '20px 0'}}> <div className='com-switch-btn-group' style={{margin: '20px 0'}}>
<div className={cx('switch-btn', orderState === 0 ? 'active' : '')} onClick={() => setOrderState(0)}>外部单据</div> <div className={cx('switch-btn', orderState === 0 ? 'active' : '')} onClick={() => setOrderState(0)}>外部单据</div>
<div className={cx('switch-btn', orderState === 1 ? 'active' : '')} onClick={() => setOrderState(1)}>内部单据</div> <div className={cx('switch-btn', orderState === 1 ? 'active' : '')} onClick={() => setOrderState(1)}>内部单据</div>
</div> </div>
<Table <Table
columns={colRef.current.columns} columns={colRef.current.columns}
dataSource={dataSource} dataSource={dataSource}
rowKey="id" rowKey="id"
/> />
</div> </div>
) )
} }
CirculationRecord.defaultProps = {} CirculationRecord.defaultProps = {}
export default CirculationRecord export default CirculationRecord
\ No newline at end of file
import React from 'react'
import { Tag } from 'antd'
export interface IStatusColor {
[key: string]: {
value: string | number,
color: string
}
}
// 用于标签状态控制
export interface StatusColorsProps {
status: number,
text?: string,
type: 'out' | 'inside' | 'saleInside'
}
export enum ORDER_EXAMINE_ENUM {
/**
* 新增订单
*/
ADD_ORDER = 1,
/**
* 一级审核
*/
ONE_LEVEL_VALIDATE,
/**
* 二级审核
*/
TWO_LEVEL_VALIDATE,
/**
* 提交订单中
*/
SUBMIT_ORDER_PROCESS,
/**
* 提交订单成功
*/
SUBMIT_ORDER_SUCCESS,
/**
* 一级审核失败
*/
ONE_LEVEL_VALIDATE_ERROR,
/**
* 二级审核失败
*/
TWO_LEVEL_VALIDATE_ERROR
}
export const ORDER_EXAMINE_LIST = ['',
'新增订单',
'一级审核中',
'二级审核中',
'提交订单',
'提交成功',
'一级审核不通过',
'二级审核不通过'
]
// 状态颜色映射
export const StatusColorsMaps = {
ready: '#C0C4CC',
process: '#FFC400',
submit: '#6C9CEB',
success: '#41CC9E',
error: '#EF6260'
}
const matchStatusColor = (status: number): string => {
const maps = {
[ORDER_EXAMINE_ENUM.ADD_ORDER]: StatusColorsMaps.ready,
[ORDER_EXAMINE_ENUM.ONE_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.TWO_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_PROCESS]: StatusColorsMaps.submit,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_SUCCESS]: StatusColorsMaps.success
}
// 默认返回错误的状态颜色
return maps[status] || StatusColorsMaps.error
}
// 订单内部状态显示
const StatusColors: React.FC<StatusColorsProps> = (props) => {
const { status, type, text = null } = props
const statusShowColor = matchStatusColor(status)
// 优先显示 后端返回的状态文本
return (<Tag color={statusShowColor}>{ text }</Tag>)
}
StatusColors.defaultProps = {}
export default StatusColors
import React from 'react' import React from 'react'
import { history } from 'umi' import { history } from 'umi'
import { formatTimeString } from '@/utils' import { formatTimeString } from '@/utils'
import StatusColors from '../components/StatusColors' import StatusColors from '../components/statusColors'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
export const baseOrderListColumns: any = () => { export const baseOrderListColumns: any = () => {
......
...@@ -4,7 +4,7 @@ import { Row, Col, Progress } from 'antd' ...@@ -4,7 +4,7 @@ import { Row, Col, Progress } from 'antd'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
import { formatTimeString } from '@/utils' import { formatTimeString } from '@/utils'
import StatusColors from '../../components/StatusColors' import StatusColors from '../../components/statusColors'
import { FieldTimeOutlined } from '@ant-design/icons' import { FieldTimeOutlined } from '@ant-design/icons'
import { import {
Chart, Chart,
......
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