inleft
2022-02-15 91dc6cdda0548ff7f6e473a81933fa206d912cef
commit | author | age
9bcb19 1 <template>
I 2   <div>
3     <h2>本页面内容均为测试功能,暂不提供稳定性保证</h2>
4     <a-divider />
5     <div class="multi-tab-test">
6       <h4>多标签组件测试功能</h4>
7       <a-button @click="handleCloseCurrentTab" style="margin-right: 16px;">关闭当前页</a-button>
8       <a-button @click="handleOpenTab" style="margin-right: 16px;">打开 任务列表</a-button>
9       <a-popconfirm :visible="visible" @confirm="confirm" @cancel="cancel" okText="确定" cancelText="取消">
10         <template v-slot:title>
11           <div>
12             <a-form :form="form" layout="inline">
13               <a-form-item label="自定义名称">
14                 <a-input v-decorator="['tabName', {rules: [{required: true, message: '请输入新的 Tab 名称'}]}]"/>
15               </a-form-item>
16             </a-form>
17           </div>
18         </template>
19         <a-button @click="() => visible = !visible" style="margin-right: 16px;">修改当前 Tab 名称</a-button>
20       </a-popconfirm>
21
22       <a-popconfirm :visible="visible2" @confirm="confirm2" @cancel="() => visible2 = false" okText="确定" cancelText="取消">
23         <template v-slot:title>
24           <div>
25             <p>页面 KEY 是由页面的路由 <code>path</code> 决定的</p>
26             <p>如果要修改某一个页面标题,该页面必须已经被打开在 Tab 栏</p>
27             <p>后期可以考虑优化到编程式 Tab 栏,就可以没有这种限制</p>
28             <a-form :form="form2" layout="inline">
29               <a-form-item label="页面KEY">
30                 <a-input v-decorator="['tabKey', { initialValue: '/dashboard/workplace' }]" />
31               </a-form-item>
32               <a-form-item label="自定义名称">
33                 <a-input v-decorator="['tabName', {rules: [{required: true, message: '请输入新的 Tab 名称'}]}]"/>
34               </a-form-item>
35             </a-form>
36           </div>
37         </template>
38         <a-button @click="() => visible2 = !visible2">修改某一个 Tab 名称</a-button>
39       </a-popconfirm>
40     </div>
41     <a-divider />
42     <div class="page-loading-test">
43       <h4>全局遮罩测试</h4>
44       <a-button @click="handleOpenLoading" style="margin-right: 16px;">打开遮罩(5s 自动关闭)</a-button>
45       <a-button @click="handleOpenLoadingCustomTip">打开遮罩(自定义提示语)</a-button>
46     </div>
47   </div>
48 </template>
49
50 <script>
51 export default {
52   name: 'TestWork',
53   data () {
54     return {
55       visible: false,
56       visible2: false
57     }
58   },
59   created () {
60     this.form = this.$form.createForm(this)
61     this.form2 = this.$form.createForm(this)
62   },
63   methods: {
64     handleCloseCurrentTab () {
65       this.$multiTab.closeCurrentPage() // or this.$multiTab.close()
66     },
67     handleOpenTab () {
68       this.$multiTab.open('/features/task')
69     },
70
71     handleOpenLoading () {
72       this.$nextTick(function () {
73         console.log('this', this)
74         console.log('this.$refs.tInput', this.$refs.tInput)
75       })
76       this.$loading.show()
77       setTimeout(() => {
78         this.$loading.hide()
79       }, 5000)
80     },
81     handleOpenLoadingCustomTip () {
82       this.$loading.show({ tip: '自定义提示语' })
83       setTimeout(() => {
84         this.$loading.hide()
85       }, 5000)
86     },
87
88     // confirm
89     confirm (e) {
90       e.stopPropagation()
91       const { path } = this.$route
92       this.form.validateFields((err, values) => {
93         if (!err) {
94           this.$multiTab.rename(path, values.tabName)
95           this.visible = false
96         }
97       })
98     },
99     cancel () {
100       this.visible = false
101     },
102     confirm2 (e) {
103       e.stopPropagation()
104       this.form2.validateFields((err, values) => {
105         if (!err) {
106           this.$multiTab.rename(values.tabKey, values.tabName)
107           this.visible2 = false
108         }
109       })
110     }
111   }
112 }
113 </script>
114
115 <style scoped>
116
117 </style>