@ -13,17 +13,17 @@ import {
message ,
} from 'antd' ;
import type { TablePaginationConfig } from 'antd' ;
import {
SearchOutlined ,
DeleteOutlined ,
} from '@ant-design/icons' ;
import { SearchOutlined , DeleteOutlined } from '@ant-design/icons' ;
import { TaskStatusText , TaskStatusColor } from '@/dicts/supplierTaskDict' ;
import { history , useIntl } from 'umi' ;
import { getEvaluateResultList , submitTaskForApproval , supplierChangeApprove } from '@/servers/api/supplierEvaluate' ;
import {
getEvaluateResultList ,
submitTaskForApproval ,
supplierChangeApprove ,
} from '@/servers/api/supplierEvaluate' ;
import { getDictList } from '@/servers/api/dicts' ;
import type { DictItem } from '@/servers/api/dicts' ;
import { render } from 'react-dom' ;
// 扩展评价任务搜索参数类型
interface EvaluateTaskSearchParams {
@ -33,29 +33,26 @@ interface EvaluateTaskSearchParams {
[ key : string ] : any ;
}
const { Option } = Select ;
const { RangePicker } = DatePicker ;
const SupplierEvaluateResult : React.FC = ( ) = > {
const userId = sessionStorage . getItem ( 'userId' ) || '' ;
const intl = useIntl ( ) ;
const [ loading , setLoading ] = useState < boolean > ( false ) ;
const [ loading , setLoading ] = useState < boolean >( false ) ;
const [ form ] = Form . useForm ( ) ;
const [ resultData , setResultData ] = useState < SupplierEvaluateResult. EvaluateTaskItem [ ] > ( [ ] ) ;
const [ pagination , setPagination ] = useState < TablePaginationConfig > ( {
const [ resultData , setResultData ] = useState < SupplierEvaluateResult. EvaluateTaskItem [ ] >( [ ] ) ;
const [ pagination , setPagination ] = useState < TablePaginationConfig >( {
current : 1 ,
pageSize : 10 ,
total : 0 ,
showSizeChanger : true ,
showQuickJumper : true ,
showTotal : ( total ) = > intl . formatMessage (
{ id : 'supplierEvaluateResult.pagination.total' } ,
{ total }
) ,
showTotal : ( total ) = >
intl . formatMessage ( { id : 'supplierEvaluateResult.pagination.total' } , { total } ) ,
} ) ;
const [ searchParams , setSearchParams ] = useState < EvaluateTaskSearchParams > ( { } ) ;
const [ evaluateStatus , setEvaluateStatus ] = useState < DictItem [ ] > ( [ ] ) ;
const [ searchParams , setSearchParams ] = useState < EvaluateTaskSearchParams >( { } ) ;
const [ evaluateStatus , setEvaluateStatus ] = useState < DictItem [ ] >( [ ] ) ;
// 获取评价结果列表
const fetchResultList = async (
current = 1 ,
@ -75,7 +72,7 @@ const SupplierEvaluateResult: React.FC = () => {
pageNo : current ,
pageSize : pageSize ,
} ,
selectBy : " create" ,
selectBy : ' create' ,
} ;
// 添加搜索条件
@ -96,7 +93,7 @@ const SupplierEvaluateResult: React.FC = () => {
const { records , total , current : currentPage , size } = response . data ;
// 处理数据, 增加表格需要的key属性
const formattedData = records . map ( record = > ( {
const formattedData = records . map ( ( record ) = > ( {
. . . record ,
key : record.id ,
} ) ) ;
@ -109,7 +106,10 @@ const SupplierEvaluateResult: React.FC = () => {
total ,
} ) ;
} else {
message . error ( response . message || intl . formatMessage ( { id : 'supplierEvaluateResult.message.fetchFailed' } ) ) ;
message . error (
response . message ||
intl . formatMessage ( { id : 'supplierEvaluateResult.message.fetchFailed' } ) ,
) ;
}
} catch ( error ) {
console . error ( '获取评价结果列表失败:' , error ) ;
@ -118,6 +118,7 @@ const SupplierEvaluateResult: React.FC = () => {
setLoading ( false ) ;
}
} ;
const [ approveTypeList , setApproveTypeList ] = useState < DictItem [ ] > ( [ ] ) ;
// 首次加载获取数据
useEffect ( ( ) = > {
@ -127,6 +128,12 @@ const SupplierEvaluateResult: React.FC = () => {
setEvaluateStatus ( res . data ) ;
}
} ) ;
// 获取审批状态字典
getDictList ( 'approve_type' ) . then ( ( res ) = > {
if ( res . success ) {
setApproveTypeList ( res . data ) ;
}
} ) ;
} , [ ] ) ;
// 处理表格分页变化
@ -158,7 +165,7 @@ const SupplierEvaluateResult: React.FC = () => {
title : intl.formatMessage ( { id : 'supplierEvaluateResult.confirm.title' } ) ,
content : intl.formatMessage (
{ id : 'supplierEvaluateResult.confirm.content' } ,
{ theme : record.evaluateTheme }
{ theme : record.evaluateTheme } ,
) ,
okText : intl.formatMessage ( { id : 'supplierEvaluateResult.confirm.ok' } ) ,
cancelText : intl.formatMessage ( { id : 'supplierEvaluateResult.confirm.cancel' } ) ,
@ -166,17 +173,22 @@ const SupplierEvaluateResult: React.FC = () => {
try {
const response = await submitTaskForApproval ( record . id ) ;
if ( response . success ) {
message . success ( intl . formatMessage ( { id : 'supplierEvaluateResult.message.approveSuccess' } ) ) ;
message . success (
intl . formatMessage ( { id : 'supplierEvaluateResult.message.approveSuccess' } ) ,
) ;
// 刷新数据
fetchResultList ( pagination . current , pagination . pageSize , searchParams ) ;
} else {
message . error ( response . message || intl . formatMessage ( { id : 'supplierEvaluateResult.message.approveFailed' } ) ) ;
message . error (
response . message ||
intl . formatMessage ( { id : 'supplierEvaluateResult.message.approveFailed' } ) ,
) ;
}
} catch ( error ) {
console . error ( '提交审批失败:' , error ) ;
message . error ( intl . formatMessage ( { id : 'supplierEvaluateResult.message.approveError' } ) ) ;
}
}
} ,
} ) ;
} ;
@ -184,11 +196,10 @@ const SupplierEvaluateResult: React.FC = () => {
const handleViewDetail = ( record : SupplierEvaluateResult.EvaluateTaskItem ) = > {
history . push ( {
pathname : 'supplierEvaluateResultInfo' ,
state : { record }
state : { record } ,
} ) ;
} ;
const columns = [
{
title : intl.formatMessage ( { id : 'supplierEvaluateResult.column.index' } ) ,
@ -219,7 +230,10 @@ const SupplierEvaluateResult: React.FC = () => {
showTitle : false ,
} ,
render : ( text : string ) = > (
< Tooltip placement = "topLeft" title = { text || intl . formatMessage ( { id : 'supplierEvaluateResult.text.unspecified' } ) } >
< Tooltip
placement = "topLeft"
title = { text || intl . formatMessage ( { id : 'supplierEvaluateResult.text.unspecified' } ) }
>
{ text || intl . formatMessage ( { id : 'supplierEvaluateResult.text.unspecified' } ) }
< / Tooltip >
) ,
@ -258,9 +272,12 @@ const SupplierEvaluateResult: React.FC = () => {
} ,
{
title : intl.formatMessage ( { id : 'supplierEvaluateResult.column.approveName' } ) ,
dataIndex : 'approveName ' ,
key : 'approveName ' ,
dataIndex : 'approveStatus ' ,
key : 'approveStatus ' ,
width : 100 ,
render : ( text : string , record : any ) = > (
< div > { approveTypeList . find ( ( item ) = > item . code === text ) ? . dicName || '-' } < / div >
) ,
} ,
{
title : intl.formatMessage ( { id : 'supplierEvaluateResult.column.action' } ) ,
@ -278,11 +295,16 @@ const SupplierEvaluateResult: React.FC = () => {
< / Button >
) }
{ record . approveStatus === '0' && userId == '8' && (
< Button type = "link" onClick = { ( ) = > {
supplierChangeApprove ( { workFlowId : record.workFlowId , approveStatus : '1' } ) . then ( ( ) = > {
handleReset ( )
} )
} } >
< Button
type = "link"
onClick = { ( ) = > {
supplierChangeApprove ( { workFlowId : record.workFlowId , approveStatus : '1' } ) . then (
( ) = > {
handleReset ( ) ;
} ,
) ;
} }
>
审 批
< / Button >
) }
@ -294,27 +316,38 @@ const SupplierEvaluateResult: React.FC = () => {
return (
< div className = "common-container" >
< div className = "filter-action-row" >
< Form
form = { form }
layout = "inlin e"
onFinish = { handleSearch }
className = "filter-form"
< Form form = { form } layout = "inline" onFinish = { handleSearch } className = "filter-form" >
< Form.Item
name = "evaluateThem e"
label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.evaluateTheme' } ) }
>
< Form.Item name = "evaluateTheme" label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.evaluateTheme' } ) } >
< Input placeholder = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.placeholder.evaluateTheme' } ) } allowClear / >
< Input
placeholder = { intl . formatMessage ( {
id : 'supplierEvaluateResult.form.placeholder.evaluateTheme' ,
} ) }
allowClear
/ >
< / Form.Item >
< Form.Item name = "timeRange" label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.evaluationTime' } ) } >
< Form.Item
name = "timeRange"
label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.evaluationTime' } ) }
>
< RangePicker
placeholder = { [
intl . formatMessage ( { id : 'supplierEvaluateResult.form.placeholder.startDate' } ) ,
intl . formatMessage ( { id : 'supplierEvaluateResult.form.placeholder.endDate' } )
intl . formatMessage ( { id : 'supplierEvaluateResult.form.placeholder.endDate' } ) ,
] }
format = "YYYY-MM-DD"
/ >
< / Form.Item >
< Form.Item name = "status" label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.status' } ) } >
< Form.Item
name = "status"
label = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.status' } ) }
>
< Select
placeholder = { intl . formatMessage ( { id : 'supplierEvaluateResult.form.placeholder.status' } ) }
placeholder = { intl . formatMessage ( {
id : 'supplierEvaluateResult.form.placeholder.status' ,
} ) }
allowClear
style = { { width : 150 } }
>
@ -329,12 +362,7 @@ const SupplierEvaluateResult: React.FC = () => {
< Button type = "primary" icon = { < SearchOutlined / > } onClick = { ( ) = > form . submit ( ) } >
{ intl . formatMessage ( { id : 'supplierEvaluateResult.button.search' } ) }
< / Button >
< Button
type = "primary"
danger
icon = { < DeleteOutlined / > }
onClick = { handleReset }
>
< Button type = "primary" danger icon = { < DeleteOutlined / > } onClick = { handleReset } >
{ intl . formatMessage ( { id : 'supplierEvaluateResult.button.reset' } ) }
< / Button >
< / Form.Item >