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

fix: 处理statusColor大小写

parent abb201b4
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 {}
/**
* 流转记录控制
*/
const outOrderCols: any[] = [
{
title: '流转顺序号',
dataIndex: 'no',
align: 'center',
key: 'no',
render: (_, __, index: number) => index + 1
},
{
title: '操作角色',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '状态',
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='out'/>
// @todo 需传递工作流状态重新render
},
{
title: '操作',
dataIndex: 'operation',
align: 'center',
key: 'operation',
},
{
title: '操作时间',
dataIndex: 'operationTime',
align: 'center',
key: 'operationTime',
render: time => formatTimeString(time)
},
{
title: '审核意见',
dataIndex: 'auditOpinion',
align: 'center',
key: 'auditOpinion',
},
]
const sideOrderCols: any[] = [
{
title: '流转记录',
dataIndex: 'no',
align: 'center',
key: 'no',
render: (_, __, index: number) => index + 1
},
{
title: '操作人',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '部门',
dataIndex: 'department',
align: 'center',
key: 'department',
},
{
title: '职位',
dataIndex: 'position',
align: 'center',
key: 'position',
},
{
title: '状态',
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='inside'/>
},
{
title: '操作',
dataIndex: 'operation',
align: 'center',
key: 'operation',
},
{
title: '操作时间',
dataIndex: 'operationTime',
align: 'center',
key: 'operationTime',
},
{
title: '审核意见',
dataIndex: 'auditOpinion',
align: 'center',
key: 'auditOpinion',
},
]
const CirculationRecord:React.FC<CirculationRecordProps> = (props) => {
const colRef = useRef<any>({
columns: outOrderCols
})
const { detailData } = useContext(ReadyAddOrderDetailContext)
const [orderState, setOrderState] = useState<number>(0)
const [dataSource, setDataSource] = useState<any>([])
useEffect(() => {
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'}}>
<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>
<Table
columns={colRef.current.columns}
dataSource={dataSource}
rowKey="id"
/>
</div>
)
}
CirculationRecord.defaultProps = {}
export default CirculationRecord
\ No newline at end of file
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 {}
/**
* 流转记录控制
*/
const outOrderCols: any[] = [
{
title: '流转顺序号',
dataIndex: 'no',
align: 'center',
key: 'no',
render: (_, __, index: number) => index + 1
},
{
title: '操作角色',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '状态',
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='out'/>
// @todo 需传递工作流状态重新render
},
{
title: '操作',
dataIndex: 'operation',
align: 'center',
key: 'operation',
},
{
title: '操作时间',
dataIndex: 'operationTime',
align: 'center',
key: 'operationTime',
render: time => formatTimeString(time)
},
{
title: '审核意见',
dataIndex: 'auditOpinion',
align: 'center',
key: 'auditOpinion',
},
]
const sideOrderCols: any[] = [
{
title: '流转记录',
dataIndex: 'no',
align: 'center',
key: 'no',
render: (_, __, index: number) => index + 1
},
{
title: '操作人',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '部门',
dataIndex: 'department',
align: 'center',
key: 'department',
},
{
title: '职位',
dataIndex: 'position',
align: 'center',
key: 'position',
},
{
title: '状态',
dataIndex: 'state',
align: 'center',
key: 'state',
render: text => <StatusColors status={text} type='inside'/>
},
{
title: '操作',
dataIndex: 'operation',
align: 'center',
key: 'operation',
},
{
title: '操作时间',
dataIndex: 'operationTime',
align: 'center',
key: 'operationTime',
},
{
title: '审核意见',
dataIndex: 'auditOpinion',
align: 'center',
key: 'auditOpinion',
},
]
const CirculationRecord:React.FC<CirculationRecordProps> = (props) => {
const colRef = useRef<any>({
columns: outOrderCols
})
const { detailData } = useContext(ReadyAddOrderDetailContext)
const [orderState, setOrderState] = useState<number>(0)
const [dataSource, setDataSource] = useState<any>([])
useEffect(() => {
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'}}>
<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>
<Table
columns={colRef.current.columns}
dataSource={dataSource}
rowKey="id"
/>
</div>
)
}
CirculationRecord.defaultProps = {}
export default CirculationRecord
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 { history } from 'umi'
import { formatTimeString } from '@/utils'
import StatusColors from '../components/StatusColors'
import StatusColors from '../components/statusColors'
import EyePreview from '@/components/EyePreview'
export const baseOrderListColumns: any = () => {
......
......@@ -4,7 +4,7 @@ import { Row, Col, Progress } from 'antd'
import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'
import { formatTimeString } from '@/utils'
import StatusColors from '../../components/StatusColors'
import StatusColors from '../../components/statusColors'
import { FieldTimeOutlined } from '@ant-design/icons'
import {
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