qcScore.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. require("../css/qcScore.less");
  2. const $ = require('jquery');
  3. require('jquery-templates');
  4. require('./modal.js');
  5. const { post, getUrlArgObject, setBoxHeight, getCookie, getLocal, initScroll } = require('./utils.js');
  6. const { api, ywCheckApi } = require('./api.js');
  7. let checkOk = require('./../images/checkOk.png')
  8. const loadingImg = require("./../images/loading.gif")
  9. const adLogo = require("../images/adlogo.png")
  10. if (localStorage.getItem('toLogin') === '1') {
  11. window.location.href = '../login.html';
  12. }
  13. $(function () {
  14. const hideLogo = getUrlArgObject("hideLg");
  15. if (hideLogo) {
  16. $(".sub-menu .logo img,.copy-right").remove();
  17. $(".menu-mini .logo").text("");
  18. }
  19. const otherLogo = getUrlArgObject("adLg");
  20. if (otherLogo) {
  21. $(".logo img").attr("src", adLogo);
  22. $(".menu-mini .logo").text("艾登");
  23. $(".copy-right").remove();
  24. }
  25. //本页全局变量
  26. let global_flawData = {}; //缺陷数据
  27. let global_flawDataPay = {}; //缺陷数据
  28. const global_id = getUrlArgObject("id");
  29. const global_hid = getUrlArgObject("hid");
  30. let global_check;
  31. let global_check_home, global_check_show, check_Operation_WithAppeal;
  32. let global_entryName, global_casesEntryId
  33. const global_code = getUrlArgObject("code");
  34. let global_activeTab = $(".sub-menu .page.active").attr("code"); //当前激活菜单项
  35. let global_modules = {}; //模板数据缓存
  36. let global_flaws = []; //缺陷条目列表缓存
  37. let global_selectedFlaw = {}; //新增时选中的条目信息
  38. let menuList = [];
  39. getAllModules();
  40. let showCheckBtns = global_code === "YH-ZKHC-HCRWLB";
  41. window.document.title = (showCheckBtns ? "质控核查-" : "质控评分-") + getUrlArgObject("name");
  42. let hasAu3 = showCheckBtns && hasData('FUNC000011'); //新增缺陷权限
  43. if (hasAu3) {
  44. $(".add-flaw").click(function () {
  45. getQcCasesEntry();
  46. });
  47. }
  48. $("body").on("click", ".refreshBtn", function () {
  49. supplementData()
  50. });
  51. function showAppealDetailEvent() {
  52. //申诉状态点击事件
  53. $(".flaw-item").off("click").on("click", ".title .btn", function () {
  54. showModal("5", $(this).attr("data_id"), $(this).attr("data_type"), $(this).attr("data_casesEntryId"), $(this).attr("data_qcresultDetailId"));
  55. });
  56. }
  57. function initMenu(data) {
  58. const menu = [{ id: 0, name: "缺陷总览", parentId: -1, sonMode: [] }, ...(data || [])];
  59. //菜单数据填充
  60. $("#subMenuTmpl").tmpl(menu).appendTo("#subMenu");
  61. $("#miniMenuTmpl").tmpl(menu).appendTo(".menu-mini ul");
  62. //菜单收起展开
  63. $(document).on("click", ".sub-menu .list-1", function () {
  64. $(".sub-menu .list-1 .slide-up").removeClass('slide-up');
  65. $(this).toggleClass('slide-up');
  66. $(this).find("ul").slideToggle();
  67. // setTimeout(function(){
  68. // initScroll("subMenu","Y",2)
  69. // },300)
  70. });
  71. $(".sub-menu .list-1 li").on("click", function (e) {
  72. e.stopPropagation();
  73. });
  74. //收起菜单
  75. $(".slide-show").click(function () {
  76. $(".sub-menu,.copy-right").animate({ "width": "60px" }, function () {
  77. $(this).hide();
  78. $(".menu-mini").show();
  79. });
  80. $(".tab-container").animate({ "margin-left": "60px" });
  81. });
  82. //展开菜单
  83. $(".slide-hide").click(function () {
  84. $(".menu-mini").hide();
  85. $(".sub-menu,.copy-right").show().animate({ "width": "220px" }, function () {
  86. });
  87. $(".tab-container").animate({ "margin-left": "220px" });
  88. });
  89. //右侧内容切换
  90. $(".page").on("click", function () {
  91. $(".info-item .cont,.flaw-item,td").removeClass("active"); //清空缺陷定位背景
  92. const title = $(this).attr("code");
  93. if (title == '缺陷总览' || !global_check_show) { //质控核查页进来隐藏原核查按钮
  94. $(".check,.ywCheck").css('display', 'none')
  95. }/*else if(title == '病案首页'){
  96. if(showCheckBtns){
  97. $(".ywCheck").show();
  98. }else{
  99. $(".check").css('display','block').text(global_check_home==1?'重新核查':'病案首页核查')
  100. }
  101. }*/else {
  102. if (showCheckBtns) {
  103. $(".ywCheck").show();
  104. } else {
  105. $(".check").css('display', 'block').text(global_check == 1 ? '重新核查' : '病历核查')
  106. }
  107. }
  108. if (title === "缺陷总览" || title === "谈话告知书" || title === "知情同意书" || title === '医嘱信息' || title === '检验信息' || title === '检查信息' || title === '护理信息' || title === '其他信息') {
  109. if (title === "缺陷总览") {
  110. getRecordDetailUpdate()
  111. }
  112. $(".flaw-table .page-item").hide();
  113. $(".flaw-table,.flaw-table .page-item[code=" + title + "]").show();
  114. } else {
  115. $(".flaw-table").hide();
  116. }
  117. iframeShow(title)
  118. //选中样式
  119. $(".sub-menu .active,.menu-mini .active").removeClass('active');
  120. const mItems = $(".sub-menu .page[code=" + title + "],.menu-mini .page[code=" + title + "]");
  121. mItems.addClass("active");
  122. mItems.parents(".list-1").addClass("active");
  123. //显示对应内容
  124. const code = $(this).attr("code");
  125. global_activeTab = code;
  126. //initModuleData();
  127. $(".content-item,.flaw-item").hide();
  128. $(".content-item[code='" + code + "']").show();
  129. showFlawList();
  130. $("#contentInfo").scrollTop(0)
  131. });
  132. // initScroll("subMenu","Y",2)
  133. }
  134. function iframeShow(title) {
  135. if (title === '医嘱信息') {
  136. $("#pacsIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentNursing,#contentOther").css("display", "none")
  137. $("#contentIframeIn").css({ display: 'block' }).attr("src", 'advice.html').contents().find(".adviceWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  138. $(window).resize(function () {
  139. $("#contentIframeIn").contents().find(".adviceWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  140. });
  141. } else if (title === '检验信息') {
  142. $("#contentIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentNursing,#contentOther").css("display", "none")
  143. $("#pacsIframeIn").css({ display: 'block' }).attr("src", 'pacs.html').contents().find(".pacsWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  144. $(window).resize(function () {
  145. $("#pacsIframeIn").contents().find(".pacsWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  146. });
  147. } else if (title === '检查信息') {
  148. $("#contentIframeIn,#pacsIframeIn,#pacsDetailIframeIn,#contentNursing,#contentOther").css("display", "none")
  149. $("#assistIframeIn").css({ display: 'block' }).attr("src", 'assist.html').contents().find(".assistWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  150. $(window).resize(function () {
  151. $("#assistIframeIn").contents().find(".assistWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  152. });
  153. } else if (title === '护理信息') {
  154. $("#pacsIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentIframeIn,#contentOther").css("display", "none")
  155. $("#contentNursing").css({ display: 'block' }).attr("src", 'nursing.html').contents().find(".nursingWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  156. $(window).resize(function () {
  157. $("#contentNursing").contents().find(".nursingWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  158. });
  159. } else if (title === '其他信息') {
  160. $("#pacsIframeIn,#assistIframeIn,#pacsDetailIframeIn,#contentIframeIn,#contentNursing").css("display", "none")
  161. $("#contentOther").css({ display: 'block' }).attr("src", 'other.html').contents().find(".otherWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  162. $(window).resize(function () {
  163. $("#contentOther").contents().find(".otherWrp").height(window.innerHeight - $("#patientInfo").height() - 20 + 'px')
  164. });
  165. } else {
  166. $("#contentIframeIn,#pacsIframeIn,#pacsDetailIframeIn,#assistIframeIn,#contentNursing,#contentOther").css({ display: 'none' })
  167. }
  168. }
  169. //判断有无某一权限
  170. function hasData(data) {
  171. return true
  172. let trdObj = JSON.parse(getLocal("trdObj"))
  173. let lis = trdObj[global_code]
  174. if (!lis) {
  175. return false
  176. }
  177. if (lis.indexOf(data) > -1) {//有权限
  178. return true
  179. }
  180. return false;
  181. }
  182. //获取病例明细
  183. function getRecordDetail(type) {
  184. post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
  185. if (res.data.code === '0') {
  186. const data = res.data.data;
  187. const { beHospital, result, msg, checkStatus, drgs, mrStatus, checkShow, checkOperationWithAppeal } = data;
  188. global_check = checkStatus
  189. global_check_home = mrStatus
  190. global_check_show = checkShow;//0隐藏操作按钮1显示
  191. const list = JSON.parse(result.menuData)
  192. for (let i = 0; i < list.length; i++) {
  193. const item = list[i];
  194. menuList.push(item.name)
  195. for (let j = 0; j < item.sonMode.length; j++) {
  196. const it = item.sonMode[j];
  197. menuList.push(it.name)
  198. }
  199. }
  200. check_Operation_WithAppeal = checkOperationWithAppeal;
  201. const info = Object.assign(beHospital, result);
  202. initMenu(JSON.parse(result.menuData));
  203. // $(".sub-menu>ul>li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
  204. $(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
  205. global_activeTab = $(".sub-menu .page.active").attr("code");
  206. $(".operation").show()
  207. initPatientInfo(info);
  208. initContent(result.pageData,2);
  209. initList(msg);
  210. initScoreItem(msg);
  211. global_flawData = msg;
  212. global_flawDataPay = drgs;
  213. setBoxHeight();
  214. changePay()
  215. }else{
  216. $.alerModal({ "message": '接口出错', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  217. }
  218. }).catch(()=>{
  219. $.alerModal({ "message": '接口出错', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  220. });
  221. }
  222. function getRecordDetailUpdate() {
  223. post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
  224. if (res.data.code === '0') {
  225. const data = res.data.data;
  226. const { beHospital, result, msg, checkStatus, drgs } = data;
  227. // global_check = checkStatus
  228. // const info=Object.assign(beHospital,result);
  229. // initMenu(JSON.parse(result.menuData));
  230. // $(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
  231. // global_activeTab=$(".sub-menu .page.active").attr("code");
  232. // initPatientInfo(info);
  233. // initContent(result.pageData);
  234. initList(msg);
  235. initScoreItem(msg);
  236. global_flawData = msg;
  237. global_flawDataPay = drgs;
  238. // setBoxHeight();
  239. // changePay()
  240. }
  241. });
  242. }
  243. //补录数据,接口来自技术服务部
  244. function supplementData() {
  245. //重新拉数据接口
  246. post(api.supplementData, { 'behospitalCode': global_id,'behospitalNum':'' }).then(function (res) {
  247. const {code,data}=res.data;
  248. if (code === '0') {
  249. if(data==='0'){ //0表示数据已更新,-1表示数据未更新
  250. //数据更新后先评分(评分成功后)再重新获取详情即刷新页面
  251. recordScore();
  252. }else{
  253. $.alerModal({ "message": '刷新失败,请重试~', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  254. }
  255. }else{
  256. $.alerModal({ "message": '刷新失败,请重试~', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  257. }
  258. });
  259. }
  260. function loading() {
  261. const str = `
  262. <div class="loadingBox">
  263. <div class="mask"></div>
  264. <img class="loadingImg" src=${loadingImg} alt="loading" />
  265. </div>
  266. `
  267. $("body", parent.document).append(str)
  268. }
  269. function hideLoading() {
  270. $(".loadingBox", parent.document).remove()
  271. }
  272. //评分
  273. function recordScore() {
  274. const param = {
  275. behospitalCode: global_id
  276. };
  277. loading();
  278. post(api.recordScore, param).then(res => {
  279. if (res.data.code === '0') {
  280. hideLoading();
  281. //评分成功,刷新病历详情页面
  282. window.parent.location.reload()
  283. } else {
  284. hideLoading()
  285. $.alerModal({ "message": res.data.msg || '刷新失败,请重试~', type: "tip", time: '1000', isFather: true, fatherWrapper: $("#mainBox", parent.document) });
  286. }
  287. }).catch(() => {
  288. hideLoading()
  289. $.alerModal({ "message": '刷新失败,请重试~', type: "tip", win: 'default', time: '1000', isFather: true, fatherWrapper: $("#mainBox", parent.document) });
  290. })
  291. }
  292. function changePay() {
  293. $(document).on('click', ".titleSpecial span", function () {
  294. let type = $(this).attr("data-type")
  295. if (type == 1) {
  296. initList(global_flawDataPay, type);
  297. } else {
  298. initList(global_flawData, type);
  299. }
  300. })
  301. }
  302. //填充患者信息
  303. function initPatientInfo(data) {
  304. const obj = Object.assign({}, data, { showCheckBtns, checkState: global_check, checkStateHome: global_check_home });
  305. $("#infoTmpl").tmpl(obj).appendTo("#patientInfo");
  306. /*$(".check").on("click", function(){
  307. checkQc()
  308. })*/
  309. $(".ywCheck").on("click", function () {
  310. checkYwQc()
  311. })
  312. }
  313. //显示病例模块明细
  314. function initContent(data,type) {
  315. const obj = JSON.parse(data);
  316. let info = [];
  317. let hml = '', moduleId = '';
  318. if(type == 2){
  319. formatSpecPage(obj["谈话告知书"], "谈话告知书");
  320. formatSpecPage(obj["知情同意书"], "知情同意书");
  321. }
  322. // formatSpecPage(obj["医嘱信息"],"医嘱信息");
  323. $(".content-box").show();
  324. for (let k in obj) {
  325. if (k === "谈话告知书" || k === "知情同意书") {
  326. continue;
  327. }
  328. for (let i in obj[k]) {
  329. info = formatInfoData(k, obj[k][i]);
  330. moduleId = info.mode_id;
  331. if (global_modules[moduleId]) {
  332. hml = initModuleData(moduleId, obj[k]);
  333. $.tmpl(hml, info).appendTo("#contentInfo");
  334. } else {
  335. const icon = require("../images/empty1.png");
  336. const sid = moduleId ? "(" + moduleId + ")" : "";
  337. const code = k.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
  338. const emptyStr = `<div class="empty">
  339. <img src="${icon}" alt="空"/>
  340. <p>暂无信息~</p>
  341. </div>`;
  342. if (!$(".content-item[code=" + code + "] .empty").length) { //显示一条空提示即可
  343. hml = '<div class="content-item" code="' + code + '">' +
  344. '<h2 class="title">' + k + sid + '</h2>' + emptyStr + '</div>';
  345. $.tmpl(hml, {}).appendTo("#contentInfo");
  346. }
  347. }
  348. }
  349. }
  350. $(".content-item[code=" + global_activeTab + "]").show();
  351. //console.log(obj)
  352. }
  353. function formatInfoData(k, data) {
  354. let obj = {}, name = "";
  355. for (let i in data) {
  356. if (i !== "mode_id") {
  357. name = i.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, "").replace(/^[0-9]+/, "a"); //过滤key中存在的特殊符号,模板会渲染不出来且不报错
  358. obj[name] = data[i].replace(/\n/g, "<br/>") || "";
  359. } else {
  360. obj[i] = data[i].replace(/\n/g, "<br/>") || "";
  361. }
  362. }
  363. return Object.assign({ title: k }, obj);
  364. }
  365. //知情同意书、谈话告知书
  366. function formatSpecPage(data, title, type) {
  367. $(".page-item[code='缺陷总览']").remove()
  368. $("#appointBookTmpl").tmpl({ title, data }).appendTo(".flaw-table");
  369. setBoxHeight();
  370. $(".page-anchor").on("click", function () {
  371. const code = $(this).attr("code");
  372. const pCode = $(this).parents("tr").attr("code").replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
  373. const tCode = $(this).parents("tr").attr("code")
  374. //菜单同步状态
  375. if (menuList.indexOf(tCode) == -1) {
  376. console.log(123);
  377. $.alerModal({ "message": '模块数据缺失~', type: "tip", time: '1000', isFather: true, fatherWrapper: $(".flaw-table", parent.document) });
  378. return;
  379. }
  380. //菜单同步状态
  381. $(".sub-menu .page[code=" + pCode + "]").parents(".list-1").click();
  382. $(".sub-menu .page[code=" + pCode + "],.menu-mini .page[code=" + pCode + "").click();
  383. //缺陷定位
  384. $(".info-item .cont,.flaw-item,td").removeClass("active");
  385. // const flawItem = $(".flaw-item .title a[code=" + code + "]");
  386. // if (!flawItem.length) {
  387. // $.alerModal({ "message": '模块数据缺失~', type: "tip", time: '1000', isFather: true, fatherWrapper: $(".flaw-table", parent.document) });
  388. // return;
  389. // }
  390. $(".flaw-item .title a[code=" + code + "]").click();
  391. const anch = $(".flaw-item .title a[code=" + code + "]").attr("href");
  392. if ($(anch)[0]) {
  393. $('#contentInfo').scrollTop($(anch).offset().top - 60);
  394. }
  395. });
  396. if (global_activeTab == "缺陷总览") {
  397. $(".check").css("display", "none")
  398. } else {
  399. $(".check").css("display", "block")
  400. }
  401. if (type && type == 1) {
  402. $(".titleNo").css({
  403. 'background-color': '#00A1FF',
  404. 'color': '#fff',
  405. 'border-color': '#00A1FF'
  406. })
  407. $(".titlePay").css({
  408. 'background-color': '#fff',
  409. 'border': '1px solid #777',
  410. 'border-right': 0,
  411. 'color': '#777'
  412. })
  413. setBoxHeight()
  414. } else if (type && type == 2) {
  415. $(".titleNo").css({
  416. 'background-color': '#fff',
  417. 'border': '1px solid #777',
  418. 'border-left': 0,
  419. 'color': '#777'
  420. })
  421. $(".titlePay").css({
  422. 'background-color': '#00A1FF',
  423. 'color': '#fff',
  424. 'border-color': '#00A1FF'
  425. })
  426. setBoxHeight()
  427. }
  428. }
  429. function initList(data, type) {
  430. //$("#flawTotalList").tmpl({title:"缺陷总览",data:data}).appendTo(".flaw-table");
  431. formatSpecPage(data, "缺陷总览", type);
  432. $(".flaw-table").show();
  433. $(".flaw-table .page-item[code=" + global_activeTab + "]").show();
  434. $(".slide-up").off("click").on("click", function () {
  435. const name = $(this).text();
  436. $("tr[code='" + name + "']").slideToggle();
  437. $(this).toggleClass("down");
  438. });
  439. }
  440. //评分项数据填充
  441. function initScoreItem(data) {
  442. $("#flaws .flaw-box").html("");
  443. let hasAu = showCheckBtns && global_check_show && hasData('FUNC000013'); //修改缺陷权限
  444. let hasAu2 = showCheckBtns && global_check_show && hasData('FUNC000012'); //删除缺陷权限
  445. let hasAu4 = check_Operation_WithAppeal && showCheckBtns
  446. let hasAu3 = check_Operation_WithAppeal
  447. for (let k in data) {
  448. for (let i = 0; i < data[k].length; i++) {
  449. let item = data[k][i];
  450. item.hasAu3 = hasAu3
  451. }
  452. $("#flawTmpl").tmpl(data[k]).appendTo("#flaws .flaw-box");
  453. }
  454. showFlawList();
  455. $(".flaw-item .oper a").unbind("click").click(function () {
  456. const i = $(".flaw-item[code=" + global_activeTab + "]").index($(this).parents(".flaw-item"));
  457. const code = $(this).attr("code");
  458. const isEdit = $(this).is(".edit-flaw");
  459. //if(!hasAu)return
  460. if (isEdit && hasAu) {
  461. showModal('0', code, i); //编辑
  462. } else if (!isEdit && hasAu2) {
  463. if ($(this).is(".recover-flaw")) {
  464. showModal('3', code, i); //恢复
  465. } else {
  466. showModal('1', code, i); //删除
  467. }
  468. }
  469. })
  470. $(".edit-flaw").css({ "display": hasAu ? "inline" : "none" });
  471. $(".del-flaw").css({ "display": hasAu2 ? "inline" : "none" });
  472. $(".add-flaw").css({ "display": hasAu4 && global_check_show ? "inline" : "none" });
  473. $(".recover-flaw").css({ "display": hasAu2 ? "inline" : "none" });
  474. $(".flaw-item .title a[href]").unbind("click").click(function () {
  475. const id = $(this).attr("href");
  476. const anchors = $(this).attr("anchors").split(",");
  477. let ans = anchors.map((it) => {
  478. return "#anchor" + it;
  479. });
  480. $(".info-item .cont,.flaw-item,td").removeClass("active");
  481. $(ans.join(",")).addClass("active");
  482. $(this).parents(".flaw-item").addClass("active");
  483. });
  484. }
  485. //显示缺陷列表
  486. function showFlawList() {
  487. const hml = $(".flaw-item[code=" + global_activeTab + "]");
  488. if (hml.length) {
  489. hml.show();
  490. $("#flaws .empty").hide();
  491. } else {
  492. $("#flaws .empty").length ? $("#flaws .empty").show() : $("#emptyTmpl").tmpl().appendTo("#flaws .flaw-box");
  493. }
  494. showAppealDetailEvent();
  495. }
  496. //删除评分项
  497. function delScore(id, info, isRecover) {
  498. const text = isRecover ? "恢复" : "删除";
  499. const param = {
  500. 'behospitalCode': global_id,
  501. 'optResultAlgVO': {
  502. 'id': id
  503. },
  504. 'delStatus': isRecover ? 1 : 0
  505. };
  506. post(api.delScore, param).then(function (res) {
  507. if (res.data.code === '0') {
  508. $("#delModal").hide();
  509. updateFlaws(res.data.data);
  510. $("#anchor" + info.pageKeyList[0]).removeClass("active");
  511. $.alerModal({ "message": text + "成功", type: "tip", time: '1000', win: true });
  512. } else {
  513. $.alerModal({ "message": res.data.msg || (text + '失败,请重试~'), type: "tip", time: '1000', win: 'default' });
  514. }
  515. }).catch(() => {
  516. $.alerModal({ "message": text + '失败,请重试~', type: "tip", time: '1000', win: 'default' });
  517. });
  518. }
  519. //修改评分项
  520. function editScore(info) {
  521. info.reviewer = info.exampleDate > info.gmtModified ? info.reviewer : info.linkman
  522. info.exampleDate = info.exampleDate > info.gmtModified ? info.exampleDate : info.gmtModified
  523. const param = {
  524. "behospitalCode": global_id,
  525. "optResultAlgVO": info
  526. };
  527. post(api.editScore, param).then(function (res) {
  528. if (res.data.code === '0') {
  529. $("#delModal").hide();
  530. updateFlaws(res.data.data);
  531. $.alerModal({ "message": "修改成功", type: "tip", time: '1000', win: true });
  532. } else {
  533. $.alerModal({ "message": '修改失败,请重试~', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  534. }
  535. }).catch(() => {
  536. $.alerModal({ "message": '修改失败,请重试~', type: "tip", time: '1000', isFather: true, win: 'default', fatherWrapper: $("#mainBox", parent.document) });
  537. });
  538. }
  539. //添加评分项
  540. function addScore(info) {
  541. const optResultAlgVO = {
  542. "casesEntryId": info.casesEntryId,
  543. "casesId": info.casesId,
  544. "casesScore": info.caseScore,
  545. "code": info.code || "",
  546. "id": info.id || "",
  547. "info": info.info || "",
  548. "isReject": info.isReject,
  549. "msg": info.msg || "",
  550. "score": info.score,
  551. "explainInfo": info.explainInfo,
  552. }
  553. const param = {
  554. "behospitalCode": global_id,
  555. "optResultAlgVO": optResultAlgVO
  556. };
  557. post(api.addScore, param).then(function (res) {
  558. if (res.data.code === '0') {
  559. $("#delModal").hide();
  560. updateFlaws(res.data.data);
  561. $.alerModal({ "message": "添加成功", type: "tip", win: true, time: '1000' });
  562. } else {
  563. $.alerModal({ "message": "添加失败,请重试~", type: "tip", win: 'default', time: '1000' });
  564. }
  565. }).catch(() => {
  566. $.alerModal({ "message": "添加失败,请重试~", type: "tip", win: 'default', time: '1000' });
  567. });
  568. }
  569. //显示删除/修改弹窗
  570. function showModal(flag, code, i, id, qcresultDetailId) {
  571. console.log(flag);
  572. $("#delModal .modal-body").html("");
  573. $("#delModal").show();
  574. $("#delModal .cancel").text("关闭")
  575. $("#delModal .cancel").hide();
  576. $(".info-item .cont,.flaw-item .title,td").removeClass("active");
  577. //事件解绑
  578. $("#delModal .confirm").off("click");
  579. const flawsList = formatFlawKeys(global_flawData);
  580. const info = flawsList[global_activeTab] && flawsList[global_activeTab][i];
  581. if (flag === '0') { //修改
  582. $("#delModal .confirm").show()
  583. $("#delModal .title").text("修改");
  584. $("#delModal .confirm").text("保存");
  585. $("#editTmpl").tmpl(info).appendTo("#delModal .modal-body");
  586. $("#qcScore,#qcMsg,#qcInfo").off("input");
  587. //分数输入验证
  588. $("#qcScore").on("input", function () {
  589. const val = $(this).val();
  590. if (/^[0-9]\d*$|^[0-9]\d*(.\d)?$/.test(val) && val <= 100) {
  591. $(".edit-box .warning").hide();
  592. } else {
  593. $(".edit-box .warning .red").text("支持≥0且≤100的数字输入,最多保留小数点后1位~");
  594. $(".edit-box .warning").show();
  595. }
  596. });
  597. //提示信息输入验证
  598. $("#qcMsg").on("input", function () {
  599. const val = $(this).val();
  600. $(this).attr("title", val)
  601. if (val.trim()) {
  602. $(".edit-box .warning").hide();
  603. } else {
  604. $(".edit-box .warning .red").text("提示信息不能为空~");
  605. $(".edit-box .warning").show();
  606. }
  607. });
  608. //提示信息输入验证
  609. $("#qcInfo").on("input", function () {
  610. const val = $(this).val();
  611. $(this).attr("title", val)
  612. if (val.length > 125) {
  613. $(".edit-box .warning .red").text("备注不能超过125个字~");
  614. $(".edit-box .warning").show();
  615. } else {
  616. $(".edit-box .warning").hide();
  617. return;
  618. }
  619. });
  620. if ($("#qcInfo").val().length > 125) {
  621. $(".edit-box .warning .red").text("备注不能超过125个字~");
  622. $(".edit-box .warning").show();
  623. return;
  624. }
  625. $("#delModal .confirm").unbind("click").click(function () {
  626. if ($(".edit-box .warning").is(":visible")) {
  627. return;
  628. }
  629. if (!$("#qcMsg").val().trim()) {
  630. $(".edit-box .warning .red").text("提示信息不能为空~");
  631. $(".edit-box .warning").show();
  632. return;
  633. }
  634. const obj = Object.assign({}, info, { explainInfo: $("#delModal #qcInfo").val(), msg: $("#delModal #qcMsg").val(), score: $("#delModal #qcScore").val() });
  635. editScore(obj);
  636. });
  637. } else if (flag === '5') { //查看
  638. $("#delModal .title").text("查看");
  639. $("#delModal .confirm").hide();
  640. $("#delModal .cancel").show();
  641. $("#delModal .modal-box").css("margin-top", '-245px');
  642. //0申诉1驳回2审核
  643. //新增项模板
  644. getAppealDetail(code, i, id, qcresultDetailId);
  645. } else if (flag === '2') { //新增
  646. $("#delModal .confirm").show();
  647. $("#delModal .title").text("新增");
  648. $("#delModal .confirm").text("保存");
  649. $("#addFlawTmpl").tmpl().appendTo("#delModal .modal-body");
  650. $("#flawDropTmpl").tmpl({ info: code }).appendTo("#delModal .modal-body ul");
  651. $("#addQcScore,#addQcMsg,#addQcInfo").off("input");
  652. //分数输入验证
  653. $("#addQcScore").on("input", function () {
  654. const val = $(this).val();
  655. if (/^[0-9]\d*$|^[0-9]\d*(.\d)?$/.test(val) && val <= 100) {
  656. $(".add-box .warning").hide();
  657. } else {
  658. $(".add-box .warning .red").text("支持≥0且≤100的数字输入,最多保留小数点后1位~");
  659. $(".add-box .warning").show();
  660. return;
  661. }
  662. });
  663. //提示信息输入验证
  664. $("#addQcMsg").on("input", function () {
  665. const val = $(this).val();
  666. $(this).attr("title", val)
  667. if (val.trim()) {
  668. $(".add-box .warning").hide();
  669. } else {
  670. $(".add-box .warning .red").text("提示信息不能为空~");
  671. $(".add-box .warning").show();
  672. return;
  673. }
  674. });
  675. //提示信息输入验证
  676. $("#addQcInfo").on("input", function () {
  677. const val = $(this).val();
  678. $(this).attr("title", val)
  679. if (val.length > 125) {
  680. $(".add-box .warning .red").text("备注不能超过125个字~");
  681. $(".add-box .warning").show();
  682. } else {
  683. $(".add-box .warning").hide();
  684. return;
  685. }
  686. });
  687. $("#delModal .confirm").unbind("click").click(function () {
  688. if (!$(".flaw-drop-input").attr("code")) {
  689. $(".add-box .warning .red").text("请选择质控条目~");
  690. $(".add-box .warning").show();
  691. return;
  692. }
  693. const msg = $("#delModal #addQcMsg").val();
  694. const score = Number($("#delModal #addQcScore").val());
  695. const explainInfo = $("#delModal #addQcInfo").val();
  696. if ($(".add-box .warning").is(":visible")) {
  697. return;
  698. }
  699. if (!msg.trim()) {
  700. $(".add-box .warning .red").text("提示信息不能为空~");
  701. $(".add-box .warning").show();
  702. return;
  703. }
  704. if ((!score) && $("#delModal #addQcScore").val() != '0') {
  705. $(".add-box .warning .red").text("分值不能为空~");
  706. $(".add-box .warning").show();
  707. return;
  708. }
  709. if ($("#addQcInfo").val().length > 125) {
  710. $(".add-box .warning .red").text("备注不能超过125个字~");
  711. $(".add-box .warning").show();
  712. return;
  713. }
  714. const obj = Object.assign({}, global_selectedFlaw, { msg, score, explainInfo });
  715. addScore(obj);
  716. });
  717. } else if (flag === '3') {
  718. $("#delModal .confirm").show();
  719. $("#delModal .title").text("恢复提示");
  720. $("#delModal .modal-body").html('<p>确定要恢复该评分记录吗?</p>');
  721. $("#delModal .confirm").text("取消").unbind("click").click(function () {
  722. $("#delModal").hide();
  723. });
  724. $("#delModal .cancel").show().text("恢复").unbind("click").click(function () {
  725. delScore(code, info, true);
  726. });
  727. } else {
  728. $("#delModal .confirm").show();
  729. $("#delModal .title").text("删除提示");
  730. $("#delModal .modal-body").html('<p>确定要删除该评分记录吗?</p>');
  731. $("#delModal .confirm").text("取消").unbind("click").click(function () {
  732. $("#delModal").hide();
  733. });
  734. $("#delModal .cancel").show().text("删除").unbind("click").click(function () {
  735. console.log(123);
  736. delScore(code, info);
  737. });
  738. }
  739. }
  740. function getAppealDetail(id, flg, casesEntryId, qcresultDetailId) {
  741. const param = {
  742. behospitalCode: global_id,
  743. casesEntryId: casesEntryId,
  744. hospitalId: global_hid,
  745. qcresultDetailId: qcresultDetailId,
  746. id: +id
  747. };
  748. post(api.getApprovedView, param).then((res) => {
  749. const info = res.data.data || {};
  750. const appealInfo = info.appealExamineRecordDTOList;
  751. $("#appealStatusTmpl").tmpl(appealInfo).appendTo("#delModal .modal-body");
  752. $("#delModal .cancel").text("关闭").unbind("click").click(function () {
  753. $("#delModal").hide();
  754. });
  755. /*if (flg === '1') {
  756. $(".check-item").hide();
  757. $(".reject-item").show();
  758. } else if (flg === '2') {
  759. $(".check-item").show();
  760. }*/
  761. })
  762. }
  763. //缺陷列表key值去掉特殊符号
  764. function formatFlawKeys(data) {
  765. const obj = {};
  766. for (let k in data) {
  767. obj[k.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '')] = data[k];
  768. }
  769. return obj;
  770. }
  771. //获取缺陷条目下拉列表
  772. function getQcCasesEntry(name) {
  773. const id = $("#subMenu [code=" + global_activeTab + "]").attr("mode");
  774. const param = {
  775. 'behospitalCode': global_id,
  776. 'entryName': name || "",
  777. 'modeId': id
  778. };
  779. post(api.findQcCasesEntry, param).then(function (res) {
  780. if (res.data.code === '0') {
  781. const data = res.data.data;
  782. if (name) {
  783. global_flaws = data;
  784. $("#delModal .modal-body ul").html("");
  785. $("#flawDropTmpl").tmpl({ info: data }).appendTo("#delModal .modal-body ul");
  786. } else {
  787. global_flaws = data;
  788. if ($("#delModal").css("display") == "block") {
  789. $("#flawDropTmpl").tmpl({ info: data }).appendTo("#delModal .modal-body ul");
  790. return
  791. }
  792. showModal('2', data);
  793. }
  794. }
  795. });
  796. }
  797. //增加条目弹窗元素事件
  798. $("body").on("click", ".add-box .flaw-drop-input", function () {
  799. $(".add-box .drop-box").addClass("show");
  800. });
  801. $("body").on("blur", ".add-box .flaw-drop-input", function () {
  802. setTimeout(function () {
  803. $(".add-box .drop-box").removeClass("show");
  804. }, 300)
  805. });
  806. $("body").on("input", ".add-box .flaw-drop-input", function () {
  807. $(this).attr({ "code": "", "title": $(this).val().trim() });
  808. getQcCasesEntry($(this).val().trim());
  809. });
  810. $("body").on("click", ".add-box .drop-box li", function () {
  811. const n = $(this).attr("idx");
  812. const flaw = global_flaws[n];
  813. const { score, msg, entryName, casesEntryId } = flaw;
  814. global_selectedFlaw = flaw;
  815. global_entryName = entryName
  816. global_casesEntryId = casesEntryId
  817. $(".flaw-drop-input").val(entryName).attr({ "code": casesEntryId, "title": entryName });
  818. $("#addQcMsg").val(msg).attr("title", msg);
  819. $("#addQcScore").val(score);
  820. $(".add-box .warning").hide();
  821. $(".add-box .drop-box").removeClass("show");
  822. console.log(123);
  823. });
  824. $(document).on("blur", ".flaw-drop-input", (e) => {
  825. $('.flaw-drop-input').val(global_entryName).attr({ "code": global_casesEntryId, "title": global_entryName });
  826. });
  827. //更新缺陷列表
  828. function updateFlaws(info) {
  829. $("#patientInfo .level").text("质控等级:" + info.level);
  830. $("#patientInfo .score").text("质控得分:" + info.scoreRes);
  831. const param = {
  832. 'behospitalCode': global_id,
  833. 'paramStr': [
  834. "msg"
  835. ]
  836. };
  837. post(api.getRecordDetail, param).then(function (res) {
  838. if (res.data.code === '0') {
  839. const data = res.data.data;
  840. const { msg } = data;
  841. initScoreItem(msg);
  842. global_flawData = msg;
  843. }
  844. });
  845. }
  846. //获取病例模板
  847. function getInfoModule(moduleId) {
  848. const param = {
  849. moduleId: moduleId
  850. };
  851. post(api.getInfoModule, param).then(function (res) {
  852. if (res.data.code === '0') {
  853. const data = res.data.data;
  854. cachemoduleDatas(data);
  855. getRecordDetail();
  856. }
  857. });
  858. }
  859. //模板数据缓存
  860. function cachemoduleDatas(data) {
  861. const moudle = data.moduleDetail;
  862. global_modules[data.modeName] = [];
  863. for (let i in moudle) {
  864. global_modules[data.modeName].push(moudle[i]);
  865. }
  866. }
  867. //初始化模板
  868. function initModuleData(mid, obj) {
  869. const n = obj.length;
  870. const module = global_modules[mid].moduleDetail;
  871. const key = global_modules[mid].modeName.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
  872. let hml = '<div class="content-item" code="' + key + '">' +
  873. '<h2 class="title">' + global_modules[mid].modeName + '(' + mid + ')</h2>' +
  874. (n > 1 ? '<div class="container">' : '<div class="container content-hts">');
  875. for (let i in module) {
  876. hml = hml + '<div class="info-item">';
  877. for (let j = 0; j < module[i].length; j++) {
  878. const detal = module[i][j].questionDTO;
  879. const { tagType } = detal;
  880. switch (tagType) {
  881. case 1:
  882. hml = hml + simpleStructure(detal, obj);
  883. break;
  884. case 4:
  885. hml = hml + combineStructure(detal);
  886. break;
  887. default:
  888. break;
  889. }
  890. }
  891. hml = hml + "</div>"
  892. }
  893. return hml + "</div></div>";
  894. }
  895. //基础类型结构生成
  896. function simpleStructure(data, obj) {
  897. const { name, val, monoLine, addLine, position, bold, retract, id } = data;
  898. if (name === "手术记录表格-1") {
  899. const value = val.replace("【", "").replace("】", "");
  900. const diag = obj[0][value] ? JSON.parse(obj[0][value]) : "";
  901. let thml = `<div class="cont" style="width: 100%;" id="anchor${id}">`;
  902. thml += $("#tableTmpl").tmpl({ k: "手术信息", data: diag })[0].outerHTML + "</div>";
  903. return thml;
  904. }
  905. if (name === "出院诊断表格-1") {
  906. const value = val.replace("【", "").replace("】", "");
  907. const diag = obj[0][value] ? JSON.parse(obj[0][value]) : "";
  908. let thml = `<div class="cont" style="width: 100%;" id="anchor${id}">`;
  909. thml += $("#tableTmpl").tmpl({ k: "出院诊断", data: diag })[0].outerHTML + "</div>";
  910. return thml;
  911. }
  912. const posClass = position === 1 ? 'text-left' : '';
  913. const boldClass = bold === 1 ? 'text-bold' : '';
  914. const retractClass = retract === 1 ? 'text-indent' : '';
  915. const lineHml = ('<p class="' + posClass + ' ' + boldClass + ' ' + retractClass + '">' + extractVars(val) + '</p>');
  916. const txtHml = ('<p style="display: inline;vertical-align: middle;" class="' + posClass + ' ' + boldClass + ' ' + retractClass + '">' + extractVars(val) + '</p>');
  917. let hml = addLine || monoLine ? `<div class="cont ${posClass}" style="width: 100%;" id="anchor${id}">` : `<div class="cont" id="anchor${id}">`;
  918. hml = hml + `<span class="label">${name}</span>` + (addLine ? lineHml : txtHml) + `</div>`;
  919. return hml;
  920. }
  921. //组合类型结构生成
  922. function combineStructure(data) {
  923. const { name, questionMapping, id } = data;
  924. let hml = '<div class="inner-table"><table>';
  925. const colNum = Math.ceil(questionMapping.length / 2);
  926. let tdVal = '';
  927. const regexp = /(【(.+?)】)/g;
  928. for (let i = 0; i < questionMapping.length;) {
  929. if (questionMapping[i + 1]) {
  930. tdVal = "<td id='anchor" + questionMapping[i].id + "'>" + questionMapping[i].name + extractVars(questionMapping[i].val) + "</td><td id='anchor" + questionMapping[i + 1].id + "'>" + questionMapping[i + 1].name + extractVars(questionMapping[i + 1].val) + "</td>";
  931. } else {
  932. tdVal = "<td id='anchor" + questionMapping[i].id + "'>" + questionMapping[i].name + extractVars(questionMapping[i].val) + "</td><td></td>";
  933. }
  934. if (i == 0) {
  935. hml = hml + `<tr><td rowspan="${colNum}" id='anchor${id}'>${name}</td>${tdVal}`;
  936. } else {
  937. hml = hml + `<tr>${tdVal}`;
  938. }
  939. hml = hml + "</tr>";
  940. i = ((i + 2) > questionMapping.length ? i + 1 : i + 2)
  941. }
  942. hml = hml + "</table></div>";
  943. return hml;
  944. }
  945. //抽取变量
  946. function extractVars(org) {
  947. const regexp = /(【(.+?)】)/g;
  948. const arr = org.split(regexp);
  949. //console.log(arr)
  950. let htl = '', val = '';
  951. for (let i = 0; i < arr.length; i++) {
  952. val = arr[i].indexOf("【") != -1 ? '' : (arr[i - 1] && arr[i - 1].indexOf("【") != -1 ? "{{html " + arr[i] + "}}" : arr[i]);
  953. htl = htl + val;
  954. }
  955. return htl;
  956. }
  957. //获取所有模板
  958. function getAllModules() {
  959. const param = {
  960. hospitalId: getUrlArgObject("hid"),
  961. modeId: ''
  962. };
  963. post(api.getModuleById, param).then((res) => {
  964. if (res.data.code === '0') {
  965. const data = res.data.data;
  966. global_modules = data;
  967. getRecordDetail();
  968. $("#loading").hide();
  969. /*setTimeout(function(){
  970. $(".operation").show()
  971. },50)*/
  972. }
  973. });
  974. }
  975. /*function checkQc(){
  976. const param={
  977. behospitalCode:getUrlArgObject("id"),
  978. hospitalId:getUrlArgObject("hid"),
  979. checkType: global_activeTab == '病案首页'?'1':'0'
  980. };
  981. post(api.checkQc,param).then((res)=>{
  982. if(res.data.code==='0') {
  983. if(global_activeTab == '病案首页'){
  984. global_check_home = 1
  985. }else{
  986. global_check = 1
  987. }
  988. $(".check").text("重新核查")
  989. $.alerModal({"message":"核查成功",type:"tip",time:'1000',win:true});
  990. }else{
  991. $.alerModal({"message":res.data.msg ||"核查失败",type:"tip",time:'1000',isFather: false});
  992. }
  993. });
  994. }*/
  995. function checkYwQc() {
  996. const param = {
  997. behospitalCode: getUrlArgObject("id"),
  998. hospitalId: getUrlArgObject("hid"),
  999. };
  1000. post(ywCheckApi.recordCheck, param).then((res) => {
  1001. if (res.data.code === '0') {
  1002. global_check = 1
  1003. $(".ywCheck").text("重新核查")
  1004. $.alerModal({ "message": "核查成功", type: "tip", time: '1000', win: true });
  1005. } else {
  1006. $.alerModal({ "message": res.data.msg || "核查失败", type: "tip", time: '1000', isFather: false });
  1007. }
  1008. });
  1009. }
  1010. });