|
@@ -5,8 +5,38 @@
|
|
|
<div class="multi-tab-test">
|
|
|
<h4>多标签组件测试功能</h4>
|
|
|
<a-button @click="handleCloseCurrentTab" style="margin-right: 16px;">关闭当前页</a-button>
|
|
|
- <a-button @click="handleOpenTab">打开 任务列表</a-button>
|
|
|
- <a-input ref="tInput" />
|
|
|
+ <a-button @click="handleOpenTab" style="margin-right: 16px;">打开 任务列表</a-button>
|
|
|
+ <a-popconfirm :visible="visible" @confirm="confirm" @cancel="cancel" okText="确定" cancelText="取消">
|
|
|
+ <template v-slot:title>
|
|
|
+ <div>
|
|
|
+ <a-form :form="form" layout="inline">
|
|
|
+ <a-form-item label="自定义名称">
|
|
|
+ <a-input v-decorator="['tabName', {rules: [{required: true, message: '请输入新的 Tab 名称'}]}]"/>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <a-button @click="() => visible = !visible" style="margin-right: 16px;">修改当前 Tab 名称</a-button>
|
|
|
+ </a-popconfirm>
|
|
|
+
|
|
|
+ <a-popconfirm :visible="visible2" @confirm="confirm2" @cancel="() => visible2 = false" okText="确定" cancelText="取消">
|
|
|
+ <template v-slot:title>
|
|
|
+ <div>
|
|
|
+ <p>页面 KEY 是由页面的路由 <code>path</code> 决定的</p>
|
|
|
+ <p>如果要修改某一个页面标题,该页面必须已经被打开在 Tab 栏</p>
|
|
|
+ <p>后期可以考虑优化到编程式 Tab 栏,就可以没有这种限制</p>
|
|
|
+ <a-form :form="form2" layout="inline">
|
|
|
+ <a-form-item label="页面KEY">
|
|
|
+ <a-input v-decorator="['tabKey', { initialValue: '/dashboard/workplace' }]" />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="自定义名称">
|
|
|
+ <a-input v-decorator="['tabName', {rules: [{required: true, message: '请输入新的 Tab 名称'}]}]"/>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <a-button @click="() => visible2 = !visible2">修改某一个 Tab 名称</a-button>
|
|
|
+ </a-popconfirm>
|
|
|
</div>
|
|
|
<a-divider />
|
|
|
<div class="page-loading-test">
|
|
@@ -20,6 +50,16 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
name: 'TestWork',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ visible2: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.form = this.$form.createForm(this)
|
|
|
+ this.form2 = this.$form.createForm(this)
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleCloseCurrentTab () {
|
|
|
this.$multiTab.closeCurrentPage() // or this.$multiTab.close()
|
|
@@ -43,6 +83,30 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
this.$loading.hide()
|
|
|
}, 5000)
|
|
|
+ },
|
|
|
+
|
|
|
+ // confirm
|
|
|
+ confirm (e) {
|
|
|
+ e.stopPropagation()
|
|
|
+ const { path } = this.$route
|
|
|
+ this.form.validateFields((err, values) => {
|
|
|
+ if (!err) {
|
|
|
+ this.$multiTab.rename(path, values.tabName)
|
|
|
+ this.visible = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ cancel () {
|
|
|
+ this.visible = false
|
|
|
+ },
|
|
|
+ confirm2 (e) {
|
|
|
+ e.stopPropagation()
|
|
|
+ this.form2.validateFields((err, values) => {
|
|
|
+ if (!err) {
|
|
|
+ this.$multiTab.rename(values.tabKey, values.tabName)
|
|
|
+ this.visible2 = false
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|