123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- 'use strict';
- module.exports = {
- test() {
- // this 就是 ctx 对象,在其中可以调用 ctx 上的其他方法,或访问属性
- },
- // 将参数变为模糊查询
- alterRegexName(query) {
- if (query.name) {
- query.name = { $regex: query.name };
- }
- },
- // 传入的五级地区 转成 ObjectId
- alterDeptId(query) {
- if (query.dept1) {
- query.dept1 = this.app.mongoose.Types.ObjectId(query.dept1);
- }
- if (query.dept2) {
- query.dept2 = this.app.mongoose.Types.ObjectId(query.dept2);
- }
- if (query.dept3) {
- query.dept3 = this.app.mongoose.Types.ObjectId(query.dept3);
- }
- if (query.dept4) {
- query.dept4 = this.app.mongoose.Types.ObjectId(query.dept4);
- }
- if (query.dept5) {
- query.dept5 = this.app.mongoose.Types.ObjectId(query.dept5);
- }
- return query;
- },
- // 根据【数组对象的某一属性】排序
- compareTo(property, sort) {
- return function(a, b) {
- const value1 = a[property];
- const value2 = b[property];
- if (sort == 'DESC') {
- return value2 - value1;
- } else if (sort == 'ASC') {
- return value1 - value2;
- }
- this.ctx.error('排序值错误,请输入 \'ASC\'|| \'DESC\'');
- };
- },
- // 响应成功
- success(result) {
- this.body = {
- data: result || '',
- code: 0,
- };
- },
- // 响应失败
- error(msg, code) {
- this.body = {
- message: msg || '数据异常',
- code: code || 1,
- };
- },
- logic(result, msg, code) {
- result ? this.success(result) : this.error(msg, code);
- },
- // 1.老年人健康状况-visit
- health() {
- const health = [];
- health.push('健康');
- health.push('一般');
- health.push('较差');
- return health;
- },
- // 2.老年人精神状态-visit
- mind() {
- const mind = [];
- mind.push('良好');
- mind.push('一般');
- mind.push('较差');
- return mind;
- },
- // 3.老年人安全情况-visit
- security() {
- const security = [];
- security.push('安全');
- security.push('一般');
- security.push('较差');
- return security;
- },
- // 4.巡防员性别分布统计-visit
- userBySex() {
- const userBySex = [];
- userBySex.push('男性巡防员');
- userBySex.push('女性巡防员');
- return userBySex;
- },
- // 5.党员群众认证状态-visit
- selectAuthAndLook() {
- const selectAuthAndLook = [];
- selectAuthAndLook.push('认证');
- selectAuthAndLook.push('未认证');
- return selectAuthAndLook;
- },
- // 6.巡访员巡访问方式统计-visit
- visitWay() {
- const visitWay = [];
- visitWay.push('电话问候');
- visitWay.push('上门巡访');
- visitWay.push('其它');
- return visitWay;
- },
- // 1.年龄分布-info
- fournums() {
- const fournums = [];
- fournums.push('60-70岁');
- fournums.push('70-80岁');
- fournums.push('80-85岁');
- fournums.push('85岁以上');
- return fournums;
- },
- // 2.性别-info
- sex() {
- const sex = [];
- sex.push('男');
- sex.push('女');
- return sex;
- },
- // 2-1.性别-info
- infoSex() {
- const infoSex = [];
- infoSex.push('老年人男性人数');
- infoSex.push('老年人女性人数');
- return infoSex;
- },
- // 3.能力评估-info
- ability() {
- const ability = [];
- ability.push('完全自理');
- ability.push('半失能');
- ability.push('失能');
- return ability;
- },
- // 4.健康状况-info
- oldHealth() {
- const oldHealth = [];
- oldHealth.push('健康');
- oldHealth.push('残疾');
- oldHealth.push('老年人慢性病');
- oldHealth.push('患重特大疾病');
- return oldHealth;
- },
- // 5.老年人类别-info
- oldType() {
- const oldType = [];
- oldType.push('失独');
- oldType.push('留守');
- oldType.push('独居');
- oldType.push('空巢');
- oldType.push('失能');
- oldType.push('特困');
- oldType.push('居家');
- oldType.push('重残');
- oldType.push('高龄');
- return oldType;
- },
- // 6.探访频次-info
- visitFrequency() {
- const visitFrequency = [];
- visitFrequency.push('每天');
- visitFrequency.push('每周');
- visitFrequency.push('每月');
- visitFrequency.push('每季');
- visitFrequency.push('其他');
- return visitFrequency;
- },
- // 7.收入来源-info
- oldIncome() {
- const oldIncome = [];
- oldIncome.push('转移性收入');
- oldIncome.push('财产性收入');
- oldIncome.push('工资性收入');
- oldIncome.push('家庭经营性收入');
- oldIncome.push('其它');
- return oldIncome;
- },
- // 8.可支配收入-info
- income() {
- const income = [];
- income.push('5000元以下');
- income.push('5000~10000元');
- income.push('10000元以上');
- return income;
- },
- // 9.生活经济状况-info
- livingCondition() {
- const livingCondition = [];
- livingCondition.push('特困供养人员');
- livingCondition.push('一般家庭');
- livingCondition.push('建档立卡贫困户');
- livingCondition.push('低保');
- return livingCondition;
- },
- // 10.关爱服务-info
- oldDemand() {
- const oldDemand = [];
- oldDemand.push('权益维护');
- oldDemand.push('文化娱乐');
- oldDemand.push('生产帮助');
- oldDemand.push('生活照料');
- oldDemand.push('紧急救助');
- oldDemand.push('医疗保健');
- oldDemand.push('精神慰藉');
- oldDemand.push('安全监护');
- oldDemand.push('其它');
- return oldDemand;
- },
- // 当前月份的数组(01,02,03...)
- monthNowArr() {
- const monthArr = [];
- const monthNow = new Date().getMonth() + 1;
- for (let i = 1; i <= monthNow; i++) {
- if (i < 10) {
- monthArr.push('0' + i);
- } else {
- monthArr.push(i.toString());
- }
- }
- return monthArr;
- },
- };
|