Former-commit-id: fdb0d1333ab90454a80078a692de62d68b528de5 [formerly fdb0d1333ab90454a80078a692de62d68b528de5 [formerly fdb0d1333ab90454a80078a692de62d68b528de5 [formerly fdb0d1333ab90454a80078a692de62d68b528de5 [formerly ad69fa918cb6a7c8be79693dd9d459ff24bd8850 [formerly d44f36c938ac0604b92959028777e5d8edd8b259]]]]] Former-commit-id: af610347b31ca2bf8277d8fefeb4831899ff8ed3 Former-commit-id: 1e5e4c58322d87756e2fc181607ee89e8a00c323 Former-commit-id: 6fb929e6919d633754f6ed05c1c0dc5fc52b1053 [formerly e009db20b84c2ceb15aad1f1a49e1e034aebcd3f] Former-commit-id: 9d4cd83c14915b798c77101bfc0e1a75677e054c Former-commit-id: ae9f646e106466297f17ce2acef5c3b6d40b2a16 Former-commit-id: 483af02ce21d32235ee89fa772aaf8559a13affd Former-commit-id: 93fff30eff6af98e6cc3f6d2194d187119ba1ef7 Former-commit-id: a557fac7e8617f522e810894526221fce2931c0a
120 lines
2.6 KiB
Vue
120 lines
2.6 KiB
Vue
<template>
|
|
<d2-container>
|
|
<template slot="header">新增数据</template>
|
|
<d2-crud
|
|
:columns="columns"
|
|
:data="data"
|
|
title="D2 CRUD"
|
|
add-mode
|
|
:addButton="addButton"
|
|
:form-template="formTemplate"
|
|
:form-options="formOptions"
|
|
@row-add="handleRowAdd"
|
|
@dialog-cancel="handleDialogCancel">
|
|
</d2-crud>
|
|
<el-card shadow="never" class="d2-mb">
|
|
<d2-markdown :source="doc"/>
|
|
</el-card>
|
|
<el-card shadow="never" class="d2-mb">
|
|
<d2-highlight :code="code"/>
|
|
</el-card>
|
|
<template slot="footer">
|
|
<d2-link-btn title="D2 CRUD" link="https://github.com/d2-projects/d2-crud"/>
|
|
</template>
|
|
</d2-container>
|
|
</template>
|
|
|
|
<script>
|
|
import doc from './doc.md'
|
|
import code from './code.js'
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
doc,
|
|
code,
|
|
columns: [
|
|
{
|
|
title: '日期',
|
|
key: 'date'
|
|
},
|
|
{
|
|
title: '姓名',
|
|
key: 'name'
|
|
},
|
|
{
|
|
title: '地址',
|
|
key: 'address'
|
|
}
|
|
],
|
|
data: [
|
|
{
|
|
date: '2016-05-02',
|
|
name: '王小虎',
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
},
|
|
{
|
|
date: '2016-05-04',
|
|
name: '王小虎',
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
},
|
|
{
|
|
date: '2016-05-01',
|
|
name: '王小虎',
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
},
|
|
{
|
|
date: '2016-05-03',
|
|
name: '王小虎',
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
}
|
|
],
|
|
addButton: {
|
|
icon: 'el-icon-plus',
|
|
size: 'small'
|
|
},
|
|
formTemplate: {
|
|
date: {
|
|
title: '日期',
|
|
value: '2016-05-05'
|
|
},
|
|
name: {
|
|
title: '姓名',
|
|
value: '王小虎'
|
|
},
|
|
address: {
|
|
title: '地址',
|
|
value: '上海市普陀区金沙江路 1520 弄'
|
|
}
|
|
},
|
|
formOptions: {
|
|
labelWidth: '80px',
|
|
labelPosition: 'left',
|
|
saveLoading: false
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
handleRowAdd (row, done) {
|
|
this.formOptions.saveLoading = true
|
|
setTimeout(() => {
|
|
console.log(row)
|
|
this.$message({
|
|
message: '保存成功',
|
|
type: 'success'
|
|
})
|
|
done()
|
|
this.formOptions.saveLoading = false
|
|
}, 300)
|
|
},
|
|
handleDialogCancel (done) {
|
|
this.$message({
|
|
message: '取消保存',
|
|
type: 'warning'
|
|
})
|
|
done()
|
|
}
|
|
}
|
|
}
|
|
</script>
|