Browse Source

考核评分模块路由

dev
巴林闲侠 2 years ago
parent
commit
f7ef80b552
  1. 86
      api/app/lib/controllers/data/assess.js
  2. 106
      api/app/lib/models/assess.js
  3. 13
      api/app/lib/routes/data/index.js
  4. 10
      api/sequelize-automate.config.js
  5. 35
      web/client/src/sections/fillion/actions/assess.js
  6. 3
      web/client/src/sections/fillion/actions/index.js
  7. 24
      web/client/src/sections/fillion/containers/assess.js
  8. 6
      web/client/src/utils/webapi.js

86
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,
};

106
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;
};

13
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
};

10
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_',] ,长度较长的 前缀放前面

35
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: '编辑或新增考核评分信息' },
});
}

3
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,
}

24
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 (
<div>
</div>
);
}
function mapStateToProps (state) {
const { auth } = state
return {
user: auth.user,
}
}
export default connect(mapStateToProps)(Assess);

6
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',

Loading…
Cancel
Save