require("../css/qcScore.less");
const $ = require('jquery');
require('jquery-templates');
require('./modal.js');
const { post, getUrlArgObject, setBoxHeight, getCookie, getLocal, initScroll } = require('./utils.js');
const { api, ywCheckApi } = require('./api.js');
let checkOk = require('./../images/checkOk.png')
const adLogo = require("../images/adlogo.png")
if (localStorage.getItem('toLogin') === '1') {
window.location.href = '../login.html';
}
$(function () {
const hideLogo = getUrlArgObject("hideLg");
if (hideLogo) {
$(".sub-menu .logo img,.copy-right").remove();
$(".menu-mini .logo").text("");
}
const otherLogo = getUrlArgObject("adLg");
if (otherLogo) {
$(".logo img").attr("src", adLogo);
$(".menu-mini .logo").text("艾登");
$(".copy-right").remove();
}
//本页全局变量
let global_flawData = {}; //缺陷数据
let global_flawDataPay = {}; //缺陷数据
const global_id = getUrlArgObject("id");
const global_hid = getUrlArgObject("hid");
let global_check;
let global_check_home, global_check_show,check_Operation_WithAppeal;
let global_entryName,global_casesEntryId
const global_code = getUrlArgObject("code");
let global_activeTab = $(".sub-menu .page.active").attr("code"); //当前激活菜单项
let global_modules = {}; //模板数据缓存
let global_flaws = []; //缺陷条目列表缓存
let global_selectedFlaw = {}; //新增时选中的条目信息
getAllModules();
let showCheckBtns = global_code === "YH-ZKHC-HCRWLB";
window.document.title = (showCheckBtns ? "质控核查-" : "质控评分-") + getUrlArgObject("name");
let hasAu3 = showCheckBtns && hasData('FUNC000011'); //新增缺陷权限
if (hasAu3) {
$(".add-flaw").click(function () {
getQcCasesEntry();
});
}
function showAppealDetailEvent() {
//申诉状态点击事件
$(".flaw-item").off("click").on("click", ".title .btn", function () {
showModal("5", $(this).attr("data_id"), $(this).attr("data_type"), $(this).attr("data_casesEntryId"), $(this).attr("data_qcresultDetailId"));
});
}
function initMenu(data) {
const menu = [{ id: 0, name: "缺陷总览", parentId: -1, sonMode: [] }, ...(data || [])];
//菜单数据填充
$("#subMenuTmpl").tmpl(menu).appendTo("#subMenu");
$("#miniMenuTmpl").tmpl(menu).appendTo(".menu-mini ul");
//菜单收起展开
$(document).on("click", ".sub-menu .list-1", function () {
$(".sub-menu .list-1 .slide-up").removeClass('slide-up');
$(this).toggleClass('slide-up');
$(this).find("ul").slideToggle();
// setTimeout(function(){
// initScroll("subMenu","Y",2)
// },300)
});
$(".sub-menu .list-1 li").on("click", function (e) {
e.stopPropagation();
});
//收起菜单
$(".slide-show").click(function () {
$(".sub-menu,.copy-right").animate({ "width": "60px" }, function () {
$(this).hide();
$(".menu-mini").show();
});
$(".tab-container").animate({ "margin-left": "60px" });
});
//展开菜单
$(".slide-hide").click(function () {
$(".menu-mini").hide();
$(".sub-menu,.copy-right").show().animate({ "width": "220px" }, function () {
});
$(".tab-container").animate({ "margin-left": "220px" });
});
//右侧内容切换
$(".page").on("click", function () {
$(".info-item .cont,.flaw-item,td").removeClass("active"); //清空缺陷定位背景
const title = $(this).attr("code");
if (title == '缺陷总览' || !global_check_show) { //质控核查页进来隐藏原核查按钮
$(".check,.ywCheck").css('display', 'none')
}/*else if(title == '病案首页'){
if(showCheckBtns){
$(".ywCheck").show();
}else{
$(".check").css('display','block').text(global_check_home==1?'重新核查':'病案首页核查')
}
}*/else {
if (showCheckBtns) {
$(".ywCheck").show();
} else {
$(".check").css('display', 'block').text(global_check == 1 ? '重新核查' : '病历核查')
}
}
if (title === "缺陷总览" || title === "谈话告知书" || title === "知情同意书" || title === '医嘱信息' || title === '检验信息' || title === '检查信息' || title === '护理信息') {
if (title === "缺陷总览") {
getRecordDetailUpdate()
}
$(".flaw-table .page-item").hide();
$(".flaw-table,.flaw-table .page-item[code=" + title + "]").show();
} else {
$(".flaw-table").hide();
}
iframeShow(title)
//选中样式
$(".sub-menu .active,.menu-mini .active").removeClass('active');
const mItems = $(".sub-menu .page[code=" + title + "],.menu-mini .page[code=" + title + "]");
mItems.addClass("active");
mItems.parents(".list-1").addClass("active");
//显示对应内容
const code = $(this).attr("code");
global_activeTab = code;
//initModuleData();
$(".content-item,.flaw-item").hide();
$(".content-item[code='" + code + "']").show();
showFlawList();
$("#contentInfo").scrollTop(0)
});
// initScroll("subMenu","Y",2)
}
function iframeShow(title) {
if (title === '医嘱信息') {
$("#pacsIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentNursing").css("display", "none")
$("#contentIframeIn").css({ display: 'block' }).attr("src", 'advice.html').contents().find(".adviceWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
$(window).resize(function () {
$("#contentIframeIn").contents().find(".adviceWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
});
} else if (title === '检验信息') {
$("#contentIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentNursing").css("display", "none")
$("#pacsIframeIn").css({ display: 'block' }).attr("src", 'pacs.html').contents().find(".pacsWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
$(window).resize(function () {
$("#pacsIframeIn").contents().find(".pacsWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
});
} else if (title === '检查信息') {
$("#contentIframeIn,#pacsIframeIn,#pacsDetailIframeIn,#contentNursing").css("display", "none")
$("#assistIframeIn").css({ display: 'block' }).attr("src", 'assist.html').contents().find(".assistWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
$(window).resize(function () {
$("#assistIframeIn").contents().find(".assistWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
});
} else if (title === '护理信息') {
$("#pacsIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentIframeIn").css("display", "none")
$("#contentNursing").css({ display: 'block' }).attr("src", 'nursing.html').contents().find(".nursingWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
$(window).resize(function () {
$("#contentNursing").contents().find(".nursingWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
});
} else {
$("#contentIframeIn,#pacsIframeIn,#pacsDetailIframeIn,#assistIframeIn,#contentNursing").css({ display: 'none' })
}
}
//判断有无某一权限
function hasData(data) {
return true
let trdObj = JSON.parse(getLocal("trdObj"))
let lis = trdObj[global_code]
if (!lis) {
return false
}
if (lis.indexOf(data) > -1) {//有权限
return true
}
return false;
}
//获取病例明细
function getRecordDetail() {
post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
if (res.data.code === '0') {
const data = res.data.data;
const { beHospital, result, msg, checkStatus, drgs, mrStatus, checkShow,checkOperationWithAppeal } = data;
global_check = checkStatus
global_check_home = mrStatus
global_check_show = checkShow;//0隐藏操作按钮1显示
check_Operation_WithAppeal =JSON.parse(checkOperationWithAppeal)
const info = Object.assign(beHospital, result);
initMenu(JSON.parse(result.menuData));
// $(".sub-menu>ul>li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
$(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
global_activeTab = $(".sub-menu .page.active").attr("code");
$(".operation").show()
initPatientInfo(info);
initContent(result.pageData);
initList(msg);
initScoreItem(msg);
global_flawData = msg;
global_flawDataPay = drgs;
setBoxHeight();
changePay()
}
});
}
function getRecordDetailUpdate() {
post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
if (res.data.code === '0') {
const data = res.data.data;
const { beHospital, result, msg, checkStatus, drgs } = data;
// global_check = checkStatus
// const info=Object.assign(beHospital,result);
// initMenu(JSON.parse(result.menuData));
// $(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
// global_activeTab=$(".sub-menu .page.active").attr("code");
// initPatientInfo(info);
// initContent(result.pageData);
initList(msg);
initScoreItem(msg);
global_flawData = msg;
global_flawDataPay = drgs;
// setBoxHeight();
// changePay()
}
});
}
function changePay() {
$(document).on('click', ".titleSpecial span", function () {
let type = $(this).attr("data-type")
if (type == 1) {
initList(global_flawDataPay, type);
} else {
initList(global_flawData, type);
}
})
}
//填充患者信息
function initPatientInfo(data) {
const obj = Object.assign({}, data, { showCheckBtns, checkState: global_check, checkStateHome: global_check_home });
$("#infoTmpl").tmpl(obj).appendTo("#patientInfo");
/*$(".check").on("click", function(){
checkQc()
})*/
$(".ywCheck").on("click", function () {
checkYwQc()
})
}
//显示病例模块明细
function initContent(data) {
const obj = JSON.parse(data);
let info = [];
let hml = '', moduleId = '';
formatSpecPage(obj["谈话告知书"], "谈话告知书");
formatSpecPage(obj["知情同意书"], "知情同意书");
// formatSpecPage(obj["医嘱信息"],"医嘱信息");
$(".content-box").show();
for (let k in obj) {
if (k === "谈话告知书" || k === "知情同意书") {
continue;
}
for (let i in obj[k]) {
info = formatInfoData(k, obj[k][i]);
moduleId = info.mode_id;
if (global_modules[moduleId]) {
hml = initModuleData(moduleId, obj[k]);
$.tmpl(hml, info).appendTo("#contentInfo");
} else {
const icon = require("../images/empty1.png");
const sid = moduleId ? "(" + moduleId + ")" : "";
const code = k.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
const emptyStr = `
暂无信息~
`;
if (!$(".content-item[code=" + code + "] .empty").length) { //显示一条空提示即可
hml = '' +
'
' + k + sid + '
' + emptyStr + '';
$.tmpl(hml, {}).appendTo("#contentInfo");
}
}
}
}
$(".content-item[code=" + global_activeTab + "]").show();
//console.log(obj)
}
function formatInfoData(k, data) {
let obj = {}, name = "";
for (let i in data) {
if (i !== "mode_id") {
name = i.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, "").replace(/^[0-9]+/, "a"); //过滤key中存在的特殊符号,模板会渲染不出来且不报错
obj[name] = data[i].replace(/\n/g, "
") || "";
} else {
obj[i] = data[i].replace(/\n/g, "
") || "";
}
}
return Object.assign({ title: k }, obj);
}
//知情同意书、谈话告知书
function formatSpecPage(data, title, type) {
$(".page-item[code='缺陷总览']").remove()
$("#appointBookTmpl").tmpl({ title, data }).appendTo(".flaw-table");
setBoxHeight();
$(".page-anchor").on("click", function () {
const code = $(this).attr("code");
const pCode = $(this).parents("tr").attr("code").replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
//菜单同步状态
$(".sub-menu .page[code=" + pCode + "]").parents(".list-1").click();
$(".sub-menu .page[code=" + pCode + "],.menu-mini .page[code=" + pCode + "").click();
//缺陷定位
$(".info-item .cont,.flaw-item,td").removeClass("active");
const flawItem = $(".flaw-item .title a[code=" + code + "]");
if (!flawItem.length) {
$.alerModal({ "message": '模块数据缺失~', type: "tip", time: '1000', isFather: true, fatherWrapper: $(".flaw-table", parent.document) });
return;
}
$(".flaw-item .title a[code=" + code + "]").click();
const anch = $(".flaw-item .title a[code=" + code + "]").attr("href");
if ($(anch)[0]) {
$('#contentInfo').scrollTop($(anch).offset().top - 60);
}
});
if (global_activeTab == "缺陷总览") {
$(".check").css("display", "none")
} else {
$(".check").css("display", "block")
}
if (type && type == 1) {
$(".titleNo").css({
'background-color': '#00A1FF',
'color': '#fff',
'border-color': '#00A1FF'
})
$(".titlePay").css({
'background-color': '#fff',
'border': '1px solid #777',
'border-right': 0,
'color': '#777'
})
setBoxHeight()
} else if (type && type == 2) {
$(".titleNo").css({
'background-color': '#fff',
'border': '1px solid #777',
'border-left': 0,
'color': '#777'
})
$(".titlePay").css({
'background-color': '#00A1FF',
'color': '#fff',
'border-color': '#00A1FF'
})
setBoxHeight()
}
}
function initList(data, type) {
//$("#flawTotalList").tmpl({title:"缺陷总览",data:data}).appendTo(".flaw-table");
formatSpecPage(data, "缺陷总览", type);
$(".flaw-table").show();
$(".flaw-table .page-item[code=" + global_activeTab + "]").show();
$(".slide-up").off("click").on("click", function () {
const name = $(this).text();
$("tr[code='" + name + "']").slideToggle();
$(this).toggleClass("down");
});
}
//评分项数据填充
function initScoreItem(data) {
$("#flaws .flaw-box").html("");
let hasAu = showCheckBtns && global_check_show && hasData('FUNC000013'); //修改缺陷权限
let hasAu2 = showCheckBtns && global_check_show && hasData('FUNC000012'); //删除缺陷权限
let hasAu3 = check_Operation_WithAppeal
console.log(hasAu3);
for (let k in data) {
for (let i = 0; i < data[k].length; i++) {
let item = data[k][i];
item.hasAu3 = hasAu3
}
$("#flawTmpl").tmpl(data[k]).appendTo("#flaws .flaw-box");
}
showFlawList();
$(".flaw-item .oper a").unbind("click").click(function () {
const i = $(".flaw-item[code=" + global_activeTab + "]").index($(this).parents(".flaw-item"));
const code = $(this).attr("code");
const isEdit = $(this).is(".edit-flaw");
//if(!hasAu)return
if (isEdit && hasAu) {
showModal('0', code, i); //编辑
} else if (!isEdit && hasAu2) {
if ($(this).is(".recover-flaw")) {
showModal('3', code, i); //恢复
} else {
showModal('1', code, i); //删除
}
}
})
$(".edit-flaw").css({ "display": hasAu ? "inline" : "none" });
$(".del-flaw").css({ "display": hasAu2 ? "inline" : "none" });
$(".add-flaw").css({ "display": hasAu3 && global_check_show ? "inline" : "none" });
$(".recover-flaw").css({ "display": hasAu2 ? "inline" : "none" });
$(".flaw-item .title a[href]").unbind("click").click(function () {
const id = $(this).attr("href");
const anchors = $(this).attr("anchors").split(",");
let ans = anchors.map((it) => {
return "#anchor" + it;
});
$(".info-item .cont,.flaw-item,td").removeClass("active");
$(ans.join(",")).addClass("active");
$(this).parents(".flaw-item").addClass("active");
});
}
//显示缺陷列表
function showFlawList() {
const hml = $(".flaw-item[code=" + global_activeTab + "]");
if (hml.length) {
hml.show();
$("#flaws .empty").hide();
} else {
$("#flaws .empty").length ? $("#flaws .empty").show() : $("#emptyTmpl").tmpl().appendTo("#flaws .flaw-box");
}
showAppealDetailEvent();
}
//删除评分项
function delScore(id, info, isRecover) {
const text = isRecover ? "恢复" : "删除";
const param = {
'behospitalCode': global_id,
'optResultAlgVO': {
'id': id
},
'delStatus': isRecover ? 1 : 0
};
post(api.delScore, param).then(function (res) {
if (res.data.code === '0') {
$("#delModal").hide();
updateFlaws(res.data.data);
$("#anchor" + info.pageKeyList[0]).removeClass("active");
$.alerModal({ "message": text + "成功", type: "tip", time: '1000', win: true });
} else {
$.alerModal({ "message": res.data.msg || (text + '失败,请重试~'), type: "tip", time: '1000', win: 'default' });
}
}).catch(() => {
$.alerModal({ "message": text + '失败,请重试~', type: "tip", time: '1000', win: 'default' });
});
}
//修改评分项
function editScore(info) {
info.reviewer = info.exampleDate > info.gmtModified ? info.reviewer : info.linkman
info.exampleDate = info.exampleDate > info.gmtModified ? info.exampleDate : info.gmtModified
const param = {
"behospitalCode": global_id,
"optResultAlgVO": info
};
post(api.editScore,param).then(function(res){
if(res.data.code==='0'){
$("#delModal").hide();
updateFlaws(res.data.data);
$.alerModal({"message":"修改成功",type:"tip",time:'1000',win:true});
}else{
$.alerModal({"message":'修改失败,请重试~',type:"tip",time:'1000',isFather: true,win: 'default', fatherWrapper: $("#mainBox", parent.document)});
}
}).catch(()=>{
$.alerModal({"message":'修改失败,请重试~',type:"tip",time:'1000',isFather: true,win: 'default', fatherWrapper: $("#mainBox", parent.document)});
});
}
//添加评分项
function addScore(info) {
const optResultAlgVO = {
"casesEntryId": info.casesEntryId,
"casesId": info.casesId,
"casesScore": info.caseScore,
"code": info.code || "",
"id": info.id || "",
"info": info.info || "",
"isReject": info.isReject,
"msg": info.msg || "",
"score": info.score,
"explainInfo": info.explainInfo,
}
const param = {
"behospitalCode": global_id,
"optResultAlgVO": optResultAlgVO
};
post(api.addScore, param).then(function (res) {
if (res.data.code === '0') {
$("#delModal").hide();
updateFlaws(res.data.data);
$.alerModal({ "message": "添加成功", type: "tip", win: true, time: '1000' });
} else {
$.alerModal({ "message": "添加失败,请重试~", type: "tip", win: 'default', time: '1000' });
}
}).catch(() => {
$.alerModal({ "message": "添加失败,请重试~", type: "tip", win: 'default', time: '1000' });
});
}
//显示删除/修改弹窗
function showModal(flag, code, i, id, qcresultDetailId) {
console.log(flag);
$("#delModal .modal-body").html("");
$("#delModal").show();
$("#delModal .cancel").text("关闭")
$("#delModal .cancel").hide();
$(".info-item .cont,.flaw-item .title,td").removeClass("active");
//事件解绑
$("#delModal .confirm").off("click");
const flawsList = formatFlawKeys(global_flawData);
const info = flawsList[global_activeTab] && flawsList[global_activeTab][i];
if (flag === '0') { //修改
$("#delModal .confirm").show()
$("#delModal .title").text("修改");
$("#delModal .confirm").text("保存");
$("#editTmpl").tmpl(info).appendTo("#delModal .modal-body");
$("#qcScore,#qcMsg,#qcInfo").off("input");
//分数输入验证
$("#qcScore").on("input", function () {
const val = $(this).val();
if (/^[0-9]\d*$|^[0-9]\d*(.\d)?$/.test(val) && val <= 100) {
$(".edit-box .warning").hide();
} else {
$(".edit-box .warning .red").text("支持≥0且≤100的数字输入,最多保留小数点后1位~");
$(".edit-box .warning").show();
}
});
//提示信息输入验证
$("#qcMsg").on("input", function () {
const val = $(this).val();
$(this).attr("title", val)
if (val.trim()) {
$(".edit-box .warning").hide();
} else {
$(".edit-box .warning .red").text("提示信息不能为空~");
$(".edit-box .warning").show();
}
});
//提示信息输入验证
$("#qcInfo").on("input", function () {
const val = $(this).val();
$(this).attr("title", val)
if (val.length > 125) {
$(".edit-box .warning .red").text("备注不能超过125个字~");
$(".edit-box .warning").show();
} else {
$(".edit-box .warning").hide();
return;
}
});
if ($("#qcInfo").val().length > 125) {
$(".edit-box .warning .red").text("备注不能超过125个字~");
$(".edit-box .warning").show();
return;
}
$("#delModal .confirm").unbind("click").click(function () {
if ($(".edit-box .warning").is(":visible")) {
return;
}
const obj = Object.assign({}, info, { explainInfo: $("#delModal #qcInfo").val(), msg: $("#delModal #qcMsg").val(), score: $("#delModal #qcScore").val() });
editScore(obj);
});
} else if (flag === '5') { //查看
$("#delModal .title").text("查看");
$("#delModal .confirm").hide();
$("#delModal .cancel").show();
$("#delModal .modal-box").css("margin-top", '-245px');
//0申诉1驳回2审核
//新增项模板
getAppealDetail(code, i, id, qcresultDetailId);
} else if (flag === '2') { //新增
$("#delModal .confirm").show();
$("#delModal .title").text("新增");
$("#delModal .confirm").text("保存");
$("#addFlawTmpl").tmpl().appendTo("#delModal .modal-body");
$("#flawDropTmpl").tmpl({ info: code }).appendTo("#delModal .modal-body ul");
$("#addQcScore,#addQcMsg,#addQcInfo").off("input");
//分数输入验证
$("#addQcScore").on("input", function () {
const val = $(this).val();
if (/^[0-9]\d*$|^[0-9]\d*(.\d)?$/.test(val) && val <= 100) {
$(".add-box .warning").hide();
} else {
$(".add-box .warning .red").text("支持≥0且≤100的数字输入,最多保留小数点后1位~");
$(".add-box .warning").show();
return;
}
});
//提示信息输入验证
$("#addQcMsg").on("input", function () {
const val = $(this).val();
$(this).attr("title", val)
if (val.trim()) {
$(".add-box .warning").hide();
} else {
$(".add-box .warning .red").text("提示信息不能为空~");
$(".add-box .warning").show();
return;
}
});
//提示信息输入验证
$("#addQcInfo").on("input", function () {
const val = $(this).val();
$(this).attr("title", val)
if (val.length > 125) {
$(".add-box .warning .red").text("备注不能超过125个字~");
$(".add-box .warning").show();
} else {
$(".add-box .warning").hide();
return;
}
});
$("#delModal .confirm").unbind("click").click(function () {
if (!$(".flaw-drop-input").attr("code")) {
$(".add-box .warning .red").text("请选择质控条目~");
$(".add-box .warning").show();
return;
}
const msg = $("#delModal #addQcMsg").val();
const score = Number($("#delModal #addQcScore").val());
const explainInfo = $("#delModal #addQcInfo").val();
if ($(".add-box .warning").is(":visible")) {
return;
}
if (!msg.trim()) {
$(".add-box .warning .red").text("提示信息不能为空~");
$(".add-box .warning").show();
return;
}
if ((!score) && $("#delModal #addQcScore").val() != '0') {
$(".add-box .warning .red").text("分值不能为空~");
$(".add-box .warning").show();
return;
}
if ($("#addQcInfo").val().length > 125) {
$(".add-box .warning .red").text("备注不能超过125个字~");
$(".add-box .warning").show();
return;
}
const obj = Object.assign({}, global_selectedFlaw, { msg, score, explainInfo });
addScore(obj);
});
} else if (flag === '3') {
$("#delModal .confirm").show();
$("#delModal .title").text("恢复提示");
$("#delModal .modal-body").html('确定要恢复该评分记录吗?
');
$("#delModal .confirm").text("取消").unbind("click").click(function () {
$("#delModal").hide();
});
$("#delModal .cancel").show().text("恢复").unbind("click").click(function () {
delScore(code, info, true);
});
} else {
$("#delModal .confirm").show();
$("#delModal .title").text("删除提示");
$("#delModal .modal-body").html('确定要删除该评分记录吗?
');
$("#delModal .confirm").text("取消").unbind("click").click(function () {
$("#delModal").hide();
});
$("#delModal .cancel").show().text("删除").unbind("click").click(function () {
console.log(123);
delScore(code, info);
});
}
}
function getAppealDetail(id, flg, casesEntryId, qcresultDetailId) {
const param = {
behospitalCode: global_id,
casesEntryId: casesEntryId,
hospitalId: global_hid,
qcresultDetailId: qcresultDetailId,
id: +id
};
post(api.getApprovedView, param).then((res) => {
const info = res.data.data || {};
const appealInfo = info.appealExamineRecordDTOList;
$("#appealStatusTmpl").tmpl(appealInfo).appendTo("#delModal .modal-body");
$("#delModal .cancel").text("关闭").unbind("click").click(function () {
$("#delModal").hide();
});
/*if (flg === '1') {
$(".check-item").hide();
$(".reject-item").show();
} else if (flg === '2') {
$(".check-item").show();
}*/
})
}
//缺陷列表key值去掉特殊符号
function formatFlawKeys(data) {
const obj = {};
for (let k in data) {
obj[k.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '')] = data[k];
}
return obj;
}
//获取缺陷条目下拉列表
function getQcCasesEntry(name) {
const id = $("#subMenu [code=" + global_activeTab + "]").attr("mode");
const param = {
'behospitalCode': global_id,
'entryName': name || "",
'modeId': id
};
post(api.findQcCasesEntry, param).then(function (res) {
if (res.data.code === '0') {
const data = res.data.data;
if (name) {
global_flaws = data;
$("#delModal .modal-body ul").html("");
$("#flawDropTmpl").tmpl({ info: data }).appendTo("#delModal .modal-body ul");
} else {
global_flaws = data;
if ($("#delModal").css("display") == "block") {
$("#flawDropTmpl").tmpl({ info: data }).appendTo("#delModal .modal-body ul");
return
}
showModal('2', data);
}
}
});
}
//增加条目弹窗元素事件
$("body").on("click", ".add-box .flaw-drop-input", function () {
$(".add-box .drop-box").addClass("show");
});
$("body").on("blur", ".add-box .flaw-drop-input", function () {
setTimeout(function () {
$(".add-box .drop-box").removeClass("show");
}, 300)
});
$("body").on("input", ".add-box .flaw-drop-input", function () {
$(this).attr({ "code": "", "title": $(this).val().trim() });
getQcCasesEntry($(this).val().trim());
});
$("body").on("click", ".add-box .drop-box li", function () {
const n = $(this).attr("idx");
const flaw = global_flaws[n];
const { score, msg, entryName, casesEntryId } = flaw;
global_selectedFlaw = flaw;
global_entryName = entryName
global_casesEntryId = casesEntryId
$(".flaw-drop-input").val(entryName).attr({ "code": casesEntryId, "title": entryName });
$("#addQcMsg").val(msg).attr("title", msg);
$("#addQcScore").val(score);
$(".add-box .warning").hide();
$(".add-box .drop-box").removeClass("show");
console.log(123);
});
$(document).on("blur", ".flaw-drop-input", (e) => {
$('.flaw-drop-input').val(global_entryName).attr({ "code": global_casesEntryId,"title": global_entryName });
});
//更新缺陷列表
function updateFlaws(info) {
$("#patientInfo .level").text("质控等级:" + info.level);
$("#patientInfo .score").text("质控得分:" + info.scoreRes);
const param = {
'behospitalCode': global_id,
'paramStr': [
"msg"
]
};
post(api.getRecordDetail, param).then(function (res) {
if (res.data.code === '0') {
const data = res.data.data;
const { msg } = data;
initScoreItem(msg);
global_flawData = msg;
}
});
}
//获取病例模板
function getInfoModule(moduleId) {
const param = {
moduleId: moduleId
};
post(api.getInfoModule, param).then(function (res) {
if (res.data.code === '0') {
const data = res.data.data;
cachemoduleDatas(data);
getRecordDetail();
}
});
}
//模板数据缓存
function cachemoduleDatas(data) {
const moudle = data.moduleDetail;
global_modules[data.modeName] = [];
for (let i in moudle) {
global_modules[data.modeName].push(moudle[i]);
}
}
//初始化模板
function initModuleData(mid, obj) {
const n = obj.length;
const module = global_modules[mid].moduleDetail;
const key = global_modules[mid].modeName.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
let hml = '' +
'
' + global_modules[mid].modeName + '(' + mid + ')
' +
(n > 1 ? '
' : '
');
for (let i in module) {
hml = hml + '
';
for (let j = 0; j < module[i].length; j++) {
const detal = module[i][j].questionDTO;
const { tagType } = detal;
switch (tagType) {
case 1:
hml = hml + simpleStructure(detal, obj);
break;
case 4:
hml = hml + combineStructure(detal);
break;
default:
break;
}
}
hml = hml + "
"
}
return hml + "
";
}
//基础类型结构生成
function simpleStructure(data, obj) {
const { name, val, monoLine, addLine, position, bold, retract, id } = data;
if (name === "手术记录表格-1") {
const value = val.replace("【", "").replace("】", "");
const diag = obj[0][value] ? JSON.parse(obj[0][value]) : "";
let thml = `
`;
thml += $("#tableTmpl").tmpl({ k: "手术信息", data: diag })[0].outerHTML + "
";
return thml;
}
if (name === "出院诊断表格-1") {
const value = val.replace("【", "").replace("】", "");
const diag = obj[0][value] ? JSON.parse(obj[0][value]) : "";
let thml = `
`;
thml += $("#tableTmpl").tmpl({ k: "出院诊断", data: diag })[0].outerHTML + "
";
return thml;
}
const posClass = position === 1 ? 'text-left' : '';
const boldClass = bold === 1 ? 'text-bold' : '';
const retractClass = retract === 1 ? 'text-indent' : '';
const lineHml = ('
' + extractVars(val) + '
');
const txtHml = ('
' + extractVars(val) + '
');
let hml = addLine || monoLine ? `
` : `
`;
hml = hml + `${name}` + (addLine ? lineHml : txtHml) + `
`;
return hml;
}
//组合类型结构生成
function combineStructure(data) {
const { name, questionMapping, id } = data;
let hml = '
';
const colNum = Math.ceil(questionMapping.length / 2);
let tdVal = '';
const regexp = /(【(.+?)】)/g;
for (let i = 0; i < questionMapping.length;) {
if (questionMapping[i + 1]) {
tdVal = "" + questionMapping[i].name + extractVars(questionMapping[i].val) + " | " + questionMapping[i + 1].name + extractVars(questionMapping[i + 1].val) + " | ";
} else {
tdVal = "" + questionMapping[i].name + extractVars(questionMapping[i].val) + " | | ";
}
if (i == 0) {
hml = hml + `${name} | ${tdVal}`;
} else {
hml = hml + `
${tdVal}`;
}
hml = hml + "
";
i = ((i + 2) > questionMapping.length ? i + 1 : i + 2)
}
hml = hml + "
";
return hml;
}
//抽取变量
function extractVars(org) {
const regexp = /(【(.+?)】)/g;
const arr = org.split(regexp);
//console.log(arr)
let htl = '', val = '';
for (let i = 0; i < arr.length; i++) {
val = arr[i].indexOf("【") != -1 ? '' : (arr[i - 1] && arr[i - 1].indexOf("【") != -1 ? "{{html " + arr[i] + "}}" : arr[i]);
htl = htl + val;
}
return htl;
}
//获取所有模板
function getAllModules() {
const param = {
hospitalId: getUrlArgObject("hid"),
modeId: ''
};
post(api.getModuleById, param).then((res) => {
if (res.data.code === '0') {
const data = res.data.data;
global_modules = data;
getRecordDetail();
$("#loading").hide();
/*setTimeout(function(){
$(".operation").show()
},50)*/
}
});
}
/*function checkQc(){
const param={
behospitalCode:getUrlArgObject("id"),
hospitalId:getUrlArgObject("hid"),
checkType: global_activeTab == '病案首页'?'1':'0'
};
post(api.checkQc,param).then((res)=>{
if(res.data.code==='0') {
if(global_activeTab == '病案首页'){
global_check_home = 1
}else{
global_check = 1
}
$(".check").text("重新核查")
$.alerModal({"message":"核查成功",type:"tip",time:'1000',win:true});
}else{
$.alerModal({"message":res.data.msg ||"核查失败",type:"tip",time:'1000',isFather: false});
}
});
}*/
function checkYwQc() {
const param = {
behospitalCode: getUrlArgObject("id"),
hospitalId: getUrlArgObject("hid"),
};
post(ywCheckApi.recordCheck, param).then((res) => {
if (res.data.code === '0') {
global_check = 1
$(".ywCheck").text("重新核查")
$.alerModal({ "message": "核查成功", type: "tip", time: '1000', win: true });
} else {
$.alerModal({ "message": res.data.msg || "核查失败", type: "tip", time: '1000', isFather: false });
}
});
}
});