dialog.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div class="dialog-container" v-show="visbile">
  3. <label>菜单名称:</label><input type="text" placeholder="菜单名称" ref="name"><br>
  4. <label>链接:</label><input type="text" placeholder="链接" ref = "uri"><br>
  5. <label>ID:</label><input type="text" placeholder="ID" ref="id"><br>
  6. <button @click="save">保存</button>
  7. <button @click="cancle">取消</button>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: "dialog",
  13. data() {
  14. return {
  15. visbile: false,
  16. id: ''
  17. };
  18. },
  19. props: {
  20. onSave: Function,
  21. onCancle: Function
  22. },
  23. methods: {
  24. save(list) {
  25. var data = {
  26. name: this.$refs.name.value,
  27. uri: this.$refs.uri.value,
  28. id: this.$refs.id.value
  29. }
  30. this.onSave(this.id, data);
  31. this.visbile = false;
  32. },
  33. show(type, data) {
  34. this.visbile = true;
  35. if (type === 'edit') {
  36. this.$refs.name.value = data.name;
  37. this.$refs.uri.value = data.uri;
  38. this.$refs.id.value = data.id;
  39. this.id = data.id;
  40. } else {
  41. this.id = data;
  42. }
  43. },
  44. cancle() {
  45. this.visbile = false
  46. }
  47. }
  48. };
  49. </script>
  50. <style lang="scss" scoped>
  51. .dialog-container{
  52. position: fixed;
  53. background: #FFF;
  54. width: 500px;
  55. height: 300px;
  56. top: 0;
  57. box-shadow: 0px 0px 5px #ccc;
  58. font-size: 20px;
  59. label{
  60. display: inline-block;
  61. width: 100px;
  62. text-align: right;
  63. }
  64. input{
  65. margin-left: 10px;
  66. }
  67. }
  68. </style>