Former-commit-id: 71a2764ab9f9182a228b4ef2430d34ac1155ab2a [formerly 5cca526567e38ae2c56a1937d6353937556d53e9] [formerly 71a2764ab9f9182a228b4ef2430d34ac1155ab2a [formerly 5cca526567e38ae2c56a1937d6353937556d53e9] [formerly 71a2764ab9f9182a228b4ef2430d34ac1155ab2a [formerly 5cca526567e38ae2c56a1937d6353937556d53e9] [formerly 5cca526567e38ae2c56a1937d6353937556d53e9 [formerly ebf639ff4f1270d7b16839504ccf2fb597aff4e9 [formerly a735f157694d21800bfa2ecfcfea33aeea5b0d90]]]]] Former-commit-id: 0a11111a407db759fb7be43b366176119998bd7c Former-commit-id: ca189c6b8b2df71163e50be10371d834939f44df Former-commit-id: 0e2dfa82b90811ba932f90ad1dbf39f5bdc7d013 [formerly c0e44e48b1cc673e0e4a0eb06a4a35af3b0aa0d7] Former-commit-id: b0be18809df8c17804dca3a1ab595e4faef65a2a Former-commit-id: 45fc9fd398f4e69bf7b2fcd2e5bdbb665c0789a8 Former-commit-id: 0391b056f26d709f7a4ff7ef4c6fa1662384f223 Former-commit-id: 5d8821dd3c5b432ab22565b309d55ad722584eb6 Former-commit-id: 544fddab22f387068f91ca546254dd27929c5dee
144 lines
3.2 KiB
Vue
144 lines
3.2 KiB
Vue
<template>
|
|
<d2-container>
|
|
<template slot="header">修改数据</template>
|
|
<d2-crud
|
|
:columns="columns"
|
|
:data="data"
|
|
title="D2 CRUD"
|
|
:rowHandle="rowHandle"
|
|
:form-template="formTemplate"
|
|
:form-options="formOptions"
|
|
@row-edit="handleRowEdit"
|
|
@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="文档" link="https://d2-projects.github.io/d2-admin-doc/zh/ecosystem-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 弄',
|
|
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',
|
|
show (index, row) {
|
|
if (row.showEditButton) {
|
|
return true
|
|
}
|
|
return false
|
|
},
|
|
disabled (index, row) {
|
|
if (row.forbidEdit) {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
},
|
|
formTemplate: {
|
|
date: {
|
|
title: '日期',
|
|
value: ''
|
|
},
|
|
name: {
|
|
title: '姓名',
|
|
value: ''
|
|
},
|
|
address: {
|
|
title: '地址',
|
|
value: ''
|
|
}
|
|
},
|
|
formOptions: {
|
|
labelWidth: '80px',
|
|
labelPosition: 'left',
|
|
saveLoading: false
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
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>
|