From d62a50d0d9f226265de1c334783fe10336dd595f Mon Sep 17 00:00:00 2001 From: BoBoooooo <17746714@qq.com> Date: Sun, 31 Mar 2019 11:08:24 +0800 Subject: [PATCH] =?UTF-8?q?[fix]{GenerateForm,CrudTable}:=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=87=A0=E5=A4=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommonTable/index.vue | 2 +- src/components/CrudTable/CrudTable.vue | 12 +++-- src/components/CrudTable/components/props.js | 10 +++-- src/components/FormDesigner/GenerateForm.vue | 6 +-- src/components/FormDesigner/WidgetConfig.vue | 45 +++++++++---------- .../Tinymce/components/editorImage.vue | 8 ++-- 6 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/components/CommonTable/index.vue b/src/components/CommonTable/index.vue index c3b8a12..dfc4c77 100644 --- a/src/components/CommonTable/index.vue +++ b/src/components/CommonTable/index.vue @@ -18,7 +18,7 @@ fit highlight-current-row @selection-change="selection => emitEvent('selection-change', selection)" - @row-click="(row, event, column) => emitEventHandler('row-click', row, event, column)" + @row-click="(row, event, column) => emitEvent('row-click', row, event, column)" > @@ -58,7 +56,6 @@ :rules="rules" :widget="item" :remote="remote" - :disabled="disabled" v-show="!item.hidden"> @@ -81,7 +78,6 @@ export default { // data 初始化表单 // value 表单赋值 // clear 清空表单 - // disabled 表单只读 data() { return { models: {}, @@ -107,7 +103,7 @@ export default { created() { this.generateModle(this.data.list); this.setFormReadOnly(this.data.list); - this.setHidden(this.data.list); + this.setFormHidden(this.data.list); }, methods: { // 设置只读 diff --git a/src/components/FormDesigner/WidgetConfig.vue b/src/components/FormDesigner/WidgetConfig.vue index eac4b44..128c100 100644 --- a/src/components/FormDesigner/WidgetConfig.vue +++ b/src/components/FormDesigner/WidgetConfig.vue @@ -550,49 +550,46 @@ export default { }, }, watch: { - 'data.options.isRange': function (val) { + 'data.options.isRange': function watchIsRange(val) { if (typeof val !== 'undefined') { if (val) { - this.data.options.defaultValue = null - } else if (Object.keys(this.data.options).indexOf('defaultValue') >= 0) { this.data.options.defaultValue = '' } + this.data.options.defaultValue = null; + } else if (Object.keys(this.data.options).includes('defaultValue')) { this.data.options.defaultValue = ''; } } }, - 'data.options.required': function (val) { + 'data.options.required': function watchRequired(val) { if (val) { - this.validator.required = { required: true, message: `${this.data.name}必须填写` } + this.validator.required = { required: true, message: `${this.data.name}必须填写` }; } else { - this.validator.required = null + this.validator.required = null; } - this.$nextTick(() => { - this.generateRule() - }) + this.generateRule(); + }); }, - 'data.options.dataType': function (val) { + 'data.options.dataType': function watchDataType(val) { if (!this.show) { - return false + return false; } - if (val) { - this.validator.type = { type: val, message: `${this.data.name}格式不正确` } + this.validator.type = { type: val, message: `${this.data.name}格式不正确` }; } else { - this.validator.type = null + this.validator.type = null; } - - this.generateRule() + this.generateRule(); + return null; }, - 'data.options.pattern': function (val) { + 'data.options.pattern': function watchPattern(val) { if (!this.show) { - return false + return false; } - if (val) { - this.validator.pattern = { pattern: eval(val), message: `${this.data.name}格式不匹配` } + this.validator.pattern = { pattern: val, message: `${this.data.name}格式不匹配` }; } else { - this.validator.pattern = null + this.validator.pattern = null; } - - this.generateRule() + this.generateRule(); + return null; }, }, methods: { @@ -637,7 +634,7 @@ export default { this.data.options.defaultValue = [] } } else if (this.data.options.defaultValue.length > 0) { - this.data.options.defaultValue = this.data.options.defaultValue[0] + [this.data.options.defaultValue] = this.data.options.defaultValue; } else { this.data.options.defaultValue = '' } diff --git a/src/components/Tinymce/components/editorImage.vue b/src/components/Tinymce/components/editorImage.vue index 8cab9cf..195809c 100644 --- a/src/components/Tinymce/components/editorImage.vue +++ b/src/components/Tinymce/components/editorImage.vue @@ -55,7 +55,7 @@ export default { this.dialogVisible = false }, handleSuccess(response, file) { - const uid = file.uid + const { uid } = file const objKeyArr = Object.keys(this.listObj) for (let i = 0, len = objKeyArr.length; i < len; i++) { if (this.listObj[objKeyArr[i]].uid === uid) { @@ -66,7 +66,7 @@ export default { } }, handleRemove(file) { - const uid = file.uid + const { uid } = file const objKeyArr = Object.keys(this.listObj) for (let i = 0, len = objKeyArr.length; i < len; i++) { if (this.listObj[objKeyArr[i]].uid === uid) { @@ -80,10 +80,10 @@ export default { const _URL = window.URL || window.webkitURL const fileName = file.uid this.listObj[fileName] = {} - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const img = new Image() img.src = _URL.createObjectURL(file) - img.onload = function () { + img.onload = function onload() { _self.listObj[fileName] = { hasSuccess: false, uid: file.uid, width: this.width, height: this.height, }