123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- var dataBase,
- jiandangCase2;
- var d = dialog({contentType:'load', skin:'bk-popup'});
- function toast(msg){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
- }
- //请求失败
- function queryFailed(){ d.close();toast('请求失败');}
- $(function(){
- var case2 = window.localStorage.getItem("jiandangCase2");
- jiandangCase2 = case2?JSON.parse(case2):'';
- // 获取字典
- d.show()
- sendPost('patient/getArchiveComboList', {}, 'json', 'get',queryFailed, function(res) {
- d.close()
- if(res.status==200) {
- dataBase = res.data;
- var html = template('list_tmp',{data:dataBase,cache:jiandangCase2})
- $('.c-main').html(html)
- bindEvent()
- }else{
- toast('获取数据失败')
- }
- })
-
- function bindEvent(){
- $('.xc-li-more .one').on('click',function(e){
- e.stopPropagation();
- var $this = $(this)
- $this.addClass('active').siblings().removeClass('active')
- var $parent = $this.closest('.xc-li-more');
- if($this.attr('data-id')==1){
- $parent.find('.xc-li-radio').show()
- }else{
- $parent.find('.xc-li-radio').hide()
- $parent.find('.child').removeClass('active')
- $parent.find('input').val('')
- $parent.find('input.j-hide').hide()
- $parent.find('select.sickSel').attr('data-code','')
- $parent.find('select.sickSel').attr('data-name','')
- if($parent.hasClass('j-family')){
- addContent5(dataBase.familyHistory,true)//初始化
- }
- }
- })
- $(".j-checkbox").on('tap',function(){
- var $this = $(this).parent()
- if($this.hasClass('active')){
- $this.removeClass('active')
- }else{
- $this.addClass('active')
- }
- })
- $(".j-showbox").on('click',function(){
- var $this = $(this).parent()
- if($this.hasClass('active')){
- $this.removeClass('active')
- $this.find('input').hide()
- $this.find('input').val('')
- }else{
- $this.addClass('active')
- $this.find('input').css('display','block')
- }
- })
- //提交
- $(".jm-btn").on('tap',function(){
- var $gen = $('.j-gen').find('.one.active').attr('data-id'),
- $past = $('.j-past').find('.one.active').attr('data-id'),
- $drug = $('.j-drug').find('.one.active').attr('data-id'),
- $family = $('.j-family').find('.one.active').attr('data-id');
- function getCode($id){
- var that = $id.find('.j-noOther.active')
- var codeArr=[];
- for(var i=0;i<that.length;i++){
- codeArr.push(that.eq(i).attr('data-code'))
- }
- return codeArr.join(',')
- }
- function getName($id){
- var that = $id.find('.j-noOther.active')
- var nameArr=[];
- for(var i=0;i<that.length;i++){
- nameArr.push(that.eq(i).attr('data-name'))
- }
- return nameArr.join(',')
- }
- function getTime($id){
- var that = $id.find('.j-noOther.active .dateSel')
- var timeArr=[];
- for(var i=0;i<that.length;i++){
- timeArr.push(that.eq(i).val()?that.eq(i).val():'0')
- }
- return timeArr.join(',')
- }
-
- var allData = {
- education:$('#school').attr('data-code'),//教育
- educationName:$('#school').attr('data-name'),
- occupation:$('#job').attr('data-code'),//职业
- occupationName:$('#job').attr('data-name'),
- payment:$('#pay').attr('data-code'),//支付方式
- paymentName:$('#pay').attr('data-name'),
- disabilitys:$('#disability').attr('data-code'),//残疾
- disabilitysName:$('#disability').attr('data-name'),
- drugFlag:$drug==undefined?'':$drug,
- drugAllergys:getCode($('.j-drug')),//药物过敏
- drugAllergysName:getName($('.j-drug')),
- drugOtherContent:$('.j-drug').find('input.other').val().trim(),//过敏其他
- pastHistorysFlag:$past==undefined?'':$past,
- pastHistorys:getCode($('.j-past')),//既往史
- pastHistorysName:getName($('.j-past')),
- pastHistoryDate:getTime($('.j-past')),
- pastHistoryContent:$('.j-past').find('input.past').val().trim(),
- geneticFlag:$gen==undefined?'':$gen,
- geneticContent:$('.j-gen').find('input.other').val().trim(),//遗传病
- familyHistoryFlag:$family==undefined?'':$family,
- familyFatherHistorys:$('.j-sel').eq(0).find('select').attr('data-code'),//父亲的疾病
- familyMotherHistorys:$('.j-sel').eq(1).find('select').attr('data-code'), //母亲的疾病
- familyBrotherHistorys:$('.j-sel').eq(2).find('select').attr('data-code'), //兄弟的疾病
- familyChildrenHistorys:$('.j-sel').eq(3).find('select').attr('data-code'), //子女的疾病
- familyFatherHistorysName:$('.j-sel').eq(0).find('select').attr('data-name'),
- familyMotherHistorysName:$('.j-sel').eq(1).find('select').attr('data-name'),
- familyBrotherHistorysName:$('.j-sel').eq(2).find('select').attr('data-name'),
- familyChildrenHistorysName:$('.j-sel').eq(3).find('select').attr('data-name'),
- }
- //判断字段不为空
- if($drug == 1){
- if(!(allData.drugOtherContent || allData.drugAllergys)){
- toast('请选择药物过敏史')
- return
- }
- }
- if($past == 1){
- if(!(allData.pastHistoryContent || allData.pastHistorys)){
- toast('请选择既往史')
- return
- }
- }
- if($gen == 1){
- if(!allData.geneticContent){
- toast('请填写遗传病史')
- return
- }
- }
- if($family == 1){
- if(!(allData.familyFatherHistorys || allData.familyMotherHistorys || allData.familyBrotherHistorys || allData.familyChildrenHistorys)){
- toast('请选择家族史')
- return
- }
- }
- //跳转
- d.show()
- window.localStorage.setItem("jiandangCase2",JSON.stringify(allData))
- window.location.href = "xinxiqueren.html";
- })
- //选择时间
- $(".dateSel").mobiscroll().date({
- theme: "ios",
- lang: "zh",
- display: "bottom",
- dateFormat: "yy-mm-dd",
- onSelect: function(valueText, inst) {
-
- }
- })
- addContent1(dataBase.education)//文化
- addContent2(dataBase.occupation)//职业
- addContent3(dataBase.payment)//支付方式
- addContent4(dataBase.disability)//残疾
- addContent5(dataBase.familyHistory)//家族疾病
- }
- function addContent1(arr) {
- var len = arr.length;
- var html = "<option disabled selected></option>";
- for(var i = 0; i < len; i++) {
- if(jiandangCase2&&jiandangCase2.education == arr[i].code){
- html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }else{
- html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }
- }
- $('#schoolSel').html(html)
- $('#schoolSel').mobiscroll().select({
- theme: "ios",
- lang: "zh",
- placeholder:'请选择文化程度',
- display: "bottom",
- onSelect: function(valueText, inst) {
- $('#school').attr('data-code',inst._tempValue)
- $('#school').attr('data-name',valueText)
- }
- })
- }
- function addContent2(arr) {
- var len = arr.length;
- var html = "<option disabled selected></option>";
- for(var i = 0; i < len; i++) {
- if(jiandangCase2&&jiandangCase2.occupation == arr[i].code){
- html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }else{
- html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }
- }
- $('#jobSel').html(html)
- $('#jobSel').mobiscroll().select({
- theme: "ios",
- lang: "zh",
- placeholder:'请选择职业',
- display: "bottom",
- onSelect: function(valueText, inst) {
- $('#job').attr('data-code',inst._tempValue)
- $('#job').attr('data-name',valueText)
- }
- })
- }
- function addContent3(arr) {
- var len = arr.length;
- var html = "<option disabled selected></option>";
- for(var i = 0; i < len; i++) {
- if(jiandangCase2&&jiandangCase2.payment == arr[i].code){
- html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }else{
- html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }
- }
- $('#paySel').html(html)
- $('#paySel').mobiscroll().select({
- theme: "ios",
- lang: "zh",
- placeholder:'请选择支付方式',
- display: "bottom",
- onSelect: function(valueText, inst) {
- $('#pay').attr('data-code',inst._tempValue)
- $('#pay').attr('data-name',valueText)
- }
- })
- }
- function addContent4(arr) {
- var len = arr.length;
- var html = "<option disabled selected></option>";
- for(var i = 0; i < len; i++) {
- if(jiandangCase2&&jiandangCase2.disabilitys == arr[i].code){
- html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }else{
- html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
- }
- }
- $('#disabilitySel').html(html)
- $('#disabilitySel').mobiscroll().select({
- theme: "ios",
- lang: "zh",
- placeholder:'请选择残疾情况',
- display: "bottom",
- onSelect: function(valueText, inst) {
- $('#disability').attr('data-code',inst._tempValue)
- $('#disability').attr('data-name',valueText)
- }
- })
- }
- function addContent5(arr,init) {
- for(var i=0;i<$('.j-sel').length;i++){
- var $this = $('.j-sel').eq(i).find('.sickSel');
- var len = arr.length;
- var html = "<option disabled selected></option>";
- if(init){
- for(var j = 0; j < len; j++) {
- html += '<option value="'+arr[j].code+'">' + arr[j].value + '</option>'
- }
- $this.html(html)
- }else{
- for(var j = 0; j < len; j++) {
- if(jiandangCase2){
- if(i==0){ html += isSelFun(jiandangCase2.familyFatherHistorys,arr[j]) }
- if(i==1){ html += isSelFun(jiandangCase2.familyMotherHistorys,arr[j]) }
- if(i==2){ html += isSelFun(jiandangCase2.familyBrotherHistorys,arr[j]) }
- if(i==3){ html += isSelFun(jiandangCase2.familyChildrenHistorys,arr[j]) }
- }else{
- html += '<option value="'+arr[j].code+'">' + arr[j].value + '</option>'
- }
- }
- $this.html(html)
- }
- $this.mobiscroll().select({
- theme: "ios",
- lang: "zh",
- placeholder:'请选择疾病类型',
- display: "bottom",
- onSelect: function(valueText, inst) {
- $(this).attr('data-code',inst._tempValue)
- $(this).attr('data-name',valueText)
- }
- })
- }
- }
- function isSelFun(str,own){
- var bood = false;
- if(str){
- var child = str.split(',')
- for(var z = 0; z < child .length; z++){
- if(own.code == child[z]){
- bood = true;
- }
- }
- }
- if(!!bood){
- return '<option selected value="'+own.code+'">' + own.value + '</option>'
- }else{
- return '<option value="'+own.code+'">' + own.value + '</option>'
- }
- }
- })
|