<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('质控概览')"/>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
    <link th:href="@{/mrqc/css/select2-bootstrap.css}" rel="stylesheet"/>
    <link th:href="@{/mrqc/js/bootstrap-table/extensions/editable/bootstrap-editable.css}" rel="stylesheet"/>
    <th:block th:include="mrqc/include :: select2-min-css"/>
    <link rel="stylesheet" th:href="@{/mrqc/css/public.css}">
    <link rel="stylesheet" th:href="@{/mrqc/css/list.css}">
    <link rel="stylesheet" th:href="@{/mrqc/css/manage_index.css}">
</head>
<script>
    var QcWay = {"人工": "2", "机器": "3"};
    var QcLv = {"甲": "lv1_emr", "乙": "lv2_emr", "丙": "lv3_emr"};
    var QcRange = {"本月归档": "month", "本月质控": "monthqc"};
    var ctx = '[[@{/}]]';
    var isAdmin = "[[${@permission.hasRole('admin')}]]";  //是否是管理員
</script>
<style>
    .badge:hover{
        cursor: pointer;
    }
    table td:hover{
        cursor: pointer;
    }
</style>
<body>


<div class="zk_indexMain">
    <input id="QcWay" name="QcWay" type="hidden"/>
    <input id="QcLv" name="QcLv" type="hidden"/>
    <input id="QcRange" name="QcRange" type="hidden"/>

    <div class="zk_rightContent scrollbar" >
        <div class="manageTop">
            <div class="manage_totalCount">
                <ul>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_recordSum">0</span>
                            <span>病历总数</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index01.png}" width="50" height="50">
                        </div>
                    </li>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_machine">0</span>
                            <span>机器质控</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index02.png}" width="50" height="50">
                        </div>
                    </li>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_manWork">0</span>
                            <span>人工质控</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index03.png}" width="50" height="50">
                        </div>
                    </li>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_sumj">0</span>
                            <span>甲级病历</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index05.png}" width="50" height="50">
                        </div>
                    </li>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_sumy">0</span>
                            <span>乙级病历</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index06.png}" width="50" height="50">
                        </div>
                    </li>
                    <li>
                        <div class="countLeft">
                            <span class="zk_yw" id="zk_sumb">0</span>
                            <span>丙级病历</span>
                        </div>
                        <div class="countRight">
                            <img th:src="@{/mrqc/images/main/index07.png}" width="50" height="50">
                        </div>
                    </li>
                </ul>
            </div>

            <div class="indexSetting" style="height: 100px;">
                <a href="javascript:void(0)" id="toConfigQcRule">规则配置</a>
            </div>
        </div>

        <div class="gr_countShow" style="margin-bottom: 5px;">
            <div class="halfPercent col-lg-12 col-md-12" style="float: none;">
                <div class="zk_boxTitle">
                    <div class="indexTitle">
                        本月归档病历
                    </div>
                    <div class="gr_totalCount">
                        <!--                        总数部分-->
                        <span style="cursor: pointer;" id="man_tapproved">0</span>
                        <span style="cursor: pointer;" class="r1" id="man_fapproved">0</span>
                    </div>
                </div>

                <div class="gr_countKinds">
                    <div class="thirtyPercent col-lg-4 col-md-4" style="padding-right: 0px; padding-left: 0px;">
                        <div class="gr_szbt" style="width: 20%; float: left; height: 96px; line-height: 96px;">
                            甲级病历
                        </div>
                        <div class="gr_sz" style="width: 80%; float: left;">
                            <ul>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['人工'], QcLv['甲'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_jmanWork">0</span>
                                    <span>人工</span>
                                </li>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['机器'], QcLv['甲'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_jmachine">0</span>
                                    <span>机器</span>
                                </li>
                            </ul>
                        </div>
                    </div>

                    <div class="thirtyPercent col-lg-4 col-md-4 GradeB" style="padding-right: 0px; padding-left: 0px;">
                        <div class="gr_szbt" style="width: 20%; float: left; height: 96px; line-height: 96px;">
                            乙级病历
                        </div>
                        <div class="gr_sz" style="width: 80%; float: left;">
                            <ul>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['人工'], QcLv['乙'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_ymanWork">0</span>
                                    <span>人工</span>
                                </li>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['机器'], QcLv['乙'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_ymachine">0</span>
                                    <span>机器</span>
                                </li>
                            </ul>
                        </div>
                    </div>

                    <div class="thirtyPercent col-lg-4 col-md-4 GradeC" style="padding-right: 0px; padding-left: 0px;">
                        <div class="gr_szbt" style="width: 20%; float: left; height: 96px; line-height: 96px;">
                            丙级病历
                        </div>
                        <div class="gr_sz" style="width: 80%; float: left;">
                            <ul>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['人工'], QcLv['丙'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_bmanWork">0</span>
                                    <span>人工</span>
                                </li>
                                <li onclick="tableInit.getSpecificMyEmr(QcWay['机器'], QcLv['丙'], QcRange['本月归档'])" style="cursor: pointer;">
                                    <span id="man_bmachine">0</span>
                                    <span>机器</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="manageIndexArea">
            <div class="manageAreaTop">
                <div class="zk_condition manage_condition" style="width: 100%;margin-top: 5px;margin-bottom: 5px;">
                    <div class="row" style="align-items: center; display: flex;">
                        <div class="col-sm-2">
                            <div class="input-group ">
                                <label class="input-group-addon" style="width: 20px"><i class="fa fa-users" style="color: #CCCC66"></i></label>
                                <select class="input-sm" id="medicalGroup"  onchange="tableInit.search()"></select>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group ">
                                <label class="input-group-addon" style="width: 20px"><i class="fa fa-user-md" style="color: #0099CC"></i></label>
                                <select class="input-sm" id="qcUserId"  onchange="tableInit.search()"></select>
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="input-group date">
                                <span class="input-group-addon" style="width: 20px"><i class="fa fa-calendar" style="color: #CCCC33"></i></span>
                                <input type="text" width="auto" class="input-sm form-control" id="date" onchange="tableInit.search()" th:value="${lastMonth}"
                                       placeholder="质控月份"/>
                                <input type="hidden" id="zkMonth" th:value="${lastMonth}"/>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <a class="btn btn-primary" onclick="tableInit.addZkUser()">
                                <i class="fa fa-plus"></i> 质控员指派
                            </a>
                            <a class="btn btn-primary" id="distributeEmrBtn">
                                <i class="fa fa-send"></i> 病历分配
                            </a>
                        </div>
                        <div class="col-sm-1">
                            <a class="btn btn-primary" onclick="tableInit.exportBl()">
                                <i class="fa fa-download"></i> 导出病历
                            </a>
                        </div>
<!--                        <div class="col-sm-12">-->
<!--                            <a shiro:hasPermission="mrqc:gm:master" class="btn btn-primary" onclick="importEmrExcel('importEmrForm')">-->
<!--                                <i class="fa fa-upload"></i> 导入分配病历模板-->
<!--                            </a>-->
<!--                            <a shiro:hasPermission="mrqc:gm:master" class="btn btn-primary" id="refreshEmrBtn">-->
<!--                                <i class="fa fa-refresh"></i> 刷新已分配病历-->
<!--                            </a>-->
<!--                        </div>-->
<!--                        <div class="col-sm-12">-->
<!--                            <a shiro:hasPermission="mrqc:pickEmr:manager" class="btn btn-primary" onclick="importEmrExcel('importEmrForm')">-->
<!--                                <i class="fa fa-upload"></i> 导入分配病历模板-->
<!--                            </a>-->
<!--                            <a shiro:hasPermission="mrqc:pickEmr:manager" class="btn btn-primary" id="refreshEmrBtn">-->
<!--                                <i class="fa fa-refresh"></i> 刷新已分配病历-->
<!--                            </a>-->
<!--                        </div>-->
                        <!--<div class="manageIcons">
                            <a href="#" onclick="tableInit.addZkUser()">新增质控员</a>
                            <a href="#" class="send" id="distributeEmrBtn">一键分配</a>
                        </div>-->
                    </div>
                </div>

            </div>

            <div class="zk_tableLayout">
                <table id="user-table"></table>
            </div>
        </div>
    </div>
</div>

<div class="popup_fullScreen" style="display:none;">
    <div class="fullScreen_title">
        新增病历
        <div class="popscreenIcon">
            <a href="#"><img th:src="@{/mrqc/images/main/popupRetract.png}" width="14" height="14"> </a>
            <a href="#"><img th:src="@{/mrqc/images/main/popupClose.png}" width="14" height="14"> </a>
        </div>
    </div>

    <div class="ConfirmSelection">
        <a href="#" class="getMore">加载更多</a><a href="#" class="doPick">确认选择</a>
    </div>
</div>

<div class="popup_addStaff" style="display: none" id="addUser">
    <div class="staffMid">
        <div class="scrollbar">

            <div class="staffSearch">
                <form id="operator-form">
                    <input type="text" name="userName">
                    <a href="#" onclick="$.table.search();"><img th:src="@{/mrqc/images/indexSearch.png}" width="16" height="16"> </a>
                </form>
            </div>
            <div style="float: right;padding-right: 20px;padding-bottom: 2px;">
                <button class="btn btn-primary" id="btn" onclick="tableInit.insertRow()">
                    <i class="fa fa-user-md">&nbsp;&nbsp;&nbsp;新建用户</i>
                </button>
            </div>
            <div class="zk_tableLayout">
                <table id="bootstrap-table" ></table>
            </div>
        </div>
    </div>
</div>

	<div class="popup_addStaff" id="configQcRuleDiv" style="display: none">

		<div class="manageRule" id="detailQcRule">
			<p>
				1、质控时间每月<input type="text" id="startQcDay">日-<input
					type="text" id="endQcDay">日;
			</p>
			<p>
				2、每位质控员每月质控<input type="text" id="emrsPerMonth">份病历；
			</p>
			<p>
				3、抽取住院时间≥<input type="text" id="deadHospitDays">天死亡病历，依次分配质控员，可多于或少于<input
					type="text" id="deadEmrNumber">份；<br> 抽取住院时间≥<input
					type="text" id="longHospitDays">天病历，内外科各<input type="text"
					id="longEmrNumber">份，依次分配给质控员；
			</p>
			<p>
				4、手术科室病历：每病区抽取三、四级手术且住院时间<input type="text" id="opStartDay">-<input
					type="text" id="opEndDay">天的病历，以首页不同 副主任/主任医师姓名为线索每人抽取<input
					type="text" id="opEmrNumberPerDoctor">份；无三四级手术，抽取二级手术病历补充。如住院时间不能满足，
				优先选<input type="text" id="opStart1Day">-<input type="text"
					id="opEnd1Day">天病历补充，其次选大于<input type="text"
					id="opStart2Day">-<input type="text" id="opEnd2Day">
				天病历补充，仍不能满足，则随机选择住院天数大于<input type="text" id="opStart3Day">天的病历补充。
			</p>
			<p>
				5、非手术科室病历：抽取住院时间<input type="text" id="nonopStartDay">-<input
					type="text" id="nonopEndDay">天病历，以首页不同的副主任/主任医师姓名为线 索每人抽取<input
					type="text" id="nonopEmrNumberPerDoctor">份；如时间不能满足，优先住院时间<input
					type="text" id="nonopStart1Day">-<input type="text"
					id="nonopEnd1Day">天补充，其次选<input type="text"
					id="nonopStart2Day"> -<input type="text" id="nonopEnd2Day">天病历补充，仍不能满足，随机选择住院天数大于<input
					type="text" id="nonopStart3Day">天的病历补充。
			</p>
			<p>
				6、质管办可对系统分配的病历进行调整和重新分配；如自动分配给质控员的病历不足<input type="text"
					id="manualDistributionThreashold">份，由质管办手工检索抽取后分配给质控
				员；如自动分配后有多余病案，将多余病案信息自动汇总。
			</p>
		</div>

		<div class="zkpopButton">
			<a href="#" id="doConfigRuleBtn">确定</a> <a href="#" class="gb"
				id="closeConfigRuleBtn">关闭</a>
		</div>
	</div>
</body>
<th:block th:include="include :: footer"/>
<script th:src="@{/mrqc/js/bootstrap-table/extensions/editable/bootstrap-editable.min.js}"></script>
<script th:src="@{/mrqc/js/bootstrap-table/extensions/editable/bootstrap-table-editable.js}"></script>
<script th:src="@{/mrqc/js/bootstrap-suggest/bootstrap-suggest.min.js}"></script>
<th:block th:include="mrqc/include :: select2-js"/>
<script th:src="@{/mrqc/js/common.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "manageRecord";
    var prefixApi = ctx + "api";
    var editable = true;

    $(function () {
        tableInit.pluginNumber();
        tableInit.initQcUserAndGroup();
        tableInit.initTimePlugin();
        tableInit.initUserTable();
    })

    function toQCdetails(recordId ) {
        var index = parent.layer.open({
            type: 2,
            title: '质控详情页面',
            content: ctx + "/mrqc/emrrecord/todetail/" + recordId + "/patient",//必须进最后有type参数的接口，不然时间线不显示
            area: ['100%', '100%'],
            maxmin: true
        });
    }

    var tableInit ={
        userName: [],
        tableMap: {},
        medicalGroup:{},
        initAddUserTable: function() {
            $.table.refresh();
            var options = {
                url: prefix + "/getZkList",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                showPageGo: false,
                pagination: true,
                pageNumber: 1,
                pageSize: 10,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'userId',
                        title: '质控员Id',
                        align: "center",
                        visible: false
                    },
                    {
                        field: 'userName',
                        title: '姓名',
                        align: "center"
                    },
                    {
                        field: 'department',
                        title: [[${@mrqcConfig.getAlias('inpatient_area')}]],
                        align: "center"
                    },
                    {
                        field: 'deptName',
                        title: [[${@mrqcConfig.getAlias('department_name')}]],
                        align: "center"
                    },
                    {
                        field: 'operationDept',
                        title: '是否为手术科室',
                        align: "center",
                        editable : {
                            type : 'select',
                            title : '是否为手术科室',
                            source : [{
                                value : '1',
                                text : "是"
                            }, {
                                value : '0',
                                text : "否"
                            }]
                        },
                    },
                    {
                        field: 'medicalGroup',
                        title: '医疗组',
                        align: "center",
                        editable : {
                            type : 'select',
                            title : '医疗组',
                            source : [{
                                value : '未分组',
                                text : "未分组"
                            }, {
                                value : '医疗组',
                                text : "医疗组"
                            }]
                        }
                    }]
            };
            $.table.init(options);
        },
        initUserTable:function(){
            $('#user-table').bootstrapTable({
                url: prefix + "/getZkUserList",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                detailView: true,
                pagination: true,
                pageNumber: 1,
                pageSize: 10,
                onExpandRow: function (index, row, $detail) {
                    tableInit.initChildTable(index, row, $detail);
                },
                queryParams: function (params) {
                    var search = {};
                    search["pageSize"] = params.limit;
                    search["pageNum"] = params.offset / params.limit + 1;
                    search["qcUserId"] = $('#qcUserId').val();
                    search["medicalGroup"] = $('#medicalGroup').val();
                    search["qcMonth"] = $('#qcMonth').val();
                    search["date"] = $("#date").val();
                    search["orderByColumn"] = params.sort;
                    search["isAsc"] = params.order;
                    return search;
                },
                columns: [
                    {
                        field: 'userId',
                        visible: false
                    },
                    {
                        field: 'userName',
                        title: '姓名',
                        align: "center"
                    },
                    {
                        field: 'loginName',
                        title: '工号',
                        align: "center"
                    },
                    {
                        field: 'emrNum',
                        title: '病历数',
                        align: "center"
                    },
                    {
                        field: 'dead3',
                        title: '住院≥3天死亡',
                        align: "center"
                    },
                    {
                        field: 'longHospit',
                        title: '住院≥31天',
                        align: "center"
                    },
                    {
                        field: 'op34',
                        title: '三、四级手术且住院10-15天',
                        align: "center"
                    },
                    {
                        field: 'other',
                        title: '其他条件病历',
                        align: "center"
                    },
                    {
                        field: 'recordScore',
                        title: '质控分数',
                        align: 'center'
                    },

                    {
                        field: 'commitStatus',
                        title: '质控提交情况',
                        align: 'center',
                        formatter:function (value, row, index) {
                            if(value === 0){
                                return "<span class='badge btn-primary' style='background-color: red;'>未提交</span>"
                            }else{
                                return "<span class='badge btn-success' style='background-color: gray;'>已提交</span>"
                            }
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            var qcMonth = row.qcMonth;
                            var zkMonth = $("#zkMonth").val();
                            if(qcMonth == zkMonth || isAdmin !== "hidden"){
                            	editable = true;
	                            actions.push('<a href="#" class="m1 m2" onclick="tableInit.addemrPick(\'' + row.userId + '\')"></a> ');
	                            actions.push('<a href="#" class="m1 m3" onclick="tableInit.deleteEmrZkUserAll(\'' + row.reportId + '\')"></a>');
                            } else {
                            	editable = false;
                            }
                            return actions.join('');
                        }
                    }]
            });
        },
        initQcUserAndGroup: function () {
            var config = {
                url: ctx + "mrqc/feedback/admin/getuserandgroup",
                method: "GET",
                dataType: 'json',
                success: function (result) {
                    if (result.code === web_status.SUCCESS) {
                        tableInit.userName = result.data["users"];
                        result.data["users"].unshift({"id": "", "text": "-请选择质控员-"});
                        result.data["medicalGroup"].unshift({"id": "", "text": "-请选择医疗组-"});
                        tableInit.initSelect2("qcUserId", result.data["users"]);
                        tableInit.initSelect2("medicalGroup", result.data["medicalGroup"]);
                        tableInit.medicalGroup = result.data["medicalGroup"]
                        console.log(tableInit.medicalGroup);
                    }
                }
            };
            $.ajax(config);
        },

        getSpecificMyEmr: function (way, lv, rang) {
            var href = ctx + "mrqc/month?emrLv=" + lv + "&rang=" + rang;
            var title = "本月病历";
            $.modal.openTab(title, href);
        },

        initChildTable: function (parentIndex, parentRow, $detail) {
            var tableId = "tableId" + (100 + ~~(Math.random() * 100));
            tableInit.tableMap[parentRow.userId] = tableId;
            var childTable = $detail.html('<table id="' + tableId + '" style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: prefix + "/getChildUserList",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams: {
                    userId: parentRow.userId,
                    date: $("#date").val()
                },
                columns: [{
                    field: 'no',
                    title: '序号',
                    sortable: true,
                    align: "center",
                    width: 75,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $(childTable).bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $(childTable).bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                    {
                        field: 'recordId',
                        title: '病例id',
                        visible: false
                    },
                    {
                        field: 'hostitNum',
                        title: '病案号',
                        align: 'center',
                        formatter:function (value, row, index) {
                            var recordId = row.recordId;
                            var hostitNum =row.hostitNum;
                            return "<a style='text-align: center;cursor: pointer;' onclick='toQCdetails(\""+recordId+"\")' >"+hostitNum+"</a>"
                        }
                    },
                    {
                        field: 'areaName',
                        title: [[${@mrqcConfig.getAlias('inpatient_area')}]],
                        align: 'center'
                    },
                    {
                        field: 'deptName',
                        title: [[${@mrqcConfig.getAlias('department_name')}]],
                        align: 'center'
                    },
                    {
                        field: 'pName',
                        title: '主治医师',
                        align: 'center'
                    },
                    {
                        field: 'dName',
                        title: '诊断',
                        align: 'center'
                    },
                    {
                        field: 'day',
                        title: '住院天数',
                        align: 'center'
                    },
                    {
                        field: 'approved',
                        title: '病历审核情况',
                        align: 'center',
                        formatter:function (value, row, index) {
                            var approved = row.approved;
                            if(approved == 1){
                                return "<span class='badge btn-success' style='background-color: green;'>已审核</span>"
                            }else{
                                return "<span class='badge btn-warning' style='background-color: red;'>未审核</span>"
                            }
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            if(editable){
                                actions.push('<a href="#" class="m1 m3" onclick="tableInit.deleteEmrZkUser(\'' + parentRow.userId + '\',\''+row.recordId+'\')"></a>');
                            }
                            return actions.join('');
                        }
                    }]
            });
        },
        initSelect2: function (id, data) {
            $("#" + id).select2({
                selectOnBlur: true,
                data: data,
                width: "auto",
                style: "height:200px"
            }).on("select2:close", function (e) {
                $("#" + id).val(e.target.value);
            });
        },
        initTimePlugin: function () {
            var max = tableInit.getoldDateMonth();
            //$("#date").val(max);
        	layui.use('laydate', function () {
                var laydate = layui.laydate;
                /*病区时间选择器*/
                var qcMonth = laydate.render({
                    elem: '#date',
                    theme: 'molv',
                    max: max,
                    format: 'yyyy-MM',
                    type: 'month',
                    trigger: 'click',
                    //value:new Date(max),
                    btns: ['clear', 'confirm'],
                    done: function (value, date) {
                        // 选择后做点什么
                        $("#date").val(value);
                        tableInit.search();
                    },
                    change: function (value, date, endDate) {
                        if ($(event.target).hasClass("layui-this")) {
                            $(this.elem).val(value);
                            $(".layui-laydate").remove();
                        }
                        // 选择后做点什么
                        $("#date").val(value);
                        tableInit.search();
                    }
                });
            });
        },
        getoldDateMonth:function(){
            var date = new Date();
            var month = date.getMonth()+1;
            if(month!=1){
                month = month - 1;
            }
            if ((month+"").length == 1) {
                month = "0" + month;
            }
            return date.getFullYear() + '-' + month;
        },
        addZkList:function(data) {
            $.operate.saveTab(prefix + "/addZkList", data,$.operate.ajaxSuccess);
        },
        search: function () {
            var params = $('#user-table').bootstrapTable('getOptions');
            params.queryParams = function (params) {
                var search = {};
                search["pageSize"] = params.limit;
                search["pageNum"] = params.offset / params.limit + 1;
                search["qcUserId"] = $("#qcUserId").val() === "0" ? "" : $('#qcUserId').val();
                search["medicalGroup"] =  $("#medicalGroup").val() === "0" ? "" : $('#medicalGroup').val();
                search["date"] = $('#date').val();
                return search;
            };

            $('#user-table').bootstrapTable('refresh', params);
        },
        addemrPick:function (userId) {
            var url = prefix + "/makeEmrPick?userId="+userId;
            var index = layer.open({
                type: 2,
                title: '新增质控病历',
                content: url,
                area: ['100%', '100%'],
                maxmin: true,
            });
        },
        addZkUser:function () {
            // $.modal.openFull("新增质控员", prefix + "/toaddqcuser");
            var index = layer.open({
                type: 2,
                area: [800 + 'px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "质控员指派",
                content: prefix + "/toaddqcuser/" + $('#date').val()
            });
            layer.full(index);
        },
        deleteEmrZkUserAll:function (reportId) {
            $.modal.confirm("你确定要删除这个用户下的所有病历吗？", function() {
                $.ajax({
                    url: prefix+'/delUserQcMrs',
                    data: {
                        'reportId':reportId
                    },
                    type: 'post',
                    success: function(res) {
                        if (res.code == 0) {
                            $("#user-table").bootstrapTable('refresh');
                            $.modal.close();
                        } else {
                            $.modal.alertError('选择失败，' + res.msg);
                        }
                    }
                });
            });
        },
        deleteEmrZkUser: function (userId, recordId) {
            //alert(recordId+"   "+userId);
            $.modal.confirm("你确定要删除这个用户下的一份病历吗？", function() {
                $.ajax({
                    url: prefix+'/delUserQcMrs',
                    data: {
                        'userId':userId,
                        'recordId':recordId
                    },
                    type: 'post',
                    success: function(res) {
                        if (res.code == 0) {
                            $("#"+tableInit.tableMap[userId]).bootstrapTable('refresh');
                            $.modal.close();
                        } else {
                            $.modal.alertError('选择失败，' + res.msg);
                        }
                    }
                });
            });
        },
        detileRecord:function (recordId) {
            var url =ctx + "mrqc/emrrecord/todetail/" + recordId;
            var index =layer.open({
                type: 2,
                title: '质控详情页面',
                content: url,
                area: ['100%', '100%'],
                maxmin: true
            });
        },

        insertRow: function (tableId, reportId, recordId, index, detailId) {
            $("#" + $.table._option.id).bootstrapTable('insertRow', {
                index: 1,
                row: {
                    no: parseInt(index) + 1,
                    detailId: feedBackAuit.uuid(),
                    reportId: reportId,
                    recordId: recordId,
                    defectInfo: '',
                    isDeleted: 0,
                    editable: true
                }
            });
        },
        pluginNumber:function () {
            //顶部数据
            //病历总数
            let zk_recordSum =[[${zkmanage.recordSum}]];
                showNumber("zk_recordSum",zk_recordSum);
            //机器质控总数
            let zk_machine =[[${zkmanage.machine}]];
                showNumber("zk_machine",zk_machine);
            //人工质控总数
            let zk_manWork =[[${zkmanage.manWork}]];
            showNumber("zk_manWork",zk_manWork);
            //甲级病历总数
            let zk_sumj =[[${zkmanage.sumj}]];
            showNumber("zk_sumj",zk_sumj);
            //乙级病历总数
            let zk_sumy =[[${zkmanage.sumy}]];
            showNumber("zk_sumy",zk_sumy);
            //丙级病历总数
            let zk_sumb =[[${zkmanage.sumb}]];
            showNumber("zk_sumb",zk_sumb);

            //本月归档病历
            let man_tapproved =[[${maindata.TMan}]]
            showNumber("man_tapproved",man_tapproved);
            //机器
            let man_fapproved = [[${maindata.TMac}]];
            showNumber("man_fapproved",man_fapproved);
            //人工-甲
            let man_jmanWork = [[${maindata.JMan}]]
            showNumber("man_jmanWork",man_jmanWork);
            //机器-甲
            let man_jmachine = [[${maindata.JMac}]];
            showNumber("man_jmachine",man_jmachine);
            //人工-乙
            let man_ymanWork = [[${maindata.YMan}]]
            showNumber("man_ymanWork",man_ymanWork);
            //机器-乙
            let man_ymachine = [[${maindata.YMac}]];
            showNumber("man_ymachine",man_ymachine);
            //人工-丙
            let man_bmanWork = [[${maindata.BMan}]];
            showNumber("man_bmanWork",man_bmanWork);
            //机器-丙
            let man_bmachine = [[${maindata.BMac}]];
            showNumber("man_bmachine",man_bmachine);


            //本月质控病历
            // let toMonthMan =[[${todaydata.TQcMan}]];
            // showNumber("toMonthMan",toMonthMan);
            //机器
            // let toMonthMachine = [[${todaydata.TQcMac}]];
            // showNumber("toMonthMachine",toMonthMachine);
            //人工-甲
            // let toMonthJmanWork = [[${todaydata.JQcMan}]];
            // showNumber("toMonthJmanWork",toMonthJmanWork);
            //机器-甲
            // let toMonthJmachine = [[${todaydata.JQcMac}]];
            // showNumber("toMonthJmachine",toMonthJmachine);
            //人工-乙
            // let toMonthYmanWork = [[${todaydata.YQcMan}]];
            // showNumber("toMonthYmanWork",toMonthYmanWork);
            // //机器-乙
            // let toMonthYmachine = [[${todaydata.YQcMac}]];
            // showNumber("toMonthYmachine",toMonthYmachine);
            // //人工-丙
            // let toMonthBmanWork = [[${todaydata.BQcMan}]];
            // showNumber("toMonthBmanWork",toMonthBmanWork);
            // //机器-丙
            // let toMonthBmachine = [[${todaydata.BQcMac}]];
            // showNumber("toMonthBmachine",toMonthBmachine);
        },
        exportBl:function () {
            window.open(prefix + "/download?date=" + $("#date").val());
        }
    }
</script>
<script th:src="@{/mrqc/js/mrqcManagerIndex.js}"></script>

<form id="importEmrForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
    <div class="col-xs-offset-1">
        <div class="mt10 pt5">
            <span style="font-weight: bold">点击下方按钮导入分配病历文档</span>
        </div>
        <input class="mt10" type="file" id="file" name="file"/>
        <div class="mt10 pt5">
            1、文档中的质控员必须是已经存在的，否则请先添加质控员再上传
        </div>
        <div class="pt5">
            2、质控员未被指派的，系统会自动指派，然后分配文档中的病历
        </div>
        <div class="pt5">
            3、质控员已被指派且已被分配病历的，会删除之前分配的病历，重新分配文档中的病历
        </div>
        <div class="pt5">
            4、分配完成后，建议点击【刷新已分配病历】按钮刷新病历
        </div>
        <div class="mt10 pt5">
            <span style="color:red;">请上传指定格式(xls或xlsx文件)，也可点击此处下载模板 →→→ </span>
            <a class="btn btn-success btn-sm" th:href="@{/mrqc/template/质控员病历手动分配模板.xls}">下载模板</a>
        </div>
    </div>
</form>
</html>
