表单创建页面及只读页面修改,formlist列表跳转修改

This commit is contained in:
GAOANG
2024-04-02 14:18:15 +08:00
parent 6fa16313cc
commit 528e8038bb
6 changed files with 546 additions and 508 deletions

View File

@ -142,6 +142,16 @@ componentMap.set('ErpApply', ErpApply);
componentMap.set('ErpUpload', ErpUpload);
componentMap.set('ErpCheck', ErpCheck);
componentMap.set('AutoComplete', AutoComplete);
const readonlySupportList = [
"Input",
"AutoCodeRule",
"DatePicker",
"TimePicker",
"Info",
"Text",
'InputTextArea',
'InputNumber'
]
export function add(compName: ComponentType, component: Component) {
componentMap.set(compName, component);
@ -151,4 +161,10 @@ export function del(compName: ComponentType) {
componentMap.delete(compName);
}
export { componentMap };
export function isreadComponent() {
let str = readonlySupportList.join('|')
const reg = new RegExp(str);
return reg
}
export { componentMap, readonlySupportList };

View File

@ -3,40 +3,41 @@
</template>
<script setup>
import { ref, watch } from 'vue';
import { ref, watch } from 'vue';
import { readonlySupportList } from '/@/components/Form/src/componentMap';
const props = defineProps({
value: String,
schema: Object,
});
const props = defineProps({
value: String,
schema: Object,
});
const fieldValue = ref(genFieldValue(props.value));
const fieldValue = ref(genFieldValue(props.value));
function genFieldValue(val) {
if (!props?.schema || (!val && val !== 0)) {
return '';
}
const schema = props.schema;
const { componentProps, component } = schema;
if (['Input', 'AutoCodeRule', 'DatePicker', 'InputTextArea', 'InputNumber'].includes(component)) {
return `${componentProps?.addonBefore || ''}${val}${componentProps?.addonAfter || ''}`;
}
if (component === 'Switch') {
return val === 1 ? '是' : '否';
}
function genFieldValue(val) {
if (!props?.schema || (!val && val !== 0)) {
return '';
}
const schema = props.schema;
const { componentProps, component } = schema;
watch(
() => props.value,
(newValue) => {
fieldValue.value = genFieldValue(newValue);
},
);
if (readonlySupportList.includes(component)) {
return `${componentProps?.addonBefore || ''}${val}${componentProps?.addonAfter || ''}`;
}
if (component === 'Switch') {
return val === 1 ? '是' : '否';
}
}
watch(
() => props.value,
(newValue) => {
fieldValue.value = genFieldValue(newValue);
},
);
</script>
<style>
.field-readonly {
white-space: pre-wrap;
}
.field-readonly {
white-space: pre-wrap;
}
</style>