mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(form): dialog支持disabled配置
This commit is contained in:
parent
ea8b863694
commit
239b5d3efe
@ -4,7 +4,6 @@
|
|||||||
ref="tMagicForm"
|
ref="tMagicForm"
|
||||||
:model="values"
|
:model="values"
|
||||||
:label-width="labelWidth"
|
:label-width="labelWidth"
|
||||||
:disabled="disabled"
|
|
||||||
:style="`height: ${height}`"
|
:style="`height: ${height}`"
|
||||||
:inline="inline"
|
:inline="inline"
|
||||||
:label-position="labelPosition"
|
:label-position="labelPosition"
|
||||||
@ -12,6 +11,7 @@
|
|||||||
<template v-if="initialized && Array.isArray(config)">
|
<template v-if="initialized && Array.isArray(config)">
|
||||||
<Container
|
<Container
|
||||||
v-for="(item, index) in config"
|
v-for="(item, index) in config"
|
||||||
|
:disabled="disabled"
|
||||||
:key="item[keyProp] ?? index"
|
:key="item[keyProp] ?? index"
|
||||||
:config="item"
|
:config="item"
|
||||||
:model="values"
|
:model="values"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
v-model="stepActive"
|
v-model="stepActive"
|
||||||
ref="form"
|
ref="form"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:config="config"
|
:config="config"
|
||||||
:init-values="values"
|
:init-values="values"
|
||||||
:parent-values="parentValues"
|
:parent-values="parentValues"
|
||||||
@ -71,6 +72,7 @@ const props = withDefaults(
|
|||||||
width?: string | number;
|
width?: string | number;
|
||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
fullscreen?: boolean;
|
fullscreen?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
size?: 'small' | 'default' | 'large';
|
size?: 'small' | 'default' | 'large';
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
:label-width="config.labelWidth || labelWidth"
|
:label-width="config.labelWidth || labelWidth"
|
||||||
:expand-more="expandMore"
|
:expand-more="expandMore"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Container>
|
></Container>
|
||||||
</TMagicCol>
|
</TMagicCol>
|
||||||
@ -30,6 +31,7 @@ const props = defineProps<{
|
|||||||
span?: number;
|
span?: number;
|
||||||
size?: string;
|
size?: string;
|
||||||
prop?: string;
|
prop?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
:is="tagName"
|
:is="tagName"
|
||||||
:model="model"
|
:model="model"
|
||||||
:config="config"
|
:config="config"
|
||||||
|
:disabled="disabled"
|
||||||
:name="name"
|
:name="name"
|
||||||
:prop="itemProp"
|
:prop="itemProp"
|
||||||
:step-active="stepActive"
|
:step-active="stepActive"
|
||||||
@ -87,6 +88,7 @@
|
|||||||
:model="name || name === 0 ? model[name] : model"
|
:model="name || name === 0 ? model[name] : model"
|
||||||
:config="item"
|
:config="item"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:step-active="stepActive"
|
:step-active="stepActive"
|
||||||
:expand-more="expand"
|
:expand-more="expand"
|
||||||
:label-width="itemLabelWidth"
|
:label-width="itemLabelWidth"
|
||||||
@ -97,7 +99,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
||||||
<TMagicButton type="primary" size="small" text @click="expandHandler">{{
|
<TMagicButton type="primary" size="small" :disabled="false" text @click="expandHandler">{{
|
||||||
expand ? '收起配置' : '展开更多配置'
|
expand ? '收起配置' : '展开更多配置'
|
||||||
}}</TMagicButton>
|
}}</TMagicButton>
|
||||||
</div>
|
</div>
|
||||||
@ -118,6 +120,7 @@ const props = withDefaults(
|
|||||||
model: FormValue;
|
model: FormValue;
|
||||||
config: ChildConfig;
|
config: ChildConfig;
|
||||||
prop?: string;
|
prop?: string;
|
||||||
|
disabled?: boolean;
|
||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
expandMore?: boolean;
|
expandMore?: boolean;
|
||||||
stepActive?: string | number;
|
stepActive?: string | number;
|
||||||
@ -159,7 +162,9 @@ const tagName = computed(() => {
|
|||||||
return 'm-fields-text';
|
return 'm-fields-text';
|
||||||
});
|
});
|
||||||
|
|
||||||
const disabled = computed(() => filterFunction(mForm, props.config.disabled, props));
|
const disabled = computed(() =>
|
||||||
|
typeof props.disabled === 'undefined' ? filterFunction(mForm, props.config.disabled, props) : props.disabled,
|
||||||
|
);
|
||||||
|
|
||||||
const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
|
const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
:rules="name ? rules[name] : []"
|
:rules="name ? rules[name] : []"
|
||||||
:config="item"
|
:config="item"
|
||||||
:prop="prop"
|
:prop="prop"
|
||||||
|
:disabled="disabled"
|
||||||
:labelWidth="lWidth"
|
:labelWidth="lWidth"
|
||||||
:size="size"
|
:size="size"
|
||||||
@change="change"
|
@change="change"
|
||||||
@ -46,6 +47,7 @@
|
|||||||
:prop="prop"
|
:prop="prop"
|
||||||
:labelWidth="lWidth"
|
:labelWidth="lWidth"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
@change="change"
|
@change="change"
|
||||||
></Container>
|
></Container>
|
||||||
</template>
|
</template>
|
||||||
@ -69,6 +71,7 @@ const props = withDefaults(
|
|||||||
model: Record<string, any>;
|
model: Record<string, any>;
|
||||||
config: FieldsetConfig;
|
config: FieldsetConfig;
|
||||||
rules?: any;
|
rules?: any;
|
||||||
|
disabled?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
rules: {},
|
rules: {},
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
:index="index"
|
:index="index"
|
||||||
:label-width="labelWidth"
|
:label-width="labelWidth"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:group-model="model[name]"
|
:group-model="model[name]"
|
||||||
@remove-item="removeHandler"
|
@remove-item="removeHandler"
|
||||||
@swap-item="swapHandler"
|
@swap-item="swapHandler"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></MFieldsGroupListItem>
|
></MFieldsGroupListItem>
|
||||||
|
|
||||||
<TMagicButton @click="addHandler" size="small" v-if="addable">添加组</TMagicButton>
|
<TMagicButton @click="addHandler" size="small" :disabled="disabled" v-if="addable">添加组</TMagicButton>
|
||||||
|
|
||||||
<TMagicButton :icon="Grid" size="small" @click="toggleMode" v-if="config.enableToggleMode">切换为表格</TMagicButton>
|
<TMagicButton :icon="Grid" size="small" @click="toggleMode" v-if="config.enableToggleMode">切换为表格</TMagicButton>
|
||||||
</div>
|
</div>
|
||||||
@ -45,6 +46,7 @@ const props = defineProps<{
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
prop?: string;
|
prop?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
@ -5,21 +5,22 @@
|
|||||||
><CaretBottom v-if="expand" /><CaretRight v-else
|
><CaretBottom v-if="expand" /><CaretRight v-else
|
||||||
/></TMagicIcon>
|
/></TMagicIcon>
|
||||||
|
|
||||||
<TMagicButton text @click="expandHandler">{{ title }}</TMagicButton>
|
<TMagicButton text :disabled="disabled" @click="expandHandler">{{ title }}</TMagicButton>
|
||||||
|
|
||||||
<TMagicButton
|
<TMagicButton
|
||||||
v-show="showDelete(parseInt(String(index)))"
|
v-show="showDelete(parseInt(String(index)))"
|
||||||
|
style="color: #f56c6c"
|
||||||
text
|
text
|
||||||
:icon="Delete"
|
:icon="Delete"
|
||||||
style="color: #f56c6c"
|
:disabled="disabled"
|
||||||
@click="removeHandler"
|
@click="removeHandler"
|
||||||
></TMagicButton>
|
></TMagicButton>
|
||||||
|
|
||||||
<template v-if="movable()">
|
<template v-if="movable()">
|
||||||
<TMagicButton v-show="index !== 0" text size="small" @click="changeOrder(-1)"
|
<TMagicButton v-show="index !== 0" text :disabled="disabled" size="small" @click="changeOrder(-1)"
|
||||||
>上移<TMagicIcon><CaretTop /></TMagicIcon
|
>上移<TMagicIcon><CaretTop /></TMagicIcon
|
||||||
></TMagicButton>
|
></TMagicButton>
|
||||||
<TMagicButton v-show="index !== length - 1" text size="small" @click="changeOrder(1)"
|
<TMagicButton v-show="index !== length - 1" :disabled="disabled" text size="small" @click="changeOrder(1)"
|
||||||
>下移<TMagicIcon><CaretBottom /></TMagicIcon
|
>下移<TMagicIcon><CaretBottom /></TMagicIcon
|
||||||
></TMagicButton>
|
></TMagicButton>
|
||||||
</template>
|
</template>
|
||||||
@ -34,6 +35,7 @@
|
|||||||
:labelWidth="labelWidth"
|
:labelWidth="labelWidth"
|
||||||
:prop="`${prop}${prop ? '.' : ''}${String(index)}`"
|
:prop="`${prop}${prop ? '.' : ''}${String(index)}`"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Container>
|
></Container>
|
||||||
</div>
|
</div>
|
||||||
@ -58,6 +60,7 @@ const props = defineProps<{
|
|||||||
prop?: string;
|
prop?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
index: number;
|
index: number;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['swap-item', 'remove-item', 'change']);
|
const emit = defineEmits(['swap-item', 'remove-item', 'change']);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
:model="name ? model[name] : model"
|
:model="name ? model[name] : model"
|
||||||
:prop="prop"
|
:prop="prop"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:label-width="config.labelWidth || labelWidth"
|
:label-width="config.labelWidth || labelWidth"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Container>
|
></Container>
|
||||||
@ -41,6 +42,7 @@
|
|||||||
:model="name ? model[name] : model"
|
:model="name ? model[name] : model"
|
||||||
:prop="prop"
|
:prop="prop"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:label-width="config.labelWidth || labelWidth"
|
:label-width="config.labelWidth || labelWidth"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Container>
|
></Container>
|
||||||
@ -67,6 +69,7 @@ const props = defineProps<{
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
prop?: string;
|
prop?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
:model="name ? model[name] : model"
|
:model="name ? model[name] : model"
|
||||||
:prop="prop"
|
:prop="prop"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
/>
|
/>
|
||||||
</TMagicRow>
|
</TMagicRow>
|
||||||
@ -32,6 +33,7 @@ const props = defineProps<{
|
|||||||
prop?: string;
|
prop?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
expandMore?: boolean;
|
expandMore?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
:model="step.name ? model[step.name] : model"
|
:model="step.name ? model[step.name] : model"
|
||||||
:prop="`${step.name}`"
|
:prop="`${step.name}`"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
:disabled="disabled"
|
||||||
:label-width="config.labelWidth || labelWidth"
|
:label-width="config.labelWidth || labelWidth"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Container>
|
></Container>
|
||||||
@ -44,6 +45,7 @@ const props = withDefaults(
|
|||||||
stepActive?: number;
|
stepActive?: number;
|
||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
stepActive: 1,
|
stepActive: 1,
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="ArrowUp"
|
:icon="ArrowUp"
|
||||||
|
:disabled="disabled"
|
||||||
text
|
text
|
||||||
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
||||||
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
||||||
@ -65,6 +66,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="ArrowDown"
|
:icon="ArrowDown"
|
||||||
|
:disabled="disabled"
|
||||||
text
|
text
|
||||||
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
||||||
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
||||||
@ -100,6 +102,7 @@
|
|||||||
<Container
|
<Container
|
||||||
v-if="scope.$index > -1"
|
v-if="scope.$index > -1"
|
||||||
labelWidth="0"
|
labelWidth="0"
|
||||||
|
:disabled="disabled"
|
||||||
:prop="getProp(scope.$index)"
|
:prop="getProp(scope.$index)"
|
||||||
:rules="column.rules"
|
:rules="column.rules"
|
||||||
:config="makeConfig(column, scope.row)"
|
:config="makeConfig(column, scope.row)"
|
||||||
@ -113,7 +116,10 @@
|
|||||||
</TMagicTable>
|
</TMagicTable>
|
||||||
</TMagicTooltip>
|
</TMagicTooltip>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<TMagicButton v-if="addable" size="small" type="primary" plain @click="newHandler()">添加</TMagicButton>
|
<TMagicButton v-if="addable" size="small" type="primary" :disabled="disabled" plain @click="newHandler()"
|
||||||
|
>添加</TMagicButton
|
||||||
|
>
|
||||||
|
|
||||||
<TMagicButton
|
<TMagicButton
|
||||||
:icon="Grid"
|
:icon="Grid"
|
||||||
size="small"
|
size="small"
|
||||||
@ -133,15 +139,18 @@
|
|||||||
</TMagicButton>
|
</TMagicButton>
|
||||||
<TMagicUpload
|
<TMagicUpload
|
||||||
v-if="importable"
|
v-if="importable"
|
||||||
|
style="display: inline-block"
|
||||||
ref="excelBtn"
|
ref="excelBtn"
|
||||||
action="/noop"
|
action="/noop"
|
||||||
|
:disabled="disabled"
|
||||||
:on-change="excelHandler"
|
:on-change="excelHandler"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
style="display: inline-block"
|
|
||||||
>
|
>
|
||||||
<TMagicButton size="small" type="success" plain>导入EXCEL</TMagicButton> </TMagicUpload
|
<TMagicButton size="small" type="success" :disabled="disabled" plain>导入EXCEL</TMagicButton> </TMagicUpload
|
||||||
>
|
>
|
||||||
<TMagicButton v-if="importable" size="small" type="warning" plain @click="clearHandler()">清空</TMagicButton>
|
<TMagicButton v-if="importable" size="small" type="warning" :disabled="disabled" plain @click="clearHandler()"
|
||||||
|
>清空</TMagicButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bottom" style="text-align: right" v-if="config.pagination">
|
<div class="bottom" style="text-align: right" v-if="config.pagination">
|
||||||
@ -191,6 +200,7 @@ const props = withDefaults(
|
|||||||
prop?: string;
|
prop?: string;
|
||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
sort?: boolean;
|
sort?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
sortKey?: string;
|
sortKey?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
@ -414,6 +424,7 @@ const itemExtra = (fuc: any, index: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const removeHandler = (index: number) => {
|
const removeHandler = (index: number) => {
|
||||||
|
if (props.disabled) return;
|
||||||
props.model[modelName.value].splice(index, 1);
|
props.model[modelName.value].splice(index, 1);
|
||||||
emit('change', props.model[modelName.value]);
|
emit('change', props.model[modelName.value]);
|
||||||
};
|
};
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
v-for="item in tabItems(tab)"
|
v-for="item in tabItems(tab)"
|
||||||
:key="item[mForm?.keyProp || '__key']"
|
:key="item[mForm?.keyProp || '__key']"
|
||||||
:config="item"
|
:config="item"
|
||||||
|
:disabled="disabled"
|
||||||
:model="
|
:model="
|
||||||
config.dynamic
|
config.dynamic
|
||||||
? (name ? model[name] : model)[tabIndex]
|
? (name ? model[name] : model)[tabIndex]
|
||||||
@ -90,6 +91,7 @@ const props = defineProps<{
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
prop?: string;
|
prop?: string;
|
||||||
expandMore?: boolean;
|
expandMore?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user