index.vue
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<template>
<div>
<BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" />
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { formSchema } from './config';
export default defineComponent({
name: 'DetailTemplate',
components: {
BasicForm,
},
props: ['alarmSeverityInfo'],
emits: ['success', 'register', 'getAllFields'],
setup(props) {
const fieldValue: any = ref({});
const [registerForm, { resetFields, getFieldsValue, setFieldsValue, updateSchema }] = useForm(
{
labelWidth: 120,
schemas: formSchema,
}
);
const resetFieldsFunc = () => {
resetFields();
};
const getFieldsValueFunc = () => {
fieldValue.value = getFieldsValue();
return fieldValue.value;
};
const item = [
{
value: 'CRITICAL',
label: '危险',
disabled: false,
},
{
value: 'MAJOR',
label: '重要',
disabled: false,
},
{
value: 'MINOR',
label: '次要',
disabled: false,
},
{
value: 'WARNING',
label: '警告',
disabled: false,
},
{
value: 'INDETERMINATE',
label: '不确定',
disabled: false,
},
];
const updateSchemaSelectDisableFunc = () => {
updateSchema({
field: 'default',
componentProps: ({ formModel }) => {
item.forEach((f) => {
if (f.value == formModel.default) {
f.disabled = true;
}
});
return {
options: item,
};
},
});
};
const setFieldsValueFunc = () => {
if (props.alarmSeverityInfo != 1) {
let newArr = Object.keys(props.alarmSeverityInfo);
setTimeout(() => {
newArr.forEach((f) => {
setFieldsValue({ default: f });
});
}, 10);
}
};
setFieldsValueFunc();
return {
resetFieldsFunc,
updateSchemaSelectDisableFunc,
getFieldsValueFunc,
registerForm,
};
},
});
</script>