new-template-form.js 1.3 KB

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