define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage', 'citypicker'], function ($, undefined, Backend, Table, Form, Selectpage, Citypicker) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'statistics/exams/index' + location.search, } }); var table = $("#table"); var common_filter = {}; var common_op = {}; // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'exam.createdAt', sortOrder: 'desc', showToggle: false, showColumns: false, exportDataType: "all", pageList: [10, 15, 25, 50], queryParams: function (params) { //这里可以追加搜索条件 let filter = JSON.parse(params.filter); let op = JSON.parse(params.op); if (op.exam_datetime_start && op.exam_datetime_end) { op.exam_datetime = 'BETWEEN'; filter.exam_datetime = filter['exam_datetime_start'].replace(/-/g,'') + "," + filter['exam_datetime_end'].replace(/-/g,'') delete op.exam_datetime_start delete op.exam_datetime_end delete filter.exam_datetime_start delete filter.exam_datetime_end } else if (op.exam_datetime_start && !op.exam_datetime_end) { op.exam_datetime = op.exam_datetime_start filter.exam_datetime = filter.exam_datetime_start.replace(/-/g,'') delete op.exam_datetime_start delete filter.exam_datetime_start } else if (!op.exam_datetime_start && op.exam_datetime_end) { op.exam_datetime = op.exam_datetime_end; filter.exam_datetime = filter.exam_datetime_end.replace(/-/g,'') delete op.exam_datetime_end delete filter.exam_datetime_end } if(filter.province){ delete op.province; let arr = filter.province.split("/"); delete filter.province; if(arr[0]){ filter['i.ris_province'] = arr[0]; op['i.ris_province'] = '='; } if(arr[1]){ filter['i.ris_city'] = arr[1]; op['i.ris_city'] = '='; } // if(arr[2]){ // filter['i.district'] = arr[2]; // op['i.district'] = '='; // } } if(filter.is_bind){ params.is_bind = filter.is_bind delete filter.is_bind delete op.is_bind } params.filter = JSON.stringify(filter); params.op = JSON.stringify(op); common_filter = params.filter; common_op = params.op; $("#centage").text('??') $("#centage").data('total', '??'); return params; }, columns: [ [ {field: 'institution_id', title: __('Institution_Name'), visible: false}, { field: 'institution_name', title: __('Institution_Name'), searchable: false, align: 'left', formatter: Table.api.formatter.bold, width: '15%' }, {field: 'exam_status', title: __('Exam_status'), visible: false, searchList: {3: '影像到达', 7: '已写报告',8:'已审报告',9:'报告完成'}, formatter:Table.api.formatter.status, addClass:'selectpicker',data:'multiple',operate:'IN' }, // {field: 'name', title: __('Name'), searchable: false}, // {field: 'patient_num', title: __('Patient_num'), searchable: false, align: 'left',}, // {field: 'accession_num', title: __('Accession_num'), searchable: false, align: 'left',}, // { // field: 'sex', title: __('Sex'), // searchable: false, // formatter: Table.api.formatter.normal, // searchList: {M: '男', F: '女'}, // custom: {M: 'primary', F: 'primary'} // }, {field: 'name', title: '姓名', width: '20%', operate: 'LIKE %...%'}, {field: 'exam_class', title: __('Exam_class'), searchList: {CR: "CR", CT: "CT", DX: "DX", ECG: "ECG", ES: "ES", MG: "MG", MR: "MR", PETCT: "PETCT", PT: "PT", RF: "RF", US: "US", XA: "XA"}, addClass:'selectpicker',data:'multiple',operate:'IN' }, {field: 'application_department', title: '申请科室', searchable: true}, {field: 'application_doctor', title: '申请医生'}, {field: 'patient_num', title: '病历号'}, {field: 'accession_num', title: '检查号'}, // { // field: 'report_result', title: __('Report_result'), // searchable: false, // formatter: Table.api.formatter.normal, // searchList: {1: '阴性', 2: '阳性'}, // custom: {1: 'primary', 2: 'danger'} // // }, { field: 'exam_datetime', title: __('Exam_datetime'), operate: 'BETWEEN', searchable: false, addclass: 'datetimepicker', data: 'data-date-format="YYYYMMDD" autocomplete="off"', }, { field: 'exam_datetime_start', title: __('检查-开始日期'), visible: false, operate: '>', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD" autocomplete="off"', }, { field: 'exam_datetime_end', title: __('检查-结束日期'), visible: false, operate: '<', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD" autocomplete="off"', }, {field: 'province', title: '省市', visible: false}, { field: 'pay_status', title: '支付状态', formatter: Table.api.formatter.status, searchList: {1: '已支付', 0: '未支付'}, // searchable: false, custom: {1: 'success', 0: 'gray'} }, { field: 'is_bind', title: '患者绑定状态', formatter: Table.api.formatter.status, searchList: {1: '已绑定', 0: '未绑定'}, // searchable: false, custom: {1: 'success', 0: 'gray'} }, { field: 'createdAt', title: '创建时间', operate : 'RANGE', addclass: 'datetimerange', data:' autocomplete="off"' }, // { // field: 'pb_id', title: '患者绑定状态', // formatter: Table.api.formatter.status, // searchList: {1: '已绑定', 0: '未绑定'}, // searchable: false, // custom: {1: 'success', 0: 'gray'} // } // {field: 'register_name', title: __('Register_name'), searchable: false}, // {field: 'register_datetime', title: __('Register_datetime'), searchable: false}, // {field: 'report_doctor_name', title: __('Report_doctor_name'), searchable: false}, // {field: 'review_doctor_name', title: __('Review_doctor_name'), searchable: false}, // {field: 'id', title: __('Price'), searchable: false, formatter: function (value) { // return '20'; // }}, ] ] }); // $("#province").on("cp:updated", function() { // var citypicker = $(this).data("province"); // var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province"); // $("#code").val(code); // }); $('#province').attr('data-level','city') $('#province').citypicker(); $('.city-picker-span').css('width','100%'); // 为表格绑定事件 Table.api.bindevent(table); //当表格数据加载完成时 table.on('post-body.bs.table', function (e, settings, json, xhr) { //这里可以获取从服务端获取的JSON数据 $('input[name="exam_datetime_start-operate"]').parent().css('white-space','break-spaces') $('input[name="exam_datetime_end-operate"]').parent().css('white-space','break-spaces') }); table.on('load-success.bs.table', function (e, data) { if(typeof data.rows === 'undefined' && typeof typeof data.code != 'undefined') { Toastr.error(data.msg); } }); $('.btn-positive').click(function () { Fast.api.ajax({ type: 'GET', url: 'statistics/exams/getPositive', data: { filter : common_filter, op : common_op }, loading:true }, function (data) { // $("#centage").text(data.centage) // $("#centage").data('total', data.positive); layer.alert('阳性总数:' + data.positive + ';阳性率:' + data.centage + '%'); return false; }, function (){ Toastr.warning('获取阳性率失败'); }); }); $('.btn-film').click(function () { Fast.api.ajax({ type: 'GET', url: 'statistics/exams/getFilm', data: { filter : common_filter, op : common_op }, loading:true }, function (data) { // $("#centage").text(data.centage) // $("#centage").data('total', data.positive); layer.alert('照片质量比例:优秀(' + data.you + '%);良好(' + data.liang + '%);合格(' + data.hege + '%);差(' + data.cha + '%);'); return false; }, function (){ Toastr.warning('获取照片质量比例失败'); }); }); $('.btn-excel').click(function () { window.location.href = 'exams/getExcel?filter='+common_filter+'&op='+common_op; // Fast.api.ajax({ // type: 'GET', // url: 'statistics/exams/getExcel', // data: { // filter : common_filter, // op : common_op // }, // loading:true // }, function (data) { // }, function (){ // }); }); $.ajax({ url: 'institution/institution/institutionSelectList', type: 'post', dataType: 'json', success: function success(res) { let data = res.rows; $('#institution_id').selectPage({ data : data, orderBy: 'index' }); } }); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });