qcScore.js 38 KB

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