浏览代码

动态获取模板

zhouna 5 年之前
父节点
当前提交
61b629a98e
共有 3 个文件被更改,包括 43 次插入20 次删除
  1. 12 11
      src/js/qcList.js
  2. 30 9
      src/js/qcScore.js
  3. 1 0
      src/js/utils.js

+ 12 - 11
src/js/qcList.js

@@ -40,10 +40,11 @@ function getTabData(activePage){
     }
     post(api.qcList,param).then(res =>{
         if(res.data.code == '0'){
-            tabList = res.data.data.records
-            const totalPage = res.data.data.pages
-            const totalNum = res.data.data.total
-            renderTab(tabList)
+            const data = res.data.data;
+            tabList = data.records;
+            const totalPage = data.pages;
+            const totalNum = data.total;
+            renderTab(tabList,data.hospitalId);
             renderPagination(totalPage,activePage,totalNum)
             if(totalPage > 1){
                 renderPagination(totalPage,activePage,totalNum)
@@ -72,7 +73,7 @@ $(".filter").on("click", function(e){
     level = levelTemp
     getTabData(1)
 })
-function renderTab(data){
+function renderTab(data,hisId){
     let str = ``
     let hasSelectAll = true
     for(let i = 0; i < data.length; i++){
@@ -113,17 +114,17 @@ function renderTab(data){
     $('tbody').html(str)
     bindScoreOperaItem()
     bindRecordScoreOper()
-    bindScoreDetail()
+    bindScoreDetail(hisId)
 }
 
-function scoreDetail(id,age){
-    window.open(`./qcScore.html?id=${id}&age=${age}`)
+function scoreDetail(id,age,hid){
+    window.open(`./qcScore.html?id=${id}&age=${age}&hid=${hid}`)
 }
-function bindScoreDetail(){
+function bindScoreDetail(hisId){
     $('.patientNameSpan').on('click',function(e){
         const index = $(this).attr("data-index")
         const id = tabList[index].behospitalCode
-        const age = tabList[index].age
+        const age = tabList[index].age;
         const noScore = tabList[index].level == '未评分'
         if(noScore){
             dialog('请先进行评分!')
@@ -132,7 +133,7 @@ function bindScoreDetail(){
             },2000)
             return
         } else{
-            scoreDetail(id,age)
+            scoreDetail(id,age,hisId)
         }
        
     })

+ 30 - 9
src/js/qcScore.js

@@ -16,7 +16,8 @@ $(function(){
   //getSubMenu();
   //initScoreItem();
   //getRecordDetail();
-  getInfoModule(15);
+  getAllModules()
+  //getInfoModule(15);    //根据对应id获取模板
 function initMenu(data){
   const menu=[{id:0,name:"缺陷总览",parentId: -1,sonMode: []},...(data||[])];
   //菜单数据填充
@@ -101,12 +102,13 @@ function initPatientInfo(data){
 function initContent(data){
   const obj = JSON.parse(data);
   let info=[];
-  let hml='';
+  let hml='',moduleId='';
   for(let k in obj){
     for(let i in obj[k]){
       info=formatInfoData(k,obj[k][i]);
-      if(global_modules[k]){
-        hml=initModuleData(k,obj[k].length);
+      moduleId=info.mode_id;
+      if(global_modules[moduleId]){
+        hml=initModuleData(moduleId,obj[k].length);
         $.tmpl(hml,info).appendTo("#contentInfo");
       };
     }
@@ -126,8 +128,12 @@ function initContent(data){
 function formatInfoData(k,data){
   let obj = {},name="";
   for(let i in data){
-    name=i.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g,"").replace(/^[0-9]+/,"a");    //过滤key中存在的特殊符号,模板会渲染不出来且不报错
-    obj[name]=data[i].replace(/\n/g,"<br/>")||"";
+    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,"<br/>")||"";
+    }else{
+      obj[i]=data[i].replace(/\n/g,"<br/>")||"";
+    }
   }
   return Object.assign({title:k},obj);
 }
@@ -312,13 +318,14 @@ function formatFlawKeys(data){
   }
 
 //初始化模板
-  function initModuleData(key,n){
-    const module=global_modules[key];
+  function initModuleData(mid,n){
+    const module=global_modules[mid].moduleDetail;
+    const key = global_modules[mid].modeName;
     let hml = '<div class="content-item" code="'+key+'">' +
       '<h2 class="title">'+key+'</h2>' +
       (n>1?'<div class="container">':'<div class="container content-ht">');
 
-    for(let i=0;i<module.length;i++){
+    for(let i in module){
       hml=hml+'<div class="info-item">';
       for(let j=0;j<module[i].length;j++) {
         const detal = module[i][j].questionDTO;
@@ -389,6 +396,20 @@ function formatFlawKeys(data){
     }
     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();
+      }
+    });
+  }
 
 });
 

+ 1 - 0
src/js/utils.js

@@ -19,6 +19,7 @@ const api={
   addScore:'/qc/behospitalInfo/addCase' ,//添加评分项
   getRecordDetail:'/qc/behospitalInfo/getByBehospitalCode', //获取病例明细
   getInfoModule:'/qc/module/getById',
+  getModuleById:'/qc/module/getModuleMap'
 };
 
 //重写assign方法