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