Former-commit-id: db05786be3e9ab66abe0b3b604d01562542cfacc [formerly db05786be3e9ab66abe0b3b604d01562542cfacc [formerly db05786be3e9ab66abe0b3b604d01562542cfacc [formerly db05786be3e9ab66abe0b3b604d01562542cfacc [formerly 2acd0640d624075a9ddc5f9a86ee5adec2b88bc0 [formerly f87fab303d38481b3aa9a8dfda9f727d4bc25904]]]]]
Former-commit-id: 7030151b1f70b55f37114edc200cf3552469d190
Former-commit-id: 1b25ebdf8718b92e2b76e2d20fc75cbd79b6b9b4
Former-commit-id: 8e0c4a7c70905f515f10b7ad17077e42dbce7e4a [formerly d576cf89831968e4b6d972279add9a571f934c7c]
Former-commit-id: 9508887808bd8d888911e5b801180124bad7d072
Former-commit-id: 83245f1c040f9fdaee900aee9a08efd9e40c1f8d
Former-commit-id: 65380a255ed238316df9da4ec1865eaeea4ffee1
Former-commit-id: ef70b25a26296e2d17945d77175934a4e1e9e94d
Former-commit-id: 40cd5c6889f026242af0508bd051d138d7d973d8
This commit is contained in:
孙昊翔
2018-12-24 14:03:12 +08:00
parent 3188b0c740
commit 52d3c46da2
3 changed files with 62 additions and 19 deletions

View File

@@ -1,15 +1,16 @@
export default `<template>
<div>
<d2-crud
ref="d2Crud"
:columns="columns"
:data="data"
title="D2 CRUD"
add-mode
:add-button="addButton"
:form-template="formTemplate"
:form-options="formOptions"
@row-add="handleRowAdd"
@dialog-cancel="handleDialogCancel"/>
@dialog-cancel="handleDialogCancel">
<el-button slot="header" style="margin-bottom: 5px" @click="addRow">新增</el-button>
<el-button slot="header" style="margin-bottom: 5px" @click="addRowWithNewTemplate">使用自定义模板新增</el-button>
</d2-crud>
</div>
</template>
@@ -53,11 +54,7 @@ export default {
address: '上海市普陀区金沙江路 1516 弄'
}
],
addButton: {
icon: 'el-icon-plus',
size: 'small'
},
formTemplate: {
addTemplate: {
date: {
title: '日期',
value: '2016-05-05'
@@ -79,6 +76,32 @@ export default {
}
},
methods: {
// 普通的新增
addRow () {
this.$refs.d2Crud.showDialog({
mode: 'add'
})
},
// 传入自定义模板的新增
addRowWithNewTemplate () {
this.$refs.d2Crud.showDialog({
mode: 'add',
template: {
name: {
title: '姓名',
value: ''
},
value1: {
title: '新属性1',
value: ''
},
value2: {
title: '新属性2',
value: ''
}
}
})
},
handleRowAdd (row, done) {
this.formOptions.saveLoading = true
setTimeout(() => {