ConditionScreeningForm.vue
1.79 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
<template>
<div class="flex" style="align-items: center">
<BasicForm @register="registerFormCondition" class="basicStyle" />
<Tooltip title="移除" class="ml-4">
<Icon
icon="fluent:delete-off-20-regular"
size="20"
class="mr-2 cursor-pointer"
@click="deleteConditionForm(index)"
/>
</Tooltip>
</div>
</template>
<script lang="ts" setup>
import { watch, ref, onMounted, inject } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { Icon } from '/@/components/Icon';
import { Tooltip } from 'ant-design-vue';
import { isType } from '../config/formatData.ts';
defineProps({
index: {
type: Number,
required: true,
},
conditionScreeningList: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['deleteConditionForm']);
const operationType = inject('operationType');
let schemas = ref([]);
onMounted(() => {
schemas.value = isType(operationType.value);
});
watch(operationType, (newValue) => {
schemas.value = isType(newValue);
resetFields();
});
const [
registerFormCondition,
{
resetFields,
appendSchemaByField,
removeSchemaByFiled,
getFieldsValue,
setFieldsValue,
validate,
},
] = useForm({
showActionButtonGroup: false,
labelWidth: 100,
compact: true,
schemas,
});
const deleteConditionForm = (index: number) => {
emit('deleteConditionForm', index);
};
defineExpose({
appendSchemaByField,
removeSchemaByFiled,
getFieldsValue,
setFieldsValue,
validate,
});
</script>
<style lang="less">
.basicStyle {
margin-top: 0.5rem;
width: 80%;
border: 1px dashed #d9d9d9;
padding: 1rem 0 0.5rem;
border-radius: 0.25rem;
}
</style>