From f7ef80b552cfc4d6fba557aafe26c21072e06d13 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 10 Jul 2023 15:18:29 +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=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/data/assess.js | 86 ++++++++++++++ api/app/lib/models/assess.js | 106 ++++++++++++++++++ api/app/lib/routes/data/index.js | 13 +++ api/sequelize-automate.config.js | 10 +- .../src/sections/fillion/actions/assess.js | 35 ++++++ .../src/sections/fillion/actions/index.js | 3 + .../src/sections/fillion/containers/assess.js | 24 ++++ web/client/src/utils/webapi.js | 6 + 8 files changed, 278 insertions(+), 5 deletions(-) create mode 100644 api/app/lib/controllers/data/assess.js create mode 100644 api/app/lib/models/assess.js create mode 100644 web/client/src/sections/fillion/actions/assess.js create mode 100644 web/client/src/sections/fillion/containers/assess.js diff --git a/api/app/lib/controllers/data/assess.js b/api/app/lib/controllers/data/assess.js new file mode 100644 index 00000000..e974d8a7 --- /dev/null +++ b/api/app/lib/controllers/data/assess.js @@ -0,0 +1,86 @@ +'use strict'; +const moment = require('moment') + +async function assessGet (ctx) { + try { + const models = ctx.fs.dc.models; + const { unit, month } = ctx.query; + + let findOption = { + where: { + + }, + order: [['id', 'DESC']] + } + if (month) { + findOption.where.month = { + $between: [moment(month).startOf('month').format(), moment(month).endOf('month').format()] + } + } + if (unit) { + findOption.where.unit = unit + } + + const roadRes = await models.Assess.findAll(findOption) + + ctx.status = 200; + ctx.body = roadRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +async function assessEdit (ctx) { + try { + const models = ctx.fs.dc.models; + const data = ctx.request.body; + + if (!data.assessId) { + await models.Assess.create(data) + } else { + await models.Assess.update( + data, { + where: { + id: data.assessId + } + }) + } + + ctx.status = 204 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +async function assessDel (ctx) { + try { + const models = ctx.fs.dc.models; + const { assessId } = ctx.params; + + await models.Assess.destroy({ + where: { + id: assessId + } + }) + + ctx.status = 204 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +module.exports = { + assessGet, assessEdit, assessDel, +}; \ No newline at end of file diff --git a/api/app/lib/models/assess.js b/api/app/lib/models/assess.js new file mode 100644 index 00000000..050b9414 --- /dev/null +++ b/api/app/lib/models/assess.js @@ -0,0 +1,106 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const Assess = sequelize.define("assess", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "assess_id_uindex" + }, + unit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "考核单位", + primaryKey: false, + field: "unit", + autoIncrement: false + }, + month: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "考核月份", + primaryKey: false, + field: "month", + autoIncrement: false + }, + totalPoints: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: "总分", + primaryKey: false, + field: "total_points", + autoIncrement: false + }, + industryPoints: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: "业内得分", + primaryKey: false, + field: "industry_points", + autoIncrement: false + }, + industryOutPoints: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: "业外得分", + primaryKey: false, + field: "industry_out_points", + autoIncrement: false + }, + plusOrSubtract: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: "加减得分", + primaryKey: false, + field: "plus_or_subtract", + autoIncrement: false + }, + industryDeductionReason: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "业内扣分原因\n", + primaryKey: false, + field: "industry_deduction_reason ", + autoIncrement: false + }, + industryOutDeductionReason: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "业外扣分原因", + primaryKey: false, + field: "industry_out_deduction_reason", + autoIncrement: false + }, + remark: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "备注", + primaryKey: false, + field: "remark", + autoIncrement: false + } + }, { + tableName: "assess", + comment: "", + indexes: [] + }); + dc.models.Assess = Assess; + return Assess; +}; \ No newline at end of file diff --git a/api/app/lib/routes/data/index.js b/api/app/lib/routes/data/index.js index 83d12f7c..bc2d012a 100644 --- a/api/app/lib/routes/data/index.js +++ b/api/app/lib/routes/data/index.js @@ -9,6 +9,8 @@ const bus = require('../../controllers/data/bus'); const publicity = require('../../controllers/data/publicity'); const dataIndex = require('../../controllers/data/index'); const task = require('../../controllers/data/task') +const assess = require('../../controllers/data/assess') + module.exports = function (app, router, opts) { // 数据导出 @@ -180,4 +182,15 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['PUT/task'] = { content: '编辑任务', visible: false }; router.put('/task', task.editTask); //task END + + // 评分考核 + app.fs.api.logAttr['GET/assess'] = { content: '获取评分考核数据', visible: true }; + router.get('/assess', assess.assessGet); + + app.fs.api.logAttr['PUT/assess'] = { content: '编辑评分考核数据', visible: true }; + router.put('/assess', assess.assessEdit); + + app.fs.api.logAttr['DEL/assess/:assessId'] = { content: '删除评分考核数据', visible: false }; + router.del('/assess/:assessId', assess.assessDel); + // 评分考核 END }; diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js index e741521e..4d844600 100644 --- a/api/sequelize-automate.config.js +++ b/api/sequelize-automate.config.js @@ -1,11 +1,11 @@ module.exports = { // 数据库配置 与 sequelize 相同 dbOptions: { - database: 'highways4good', - username: 'postgres', - password: '123', + database: 'highway4goodn0728', + username: 'FashionAdmin', + password: '123456', dialect: 'postgres', - host: '10.8.30.32', + host: '10.8.30.156', port: 5432, define: { underscored: false, @@ -27,7 +27,7 @@ module.exports = { dir: './app/lib/models', // 指定输出 models 文件的目录 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir` - tables: null, // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 + tables: ['assess'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/web/client/src/sections/fillion/actions/assess.js b/web/client/src/sections/fillion/actions/assess.js new file mode 100644 index 00000000..0cc6345b --- /dev/null +++ b/web/client/src/sections/fillion/actions/assess.js @@ -0,0 +1,35 @@ +import { basicAction } from '@peace/utils' +import { ApiTable } from '$utils' + +export function getAssess (query) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + query: query, + actionType: 'GET_ASSESS', + url: ApiTable.getAssess, + msg: { error: '获取考核评分信息' }, + reducer: { name: 'assess' } + }); +} + +export function delAssess (query) { + return dispatch => basicAction({ + type: 'del', + dispatch: dispatch, + actionType: 'DEL_ASSESS', + url: ApiTable.delAssess.replace("{assessId}", query?.id), + msg: { option: '删除考核评分信息' }, + }); +} + +export function editAssess (query) { + return dispatch => basicAction({ + type: 'put', + dispatch: dispatch, + data: query, + actionType: 'PUT_ASSESS', + url: ApiTable.editAssess, + msg: { option: '编辑或新增考核评分信息' }, + }); +} \ No newline at end of file diff --git a/web/client/src/sections/fillion/actions/index.js b/web/client/src/sections/fillion/actions/index.js index e807a408..1a7ae700 100644 --- a/web/client/src/sections/fillion/actions/index.js +++ b/web/client/src/sections/fillion/actions/index.js @@ -3,8 +3,11 @@ import * as infor from './infor' import * as patrol from './patrol' import * as file from './file' +import * as assess from './assess' + export default { ...infor, ...patrol, ...file, + ...assess, } \ No newline at end of file diff --git a/web/client/src/sections/fillion/containers/assess.js b/web/client/src/sections/fillion/containers/assess.js new file mode 100644 index 00000000..7828dcfa --- /dev/null +++ b/web/client/src/sections/fillion/containers/assess.js @@ -0,0 +1,24 @@ +import React, { useState, useEffect } from 'react'; +import { connect } from 'react-redux'; + +function Assess () { + + useEffect(() => { + + return () => { + }; + }, []); + + return ( +
+ +
+ ); +} +function mapStateToProps (state) { + const { auth } = state + return { + user: auth.user, + } +} +export default connect(mapStateToProps)(Assess); \ No newline at end of file diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 1746a7f4..a4bb27e0 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -165,6 +165,12 @@ export const ApiTable = { getBridge: 'bridge', putBridge: 'bridge', delBridge: 'bridge/{bridgeId}', + + // 考核评分 + getAssess: 'assess', + putAssess: 'assess', + delAssess: 'assess/{assessId}', + //工程数据 getProject: 'project', putProject: 'project',