const $ = require('jquery');
require("../css/creatCheckTask.less");
require('./modal.js');
const { api, ywCheckApi } = require('./api.js')
const { post, getCookie, emptyBox, listenScroll, getScoreTabList } = require('./utils.js')
require('./../resource/jquery-ui/jquery-ui.min.js');
require('./../resource/jquery-ui/jquery-ui.min.css');
const iconCheck = require("./../images/icon_check.png")
const iconUnCheck = require("./../images/icon_unchecked.png")
const iconDisCheck = require("./../images/icon_dis.png")
const iconCalenBlue = require("./../images/icon_calen_blue.png")
const iconCalenGrey = require("./../images/icon_calen_grey.png")
const iconDown = require("./../images/arrow_down.png")
const iconUp = require("./../images/arrow_up.png")
const loadingImg = require("./../images/loading.gif")
const arrowLeft = require("./../images/arrow_left.png")
const arrowRight = require("./../images/arrow_right.png")
listenScroll()
let tabList = [], global_level = "", global_status = "0",
global_deptId = [], global_deptName = "", global_score = '',
data_desc = ["leaveHospitalDate"], data_asc = [], global_taskList = [], global_delOrAdd = 1;//1生成0取消
let global_activeTabCode = '0'; //激活的tab code
let isPlacefile = getCookie('isPlacefile') || 1
$(function () {
$(window.parent.document).find(".modaltip").hide();//切换页面过快时toast隐藏
const checkAuth = getCookie('checkAuth');
/*if(!checkAuth){
$(".tabs").hide();
toast("没有质控核查权限!");
return
}*/
const tabs = checkAuth.replace(/[^456]/g, '');
if (tabs.length === 0) {
//$(".tabs").hide();
toast("没有质控核查权限!");
return;
} else if (tabs.length > 1) {
//多于一个权限,显示tab切换
$(".tabs").show();
const last = "456".replace(tabs, '');
$(".tabs [data-code=" + (last - 4) + "]").parent().hide();
}
global_activeTabCode = tabs.substr(0, 1) - 4;
//获取科室列表
if (global_activeTabCode == "0") {
getSubDeptList();
} else {
getDeptList();
}
$(".tabs [data-code=" + global_activeTabCode + "]").addClass("active");
$('.datapickerBox').append(``)
$('.iconCalen').on("mouseenter", function (e) {
$(this).attr("src", iconCalenBlue)
})
$('.iconCalen').on("mouseleave", function (e) {
$(this).attr("src", iconCalenGrey)
})
$('.iconCalen').on("click", function (e) {
$(this).parent().find("input").focus()
})
$(".menu .page", parent.document).removeClass("active")
$(parent.document).find(".menu .page[code=YH-ZKHC-SCHCRW]").addClass("active")
$(".filter").on("click", function (e) {
global_taskList = [];
const isCreated = (global_status == "1");
const text = isCreated ? '取消' : '生成';
$(".modal-body p").text("确定要" + text + "这些任务吗?");
$("th[code]").removeClass("asc desc");
if (isCreated) {
$(".creatTask").addClass("disabled");
$(".cancelTask").removeClass("disabled");
} else {
$(".creatTask").removeClass("disabled");
$(".cancelTask").addClass("disabled");
}
//已生成筛选时按生成日期倒序筛选
if (isCreated) {
global_delOrAdd = 0;
data_desc = ["jobCreateTime"];
$("th[code=jobCreateTime]").addClass("desc");
$("th[code=leaveHospitalDate]").removeClass("desc");
} else {
global_delOrAdd = 1;
data_desc = ["leaveHospitalDate"];
$("th[code=leaveHospitalDate]").addClass("desc");
$("th[code=jobCreateTime]").removeClass("desc");
}
getTabData(1)
})
$(".abnormalClear").on("click", function (e) {
clearFilter();
getTabData(1)
})
//切换tab
$(".tabBox .tabs button").on("click", (e) => {
const me = e.target;
$('.selectDept i').text('全部')
$(".deptItem.active").removeClass("active");
$(".deptList").css("display", "none")
global_deptId = [];
global_deptName = "";
global_activeTabCode = $(me).attr("data-code");
if (global_activeTabCode == "0") {
getSubDeptList();
} else {
getDeptList();
}
$(".tabBox .tabs button").removeClass("active");
$(me).addClass("active");
//更新列表并重置筛选条件
$(".filter").click();
});
//选择生成状态
$('.selectStatus').on("click", function (e) {
e.stopPropagation()
const showList = $(".statusList ").css("display")
if (showList == "none" || !showList) {
$(".levelList ").css("display", "none")
$(".deptList ").css("display", "none")
$(".scoreList ").css("display", "none")
$(".statusList ").css("display", "block")
} else {
$(".statusList ").css("display", "none")
}
})
//选择病历等级
$('.selectLevel').on("click", function (e) {
e.stopPropagation()
$(".deptList ").css("display", "none")
const showList = $(".levelList ").css("display")
if (showList == "none" || !showList) {
$(".deptList ").css("display", "none")
$(".statusList ").css("display", "none")
$(".scoreList ").css("display", "none")
$(".levelList ").css("display", "block")
} else {
$(".levelList ").css("display", "none")
}
})
//科室选择
$('.selectDept').on("click", function (e) {
e.stopPropagation();
$(".levelList ").css("display", "none")
$(".statusList ").css("display", "none")
$(".scoreList ").css("display", "none")
$(".deptList ").css("display", "block")
})
//筛选分值选择
$('.selectScore').on("click", function (e) {
e.stopPropagation();
$(".levelList ").css("display", "none")
$(".deptList ").css("display", "none")
$(".statusList ").css("display", "none")
$(".scoreList ").css("display", "block")
})
$(".creatTask,.cancelTask").click(function () {
if ($(this).is(".disabled")) {
return;
}
if (!global_taskList.join("").length) {
toast("至少勾选一个任务");
return;
}
$(".modal-container").show();
});
$(".modal-container .confirm").click(function () {
creatTask(global_delOrAdd)
});
$(".modal-container .cancel,.modal-container .close").click(function () {
/*if(global_delOrAdd==0){
global_taskList=[];
}*/
$(".modal-container").hide();
})
//出院日期初始化
$.datepicker.regional['zh-CN'] = {
clearText: '清除',
clearStatus: '清除已选日期',
closeText: '关闭',
closeStatus: '不改变当前选择',
prevText: '<上月',
prevStatus: '显示上月',
prevBigText: '<<',
prevBigStatus: '显示上一年',
nextText: '下月>',
nextStatus: '显示下月',
nextBigText: '>>',
nextBigStatus: '显示下一年',
currentText: '今天',
currentStatus: '显示本月',
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
yearNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
monthStatus: '选择月份',
yearStatus: '选择年份',
weekHeader: '周',
weekStatus: '年内周次',
dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
dayStatus: '设置 DD 为一周起始',
dateStatus: '选择 m月 d日, DD',
dateFormat: 'yy-mm-dd',
firstDay: 1,
initStatus: '请选择日期',
isRTL: false
};
const days = new Date().getDate() - 1;
let startDate = "-" + days + "d", endDate = new Date();
$.datepicker.setDefaults($.datepicker.regional['zh-CN']);
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
}).datepicker("setDate", startDate);
$("#datepicker2").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
}).datepicker("setDate", endDate);
getScoreTabList((data) => { rendeScoreList(data) })
//获取列表数据
getTabData(1)
//状态选择
bindStatusSelect()
//等级选择
bindLeveldSelect()
//关闭下拉
$(document).on("click", function () {
$(".levelList ").css("display", "none")
$(".deptList ").css("display", "none")
$(".statusList ").css("display", "none")
$(".scoreList ").css("display", "none")
})
});
//判断有无某一权限
function hasData(data) {
let trdObj = JSON.parse(getCookie("trdObj"))
let lis = trdObj['YH-ZKHC-SCRW']
if (!lis) {
return false
}
if (lis.indexOf(data) > -1) {//有权限
return true
}
return false;
}
function rendeScoreList(list) {
if (list.length == 0) {
$('.scoreList').html("")
return
}
let str = `