const $ = require('jquery'); require("../css/assertTypeDetail.less"); require('./modal.js'); const {api} = require('./api.js') const {post,getCookie,getUrlArgObjectNew,getUrlArgObject,debounce} = require('./utils.js') const iconCheck= require("./../images/icon_check.png") const iconUnCheck = require("./../images/icon_unchecked.png") const arrowUp = require("./../images/arrow_up22.png") const arrowDown = require("./../images/arrow_down22.png") let dataCopy,paramType,paramId,submitMsg="新增成功",win=null $(function(){ let srcUrl = $("#contentIframe",parent.document).attr("src") paramType = getUrlArgObject("type")||"" paramId = getUrlArgObject("id")||"" getList(paramType)//获取条目列表 }) function setInpWidth(){ const winWidth = $(window).width() $('.patientNumInp').css('width', winWidth-155-15 +'px') } setInpWidth() $(window).resize(function(){ setInpWidth() }) function getList(type){ if(!type){ post(api.getEntryByHospital,{}).then(res =>{ let result = res.data if(result.code == '0'){ const data = result.data; win = true renderData(data) }else{ } }).catch((e) =>{ }) }else{ if(type =='"edit"'){ $('.partTitle p span').html('修改') submitMsg="修改成功" win = true }else{ $('.partTitle p span').html('复制') submitMsg="复制成功" win = true } post(api.typeGetById,{id: paramId}).then(res =>{ let result = res.data if(result.code == '0'){ const data = result.data; const qcName = data.name const tabData = data.entryMap if(type =='"edit"'){ $('.patientNumInp').val(qcName) } renderData(tabData) }else{ } }).catch((e) =>{ }) } } function renderData(data){ dataCopy = data const dataKeys = Object.keys(dataCopy) let str = "" for(let i = 0; i < dataKeys.length; i++){ str += `
${dataKeys[i]}
` if(dataCopy[dataKeys[i]].length > 0){ str += `
操作质控条目是否启用
` } for(let j = 0; j < dataCopy[dataKeys[i]].length; j++){ const dataItem = dataCopy[dataKeys[i]][j] str += `
${dataItem.sel == '1' ? ``:``}${dataItem.name}${dataItem.isUsed == '1' ? "是":"否"}
` } if(dataCopy[dataKeys[i]].length > 0){ str += `
` } str += `
` } $('.listTypeAll').html(str) bindBlockSlideToggle() bindCheck() } function bindBlockSlideToggle(){ $('.caseEntryName').click(function(){ const display = $(this).parent().find('.caseEntryDetail').css("display"); if(display === "none"){ $(this).find('img').attr('src', arrowUp) $('.caseEntryDetail').slideUp() $(this).parent().find('.caseEntryDetail').slideDown() } else{ $(this).find('img').attr('src', arrowDown) $('.caseEntryDetail').slideUp() } }) } function bindCheck(){ $('.iconCheck').click(function(){ const checked = $(this).attr('src') == iconCheck; const index = $(this).parent().attr('data-index') const pIndex = $(this).parent().attr('data-pIndex') if(checked){ dataCopy[pIndex][index].sel = 0 $(this).attr('src',iconUnCheck) } else{ dataCopy[pIndex][index].sel = 1 $(this).attr('src',iconCheck) } }) } $('.submit').click(debounce(function(){ const qcName = $('.patientNumInp').val().trim(); if(!qcName){ $.alerModal({"message":"质控类型不能为空",type:"tip",time:'1000',isFather: true, fatherWrapper: $("#mainBox", parent.document)}); return } let qcTypeCasesEntryVOList = [] const dataKeys = Object.keys(dataCopy) for(let i = 0; i < dataKeys.length; i++){ for(let j = 0; j < dataCopy[dataKeys[i]].length; j++){ const dataItem = dataCopy[dataKeys[i]][j] if(dataItem.sel == '1'){ qcTypeCasesEntryVOList.push({ caseEntryId: dataItem.id }) } } } const id = paramType == '"edit"' ? paramId:"" const param = { id:id, name: qcName, qcTypeCasesEntryVOList } if(!paramType){ post(api.addqcType,param).then(res =>{ let result = res.data if(result.code == '0'){ $.alerModal({"message":submitMsg,type:"tip",time:'1000',isFather: true,win:win, fatherWrapper: $("#mainBox", parent.document)}); setTimeout(function(){ $(parent.document).find("#contentIframe").attr("src","./assertType.html") },1000) }else{ $.alerModal({"message":res.data.msg,type:"tip",time:'1000',isFather: true,win:"default", fatherWrapper: $("#mainBox", parent.document)}); } }).catch((e) =>{ }) }else if(paramType == '"edit"'){ post(api.updateqcType,param).then(res =>{ let result = res.data if(result.code == '0'){ $.alerModal({"message":submitMsg,type:"tip",time:'1000',isFather: true,win:win, fatherWrapper: $("#mainBox", parent.document)}); setTimeout(function(){ $(parent.document).find("#contentIframe").attr("src","./assertType.html") },1000) }else{ $.alerModal({"message":res.data.msg,type:"tip",time:'1000',isFather: true,win:"default", fatherWrapper: $("#mainBox", parent.document)}); } }).catch((e) =>{ }) }else{ post(api.copyqcType,param).then(res =>{ let result = res.data if(result.code == '0'){ $.alerModal({"message":submitMsg,type:"tip",time:'1000',isFather: true,win:win, fatherWrapper: $("#mainBox", parent.document)}); setTimeout(function(){ $(parent.document).find("#contentIframe").attr("src","./assertType.html") },1000) }else{ $.alerModal({"message":res.data.msg,type:"tip",time:'1000',isFather: true,win:"default", fatherWrapper: $("#mainBox", parent.document)}); } }).catch((e) =>{ }) } // post(api.saveOrUpdate,param).then(res =>{ // let result = res.data // if(result.code == '0'){ // $.alerModal({"message":submitMsg,type:"tip",time:'1000',isFather: true,win:win, fatherWrapper: $("#mainBox", parent.document)}); // setTimeout(function(){ // $(parent.document).find("#contentIframe").attr("src","./assertType.html") // },1000) // }else{ // $.alerModal({"message":res.data.msg,type:"tip",time:'1000',isFather: true,win:"default", fatherWrapper: $("#mainBox", parent.document)}); // } // }).catch((e) =>{ // }) },300,true))