巴林闲侠
2 years ago
8 changed files with 278 additions and 5 deletions
@ -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, |
|||
}; |
@ -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; |
|||
}; |
@ -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: '编辑或新增考核评分信息' }, |
|||
}); |
|||
} |
@ -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); |
Loading…
Reference in new issue