feat(transfer): add beforeTransfer props (#75)

This commit is contained in:
Kagol 2023-03-20 09:17:04 +08:00 committed by GitHub
parent f551d40f67
commit 7223cf8976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 3 deletions

View File

@ -0,0 +1,39 @@
<template>
<tiny-transfer v-model="value" :data="data" :before-transfer="beforeTransfer"></tiny-transfer>
</template>
<script>
import { Transfer, Modal } from '@opentiny/vue'
export default {
components: {
TinyTransfer: Transfer
},
data() {
const generateData = () => {
const data = []
for (let i = 0; i <= 15; i++) {
data.push({
key: i,
label: `备选项 ${i}`,
disabled: i % 4 === 0
})
}
return data
}
return {
data: generateData(),
value: [1, 4]
}
},
methods: {
beforeTransfer(done) {
Modal.message('穿梭功能已被拦截,必须调用 done 方法才能执行穿梭2s后将自动调用 done 方法执行穿梭')
setTimeout(done, 2000)
}
}
}
</script>

View File

@ -10,7 +10,7 @@
Switch 在两种状态间切换选择。
</div>
### 基本用法
### 开关切换前的回调
<nova-demo-view link="switch/before-change"></nova-demo-view>

View File

@ -0,0 +1,19 @@
<div class="demo-header">
<p class="overviewicon">
<span class="wapi-ui-transfer"/>
</p>
## Transfer 穿梭框
<nova-uxlink widget-name="Transfer"></nova-uxlink>
穿梭框,提供表格数据的双向选择。
</div>
### 穿梭前的回调
<nova-demo-view link="transfer/before-transfer.vue"></nova-demo-view>
<br>
<nova-attributes link="transfer"></nova-attributes>

View File

@ -3091,6 +3091,10 @@
{
"path": "/transfer/nested-tree",
"name": "嵌套树"
},
{
"path": "/transfer/before-transfer",
"name": "穿梭前的回调"
}
]
}

View File

@ -1851,6 +1851,11 @@ const routers = [
meta: { title: '表单组件-Transfer 穿梭框-嵌套树', lang: 'zh-CN', sign: 'component' },
component: () => import(/* webpackChunkName: 'v3-transfer' */ './docs/zh-CN/transfer/nested-tree.md')
},
{
path: 'transfer/before-transfer',
meta: { title: '表单组件-Transfer 穿梭框-穿梭前的回调', lang: 'zh-CN', sign: 'component' },
component: () => import(/* webpackChunkName: 'v3-transfer' */ './docs/zh-CN/transfer/before-transfer.md')
},
{
path: 'grid',
meta: { title: '表格组件-导入导出', lang: 'zh-CN', sign: 'component' },

View File

@ -93,7 +93,8 @@ export default {
type: Boolean,
default: true
},
treeOp: Object
treeOp: Object,
beforeTransfer: Function
},
setup(props, context) {
return $setup({ props, context, template })

View File

@ -137,7 +137,8 @@ export default {
'pagerOp',
'showPager',
'render',
'treeOp'
'treeOp',
'beforeTransfer'
],
setup(props, context) {
return setup({ props, context, renderless, api })