disabled editor
This commit is contained in:
@ -18,10 +18,11 @@ const ruleTrigger = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const layouts = {
|
const layouts = {
|
||||||
colFormItem(h, scheme) {
|
colFormItem(h, scheme, disabled) {
|
||||||
|
console.log(disabled);
|
||||||
const config = scheme.__config__;
|
const config = scheme.__config__;
|
||||||
const listeners = buildListeners.call(this, scheme);
|
const listeners = buildListeners.call(this, scheme);
|
||||||
console.log(listeners, "28");
|
console.log(config, "28");
|
||||||
let labelWidth = config.labelWidth ? `${config.labelWidth}px` : null;
|
let labelWidth = config.labelWidth ? `${config.labelWidth}px` : null;
|
||||||
if (config.showLabel === false) labelWidth = "0";
|
if (config.showLabel === false) labelWidth = "0";
|
||||||
return (
|
return (
|
||||||
@ -31,13 +32,13 @@ const layouts = {
|
|||||||
prop={scheme.__vModel__}
|
prop={scheme.__vModel__}
|
||||||
label={config.showLabel ? config.label : ""}
|
label={config.showLabel ? config.label : ""}
|
||||||
>
|
>
|
||||||
<render conf={scheme} on={listeners} />
|
<render conf={{ ...scheme, noedit: disabled }} on={listeners} />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
rowFormItem(h, scheme) {
|
rowFormItem(h, scheme, disabled) {
|
||||||
let child = renderChildren.apply(this, arguments);
|
let child = renderChildren.apply(this, arguments, disabled);
|
||||||
if (scheme.type === "flex") {
|
if (scheme.type === "flex") {
|
||||||
child = (
|
child = (
|
||||||
<el-row
|
<el-row
|
||||||
@ -73,7 +74,12 @@ function renderFrom(h) {
|
|||||||
props={{ model: this[formConfCopy.formModel] }}
|
props={{ model: this[formConfCopy.formModel] }}
|
||||||
rules={this[formConfCopy.formRules]}
|
rules={this[formConfCopy.formRules]}
|
||||||
>
|
>
|
||||||
{renderFormItem.call(this, h, formConfCopy.fields)}
|
{renderFormItem.call(
|
||||||
|
this,
|
||||||
|
h,
|
||||||
|
formConfCopy.fields,
|
||||||
|
formConfCopy.disabled
|
||||||
|
)}
|
||||||
{formConfCopy.formBtns && formBtns.call(this, h)}
|
{formConfCopy.formBtns && formBtns.call(this, h)}
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -93,23 +99,23 @@ function formBtns(h) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderFormItem(h, elementList) {
|
function renderFormItem(h, elementList, disabled) {
|
||||||
return elementList.map((scheme) => {
|
return elementList.map((scheme) => {
|
||||||
const config = scheme.__config__;
|
const config = scheme.__config__;
|
||||||
const layout = layouts[config.layout];
|
const layout = layouts[config.layout];
|
||||||
|
|
||||||
if (layout) {
|
|
||||||
console.log(layout);
|
console.log(layout);
|
||||||
return layout.call(this, h, scheme);
|
if (layout) {
|
||||||
|
return layout.call(this, h, scheme, disabled);
|
||||||
}
|
}
|
||||||
throw new Error(`没有与${config.layout}匹配的layout`);
|
throw new Error(`没有与${config.layout}匹配的layout`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderChildren(h, scheme) {
|
function renderChildren(h, scheme, disabled) {
|
||||||
const config = scheme.__config__;
|
const config = scheme.__config__;
|
||||||
if (!Array.isArray(config.children)) return null;
|
if (!Array.isArray(config.children)) return null;
|
||||||
return renderFormItem.call(this, h, config.children);
|
return renderFormItem.call(this, h, config.children, disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setValue(event, config, scheme) {
|
function setValue(event, config, scheme) {
|
||||||
|
@ -17,7 +17,7 @@ import {
|
|||||||
ElCheckboxGroup,
|
ElCheckboxGroup,
|
||||||
} from "element-plus";
|
} from "element-plus";
|
||||||
import Editor from "@/components/Editor";
|
import Editor from "@/components/Editor";
|
||||||
import { h, defineComponent } from "vue";
|
import { h, defineComponent, readonly } from "vue";
|
||||||
|
|
||||||
const formComponentsMap = {
|
const formComponentsMap = {
|
||||||
"el-row": ElRow,
|
"el-row": ElRow,
|
||||||
@ -171,6 +171,9 @@ export default defineComponent({
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
// noedit: {
|
||||||
|
// type: Boolean,
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -237,6 +240,11 @@ export default defineComponent({
|
|||||||
) : (
|
) : (
|
||||||
<Tag
|
<Tag
|
||||||
{...dataObject.attrs}
|
{...dataObject.attrs}
|
||||||
|
{...(this.$props.conf.__config__.tag === "editor"
|
||||||
|
? {
|
||||||
|
readOnly: dataObject.attrs.noedit,
|
||||||
|
}
|
||||||
|
: {})}
|
||||||
on={dataObject.on}
|
on={dataObject.on}
|
||||||
modelValue={this.$props.conf.__config__.defaultValue}
|
modelValue={this.$props.conf.__config__.defaultValue}
|
||||||
></Tag>
|
></Tag>
|
||||||
|
Reference in New Issue
Block a user