Skip to content

Commit

Permalink
fix: 修复this.value初始值bug ,版本更新至0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Dec 18, 2020
1 parent c95fe9f commit 5b32d30
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.5.3",
"version": "0.5.4",
"main": "lib/ProCrud.umd.min.js",
"files": [
"lib",
Expand Down
3 changes: 2 additions & 1 deletion packages/form-designer/src/GenerateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ export default class GenerateForm extends Vue {

@Watch('value', {
deep: true,
immediate: true,
})
valueOnChange(val) {
this.$nextTick(() => {
Expand All @@ -419,7 +420,7 @@ export default class GenerateForm extends Vue {

@Watch('models', {
deep: true,
immediate: true,
// immediate: true,
})
modelsOnChange(val) {
this.$emit('update:entity', val);
Expand Down
18 changes: 2 additions & 16 deletions packages/form-designer/src/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export default class GenerateFormItem extends Vue {
readOnly: any;

// 当前组件对象
dataModel: any = this.models[this.widget.model];
dataModel: string | number | null | object = this.models[this.widget.model] || null;

copyOption: any = []; // 备份一份初始选项

Expand All @@ -375,21 +375,7 @@ export default class GenerateFormItem extends Vue {
};
};
}
let model = this.models[this.widget.model];

if (this.widget.type === 'date') {
// 此处防止传入的值为非正常时间格式导致日历控件报错
// new Date校验以下四种情况yyyy-MM-dd yyyy-M-d yyyy/MM/dd yyyy/M/d yyyy-MM yyyy-M yyyy/MM yyyy/M
// 正则表达式校验 yyyy年MM月dd日 yyyy年M月d日情况 yyyy年MM月 yyyy年M月
const reg = /^([1-9]\d{3})年(\d{1,2})月(\d{1,2})日$/;
const regForYYYYMM = /^([1-9]\d{3})年(\d{1,2})月$/;
const regForYYYYMMDD = /^([1-9]\d{3})(\d{1,2})(\d{1,2})$/;
const isValid = !this.dayjs(model).isValid() || reg.test(model) || regForYYYYMM.test(model) || regForYYYYMMDD.test(model);
if (!isValid) {
model = '';
}
}

const model = this.models[this.widget.model];
this.normalizer = normalizer;
this.dataModel = model;
}
Expand Down

0 comments on commit 5b32d30

Please sign in to comment.