fix: 日期时间区间支持只读显示,选人组件在只读状态下不再可选
fix: 略微调整表单标签的高度
This commit is contained in:
@ -162,6 +162,9 @@ export const basicComponents = [
|
|||||||
typeName: t('编码组件'),
|
typeName: t('编码组件'),
|
||||||
type: 'auto-code',
|
type: 'auto-code',
|
||||||
options: {
|
options: {
|
||||||
|
labelWidthMode: 'fix',
|
||||||
|
labelFixWidth: 120,
|
||||||
|
responsive: false,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
span: '',
|
span: '',
|
||||||
placeholder: t('请输入编码组件'),
|
placeholder: t('请输入编码组件'),
|
||||||
@ -1151,6 +1154,9 @@ export const infoComponents = [
|
|||||||
typeName: t('组织架构'),
|
typeName: t('组织架构'),
|
||||||
type: 'organization',
|
type: 'organization',
|
||||||
options: {
|
options: {
|
||||||
|
labelWidthMode: 'fix',
|
||||||
|
labelFixWidth: 120,
|
||||||
|
responsive: false,
|
||||||
span: '',
|
span: '',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
defaultValue: undefined,
|
defaultValue: undefined,
|
||||||
|
|||||||
@ -3,48 +3,62 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: String,
|
value: String,
|
||||||
schema: Object,
|
schema: Object,
|
||||||
});
|
model: Object
|
||||||
|
});
|
||||||
|
|
||||||
const fieldValue = ref(genFieldValue(props.value));
|
const fieldValue = ref(genFieldValue(props.value));
|
||||||
|
const textComponents = ['Input', 'AutoCodeRule', 'DatePicker', 'TimePicker', 'Info', 'Text', 'InputTextArea', 'InputNumber'];
|
||||||
|
|
||||||
function genFieldValue(val) {
|
function parseRangeVal(val, component) {
|
||||||
if (!props?.schema || (!val && val !== 0)) {
|
if (component !== 'RangePicker' || !val) {
|
||||||
|
return val || '';
|
||||||
|
}
|
||||||
|
return val.split(' ')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function genFieldValue(val) {
|
||||||
|
const schema = props.schema;
|
||||||
|
const model = props.model;
|
||||||
|
const { componentProps, component } = schema;
|
||||||
|
if (model && (component === 'TimeRangePicker' || component === 'RangePicker')) {
|
||||||
|
const fieldArr = schema.field.split(',');
|
||||||
|
const valStart = parseRangeVal(model[fieldArr[0]], component);
|
||||||
|
const valEnd = parseRangeVal(model[fieldArr[1]], component);
|
||||||
|
return `${valStart} - ${valEnd}`;
|
||||||
|
}
|
||||||
|
if (!schema || (!val && val !== 0)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const schema = props.schema;
|
|
||||||
const { componentProps, component } = schema;
|
|
||||||
|
|
||||||
if ([
|
if (textComponents.includes(component)) {
|
||||||
"Input",
|
|
||||||
"AutoCodeRule",
|
|
||||||
"DatePicker",
|
|
||||||
"TimePicker",
|
|
||||||
"Info",
|
|
||||||
"Text",
|
|
||||||
'InputTextArea',
|
|
||||||
'InputNumber'].includes(component)) {
|
|
||||||
return `${componentProps?.addonBefore || ''}${val}${componentProps?.addonAfter || ''}`;
|
return `${componentProps?.addonBefore || ''}${val}${componentProps?.addonAfter || ''}`;
|
||||||
}
|
} else if (component === 'Switch') {
|
||||||
if (component === 'Switch') {
|
|
||||||
return val === 1 ? '是' : '否';
|
return val === 1 ? '是' : '否';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.value,
|
() => props.value,
|
||||||
|
(newValue) => {
|
||||||
|
fieldValue.value = genFieldValue(newValue);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.model,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
fieldValue.value = genFieldValue(newValue);
|
fieldValue.value = genFieldValue(newValue);
|
||||||
},
|
},
|
||||||
);
|
{ deep: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.field-readonly {
|
.field-readonly {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div :class="{ disabled }" class="form-select-user">
|
||||||
<FormItemRest>
|
<FormItemRest>
|
||||||
<SelectUser
|
<SelectUser
|
||||||
|
:key="key"
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:selectedIds="selectedIds"
|
:selectedIds="selectedIds"
|
||||||
:key="key"
|
:disabled="disabled"
|
||||||
@change="
|
@change="
|
||||||
(ids, options) => {
|
(ids, options) => {
|
||||||
emit('update:value', ids.join(','));
|
emit('update:value', ids.join(','));
|
||||||
@ -18,18 +19,11 @@
|
|||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<a-input
|
<a-input v-model:value="userNames" :bordered="bordered" :disabled="disabled" :placeholder="placeholder" :size="size" readonly>
|
||||||
readonly
|
<template v-if="prefix" #prefix>
|
||||||
:disabled="disabled"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
v-model:value="userNames"
|
|
||||||
:size="size"
|
|
||||||
:bordered="bordered"
|
|
||||||
>
|
|
||||||
<template #prefix v-if="prefix">
|
|
||||||
<Icon :icon="prefix" />
|
<Icon :icon="prefix" />
|
||||||
</template>
|
</template>
|
||||||
<template #suffix v-if="suffix">
|
<template v-if="suffix" #suffix>
|
||||||
<Icon :icon="suffix" />
|
<Icon :icon="suffix" />
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
@ -56,12 +50,12 @@
|
|||||||
size: String,
|
size: String,
|
||||||
bordered: {
|
bordered: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true
|
||||||
},
|
},
|
||||||
multiple: {
|
multiple: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const userNames = ref<string>();
|
const userNames = ref<string>();
|
||||||
@ -80,7 +74,29 @@
|
|||||||
key.value++;
|
key.value++;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="less">
|
||||||
|
.form-select-user {
|
||||||
|
&.disabled {
|
||||||
|
.ant-input-suffix {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-input-affix-wrapper-disabled {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-input[disabled] {
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-input-affix-wrapper{
|
||||||
|
border: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
disabledIds?: Array<string>;
|
disabledIds?: Array<string>;
|
||||||
multiple?: Boolean;
|
multiple?: Boolean;
|
||||||
visible?: Boolean;
|
visible?: Boolean;
|
||||||
|
disabled?: Boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
selectedIds: () => {
|
selectedIds: () => {
|
||||||
@ -126,6 +127,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
async function show() {
|
async function show() {
|
||||||
|
if(props.disabled) return;
|
||||||
data.selectedIds = [];
|
data.selectedIds = [];
|
||||||
data.selectedList = [];
|
data.selectedList = [];
|
||||||
data.page.current = 1;
|
data.page.current = 1;
|
||||||
|
|||||||
@ -2,65 +2,68 @@
|
|||||||
<div>
|
<div>
|
||||||
<!--如果是grid 组件 需要新增grid布局包裹-->
|
<!--如果是grid 组件 需要新增grid布局包裹-->
|
||||||
<template v-if="schema.component.includes('Grid')">
|
<template v-if="schema.component.includes('Grid')">
|
||||||
<Row v-show="getIsShow(schema)" :align="(schema.componentProps as any).align"
|
<Row v-show="getIsShow(schema)" :align="(schema.componentProps as any).align" :gutter="(schema.componentProps as any).gutter ?? 0" :justify="(schema.componentProps as any).justify" type="flex">
|
||||||
:gutter="(schema.componentProps as any).gutter ?? 0" :justify="(schema.componentProps as any).justify"
|
|
||||||
type="flex">
|
|
||||||
<Col v-for="(col, colIndex) in schema.children" :key="colIndex" :span="col.span">
|
<Col v-for="(col, colIndex) in schema.children" :key="colIndex" :span="col.span">
|
||||||
<template v-for="childSchema in col.list" :key="childSchema.field">
|
<template v-for="childSchema in col.list" :key="childSchema.field">
|
||||||
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]"
|
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :label-col="labelCol" :refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
||||||
:form-api="formApi" :isWorkFlow="isWorkFlow" :label-col="labelCol"
|
|
||||||
:refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
|
||||||
</template>
|
</template>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</template>
|
</template>
|
||||||
<!--如果是tab 组件 需要新增tab组件包裹-->
|
<!--如果是tab 组件 需要新增tab组件包裹-->
|
||||||
<template v-else-if="schema.component === 'Tab'">
|
<template v-else-if="schema.component === 'Tab'">
|
||||||
<Tabs v-show="getIsShow(schema)" v-model:activeKey="activeKey"
|
<Tabs v-show="getIsShow(schema)" v-model:activeKey="activeKey" :size="(schema.componentProps as any).tabSize" :tabPosition="(schema.componentProps as any).tabPosition" :type="(schema.componentProps as any).type">
|
||||||
:size="(schema.componentProps as any).tabSize" :tabPosition="(schema.componentProps as any).tabPosition"
|
|
||||||
:type="(schema.componentProps as any).type">
|
|
||||||
<TabPane v-for="(tab, tabIndex) in schema.children" :key="tabIndex" :forceRender="true" :tab="tab.name">
|
<TabPane v-for="(tab, tabIndex) in schema.children" :key="tabIndex" :forceRender="true" :tab="tab.name">
|
||||||
<template v-for="childSchema in tab.list" :key="childSchema.field">
|
<template v-for="childSchema in tab.list" :key="childSchema.field">
|
||||||
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]"
|
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
||||||
:form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj"
|
|
||||||
:schema="childSchema" />
|
|
||||||
</template>
|
</template>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</template>
|
</template>
|
||||||
<!--如果是子表单 组件 需要v-model:value="表单对象[字段名]"-->
|
<!--如果是子表单 组件 需要v-model:value="表单对象[字段名]"-->
|
||||||
<template v-else-if="schema.component.includes('Form')">
|
<template v-else-if="schema.component.includes('Form')">
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol"
|
v-if="getShow(schema)"
|
||||||
:labelAlign="formProps?.labelAlign" :name="schema.field" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
v-show="getIsShow(schema)"
|
||||||
<component :is="formComponent(schema)" v-model:value="formModel![schema.field]" :disabled="getDisable"
|
:key="schema.key"
|
||||||
:size="formProps?.size" v-bind="schema.componentProps" />
|
:label="getComponentsProps.showLabel ? schema.label : ''"
|
||||||
|
:label-col="labelCol"
|
||||||
|
:labelAlign="formProps?.labelAlign"
|
||||||
|
:name="schema.field"
|
||||||
|
:wrapperCol="itemLabelWidthProp.wrapperCol"
|
||||||
|
>
|
||||||
|
<component :is="formComponent(schema)" v-model:value="formModel![schema.field]" :disabled="getDisable" :size="formProps?.size" v-bind="schema.componentProps" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<!--如果是子表单 组件 需要v-model:value="表单对象[字段名]"-->
|
<!--如果是子表单 组件 需要v-model:value="表单对象[字段名]"-->
|
||||||
<template v-else-if="schema.component.includes('OneForOne')">
|
<template v-else-if="schema.component.includes('OneForOne')">
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol"
|
v-if="getShow(schema)"
|
||||||
:labelAlign="formProps?.labelAlign" :name="schema.field" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
v-show="getIsShow(schema)"
|
||||||
<component :is="componentMap.get(schema.component)" v-model:value="formModel![schema.field]"
|
:key="schema.key"
|
||||||
:disabled="getDisable" :refreshFieldObj="refreshFieldObj" :size="formProps?.size"
|
:label="getComponentsProps.showLabel ? schema.label : ''"
|
||||||
v-bind="schema.componentProps" />
|
:label-col="labelCol"
|
||||||
|
:labelAlign="formProps?.labelAlign"
|
||||||
|
:name="schema.field"
|
||||||
|
:wrapperCol="itemLabelWidthProp.wrapperCol"
|
||||||
|
>
|
||||||
|
<component :is="componentMap.get(schema.component)" v-model:value="formModel![schema.field]" :disabled="getDisable" :refreshFieldObj="refreshFieldObj" :size="formProps?.size" v-bind="schema.componentProps" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="schema.component === 'TableLayout'">
|
<template v-else-if="schema.component === 'TableLayout'">
|
||||||
<TableLayoutPreview v-if="getShow(schema)" v-show="getIsShow(schema)" :element="schema">
|
<TableLayoutPreview v-if="getShow(schema)" v-show="getIsShow(schema)" :element="schema">
|
||||||
<template #tdElement="{ tdElement }">
|
<template #tdElement="{ tdElement }">
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
<div :style="{
|
<div
|
||||||
|
:style="{
|
||||||
height: tdElement.height ? tdElement.height + 'px' : '',
|
height: tdElement.height ? tdElement.height + 'px' : '',
|
||||||
minHeight: (tdElement.height || '42') + 'px',
|
minHeight: (tdElement.height || '42') + 'px',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
padding: '10px'
|
padding: '10px'
|
||||||
}">
|
}"
|
||||||
|
>
|
||||||
<template v-for="childSchema in tdElement.children" :key="childSchema.field">
|
<template v-for="childSchema in tdElement.children" :key="childSchema.field">
|
||||||
<SimpleFormItem v-if="showComponent(childSchema)"
|
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
||||||
v-model:value="formModel![childSchema.field]" :form-api="formApi"
|
|
||||||
:isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -69,41 +72,51 @@
|
|||||||
</template>
|
</template>
|
||||||
<!--如果是时间区间 组件 需要v-model:startField="表单对象[字段名]" v-model:endField="表单对象[字段名]"-->
|
<!--如果是时间区间 组件 需要v-model:startField="表单对象[字段名]" v-model:endField="表单对象[字段名]"-->
|
||||||
<template v-else-if="schema.component.includes('Range')">
|
<template v-else-if="schema.component.includes('Range')">
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol" :name="schema.field"
|
v-if="getShow(schema)"
|
||||||
:rules="rules" :validateTrigger="['blur', 'change']" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
v-show="getIsShow(schema)"
|
||||||
<component :is="componentMap.get(schema.component)" v-model:endField="schema.field.split(',')[1]"
|
:key="schema.key"
|
||||||
v-model:startField="schema.field.split(',')[0]" v-model:value="formModel![schema.field]"
|
:label="getComponentsProps.showLabel ? schema.label : ''"
|
||||||
:disabled="getDisable" :size="formProps?.size" v-bind="schema.componentProps" />
|
:label-col="labelCol"
|
||||||
|
:name="schema.field"
|
||||||
|
:rules="rules"
|
||||||
|
:validateTrigger="['blur', 'change']"
|
||||||
|
:wrapperCol="itemLabelWidthProp.wrapperCol"
|
||||||
|
>
|
||||||
|
<template v-if="getDisable && readonlySupport(schema.component)">
|
||||||
|
<readonly :schema="schema" :model="formModel" />
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<component
|
||||||
|
:is="componentMap.get(schema.component)"
|
||||||
|
v-model:endField="schema.field.split(',')[1]"
|
||||||
|
v-model:startField="schema.field.split(',')[0]"
|
||||||
|
v-model:value="formModel![schema.field]"
|
||||||
|
:disabled="getDisable"
|
||||||
|
:size="formProps?.size"
|
||||||
|
v-bind="schema.componentProps"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<!-- 因为Range会变为 开始时间 和 结束时间 2个属性给与表单数据 所以需要2个隐藏框绑定 starTime 和 endTime -->
|
<!-- 因为Range会变为 开始时间 和 结束时间 2个属性给与表单数据 所以需要2个隐藏框绑定 starTime 和 endTime -->
|
||||||
<FormItem v-show="false" :key="schema.key" :label="getComponentsProps.showLabel ? schema.label : ''"
|
<FormItem v-show="false" :key="schema.key" :label="getComponentsProps.showLabel ? schema.label : ''" :name="schema.field.split(',')[0]">
|
||||||
:name="schema.field.split(',')[0]">
|
|
||||||
<input type="hidden" />
|
<input type="hidden" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem v-show="false" :key="schema.key" :label="getComponentsProps.showLabel ? schema.label : ''"
|
<FormItem v-show="false" :key="schema.key" :label="getComponentsProps.showLabel ? schema.label : ''" :name="schema.field.split(',')[1]">
|
||||||
:name="schema.field.split(',')[1]">
|
|
||||||
<input type="hidden" />
|
<input type="hidden" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<!--如果checked 或者 switch组件 需要v-model:checked="表单对象[字段名]" "-->
|
<!--如果checked 或者 switch组件 需要v-model:checked="表单对象[字段名]" "-->
|
||||||
<template v-else-if="checkedValueComponents.includes(schema.component)">
|
<template v-else-if="checkedValueComponents.includes(schema.component)">
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key" :label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol" :name="schema.field" :rules="rules" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol" :name="schema.field"
|
<component :is="componentMap.get(schema.component)" :key="refreshFieldObj[schema.field]" v-model:checked="formModel![schema.field]" :disabled="getDisable" :size="formProps?.size" v-bind="getComponentsProps" />
|
||||||
:rules="rules" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
|
||||||
<component :is="componentMap.get(schema.component)" :key="refreshFieldObj[schema.field]"
|
|
||||||
v-model:checked="formModel![schema.field]" :disabled="getDisable" :size="formProps?.size"
|
|
||||||
v-bind="getComponentsProps" />
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<!--如果是card 组件 需要新增card组件包裹-->
|
<!--如果是card 组件 需要新增card组件包裹-->
|
||||||
<template v-else-if="schema.component.includes('Card')">
|
<template v-else-if="schema.component.includes('Card')">
|
||||||
<CollapseContainer v-show="getIsShow(schema)" :bordered="false" :hasLeftBorder="true"
|
<CollapseContainer v-show="getIsShow(schema)" :bordered="false" :hasLeftBorder="true" :title="(schema.componentProps as any).title">
|
||||||
:title="(schema.componentProps as any).title">
|
|
||||||
<template v-for="childSchema in schema.children![0].list" :key="childSchema.field">
|
<template v-for="childSchema in schema.children![0].list" :key="childSchema.field">
|
||||||
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]"
|
<SimpleFormItem v-if="showComponent(childSchema)" v-model:value="formModel![childSchema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="childSchema" />
|
||||||
:form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj"
|
|
||||||
:schema="childSchema" />
|
|
||||||
</template>
|
</template>
|
||||||
</CollapseContainer>
|
</CollapseContainer>
|
||||||
</template>
|
</template>
|
||||||
@ -115,52 +128,64 @@
|
|||||||
</template>
|
</template>
|
||||||
<!--如果是 意见簿 组件 需要使用defaultValue直接赋值 -->
|
<!--如果是 意见簿 组件 需要使用defaultValue直接赋值 -->
|
||||||
<template v-else-if="schema.component.includes('Opinion')">
|
<template v-else-if="schema.component.includes('Opinion')">
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol" :name="schema.field"
|
v-if="getShow(schema)"
|
||||||
:rules="rules" :validateTrigger="['blur', 'change']" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
v-show="getIsShow(schema)"
|
||||||
<component :is="componentMap.get(schema.component)" :key="refreshFieldObj[schema.field]"
|
:key="schema.key"
|
||||||
:disabled="getDisable" :size="formProps?.size" :value="schema.defaultValue"
|
:label="getComponentsProps.showLabel ? schema.label : ''"
|
||||||
v-bind="getComponentsProps" />
|
:label-col="labelCol"
|
||||||
|
:name="schema.field"
|
||||||
|
:rules="rules"
|
||||||
|
:validateTrigger="['blur', 'change']"
|
||||||
|
:wrapperCol="itemLabelWidthProp.wrapperCol"
|
||||||
|
>
|
||||||
|
<component :is="componentMap.get(schema.component)" :key="refreshFieldObj[schema.field]" :disabled="getDisable" :size="formProps?.size" :value="schema.defaultValue" v-bind="getComponentsProps" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<FormItem v-if="getShow(schema)" v-show="getIsShow(schema)" :key="schema.key"
|
<FormItem
|
||||||
:label="getComponentsProps.showLabel ? schema.label : ''" :label-col="labelCol" :name="schema.field"
|
v-if="getShow(schema)"
|
||||||
:rules="rules" :validateTrigger="['blur', 'change']" :wrapperCol="itemLabelWidthProp.wrapperCol">
|
v-show="getIsShow(schema)"
|
||||||
|
:key="schema.key"
|
||||||
|
:label="getComponentsProps.showLabel ? schema.label : ''"
|
||||||
|
:label-col="labelCol"
|
||||||
|
:name="schema.field"
|
||||||
|
:rules="rules"
|
||||||
|
:validateTrigger="['blur', 'change']"
|
||||||
|
:wrapperCol="itemLabelWidthProp.wrapperCol"
|
||||||
|
>
|
||||||
<template v-if="getDisable && readonlySupport(schema.component)">
|
<template v-if="getDisable && readonlySupport(schema.component)">
|
||||||
<readonly :schema="schema" :value="formModel![schema.field]" />
|
<readonly :schema="schema" :value="formModel![schema.field]" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<component :is="defaultComponent(schema)" :key="refreshFieldObj[schema.field]"
|
<component :is="defaultComponent(schema)" :key="refreshFieldObj[schema.field]" v-model:value="formModel![schema.field]" :disabled="getDisable" :size="formProps?.size" v-bind="getComponentsProps" />
|
||||||
v-model:value="formModel![schema.field]" :disabled="getDisable" :size="formProps?.size"
|
|
||||||
v-bind="getComponentsProps" />
|
|
||||||
</template>
|
</template>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Form, Col, Row, Tabs, TabPane, Divider } from 'ant-design-vue';
|
import { Form, Col, Row, Tabs, TabPane, Divider } from 'ant-design-vue';
|
||||||
import { isBoolean, isFunction, upperFirst, cloneDeep } from 'lodash-es';
|
import { isBoolean, isFunction, upperFirst, cloneDeep } from 'lodash-es';
|
||||||
import { computed, onMounted, unref, inject, Ref, watch, ref } from 'vue';
|
import { computed, onMounted, unref, inject, Ref, watch, ref } from 'vue';
|
||||||
import { componentMap } from '/@/components/Form/src/componentMap';
|
import { componentMap } from '/@/components/Form/src/componentMap';
|
||||||
import { checkedValueComponents } from '/@/components/Form/src/helper';
|
import { checkedValueComponents } from '/@/components/Form/src/helper';
|
||||||
import { useItemLabelWidth } from '/@/components/Form/src/hooks/useLabelWidth';
|
import { useItemLabelWidth } from '/@/components/Form/src/hooks/useLabelWidth';
|
||||||
import { FormActionType, FormProps, FormSchema } from '/@/components/Form/src/types/form';
|
import { FormActionType, FormProps, FormSchema } from '/@/components/Form/src/types/form';
|
||||||
import { CollapseContainer } from '/@/components/Container';
|
import { CollapseContainer } from '/@/components/Container';
|
||||||
import { noShowWorkFlowComponents, noShowGenerateComponents } from '/@/components/Form/src/helper';
|
import { noShowWorkFlowComponents, noShowGenerateComponents } from '/@/components/Form/src/helper';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import TableLayoutPreview from '/@/components/Form/src/components/TableLayoutPreview.vue';
|
import TableLayoutPreview from '/@/components/Form/src/components/TableLayoutPreview.vue';
|
||||||
import { camelCaseString } from '/@/utils/event/design';
|
import { camelCaseString } from '/@/utils/event/design';
|
||||||
import Readonly from '/@/components/Form/src/components/Readonly.vue';
|
import Readonly from '/@/components/Form/src/components/Readonly.vue';
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// 表单配置规则
|
// 表单配置规则
|
||||||
schema: {
|
schema: {
|
||||||
type: Object as PropType<FormSchema>,
|
type: Object as PropType<FormSchema>,
|
||||||
default: () => { }
|
default: () => {}
|
||||||
},
|
},
|
||||||
value: [Object, String, Number, Boolean, Array],
|
value: [Object, String, Number, Boolean, Array],
|
||||||
formApi: {
|
formApi: {
|
||||||
@ -169,23 +194,23 @@ const props = defineProps({
|
|||||||
//刷新api使用
|
//刷新api使用
|
||||||
refreshFieldObj: {
|
refreshFieldObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => { }
|
default: () => {}
|
||||||
},
|
},
|
||||||
//是否是工作流
|
//是否是工作流
|
||||||
isWorkFlow: {
|
isWorkFlow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const formModel = inject<Recordable>('formModel');
|
const formModel = inject<Recordable>('formModel');
|
||||||
const formProps = inject<Ref<FormProps>>('formProps');
|
const formProps = inject<Ref<FormProps>>('formProps');
|
||||||
const tabActiveKey = inject<Ref<number>>('tabActiveKey', ref(0));
|
const tabActiveKey = inject<Ref<number>>('tabActiveKey', ref(0));
|
||||||
const activeKey = ref<number>(0);
|
const activeKey = ref<number>(0);
|
||||||
const isCamelCase = inject<boolean>('isCamelCase', false);
|
const isCamelCase = inject<boolean>('isCamelCase', false);
|
||||||
// 注入整个表单的配置,formProps是个计算属性,不能修改,formData则来自每个业务的表单页面。
|
// 注入整个表单的配置,formProps是个计算属性,不能修改,formData则来自每个业务的表单页面。
|
||||||
const formData = inject('formData', { noInject: true });
|
const formData = inject('formData', { noInject: true });
|
||||||
watch(
|
watch(
|
||||||
() => tabActiveKey?.value,
|
() => tabActiveKey?.value,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (props.isWorkFlow) activeKey.value = val!;
|
if (props.isWorkFlow) activeKey.value = val!;
|
||||||
@ -193,8 +218,8 @@ watch(
|
|||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
() => activeKey?.value,
|
() => activeKey?.value,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (props.isWorkFlow) tabActiveKey.value = val!;
|
if (props.isWorkFlow) tabActiveKey.value = val!;
|
||||||
@ -202,43 +227,43 @@ watch(
|
|||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// watch(
|
// watch(
|
||||||
// () => props.value,
|
// () => props.value,
|
||||||
// (val) => {
|
// (val) => {
|
||||||
// if (!val) return;
|
// if (!val) return;
|
||||||
// let { componentProps = {} } = props.schema;
|
// let { componentProps = {} } = props.schema;
|
||||||
// if (componentProps['events']) {
|
// if (componentProps['events']) {
|
||||||
// for (const eventKey in componentProps['events']) {
|
// for (const eventKey in componentProps['events']) {
|
||||||
// try {
|
// try {
|
||||||
// const event = new Function(
|
// const event = new Function(
|
||||||
// 'schema',
|
// 'schema',
|
||||||
// 'formModel',
|
// 'formModel',
|
||||||
// 'formActionType',
|
// 'formActionType',
|
||||||
// `${componentProps['events'][eventKey]}`,
|
// `${componentProps['events'][eventKey]}`,
|
||||||
// );
|
// );
|
||||||
// event(props.schema, formModel, props.formApi);
|
// event(props.schema, formModel, props.formApi);
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// notification.error({
|
// notification.error({
|
||||||
// message: 'Tip',
|
// message: 'Tip',
|
||||||
// description: '触发事件填写有误!',
|
// description: '触发事件填写有误!',
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// immediate: true,
|
// immediate: true,
|
||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|
||||||
const { notification } = useMessage();
|
const { notification } = useMessage();
|
||||||
const getSchema = computed(() => {
|
const getSchema = computed(() => {
|
||||||
return props.schema as FormSchema;
|
return props.schema as FormSchema;
|
||||||
});
|
});
|
||||||
|
|
||||||
const getDisable = computed(() => {
|
const getDisable = computed(() => {
|
||||||
const { disabled: globDisabled } = formProps!.value;
|
const { disabled: globDisabled } = formProps!.value;
|
||||||
const { dynamicDisabled } = getSchema.value;
|
const { dynamicDisabled } = getSchema.value;
|
||||||
const { disabled: itemDisabled = false } = unref(getComponentsProps);
|
const { disabled: itemDisabled = false } = unref(getComponentsProps);
|
||||||
@ -255,9 +280,9 @@ const getDisable = computed(() => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return disabled;
|
return disabled;
|
||||||
});
|
});
|
||||||
|
|
||||||
const getComponentsProps = computed(() => {
|
const getComponentsProps = computed(() => {
|
||||||
let { componentProps = {} } = props.schema;
|
let { componentProps = {} } = props.schema;
|
||||||
|
|
||||||
if (isFunction(componentProps)) {
|
if (isFunction(componentProps)) {
|
||||||
@ -313,9 +338,9 @@ const getComponentsProps = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return componentProps as Recordable;
|
return componentProps as Recordable;
|
||||||
});
|
});
|
||||||
|
|
||||||
const labelCol = computed(() => {
|
const labelCol = computed(() => {
|
||||||
// 列宽支持两种模式 labelWidthMode = flex为百分比宽度 fix 为定宽
|
// 列宽支持两种模式 labelWidthMode = flex为百分比宽度 fix 为定宽
|
||||||
const commonLabelCol = unref(itemLabelWidthProp).labelCol;
|
const commonLabelCol = unref(itemLabelWidthProp).labelCol;
|
||||||
const itemLabelCol = unref(getComponentsProps).labelCol;
|
const itemLabelCol = unref(getComponentsProps).labelCol;
|
||||||
@ -329,9 +354,9 @@ const labelCol = computed(() => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return labelCol;
|
return labelCol;
|
||||||
});
|
});
|
||||||
|
|
||||||
const rules = computed(() => {
|
const rules = computed(() => {
|
||||||
const requiredRule = {
|
const requiredRule = {
|
||||||
required: unref(getComponentsProps).required || false,
|
required: unref(getComponentsProps).required || false,
|
||||||
message: `${props.schema.label}是必填项`
|
message: `${props.schema.label}是必填项`
|
||||||
@ -340,11 +365,11 @@ const rules = computed(() => {
|
|||||||
if (!rulesList) return [requiredRule];
|
if (!rulesList) return [requiredRule];
|
||||||
rulesList?.map((item) => (item.pattern = eval(item.pattern)));
|
rulesList?.map((item) => (item.pattern = eval(item.pattern)));
|
||||||
return [...rulesList, requiredRule];
|
return [...rulesList, requiredRule];
|
||||||
});
|
});
|
||||||
|
|
||||||
//根据labelwidth 生成labelCol
|
//根据labelwidth 生成labelCol
|
||||||
const itemLabelWidthProp = useItemLabelWidth(getSchema, formProps!);
|
const itemLabelWidthProp = useItemLabelWidth(getSchema, formProps!);
|
||||||
watch(
|
watch(
|
||||||
() => formModel,
|
() => formModel,
|
||||||
() => {
|
() => {
|
||||||
// console.log('formitem watch!!!!!!!!');
|
// console.log('formitem watch!!!!!!!!');
|
||||||
@ -360,8 +385,8 @@ watch(
|
|||||||
deep: true,
|
deep: true,
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// console.log('onMounted');
|
// console.log('onMounted');
|
||||||
// if (
|
// if (
|
||||||
// staticDataComponents.includes(props.schema.component) &&
|
// staticDataComponents.includes(props.schema.component) &&
|
||||||
@ -377,25 +402,25 @@ onMounted(() => {
|
|||||||
// emit('update:value', defaultValue);
|
// emit('update:value', defaultValue);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
const formComponent = (schema) => {
|
const formComponent = (schema) => {
|
||||||
return componentMap.get(['caseErpApplyDetailList', 'case_erp_apply_detailList', 'CASE_ERP_APPLY_DETAILList'].includes(schema.field) ? 'ErpApply' : schema.component);
|
return componentMap.get(['caseErpApplyDetailList', 'case_erp_apply_detailList', 'CASE_ERP_APPLY_DETAILList'].includes(schema.field) ? 'ErpApply' : schema.component);
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultComponent = (schema) => {
|
const defaultComponent = (schema) => {
|
||||||
return componentMap.get(schema.key === 'ac18952da41b45c9a66ffba3e42b7f3d' ? 'ErpUpload' : schema.key === 'b3ba87573cf0466d951bc63fd4df1c78' ? 'ErpCheck' : schema.component);
|
return componentMap.get(schema.key === 'ac18952da41b45c9a66ffba3e42b7f3d' ? 'ErpUpload' : schema.key === 'b3ba87573cf0466d951bc63fd4df1c78' ? 'ErpCheck' : schema.component);
|
||||||
};
|
};
|
||||||
|
|
||||||
function showComponent(schema) {
|
function showComponent(schema) {
|
||||||
return props.isWorkFlow ? !noShowWorkFlowComponents.includes(schema.type) : !noShowGenerateComponents.includes(schema.type);
|
return props.isWorkFlow ? !noShowWorkFlowComponents.includes(schema.type) : !noShowGenerateComponents.includes(schema.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readonlySupport(name) {
|
function readonlySupport(name) {
|
||||||
return /Input|AutoCodeRule|DatePicker|Text|TimePicker|Info/.test(name)
|
return /Input|AutoCodeRule|DatePicker|Text|TimePicker|Info|Range/.test(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShow(schema: FormSchema): boolean {
|
function getShow(schema: FormSchema): boolean {
|
||||||
const { show } = schema;
|
const { show } = schema;
|
||||||
let isIfShow = true;
|
let isIfShow = true;
|
||||||
|
|
||||||
@ -403,9 +428,9 @@ function getShow(schema: FormSchema): boolean {
|
|||||||
isIfShow = show;
|
isIfShow = show;
|
||||||
}
|
}
|
||||||
return isIfShow;
|
return isIfShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIsShow(schema: FormSchema): boolean {
|
function getIsShow(schema: FormSchema): boolean {
|
||||||
const { componentProps, show } = schema as any;
|
const { componentProps, show } = schema as any;
|
||||||
let isShow = true;
|
let isShow = true;
|
||||||
if (isBoolean(componentProps?.isShow)) {
|
if (isBoolean(componentProps?.isShow)) {
|
||||||
@ -415,17 +440,17 @@ function getIsShow(schema: FormSchema): boolean {
|
|||||||
isShow = show;
|
isShow = show;
|
||||||
}
|
}
|
||||||
return isShow;
|
return isShow;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
:deep(.ant-form-item-label > label) {
|
:deep(.ant-form-item-label > label) {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
display: inline;
|
display: inline;
|
||||||
line-height: 28px;
|
line-height: 32px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.ant-select-disabled {
|
.ant-select-disabled {
|
||||||
.ant-select-selector {
|
.ant-select-selector {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
@ -439,5 +464,5 @@ function getIsShow(schema: FormSchema): boolean {
|
|||||||
.ant-select-arrow {
|
.ant-select-arrow {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user