mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 20:58:22 +08:00
575835a2f8
* docs(components): use `script setup` replace `defineComponent` * docs(components): use setup sugar simplify `checkbox` demo * docs(components): use setup sugar simplify `collapse` demo * docs(components): use setup sugar simplify `color-picker` demo * docs(components): use setup sugar simplify `config-provider` demo * docs(components): use setup sugar simplify `container` demo * docs(components): use setup sugar simplify `date-picker` demo * docs(components): use setup sugar simplify `datetime-picker` demo * docs(components): use setup sugar simplify `dialog` demo * docs(components): use setup sugar simplify `drawer` demo * docs(components): use setup sugar simplify `dropdown` demo * docs(components): use setup sugar simplify `image` demo * docs(components): use setup sugar simplify `infinite-scroll` demo * docs(components): use setup sugar simplify `input-number` demo * docs(components): use setup sugar simplify `loading` demo * docs(components): use setup sugar simplify `menu` demo * docs(components): use setup sugar simplify `message` demo * docs(components): use setup sugar simplify `message-box` demo * docs(components): use setup sugar simplify `notification` demo * docs(components): use setup sugar simplify `page-header` demo * docs(components): use setup sugar simplify `pagination` demo * docs(components): use setup sugar simplify `popover` demo * docs(components): use setup sugar simplify `progress` demo * docs(components): use setup sugar simplify `radio` demo * docs(components): use setup sugar simplify `rate` demo * docs(components): use setup sugar simplify `scrollbar` demo * docs(components): use setup sugar simplify `select` demo * docs(components): use setup sugar simplify `select-v2` demo * docs(components): use setup sugar simplify `skeleton` demo * docs(components): use setup sugar simplify `slider` demo * docs(components): use setup sugar simplify `space` demo * docs(components): use setup sugar simplify `step` demo * docs(components): use setup sugar simplify `switch` demo * docs(components): use setup sugar simplify `tabs` demo * docs(components): use setup sugar simplify `tag` demo * docs(components): use setup sugar simplify `time-picker` demo * docs(components): use setup sugar simplify `time-select` demo * docs(components): use setup sugar simplify `timeline` demo * docs(components): use setup sugar simplify `tooltip` demo * docs(components): use setup sugar simplify `transfer` demo * docs(components): use setup sugar simplify `transition` demo * docs(components): use setup sugar simplify `tree` demo * docs(components): use setup sugar simplify `table` demo * docs(components): Escape character * docs(components): use setup sugar simplify `tree-v2` demo * docs(components): use setup sugar simplify `upload` demo * docs(components): use `ref` to replace `reactive` * docs(ci): use `playground` to replace `codepen` * docs(ci): change icon from `codepen` to `ep` * docs(components): `sass` to `css` * fix(components): add button CssVar * docs(ci): change `Edit in Codepen.io` to `Edit in Playground` * docs(ci): add vitepress i18
139 lines
3.1 KiB
Vue
139 lines
3.1 KiB
Vue
<template>
|
|
<el-button type="text" @click="table = true"
|
|
>Open Drawer with nested table</el-button
|
|
>
|
|
<el-button type="text" @click="dialog = true"
|
|
>Open Drawer with nested form</el-button
|
|
>
|
|
<el-drawer
|
|
v-model="table"
|
|
title="I have a nested table inside!"
|
|
direction="rtl"
|
|
size="50%"
|
|
>
|
|
<el-table :data="gridData">
|
|
<el-table-column
|
|
property="date"
|
|
label="Date"
|
|
width="150"
|
|
></el-table-column>
|
|
<el-table-column
|
|
property="name"
|
|
label="Name"
|
|
width="200"
|
|
></el-table-column>
|
|
<el-table-column property="address" label="Address"></el-table-column>
|
|
</el-table>
|
|
</el-drawer>
|
|
|
|
<el-drawer
|
|
ref="drawerRef"
|
|
v-model="dialog"
|
|
title="I have a nested form inside!"
|
|
:before-close="handleClose"
|
|
direction="ltr"
|
|
custom-class="demo-drawer"
|
|
>
|
|
<div class="demo-drawer__content">
|
|
<el-form :model="form">
|
|
<el-form-item label="Name" :label-width="formLabelWidth">
|
|
<el-input v-model="form.name" autocomplete="off"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="Area" :label-width="formLabelWidth">
|
|
<el-select
|
|
v-model="form.region"
|
|
placeholder="Please select activity area"
|
|
>
|
|
<el-option label="Area1" value="shanghai"></el-option>
|
|
<el-option label="Area2" value="beijing"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="demo-drawer__footer">
|
|
<el-button @click="cancelForm">Cancel</el-button>
|
|
<el-button type="primary" :loading="loading" @click="onClick">{{
|
|
loading ? 'Submitting ...' : 'Submit'
|
|
}}</el-button>
|
|
</div>
|
|
</div>
|
|
</el-drawer>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { reactive, ref } from 'vue'
|
|
import { ElMessageBox } from 'element-plus'
|
|
import type { ElDrawer } from 'element-plus'
|
|
|
|
const formLabelWidth = '80px'
|
|
let timer
|
|
|
|
const table = ref(false)
|
|
const dialog = ref(false)
|
|
const loading = ref(false)
|
|
|
|
const form = reactive({
|
|
name: '',
|
|
region: '',
|
|
date1: '',
|
|
date2: '',
|
|
delivery: false,
|
|
type: [],
|
|
resource: '',
|
|
desc: '',
|
|
})
|
|
|
|
const gridData = [
|
|
{
|
|
date: '2016-05-02',
|
|
name: 'Peter Parker',
|
|
address: 'Queens, New York City',
|
|
},
|
|
{
|
|
date: '2016-05-04',
|
|
name: 'Peter Parker',
|
|
address: 'Queens, New York City',
|
|
},
|
|
{
|
|
date: '2016-05-01',
|
|
name: 'Peter Parker',
|
|
address: 'Queens, New York City',
|
|
},
|
|
{
|
|
date: '2016-05-03',
|
|
name: 'Peter Parker',
|
|
address: 'Queens, New York City',
|
|
},
|
|
]
|
|
|
|
const drawerRef = ref<InstanceType<typeof ElDrawer>>()
|
|
const onClick = () => {
|
|
drawerRef.value!.close()
|
|
}
|
|
|
|
const handleClose = (done) => {
|
|
if (loading.value) {
|
|
return
|
|
}
|
|
ElMessageBox.confirm('Do you want to submit?')
|
|
.then(() => {
|
|
loading.value = true
|
|
timer = setTimeout(() => {
|
|
done()
|
|
// 动画关闭需要一定的时间
|
|
setTimeout(() => {
|
|
loading.value = false
|
|
}, 400)
|
|
}, 2000)
|
|
})
|
|
.catch(() => {
|
|
// catch error
|
|
})
|
|
}
|
|
|
|
const cancelForm = () => {
|
|
loading.value = false
|
|
dialog.value = false
|
|
clearTimeout(timer)
|
|
}
|
|
</script>
|