Explorar el Código

关联数据组件是否可添加功能调整,默认为可添加,空值和true为开起状态,false为关闭状态。

shenqilong hace 1 año
padre
commit
c4f20a165b

+ 17 - 1
src/business/platform/form/formbuilder/right-aside/editors/editor-field-linkdata.vue

@@ -24,7 +24,8 @@
                 <template slot="label">是否可添加<help-tip prop="allowCreategl" />
                 </template>
                 <el-switch
-                    v-model="fieldOptions.allowCreate"
+                    v-model="allowCreate"
+                    @change="changeAllowCreate"
                 />
             </el-form-item>
             <el-form-item>
@@ -126,11 +127,23 @@ export default {
         DataTemplateLinkdata
     },
     mixins: [EditorMixin, DataTemplateMixin],
+    data () {
+        return {
+            allowCreate: true
+        }
+    },
     computed: {
         multiple () {
             return this.fieldOptions.multiple === 'Y'
         }
     },
+    created () {
+        if (this.fieldOptions.allowCreate !== false) {
+            this.allowCreate = true
+        } else {
+            this.allowCreate = false
+        }
+    },
     methods: {
         changeDataTemplateSelector (data, val, oldVal) {
             if (data && val !== oldVal) {
@@ -138,6 +151,9 @@ export default {
                 this.setDataTemplateDefaultValue()
             }
             this.changeDataSource(val, 'value_source')
+        },
+        changeAllowCreate (val) {
+            this.fieldOptions.allowCreate = val
         }
     }
 }