123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var Request = GetRequest();
- var pregnancyNo = Request['pregnancyNo'];
- function toast(msg){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
- }
- $(function(){
- var firstRecord = null,//保存记录
- secondRecord = null,
- $view = $('#viewContain');
-
- //区域滚动
- mui('#main_text').scroll({
- scrollY: true, //是否竖向滚动
- scrollX: false, //是否横向滚动
- bounce: false, //是否启用回弹
- deceleration: 0.0005
- })
- mui('#nav_text').scroll({
- scrollY: true, //是否竖向滚动
- scrollX: false, //是否横向滚动
- bounce: false, //是否启用回弹
- deceleration: 0.0005
- })
- //侧屏
- $('.cj-menu').on('tap',function(){
- mui('.mui-off-canvas-wrap').offCanvas().show();
- })
-
- //切换
- $('.cj-li').on('tap',function(){
- var $this = $(this)
- if(!$this.hasClass('active')){
- $this.addClass('active').siblings().removeClass('active')
- templateRender($this.attr('data-num'))
- setTimeout(function(){
- mui('#main_text').scroll().scrollTo(0,0,0);
- mui('.mui-off-canvas-wrap').offCanvas().close();
- },300)
- }else{
- setTimeout(function(){
- mui('.mui-off-canvas-wrap').offCanvas().close();
- },300)
- }
- })
-
- //请求模板
- var templateRequest = function(num){
- return new Promise(function(resolve, reject){
- $.ajax('../template/'+num+'.html',
- { dataType: 'html',
- type:'GET',
- error: function(xht, type, throwErr) {
- toast("模板获取失败");
- },
- success: function(html) {
- resolve(html);
- }
- }
- )
- })
- },
- //请求模板数据
- dataRequest = function(num){
- return new Promise(function(resolve, reject){
- if(num == 0 || num == 2){
- if(!firstRecord){
- d.show()
- sendPost('patient/prenatalnspector/getEhrMaternalFirstExamRecord',{pregnancyNo:pregnancyNo},'json', 'get',null,function(res){
- d.close()
- if(res.status == 200){
- if(! $.isEmptyObject(res.data)){
- firstRecord = res.data
- resolve(res.data)
- }else{
- toast('查无数据')
- }
- }else{
- toast('请求数据失败')
- return
- }
- })
- }else{
- resolve(firstRecord)
- }
- }
- if(num == 1){
- if(!secondRecord){
- d.show()
- sendPost('patient/prenatalnspector/getEhrMaternalReExamRecord',{pregnancyNo:pregnancyNo},'json', 'get',null,function(res){
- d.close()
- if(res.status == 200){
- if(! $.isEmptyObject(res.data)){
- secondRecord = res.data
- resolve(res.data)
- }else{
- toast('查无数据')
- }
- }else{
- toast('请求数据失败')
- return
- }
- })
- }else{
- resolve(secondRecord)
- }
- }
- })
- },
- bindEvent = function(){
- //展开
- $('.cj-section').on('tap','.up.icon',function(){
- var $this = $(this).parent()
- if($this.hasClass('active')){
- $this.removeClass('active')
- }else{
- $this.addClass('active')
- }
- })
- }
-
- //渲染
- function templateRender(num){
- Promise.all([templateRequest(num),dataRequest(num)]).then(function(datas){
- $view.html(datas[0])
- $view.removeAttr('avalonctrl').attr('ms-controller',"template");
- var vm = avalon.define($.extend({"$id": "template"},{data:datas[1]}))
- avalon.scan();
- }).then(function(){
- //隐藏都没有的模块
- for(var i=0; i<$('.cj-section').length;i++){
- var $this = $('.cj-section').eq(i)
- if($this.find('.cj-position-1').length == 0 && $this.find('.cj-flex-1').length == 0){
- $this.hide()
- }
- }
- bindEvent()
- })
- }
- //初始化
- templateRender(0)
- })
|