var httpData = GetRequest() console.log('httpDatahttpDatahttpData', httpData) var previewLayerIndex; function closeGuidancePreview(){ layer.close(previewLayerIndex) } var TempSendPanel = { template: '
', props: [], data: function() { return { words: 1000, count: 0, modelName: '', content: '', modelCode: '', imgs: [], curTemplate: undefined, previewLayerIndex: undefined, planDetaiId: httpData['planDetaiId'], docInfo: JSON.parse(window.localStorage.getItem('wlyyAgent')), isRecordId: httpData['isRecordId']|| false, relationRecordId: null } }, watch: { content: function(){ this.countWord() } }, mounted: function(){ var vm = this EventBus.$on('active-template', function(o){ vm.modelCode = o.code vm.selectGuidances() }) }, destroyed: function(){ }, methods: { countWord: function() { if(this.content.length <= this.words) { this.count = this.content.length } else { this.content = this.content.slice(0, this.words) } }, selectGuidances: function(){ var vm=this; var params={ type: '', id: vm.modelCode, title: '', page: 1, pagesize: 1 } rehaAPI.selectGuidances(params).then(function(res){ if(res.status==200){ if(res.data && res.data.length) { var data = res.data[0] vm.curTemplate = data vm.content = data.content vm.modelName = data.title } } else { layer.msg(res.msg,{icon:5}); } }) }, preViewTemplate: function(){ var vm = this previewLayerIndex = layer.open({ type: 2, area: ['380px', '600px'], shade: 0.5, title: '预览', fixed: true, //不固定 maxmin: true, closeBtn:1, shift: 5, shadeClose: false, //点击遮罩关闭层 content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+vm.modelCode }); }, sendTemplate: function() { var vm = this if(!vm.modelName) { toastr && toastr.error("模板名称不能为空") return } if(!vm.content) { toastr && toastr.error("模板内容不能为空") return } layer.confirm('发出后无法变更,是否确认发送给居民?', { btn: ['继续发送', '取消'], title: "提示" }, function () { if(vm.isRecordId){ vm.saveRehabilitationOperateRecord() } else { vm.sendGuidance(vm.planDetaiId) } }) }, saveRehabilitationOperateRecord: function(){ var vm=this var params={ rehabilitationDetailId: vm.planDetaiId, node: '', patientCode: httpData['patient'], doctorCode: vm.docInfo.uid, relationRecordType: 5, relationRecordCode: '', relationRecordImg: '', status: 0, // 改记录的状态 } rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){ if(res.status==200){ vm.relationRecordId = res.data.id vm.sendGuidance(res.data.id) }else { showErrorMessage(res.msg) } }) }, saveRehabilitationOperateRecord2: function(){ var vm=this var params={ rehabilitationDetailId: vm.planDetaiId, node: '', patientCode: httpData['patient'], doctorCode: vm.docInfo.uid, relationRecordType: 5, relationRecordCode: '', relationRecordImg: '', status: 1, // 改记录的状态 id: vm.relationRecordId } rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){ if(res.status==200){ window.parent.closeKFZD(vm.planDetaiId) }else { showErrorMessage(res.msg) } }) }, sendGuidance: function(relationCode){ var vm =this var loading = layer.load(0, {shade: false}) var params = [{ patient: httpData['patient'], article: vm.modelCode, doctor: vm.docInfo.uid, attachedContent: vm.content, attachedTitle: vm.modelName, relationCode: relationCode }] rehaAPI.sendGuidance({ json: JSON.stringify(params), planId: httpData['planId'] }).then(function(res) { layer.close(loading) if(res.status == 200){ // 确认完成康复指导 if(vm.isRecordId){ vm.saveRehabilitationOperateRecord2() } else { window.parent.closeKFZDlayer(vm.planDetaiId) } layer.msg('发送成功', { icon: 1 }) } else { layer.msg(res.msg, { icon: 5 }) } }).catch(function(e) { console.error(e) }) } } }