new-template-form.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  2. var NewTemplateForm = {
  3. template: '<div>\
  4. <div class="title-name c-f16">\
  5. <span class="c-vam">模板未命名</span>\
  6. </div>\
  7. <div class="c-t-center" style="margin-top: 240px;">\
  8. <span class="c-vam c-f14 mr5">模板名称: </span>\
  9. <input v-model="name" placeholder="请输入新模板名称" class="c-vam temp-name-inpt"/>\
  10. <a @click="save" href="javascript: void(0);" class="ml10 save-temp-name-btn c-f14 c-vam">保存</a>\
  11. </div>\
  12. </div>',
  13. props: [],
  14. data: function() {
  15. return {
  16. name:''
  17. }
  18. },
  19. beforeRouteEnter: function (to, from, next) {
  20. next(function(vm) {
  21. vm.name = ""
  22. })
  23. },
  24. mounted: function() {
  25. var vm = this
  26. },
  27. methods: {
  28. save: function() {
  29. var vm = this
  30. if(vm.name) {
  31. if(vm.name=='系统模板'){
  32. layer.msg('不能创建系统模板!', {
  33. icon: 5
  34. })
  35. return false
  36. }
  37. rehaAPI.createTemplate({
  38. doctor: docInfo.uid,
  39. title: vm.name,
  40. adminTeamCode:vm.$route.query.teamCode
  41. }).then(function(res) {
  42. if(res.status == 200) {
  43. vm.$router.push({
  44. path:'/template-items',
  45. query: {
  46. name: vm.name,
  47. isNew: true,
  48. templateId: res.data
  49. }
  50. })
  51. } else {
  52. toastr && toastr.error(res.msg)
  53. }
  54. }).catch(function(e) {
  55. console.error(e)
  56. })
  57. }
  58. }
  59. }
  60. }