mirror of
https://github.com/youzan/vant.git
synced 2026-04-17 02:06:57 +08:00
[Improvement] extract component common part (#703)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="van-contact-edit">
|
||||
<cell-group>
|
||||
<field
|
||||
v-model="currentInfo.name"
|
||||
v-model="data.name"
|
||||
maxlength="30"
|
||||
:label="$t('contact')"
|
||||
:placeholder="$t('name')"
|
||||
@@ -10,7 +10,7 @@
|
||||
@focus="onFocus('name')"
|
||||
/>
|
||||
<field
|
||||
v-model="currentInfo.tel"
|
||||
v-model="data.tel"
|
||||
type="tel"
|
||||
:label="$t('tel')"
|
||||
:placeholder="$t('telPlaceholder')"
|
||||
@@ -28,19 +28,17 @@
|
||||
<script>
|
||||
import Field from '../field';
|
||||
import VanButton from '../button';
|
||||
import CellGroup from '../cell-group';
|
||||
import Dialog from '../dialog';
|
||||
import Toast from '../toast';
|
||||
import validateMobile from '../utils/validate/mobile';
|
||||
import { create } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'van-contact-edit',
|
||||
name: 'contact-edit',
|
||||
|
||||
components: {
|
||||
Field,
|
||||
VanButton,
|
||||
CellGroup
|
||||
VanButton
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -63,7 +61,7 @@ export default create({
|
||||
|
||||
data() {
|
||||
return {
|
||||
currentInfo: this.contactInfo,
|
||||
data: this.contactInfo,
|
||||
errorInfo: {
|
||||
name: false,
|
||||
tel: false
|
||||
@@ -73,7 +71,7 @@ export default create({
|
||||
|
||||
watch: {
|
||||
contactInfo(val) {
|
||||
this.currentInfo = val;
|
||||
this.data = val;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -83,7 +81,7 @@ export default create({
|
||||
},
|
||||
|
||||
getErrorMessageByKey(key) {
|
||||
const value = this.currentInfo[key];
|
||||
const value = this.data[key];
|
||||
switch (key) {
|
||||
case 'name':
|
||||
return value ? value.length <= 15 ? '' : this.$t('nameOverlimit') : this.$t('nameEmpty');
|
||||
@@ -108,7 +106,7 @@ export default create({
|
||||
});
|
||||
|
||||
if (isValid && !this.isSaving) {
|
||||
this.$emit('save', this.currentInfo);
|
||||
this.$emit('save', this.data);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -120,7 +118,7 @@ export default create({
|
||||
Dialog.confirm({
|
||||
message: this.$t('confirmDelete')
|
||||
}).then(() => {
|
||||
this.$emit('delete', this.currentInfo);
|
||||
this.$emit('delete', this.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user