Signed-off-by: liwenxuan <1298531568@qq.com>
@ -94,11 +94,38 @@ const clickBtn = (control: any) => {
injectBtnEvent && injectBtnEvent(control)
}
// 根据表单设置不显示指定字段
const linksIf = (obj: FormList) => {
const { type } = formProps.value;
const { config: { disabledAdd, disabledEdit, disabledDetail } = {} } = obj;
if (type === 1) {
if (disabledAdd) {
// 编辑页 || 新增页
return false; // 不显示
} else if (type === 2) {
// 编辑
if (disabledEdit) {
return false;
} else if (type === 4 || type === 3) {
// 查看
if (disabledDetail) {
// 如果当前字段的name值存在于表单数据的vIf中,则不显示
const vIf: string | string[] = formProps.value.hideField;
if (vIf?.length > 0 && obj.name) {
return vIf.indexOf(obj.name) === -1; // 存在时返回false隐藏
return true;
};
</script>
<template>
<div v-for="(element,index) in dataList" :key="index" :style="getFormItemDivStyle(element)">
<div v-if="linksIf(element)">
<template v-if="element.type === 'tabs'">
<!--选项卡-->
<el-tabs
@ -233,6 +260,7 @@ const clickBtn = (control: any) => {
</template>
<FormItem v-else :data="element" />
</div>
<style lang='scss' scoped>