123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829 |
- /**
- * Created by fy on 2016/12/29.
- */
- 'use strict';
- const express = require('express');
- const router = express.Router();
- const fs = require('fs');
- const utils = require('../../lib/utils');
- const adminService = require('../../service/dna/admin');
- const excel = require('node-excel-export');
- router.get('/', (req, res) => {
- res.render('dna/admin/list');
- });
- router.route('/list').get(adminService.list).post(adminService.list);
- /**
- * 显示修改界面
- */
- router.get('/preEdit', (req, res) => {
- adminService.selectDnaFlowById(req.query.id, (err, rows) => {
- console.error(err);
- if (rows && rows.length == 1) {
- let row = rows[0];
- row.action = '/dna/admin/edit';
- res.render('dna/admin/edit', row);
- }
- });
- });
- /**
- * 修改信息
- */
- router.post('/edit', (req, res) => {
- let params = req.body;
- adminService.updateDnaFlowById(params, (err, result) => {
- if (err) throw err;
- console.error(err);
- let errMsg = JSON.stringify(err);
- let rowCount = null;
- if (result) {
- rowCount = result.changedRows;
- if (result.affectedRows == 1 && rowCount == 0) rowCount = '-1'; // 数据没有发生变化
- }
- utils.jsonpAndEnd(res, `parent.parent.editCb(${rowCount}, '${errMsg}');`);
- });
- });
- /**
- * 彻底删除数据
- */
- router.post('/delete', (req, res) => {
- let ids = req.body.ids;
- adminService.deleteDnaByIds(ids, (err, result) => {
- if (err)throw err;
- res.send({
- affectedRows: result.affectedRows,
- err: err
- });
- });
- });
- /**
- * 导出excel
- */
- router.post('/exportExcel', (req, res) => {
- adminService.listAll(req, (err, rows) => {
- if (err)throw err;
- if (rows && rows.length > 0) {
- let dataset = JSON.parse(JSON.stringify(rows));
- let styles = {
- title: {
- font: {
- sz: 30,
- bold: true
- }
- },
- header: {
- font: {
- color: {
- // rgb: 'FFFFFFFF'
- },
- sz: 14,
- bold: true,
- underline: false
- }
- },
- cell: {}
- };
- let heading = [
- [{value: 'DNA检测流程全部数据导出', style: styles.header}],
- ];
- let specification = {
- barcode_long: {
- displayName: '条码编号',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- hospital: {
- displayName: '医院名称',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- sample_code: {
- displayName: '样本编号',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- sample_date: {
- displayName: '采样日期',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- receive_date: {
- displayName: '接收日期',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- real_name: {
- displayName: '姓名',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- id_card: {
- displayName: '身份证',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- age: {
- displayName: '年龄',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- pregnancy_week: {
- displayName: '孕周',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- pregnancy_day: {
- displayName: '孕天',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- pregnancy_condition: {
- displayName: '妊娠情况',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- pregnancy_bad_history: {
- displayName: '不良孕产史',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- comments: {
- displayName: '备注',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- inputter: {
- displayName: '录入人员',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- input_date: {
- displayName: '录入日期',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- // changer: {
- // displayName: '换管人员',
- // headerStyle: styles.header,
- // cellStyle: styles.cell,
- // cellFormat: function (value, row) {
- // return value || '';
- // },
- // width: '15'
- // },
- // change_date: {
- // displayName: '换管日期',
- // headerStyle: styles.header,
- // cellStyle: styles.cell,
- // cellFormat: function (value, row) {
- // return value || '';
- // },
- // width: '15'
- // },
- checker: {
- displayName: '审批人员',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- check_date: {
- displayName: '审批日期',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- warehouser: {
- displayName: '采血管入库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- warehouse_place: {
- displayName: '采血管入库位置',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- warehouse_date: {
- displayName: '采血管入库时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- // barcode_short: {
- // displayName: '短条码编号',
- // headerStyle: styles.header,
- // cellStyle: styles.cell,
- // cellFormat: function (value, row) {
- // return value || '';
- // },
- // width: '15'
- // },
- sample_outer: {
- displayName: '采血管出库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- sample_out_residue: {
- displayName: '接收组样本剩余量',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_handover: {
- displayName: '提取组接收人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_handover_date: {
- displayName: '提取组接收时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_qbite_deep: {
- displayName: 'Qubit浓度(ng/ul)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_epoch_deep: {
- displayName: 'epoch浓度(ng/ul)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_purity_deep: {
- displayName: '纯度(%)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_part_size: {
- displayName: '片段大小(bp)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_part_after_break: {
- displayName: '打断后片段(bp)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extracter: {
- displayName: '提取人员',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_date: {
- displayName: '提取时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_checker: {
- displayName: '提取审核人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_check_date: {
- displayName: '提取审核时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_outer: {
- displayName: '提取出库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- extract_out_residue: {
- displayName: '提取组样本剩余量',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_handover: {
- displayName: '建库组接收人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_handover_date: {
- displayName: '建库组接收时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_deep: {
- displayName: '建库浓度(ng/ul)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_index: {
- displayName: '建库index号',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_part_size: {
- displayName: '建库片段大小(bp)',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storager: {
- displayName: '建库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_date: {
- displayName: '建库时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_checker: {
- displayName: '建库审查人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_check_date: {
- displayName: '建库审查时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_outer: {
- displayName: '建库组出库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- storage_out_residue: {
- displayName: '建库组样本剩余量',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_handover: {
- displayName: '上机组接收人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_handover_date: {
- displayName: '上机组接收时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_chip_code: {
- displayName: '上机芯片编码',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_reads_val: {
- displayName: '上机reads数',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_q30_val: {
- displayName: '上机q30值',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operater: {
- displayName: '上机人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_date: {
- displayName: '上机时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_checker: {
- displayName: '上机审查人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_check_date: {
- displayName: '上机审查时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_outer: {
- displayName: '上机组出库人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- operate_out_residue: {
- displayName: '上机组样本剩余量',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_handover: {
- displayName: '分析报告组接收人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_handover_date: {
- displayName: '分析报告组接收时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_result: {
- displayName: '分析结果',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_advice: {
- displayName: '建议',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_is_send: {
- displayName: '是否发送',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- if (value == 1) {
- return '不发送';
- } else if (value == 2) {
- return '发送';
- } else {
- return '';
- }
- },
- width: '15'
- },
- reporter: {
- displayName: '分析人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_date: {
- displayName: '分析时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_sender: {
- displayName: '报告发送人',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- report_send_date: {
- displayName: '报告发送时间',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- return value || '';
- },
- width: '15'
- },
- status: {
- displayName: '状态',
- headerStyle: styles.header,
- cellStyle: styles.cell,
- cellFormat: function (value, row) {
- let text = '';
- switch (value) {
- case 0:
- text = '已删除';
- break;
- case 1:
- text = '已录入';
- break;
- case 2:
- text = '已审批';
- break;
- case 3:
- text = '已入库';
- break;
- case 4:
- text = '已出库';
- break;
- case 5:
- text = '已提取';
- break;
- case 6:
- text = '提取合格';
- break;
- case 7:
- text = '提取废弃';
- break;
- case 8:
- text = '重提取';
- break;
- case 9:
- text = '提取已交接';
- break;
- case 10:
- text = '已建库';
- break;
- case 11:
- text = '建库合格';
- break;
- case 12:
- text = '建库废弃';
- break;
- case 13:
- text = '重建库';
- break;
- case 14:
- text = '建库已交接';
- break;
- case 15:
- text = '已上机';
- break;
- case 16:
- text = '上机合格';
- break;
- case 17:
- text = '上机废弃';
- break;
- case 18:
- text = '重上机';
- break;
- case 19:
- text = '上机已交接';
- break;
- case 20:
- text = '已分析';
- break;
- case 21:
- text = '报告已发送';
- break;
- default:
- text = '';
- }
- return text;
- },
- width: '15'
- }
- };
- let report = excel.buildExport(
- [
- {
- name: 'DNA检测流程全部数据导出',
- heading: heading,
- specification: specification,
- data: dataset
- }
- ]
- );
- res.attachment('DNA检测流程全部数据导出.xlsx'); // This is sails.js specific (in general you need to set headers)
- return res.send(report);
- } else {
- let msg = encodeURI('没有数据可导出');
- return utils.jsonpAndEnd(res, `alert(decodeURI('${msg}'));window.close();`)
- }
- });
- });
- module.exports = router;
|