com-add-tab.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- 双击弹出的窗口 -->
  3. <div class="at-form-fox" style="width: 0px; height: 0px; overflow: hidden; ">
  4. <div class="at-form-dom" style="width: 300px; padding: 20px 0 10px 0; background-color: #FFF;">
  5. <el-form label-width="80px" size="mini">
  6. <!-- <h5 style="padding: 0 0 10px 26px;">创建新页面</h5> -->
  7. <el-form-item label="标题:">
  8. <el-input style="width: 200px;" v-model="atTitle" placeholder="页面标题"></el-input>
  9. </el-form-item>
  10. <el-form-item label="地址:" style="margin-top: -10px;">
  11. <el-input style="width: 200px;" v-model="atUrl" placeholder="https://www.baidu.com/" @keyup.native.enter="atOk()"></el-input>
  12. </el-form-item>
  13. <el-form-item label="操作:" style="margin-top: -10px;">
  14. <el-button type="primary" icon="el-icon-plus" size="mini" @click="atOk()">确定</el-button>
  15. </el-form-item>
  16. </el-form>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. module.exports = {
  22. data() {
  23. return {
  24. atTitle: '', // 添加窗口时: 标题
  25. atUrl: '', // 添加窗口时: 地址
  26. }
  27. },
  28. methods: {
  29. // 双击tab栏空白处, 打开弹窗添加窗口
  30. atOpen: function() {
  31. window.r_layer_12345678910 = layer.open({
  32. type: 1,
  33. // shade: false,
  34. shade: 0.5,
  35. title: "添加新窗口", //不显示标题
  36. content: $('.at-form-dom'), //捕获的元素
  37. cancel: function(){
  38. }
  39. });
  40. },
  41. // 根据表单添加新窗口
  42. atOk: function() {
  43. if(this.atTitle == '' || this.atUrl == '') {
  44. return;
  45. }
  46. this.$root.showTab({id: new Date().getTime(), name: this.atTitle, url: this.atUrl});
  47. layer.close(window.r_layer_12345678910);
  48. this.atTitle = '';
  49. this.atUrl = '';
  50. },
  51. },
  52. created() {
  53. }
  54. }
  55. </script>
  56. <style scoped>
  57. </style>