9 changed files with 338 additions and 15 deletions
			
			
		@ -0,0 +1,40 @@ | 
				
			|||||
 | 
					create table if not exists assess | 
				
			||||
 | 
					( | 
				
			||||
 | 
					    id                            serial not null | 
				
			||||
 | 
					        constraint assess_pk | 
				
			||||
 | 
					            primary key, | 
				
			||||
 | 
					    unit                          varchar(64), | 
				
			||||
 | 
					    month                         timestamp with time zone, | 
				
			||||
 | 
					    total_points                  double precision, | 
				
			||||
 | 
					    industry_points               double precision, | 
				
			||||
 | 
					    industry_out_points           double precision, | 
				
			||||
 | 
					    plus_or_subtract              double precision, | 
				
			||||
 | 
					    "industry_deduction_reason "  varchar(1024), | 
				
			||||
 | 
					    industry_out_deduction_reason varchar(1024), | 
				
			||||
 | 
					    remark                        varchar(1024) | 
				
			||||
 | 
					); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on table assess is '考核评分'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.unit is '考核单位'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.month is '考核月份'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.total_points is '总分'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.industry_points is '业内得分'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.industry_out_points is '业外得分'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.plus_or_subtract is '加减得分'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess."industry_deduction_reason " is '业内扣分原因 | 
				
			||||
 | 
					'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.industry_out_deduction_reason is '业外扣分原因'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					comment on column assess.remark is '备注'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					create unique index if not exists assess_id_uindex | 
				
			||||
 | 
					    on assess (id); | 
				
			||||
 | 
					
 | 
				
			||||
@ -0,0 +1,108 @@ | 
				
			|||||
 | 
					import React, { useState, useEffect } from 'react'; | 
				
			||||
 | 
					import { connect } from 'react-redux'; | 
				
			||||
 | 
					import { Form, Input, Select, DatePicker, InputNumber, Button, Modal } from 'antd'; | 
				
			||||
 | 
					import { unitList } from '../containers/assess' | 
				
			||||
 | 
					import { getAssess, delAssess, editAssess } from '../actions/assess'; | 
				
			||||
 | 
					import moment from 'moment'; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					const { Option } = Select; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					const AssessModal = ({ editData, check, visible, onCancel, dispatch }) => { | 
				
			||||
 | 
					    const [form] = Form.useForm(); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    return ( | 
				
			||||
 | 
					        <Modal | 
				
			||||
 | 
					            title="考核评分" | 
				
			||||
 | 
					            open={visible} | 
				
			||||
 | 
					            visible={visible} | 
				
			||||
 | 
					            cancelButtonProps={{ | 
				
			||||
 | 
					                disabled: check, | 
				
			||||
 | 
					            }} | 
				
			||||
 | 
					            onOk={() => { | 
				
			||||
 | 
					                if (check) { | 
				
			||||
 | 
					                    return onCancel() | 
				
			||||
 | 
					                } | 
				
			||||
 | 
					                form.validateFields().then(values => { | 
				
			||||
 | 
					                    dispatch(editAssess({ | 
				
			||||
 | 
					                        ...values, | 
				
			||||
 | 
					                        month: moment(values.month).format('YYYY-MM-DD'), | 
				
			||||
 | 
					                        assessId: editData ? editData.id : undefined | 
				
			||||
 | 
					                    })).then(res => { | 
				
			||||
 | 
					                        if (res.success) { | 
				
			||||
 | 
					                            onCancel() | 
				
			||||
 | 
					                        } | 
				
			||||
 | 
					                    }) | 
				
			||||
 | 
					                }) | 
				
			||||
 | 
					            }} | 
				
			||||
 | 
					            onCancel={() => { | 
				
			||||
 | 
					                onCancel() | 
				
			||||
 | 
					            }} | 
				
			||||
 | 
					        > | 
				
			||||
 | 
					            <Form | 
				
			||||
 | 
					                form={form} | 
				
			||||
 | 
					                initialValues={editData ? { | 
				
			||||
 | 
					                    ...editData, | 
				
			||||
 | 
					                    month: moment(editData.month), | 
				
			||||
 | 
					                } : {}} | 
				
			||||
 | 
					                disabled={check} | 
				
			||||
 | 
					                labelCol={{ | 
				
			||||
 | 
					                    span: 6, | 
				
			||||
 | 
					                }} | 
				
			||||
 | 
					                wrapperCol={{ | 
				
			||||
 | 
					                    span: 18, | 
				
			||||
 | 
					                }} | 
				
			||||
 | 
					            > | 
				
			||||
 | 
					                <Form.Item name="unit" label="管养责任单位" rules={[{ required: true, message: '请填写' }]}> | 
				
			||||
 | 
					                    <Select> | 
				
			||||
 | 
					                        { | 
				
			||||
 | 
					                            unitList.map(item => ( | 
				
			||||
 | 
					                                <Option value={item} key={item} /> | 
				
			||||
 | 
					                            )) | 
				
			||||
 | 
					                        } | 
				
			||||
 | 
					                    </Select> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="month" label="考核月份" rules={[{ required: true, message: '请填写' }]}> | 
				
			||||
 | 
					                    <DatePicker picker="month" /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="totalPoints" label="考核总分" rules={[{ required: true, message: '请填写' }]}> | 
				
			||||
 | 
					                    <InputNumber step={0.1} precision={1} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="industryPoints" label="内业得分"> | 
				
			||||
 | 
					                    <InputNumber step={0.1} precision={1} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="industryOutPoints" label="外业得分"> | 
				
			||||
 | 
					                    <InputNumber step={0.1} precision={1} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="plusOrSubtract" label="加减分"> | 
				
			||||
 | 
					                    <InputNumber step={0.1} precision={1} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="industryDeductionReason" label="内业扣分原因"> | 
				
			||||
 | 
					                    <Input.TextArea rows={4} maxLength={1024} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="industryOutDeductionReason" label="外业扣分原因"> | 
				
			||||
 | 
					                    <Input.TextArea rows={4} maxLength={1024} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Form.Item name="remark" label="备注"> | 
				
			||||
 | 
					                    <Input.TextArea rows={4} maxLength={1024} /> | 
				
			||||
 | 
					                </Form.Item> | 
				
			||||
 | 
					            </Form> | 
				
			||||
 | 
					        </Modal> | 
				
			||||
 | 
					    ); | 
				
			||||
 | 
					}; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					function mapStateToProps (state) { | 
				
			||||
 | 
					    const { auth, assess } = state | 
				
			||||
 | 
					    return { | 
				
			||||
 | 
					        user: auth.user, | 
				
			||||
 | 
					        assess: assess.data || [] | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
 | 
					export default connect(mapStateToProps)(AssessModal); | 
				
			||||
@ -1,24 +1,167 @@ | 
				
			|||||
import React, { useState, useEffect } from 'react'; | 
					import React, { useState, useEffect } from 'react'; | 
				
			||||
import { connect } from 'react-redux'; | 
					import { connect } from 'react-redux'; | 
				
			||||
 | 
					import { getAssess, delAssess, editAssess } from '../actions/assess'; | 
				
			||||
 | 
					import ProTable from '@ant-design/pro-table'; | 
				
			||||
 | 
					import AssessModal from '../components/assessModal'; | 
				
			||||
 | 
					import { Form, Space, DatePicker, Button, Select, Popconfirm } from 'antd' | 
				
			||||
 | 
					import moment from 'moment'; | 
				
			||||
 | 
					
 | 
				
			||||
function Assess () { | 
					export const unitList = [ | 
				
			||||
 | 
					    '县道', | 
				
			||||
 | 
					    '蒋巷镇', | 
				
			||||
 | 
					    '三江镇', | 
				
			||||
 | 
					    '塔城乡', | 
				
			||||
 | 
					    '泾口乡', | 
				
			||||
 | 
					    '八一乡', | 
				
			||||
 | 
					    '冈上镇', | 
				
			||||
 | 
					    '南新乡', | 
				
			||||
 | 
					    '富山乡', | 
				
			||||
 | 
					    '莲塘镇', | 
				
			||||
 | 
					    '金湖管理处', | 
				
			||||
 | 
					    '武阳镇', | 
				
			||||
 | 
					    '向塘镇', | 
				
			||||
 | 
					    '幽兰镇', | 
				
			||||
 | 
					    '广福镇', | 
				
			||||
 | 
					    '塘南镇', | 
				
			||||
 | 
					    '银三角管委会', | 
				
			||||
 | 
					    '黄马乡', | 
				
			||||
 | 
					] | 
				
			||||
 | 
					function Assess (props) { | 
				
			||||
 | 
					    const { dispatch, assess } = props; | 
				
			||||
 | 
					    const [assessModalVisible, setAssessModalVisible] = useState(false); | 
				
			||||
 | 
					    const [editData, setEditData] = useState(null); | 
				
			||||
 | 
					    const [query, setQuery] = useState({ page: 1, pageSize: 10 }) | 
				
			||||
 | 
					    const [loading, setLoading] = useState(false); | 
				
			||||
 | 
					    const [isCheck, setIsCheck] = useState(false) | 
				
			||||
 | 
					
 | 
				
			||||
    useEffect(() => { | 
					    useEffect(() => { | 
				
			||||
 | 
					        return () => { }; | 
				
			||||
        return () => { | 
					 | 
				
			||||
        }; | 
					 | 
				
			||||
    }, []); | 
					    }, []); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    useEffect(() => { | 
				
			||||
 | 
					        getData() | 
				
			||||
 | 
					    }, [query]) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    const getData = () => { | 
				
			||||
 | 
					        setLoading(true) | 
				
			||||
 | 
					        dispatch(getAssess(query)).then(res => { | 
				
			||||
 | 
					            setLoading(false) | 
				
			||||
 | 
					        }) | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
    return ( | 
					    return ( | 
				
			||||
        <div> | 
					        <div> | 
				
			||||
 | 
					            <div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between' }}> | 
				
			||||
 | 
					                <Form layout="inline" onFinish={(v) => { | 
				
			||||
 | 
					                    setQuery({ ...query, unit: v.unit, month: v.month ? moment(v.month).format() : undefined }) | 
				
			||||
 | 
					                }}> | 
				
			||||
 | 
					                    <Form.Item name="unit" label="责任单位" > | 
				
			||||
 | 
					                        <Select style={{ width: 200 }} placeholder="全部" allowClear> | 
				
			||||
 | 
					                            { | 
				
			||||
 | 
					                                unitList.map(item => ( | 
				
			||||
 | 
					                                    <Option value={item} key={item} /> | 
				
			||||
 | 
					                                )) | 
				
			||||
 | 
					                            } | 
				
			||||
 | 
					                        </Select> | 
				
			||||
 | 
					                    </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                    <Form.Item name="month" label="考核月份"> | 
				
			||||
 | 
					                        <DatePicker picker="month" style={{ width: 200 }} /> | 
				
			||||
 | 
					                    </Form.Item> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                    <Form.Item> | 
				
			||||
 | 
					                        <Button type="primary" htmlType="submit">搜索</Button> | 
				
			||||
 | 
					                    </Form.Item> | 
				
			||||
 | 
					                </Form> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					                <Button type="primary" onClick={() => { | 
				
			||||
 | 
					                    setAssessModalVisible(true) | 
				
			||||
 | 
					                }}>新增</Button> | 
				
			||||
 | 
					            </div> | 
				
			||||
 | 
					            <ProTable | 
				
			||||
 | 
					                columns={[{ | 
				
			||||
 | 
					                    title: '责任单位', | 
				
			||||
 | 
					                    dataIndex: 'unit', | 
				
			||||
 | 
					                    key: 'unit', | 
				
			||||
 | 
					                }, | 
				
			||||
 | 
					                { | 
				
			||||
 | 
					                    title: '考核月份', | 
				
			||||
 | 
					                    dataIndex: 'month', | 
				
			||||
 | 
					                    key: 'month', | 
				
			||||
 | 
					                    render: (text, record) => ( | 
				
			||||
 | 
					                        text ? moment(record.month).format('YYYY-MM') : '' | 
				
			||||
 | 
					                    ) | 
				
			||||
 | 
					                }, | 
				
			||||
 | 
					                { | 
				
			||||
 | 
					                    title: '考核得分', | 
				
			||||
 | 
					                    dataIndex: 'totalPoints', | 
				
			||||
 | 
					                    key: 'totalPoints', | 
				
			||||
 | 
					                }, | 
				
			||||
 | 
					                { | 
				
			||||
 | 
					                    title: '操作', | 
				
			||||
 | 
					                    key: 'action', | 
				
			||||
 | 
					                    render: (text, record) => ( | 
				
			||||
 | 
					                        <span> | 
				
			||||
 | 
					                            <Button type="link" onClick={() => { | 
				
			||||
 | 
					                                setAssessModalVisible(true) | 
				
			||||
 | 
					                                setEditData(record) | 
				
			||||
 | 
					                                setIsCheck(true) | 
				
			||||
 | 
					                            }}>详情</Button> | 
				
			||||
 | 
					                            <Button type="link" onClick={() => { | 
				
			||||
 | 
					                                setAssessModalVisible(true) | 
				
			||||
 | 
					                                setEditData(record) | 
				
			||||
 | 
					                            }}>编辑</Button> | 
				
			||||
 | 
					                            <Popconfirm | 
				
			||||
 | 
					                                title="确定删除此条数据吗?" | 
				
			||||
 | 
					                                onConfirm={() => { | 
				
			||||
 | 
					                                    setLoading(true) | 
				
			||||
 | 
					                                    dispatch(delAssess({ id: record.id })).then(res => { | 
				
			||||
 | 
					                                        setLoading(false) | 
				
			||||
 | 
					                                        if (res.success) { | 
				
			||||
 | 
					                                            getData() | 
				
			||||
 | 
					                                        } | 
				
			||||
 | 
					                                    }) | 
				
			||||
 | 
					                                }} | 
				
			||||
 | 
					                            > | 
				
			||||
 | 
					                                <Button type="link" danger>删除</Button> | 
				
			||||
 | 
					                            </Popconfirm> | 
				
			||||
 | 
					                        </span> | 
				
			||||
 | 
					                    ), | 
				
			||||
 | 
					                },]} | 
				
			||||
 | 
					                dataSource={assess.rows || []} | 
				
			||||
 | 
					                loading={loading} | 
				
			||||
 | 
					                pagination={{ | 
				
			||||
 | 
					                    total: assess?.count || 0, | 
				
			||||
 | 
					                    pageSize: 10, | 
				
			||||
 | 
					                    defaultPageSize: 10, | 
				
			||||
 | 
					                    showSizeChanger: false, | 
				
			||||
 | 
					                    onChange: (page, pageSize) => { | 
				
			||||
 | 
					                        setQuery({ | 
				
			||||
 | 
					                            ...query, | 
				
			||||
 | 
					                            page, limit: pageSize | 
				
			||||
 | 
					                        }) | 
				
			||||
 | 
					                    } | 
				
			||||
 | 
					                }} | 
				
			||||
 | 
					                rowKey="key" | 
				
			||||
 | 
					                toolBarRender={false} | 
				
			||||
 | 
					                search={false} | 
				
			||||
 | 
					            /> | 
				
			||||
 | 
					            { | 
				
			||||
 | 
					                assessModalVisible ? <AssessModal check={isCheck} visible={assessModalVisible} editData={editData} onCancel={() => { | 
				
			||||
 | 
					                    getData() | 
				
			||||
 | 
					                    setIsCheck(false) | 
				
			||||
 | 
					                    setEditData(null) | 
				
			||||
 | 
					                    setAssessModalVisible(false) | 
				
			||||
 | 
					                }} /> : '' | 
				
			||||
 | 
					            } | 
				
			||||
        </div> | 
					        </div> | 
				
			||||
    ); | 
					    ); | 
				
			||||
} | 
					} | 
				
			||||
function mapStateToProps (state) { | 
					function mapStateToProps (state) { | 
				
			||||
    const { auth } = state | 
					    const { auth, assess } = state | 
				
			||||
    return { | 
					    return { | 
				
			||||
        user: auth.user, | 
					        user: auth.user, | 
				
			||||
 | 
					        assess: assess.data || [], | 
				
			||||
    } | 
					    } | 
				
			||||
} | 
					} | 
				
			||||
export default connect(mapStateToProps)(Assess); | 
					export default connect(mapStateToProps)(Assess); | 
				
			||||
					Loading…
					
					
				
		Reference in new issue