Files
mes-ui-d2/src/pages/demo/d2-crud/demo30/index.vue
孙昊翔 976313bffb demo31
Former-commit-id: f3591905bf88c7d95047cb6651f9cdc77fc58cbd [formerly f3591905bf88c7d95047cb6651f9cdc77fc58cbd [formerly f3591905bf88c7d95047cb6651f9cdc77fc58cbd [formerly f3591905bf88c7d95047cb6651f9cdc77fc58cbd [formerly 3dd6a8182394b5e228415fdb74cafa540ff637ce [formerly 2357e57aaa8e9446e37a6bddb38974e1925bf55d]]]]]
Former-commit-id: fbac67443f4b103cc40afdac42189d6030c02374
Former-commit-id: 113f699cf579ea681f97a17a90783909e817c754
Former-commit-id: 342be87ea820c21a99677f4bf367cf86208ac805 [formerly 5d23eec7280ba7a52e1b1622cb2b27f95172e8ff]
Former-commit-id: 785cbd080e51be48484fbd7c41e931a796922de8
Former-commit-id: 52b5723a9e77044a86c63b4fe239945b74ce89a0
Former-commit-id: 073b10060b38e82221b4c3ce14e96a50c8155d12
Former-commit-id: 3120c8c429a6986b53bdc34e401965d181cadb41
Former-commit-id: bc38d66f3039940a24fc8958a11050e1058ae37e
2018-12-25 13:59:37 +08:00

151 lines
3.4 KiB
Vue

<template>
<d2-container :filename="filename">
<template slot="header">表单事件监听</template>
<d2-crud
ref="d2Crud"
:columns="columns"
:data="data"
:rowHandle="rowHandle"
:edit-template="editTemplate"
:form-options="formOptions"
@row-edit="handleRowEdit"
@dialog-cancel="handleDialogCancel"
@form-data-change="handleFormDataChange"/>
<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="文档" link="https://doc.d2admin.fairyever.com/zh/ecosystem-d2-crud/"/>
</template>
</d2-container>
</template>
<script>
import doc from './doc.md'
import code from './code.js'
export default {
data () {
return {
filename: __filename,
doc,
code,
columns: [
{
title: '日期',
key: 'date'
},
{
title: '姓名',
key: 'name'
},
{
title: '地址',
key: 'address'
}
],
data: [
{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄',
forbidEdit: true,
showEditButton: true
},
{
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄',
forbidEdit: false,
showEditButton: true
},
{
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄',
forbidEdit: false,
showEditButton: false
},
{
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄',
forbidEdit: false,
showEditButton: true
}
],
rowHandle: {
columnHeader: '编辑表格',
edit: {
icon: 'el-icon-edit',
text: '点我进行编辑',
size: 'small'
}
},
editTemplate: {
date: {
title: '日期',
value: ''
},
name: {
title: '姓名',
value: ''
},
address: {
title: '地址',
value: ''
},
forbidEdit: {
title: '禁用按钮',
value: false,
component: {
show: false
}
},
showEditButton: {
title: '显示按钮',
value: true,
component: {
show: false
}
}
},
formOptions: {
labelWidth: '80px',
labelPosition: 'left',
saveLoading: false
}
}
},
methods: {
handleFormDataChange ({key, value}) {
console.log(key)
console.log(value)
},
handleRowEdit ({index, row}, done) {
this.formOptions.saveLoading = true
setTimeout(() => {
console.log(index)
console.log(row)
this.$message({
message: '编辑成功',
type: 'success'
})
done()
this.formOptions.saveLoading = false
}, 300)
},
handleDialogCancel (done) {
this.$message({
message: '取消编辑',
type: 'warning'
})
done()
}
}
}
</script>