demo22
Former-commit-id: 516f429f12d7cede7fe8dcba63f9ae0df7490be4 [formerly 516f429f12d7cede7fe8dcba63f9ae0df7490be4 [formerly 516f429f12d7cede7fe8dcba63f9ae0df7490be4 [formerly 516f429f12d7cede7fe8dcba63f9ae0df7490be4 [formerly ecdf89609ed868b930ebd3a7daf34dea36638507 [formerly f043c34a3b53d77c5c3d6a8a0186e3cb58adb991]]]]] Former-commit-id: 385f4794597cefd09beda84f721b2962607465a0 Former-commit-id: d8e900bc4a5887cda041444d82ede966b813b20b Former-commit-id: 340653ee70150f438304ac2037bc0e5ad3c282d7 [formerly a089f9bdf778a961388e2c3e5293bfac7097403f] Former-commit-id: 01b782101d2e79644a2fcd411b5e678bdd43e8de Former-commit-id: c0f0ef360c820310e243556812afedeb6129adca Former-commit-id: ca94fee2a3938983e318797ee9b36ed18eeb0528 Former-commit-id: b73a023aa8b6d3e08aee20b8d9f79ef88a1b9a53 Former-commit-id: 181da64d2d5f93b3daa2584ef46990dea5e3c6ad
This commit is contained in:
parent
4ff4ea3d91
commit
9d4a9af5aa
|
|
@ -13,7 +13,7 @@
|
|||
"test:unit": "vue-cli-service test:unit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@d2-projects/d2-crud": "^2.0.0",
|
||||
"@d2-projects/d2-crud": "^2.0.2",
|
||||
"@d2-projects/vue-filters-date": "^1.0.2",
|
||||
"@d2-projects/vue-table-export": "^1.0.1",
|
||||
"@d2-projects/vue-table-import": "^1.0.0",
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export default {
|
|||
methods: {
|
||||
editRowWithNewTemplate () {
|
||||
this.$refs.d2Crud.showDialog({
|
||||
mode: "edit",
|
||||
mode: 'edit',
|
||||
rowIndex: 2,
|
||||
template: {
|
||||
date: {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
export default `<template>
|
||||
<div>
|
||||
<d2-crud
|
||||
ref="d2Crud"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
add-mode
|
||||
:add-button="addButton"
|
||||
:form-template="formTemplate"
|
||||
:add-template="addTemplate"
|
||||
:form-options="formOptions"
|
||||
:form-rules="formRules"
|
||||
:add-rules="addRules"
|
||||
@row-add="handleRowAdd"
|
||||
@dialog-cancel="handleDialogCancel"/>
|
||||
@dialog-cancel="handleDialogCancel">
|
||||
<el-button slot="header" style="margin-bottom: 5px" @click="addRow">新增</el-button>
|
||||
</d2-crud>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -58,7 +59,7 @@ export default {
|
|||
icon: 'el-icon-plus',
|
||||
size: 'small'
|
||||
},
|
||||
formTemplate: {
|
||||
addTemplate: {
|
||||
date: {
|
||||
title: '日期',
|
||||
value: ''
|
||||
|
|
@ -77,7 +78,7 @@ export default {
|
|||
labelPosition: 'left',
|
||||
saveLoading: false
|
||||
},
|
||||
formRules: {
|
||||
addRules: {
|
||||
date: [ { required: true, message: '请输入日期', trigger: 'blur' } ],
|
||||
name: [ { required: true, message: '请输入姓名', trigger: 'blur' } ],
|
||||
address: [ { required: true, message: '请输入地址', trigger: 'blur' } ]
|
||||
|
|
@ -85,6 +86,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
addRow () {
|
||||
this.$refs.d2Crud.showDialog({
|
||||
mode: 'add'
|
||||
})
|
||||
},
|
||||
handleRowAdd (row, done) {
|
||||
this.formOptions.saveLoading = true
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
通过给 `D2 Crud` 传入 `form-rules` 可开启表单校验,校验规则参见:[async-validator](https://github.com/yiminghe/async-validator)。代码如下:
|
||||
通过给 `D2 Crud` 传入 `add-rules` 或 `edit-rules` 可开启新增/修改表单校验,校验规则参见:[async-validator](https://github.com/yiminghe/async-validator)。代码如下:
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
<d2-container :filename="filename">
|
||||
<template slot="header">表单校验</template>
|
||||
<d2-crud
|
||||
ref="d2Crud"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
add-mode
|
||||
:add-button="addButton"
|
||||
:form-template="formTemplate"
|
||||
:add-template="addTemplate"
|
||||
:form-options="formOptions"
|
||||
:form-rules="formRules"
|
||||
:add-rules="addRules"
|
||||
@row-add="handleRowAdd"
|
||||
@dialog-cancel="handleDialogCancel">
|
||||
<el-button slot="header" style="margin-bottom: 5px" @click="addRow">新增</el-button>
|
||||
</d2-crud>
|
||||
<el-card shadow="never" class="d2-mb">
|
||||
<d2-markdown :source="doc"/>
|
||||
|
|
@ -75,7 +75,7 @@ export default {
|
|||
icon: 'el-icon-plus',
|
||||
size: 'small'
|
||||
},
|
||||
formTemplate: {
|
||||
addTemplate: {
|
||||
date: {
|
||||
title: '日期',
|
||||
value: ''
|
||||
|
|
@ -94,7 +94,7 @@ export default {
|
|||
labelPosition: 'left',
|
||||
saveLoading: false
|
||||
},
|
||||
formRules: {
|
||||
addRules: {
|
||||
date: [ { required: true, message: '请输入日期', trigger: 'blur' } ],
|
||||
name: [ { required: true, message: '请输入姓名', trigger: 'blur' } ],
|
||||
address: [ { required: true, message: '请输入地址', trigger: 'blur' } ]
|
||||
|
|
@ -102,6 +102,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
addRow () {
|
||||
this.$refs.d2Crud.showDialog({
|
||||
mode: 'add'
|
||||
})
|
||||
},
|
||||
handleRowAdd (row, done) {
|
||||
this.formOptions.saveLoading = true
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
0112dcaa59d17f79454b15cb17a0dc1116fdeb13
|
||||
f4643ebdf5dd651b6d5e06f58d00fd84549c6cd3
|
||||
Loading…
Reference in New Issue