From 8753881f6570e03305c84fbb80549c8698b07510 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 10 Jul 2023 17:03:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E6=A0=B8=E8=AF=84=E5=88=86=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/data/assess.js | 25 ++- scripts/1.2.3/schema/1.create_assess.sql | 40 +++++ .../src/sections/fillion/actions/assess.js | 2 +- .../fillion/components/assessModal.js | 108 ++++++++++++ .../src/sections/fillion/containers/assess.js | 155 +++++++++++++++++- .../src/sections/fillion/containers/index.js | 3 +- web/client/src/sections/fillion/nav-item.js | 6 +- web/client/src/sections/fillion/routes.js | 12 +- web/client/src/utils/webapi.js | 2 +- 9 files changed, 338 insertions(+), 15 deletions(-) create mode 100644 scripts/1.2.3/schema/1.create_assess.sql create mode 100644 web/client/src/sections/fillion/components/assessModal.js diff --git a/api/app/lib/controllers/data/assess.js b/api/app/lib/controllers/data/assess.js index e974d8a7..0ff55cb1 100644 --- a/api/app/lib/controllers/data/assess.js +++ b/api/app/lib/controllers/data/assess.js @@ -4,7 +4,7 @@ const moment = require('moment') async function assessGet (ctx) { try { const models = ctx.fs.dc.models; - const { unit, month } = ctx.query; + const { unit, month, page, limit } = ctx.query; let findOption = { where: { @@ -21,7 +21,14 @@ async function assessGet (ctx) { findOption.where.unit = unit } - const roadRes = await models.Assess.findAll(findOption) + if (limit) { + findOption.limit = limit + } + if (page && limit) { + findOption.offset = (page - 1) * limit + } + + const roadRes = await models.Assess.findAndCountAll(findOption) ctx.status = 200; ctx.body = roadRes @@ -39,9 +46,23 @@ async function assessEdit (ctx) { const models = ctx.fs.dc.models; const data = ctx.request.body; + const repeatRes = await models.Assess.findOne({ + where: { + unit: data.unit, + month: { $between: [moment(data.month).startOf('month').format(), moment(data.month).endOf('month').format()] } + } + }) + if (!data.assessId) { + if (repeatRes) { + throw '已有相同月份的考核记录' + } + await models.Assess.create(data) } else { + if (repeatRes && repeatRes.id != data.assessId) { + throw '已有相同月份的考核记录' + } await models.Assess.update( data, { where: { diff --git a/scripts/1.2.3/schema/1.create_assess.sql b/scripts/1.2.3/schema/1.create_assess.sql new file mode 100644 index 00000000..4e15db48 --- /dev/null +++ b/scripts/1.2.3/schema/1.create_assess.sql @@ -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); + diff --git a/web/client/src/sections/fillion/actions/assess.js b/web/client/src/sections/fillion/actions/assess.js index 0cc6345b..e76f4bd5 100644 --- a/web/client/src/sections/fillion/actions/assess.js +++ b/web/client/src/sections/fillion/actions/assess.js @@ -30,6 +30,6 @@ export function editAssess (query) { data: query, actionType: 'PUT_ASSESS', url: ApiTable.editAssess, - msg: { option: '编辑或新增考核评分信息' }, + msg: { option: '编辑/新增考核评分信息' }, }); } \ No newline at end of file diff --git a/web/client/src/sections/fillion/components/assessModal.js b/web/client/src/sections/fillion/components/assessModal.js new file mode 100644 index 00000000..5f8eb5b4 --- /dev/null +++ b/web/client/src/sections/fillion/components/assessModal.js @@ -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 ( + { + 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() + }} + > +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ ); +}; + +function mapStateToProps (state) { + const { auth, assess } = state + return { + user: auth.user, + assess: assess.data || [] + } +} +export default connect(mapStateToProps)(AssessModal); diff --git a/web/client/src/sections/fillion/containers/assess.js b/web/client/src/sections/fillion/containers/assess.js index 7828dcfa..7343db9a 100644 --- a/web/client/src/sections/fillion/containers/assess.js +++ b/web/client/src/sections/fillion/containers/assess.js @@ -1,24 +1,167 @@ import React, { useState, useEffect } from 'react'; 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(() => { - - return () => { - }; + return () => { }; }, []); + useEffect(() => { + getData() + }, [query]) + + const getData = () => { + setLoading(true) + dispatch(getAssess(query)).then(res => { + setLoading(false) + }) + } + return (
- +
+
{ + setQuery({ ...query, unit: v.unit, month: v.month ? moment(v.month).format() : undefined }) + }}> + + + + + + + + + + + +
+ + +
+ ( + text ? moment(record.month).format('YYYY-MM') : '' + ) + }, + { + title: '考核得分', + dataIndex: 'totalPoints', + key: 'totalPoints', + }, + { + title: '操作', + key: 'action', + render: (text, record) => ( + + + + { + setLoading(true) + dispatch(delAssess({ id: record.id })).then(res => { + setLoading(false) + if (res.success) { + getData() + } + }) + }} + > + + + + ), + },]} + 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 ? { + getData() + setIsCheck(false) + setEditData(null) + setAssessModalVisible(false) + }} /> : '' + }
); } function mapStateToProps (state) { - const { auth } = state + const { auth, assess } = state return { user: auth.user, + assess: assess.data || [], } } export default connect(mapStateToProps)(Assess); \ No newline at end of file diff --git a/web/client/src/sections/fillion/containers/index.js b/web/client/src/sections/fillion/containers/index.js index dc231384..93435b4e 100644 --- a/web/client/src/sections/fillion/containers/index.js +++ b/web/client/src/sections/fillion/containers/index.js @@ -14,4 +14,5 @@ import Patrol from './patrol'; import File from './file'; import Jiekouguanli from './jiekouguanli'; import Task from './task' -export { Infor, transportation, BridgeTable, HigHways, OperaTional, Enforce, Public, Videois, PromoTional, Maintenance, Patrol, File, Jiekouguanli, Task }; \ No newline at end of file +import Assess from './assess' +export { Infor, transportation, BridgeTable, HigHways, OperaTional, Enforce, Public, Videois, PromoTional, Maintenance, Patrol, File, Jiekouguanli, Task, Assess }; \ No newline at end of file diff --git a/web/client/src/sections/fillion/nav-item.js b/web/client/src/sections/fillion/nav-item.js index 57cc1deb..349ab5b7 100644 --- a/web/client/src/sections/fillion/nav-item.js +++ b/web/client/src/sections/fillion/nav-item.js @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'; import { Menu } from 'antd'; import { ReadOutlined } from '@ant-design/icons'; const SubMenu = Menu.SubMenu; -export function getNavItem(user, dispatch) { +export function getNavItem (user, dispatch) { const isshow = user?.userResources?. filter(i => i.resourceId === 'OVERLOADMANAGE' || i.resourceId === 'ROADMANAGE' || @@ -84,6 +84,10 @@ export function getNavItem(user, dispatch) { 建设上报 : ''} + + + 考核评分 + : null ); } diff --git a/web/client/src/sections/fillion/routes.js b/web/client/src/sections/fillion/routes.js index c4fc6448..ce477b61 100644 --- a/web/client/src/sections/fillion/routes.js +++ b/web/client/src/sections/fillion/routes.js @@ -12,7 +12,8 @@ import { Maintenance } from './containers' import { Patrol } from './containers' import { File } from './containers'; import { Jiekouguanli } from './containers' -import { Task } from './containers' +import { Task, Assess } from './containers' + export default [{ type: 'inner', route: { @@ -116,13 +117,18 @@ export default [{ menuSelectKeys: ['jiekouguanli'], component: Jiekouguanli, breadcrumb: '接口管理', - } - , { + }, { path: '/promotional', key: 'fillionpromotional', menuSelectKeys: ['fillionpromotional'], component: PromoTional, breadcrumb: '视频管理', + }, { + path: '/assess', + key: 'fillionassess', + menuSelectKeys: ['fillionassess'], + component: Assess, + breadcrumb: '考核评分', } ] } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index a4bb27e0..cdda9456 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -168,7 +168,7 @@ export const ApiTable = { // 考核评分 getAssess: 'assess', - putAssess: 'assess', + editAssess: 'assess', delAssess: 'assess/{assessId}', //工程数据