var TeamNewtPanel = { template: '
\
\
\ 保存为个人模板\
\
\ 模板名称:\
\
\ 所属团队:\
\
\
指导标签:{{selectedLabel && selectedLabel.name}}
\
    \
  • \
    \ {{label.name}}\
    \
  • \
\
\
\ \
{{count}}/{{words}}
\
\
\
\
插入图片({{imgs.length}}/9)
\
\
\ \
\
\ \
\
\
\ \ 预览\ \ \ 保存\ \ \ 发送\ \
\
', props: [], data: function() { return { words: 1000, count: 0, content: "", modelName: "", imgs: [], modelCode: "", teamId: "", teamTemplateCode: "", teams: [], labelsDropdown: false, selectedLabel: null, labelList: [], selectedTeam: "", sendMode: false // 根据url中是否携带patient来判断是否是"发送"模式 } }, computed: { }, created: function() { var vm = this vm.findDoctorLeaderTeam().then(function(res) { vm.teams = res.teamList }) }, mounted: function() { EventBus.$emit('active-nav-tab', 1) }, methods: { countWord: function() { if(this.content.length <= this.words) { this.count = this.content.length } else { this.content = this.content.slice(0, this.words) } }, findDoctorLeaderTeam: function() { return guidanceAPI.findDoctorLeaderTeam() }, selectTeam: function() { var vm = this if(vm.selectedTeam !== '') { vm.teamId = vm.teams[vm.selectedTeam].teamId vm.findAllLabelList() } }, findAllLabelList: function() { var vm = this return guidanceAPI.findAllLabelList({ teamId: vm.teamId }).then(function(res) { var selected = null var label = vm.selectedLabel? vm.selectedLabel.name: '未分组' selected = _.filter(res.data, function(o) { return o.name == label }) if(selected[0]) { selected[0].active = true vm.selectedLabel = selected[0] } vm.labelList = res.data }).catch(function(e){ console.error(e) }) }, selectLabel: function(label) { var vm = this vm.selectedLabel && (vm.selectedLabel.active = false) label.active = true vm.selectedLabel = label vm.labelsDropdown = false }, imgUploaded: function(url) { var vm = this vm.imgs.push(httpRequest.getImgUrl(url)) }, removeImg: function(url, idx) { var vm = this vm.imgs.splice(idx, 1) }, save: function() { var vm = this if(!vm.modelName) { toastr && toastr.error("模板名称不能为空") return } if(vm.selectedTeam === '') { toastr && toastr.error("请选择所属团队") return } if(!vm.content) { toastr && toastr.error("模板内容不能为空") return } var param = { content: vm.content, title: vm.modelName, images: vm.imgs.join(','), teamInfo: vm.teams&&JSON.stringify(vm.teams)||"" } if(vm.selectedLabel && vm.selectedLabel.code) { param.labelCode = vm.selectedLabel.code } guidanceAPI.saveTeamGuidance(param).then(function(res) { if(res.status == 200) { toastr && toastr.success("保存成功") EventBus.$emit('refresh-team-panel') } }).catch(function(e) { console.error(e) }) }, saveAsPersonTemplate: function() { var vm = this if(!vm.modelName) { toastr && toastr.error("模板名称不能为空") return } if(!vm.content) { toastr && toastr.error("模板内容不能为空") return } var param = { content: vm.content, modelName: vm.modelName } var img = vm.imgs.join(',').trim() if(img) { param.imagesUrl = img } guidanceAPI.newTemplate(param).then(function(res) { if(res.status == 200) { toastr && toastr.success("保存成功") EventBus.$emit('refresh-person-panel') } else { toastr && toastr.error(res.msg) } }).catch(function(e) { console.error(e) }) }, sendTeamTemplate: function() { var vm = this if(!vm.modelName) { toastr && toastr.error("模板名称不能为空") return } if(!vm.content) { toastr && toastr.error("模板内容不能为空") return } var team = _.filter(vm.teams, function(o) { return o.teamId == vm.teamId }) if(!team.length) { // 匹配不了说明医生修改了指导所属的 团队,并且入口团队并不在选中的列表中。则默认选择选中团队中的第一个团队来发送 team = [vm.teams[0]] } var d = dialog({ width: 350, content: '发出后无法变更,是否确认发送给居民?', okValue: '继续发送', ok: function () { guidanceAPI.sendTemplate( { patient: storage.patient, content: vm.content, guidanceCode: vm.teamTemplateCode, images: vm.imgs.join(','), teamId: JSON.stringify(team) }).then(function(res) { toastr && toastr.success("发送成功") }).catch(function(e) { console.error(e) }) }, cancelValue: '取消', cancel: function () {} }); d.showModal(); }, preview: function() { var vm = this var query = { modelCode: vm.modelCode, patient: storage.patient||"", timestemp: $.now() } this.$router.push({path:'/preview-panel',query:query}) } }, watch: { '$route': function (to, from) { var vm = this if(to.path == "/preview-panel") { EventBus.$emit('preview-template', { content: vm.content, modelName: vm.modelName, imgs: vm.imgs }) } }, 'content': function(v) { this.countWord() } } }