CreateTCPCommandModal.vue
1.41 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
<script lang="ts" setup>
import { Button } from 'ant-design-vue';
import { BasicForm, useForm } from '/@/components/Form';
import { BasicModal, useModal } from '/@/components/Modal';
import { formSchemas } from './config';
import { ref } from 'vue';
import { unref } from 'vue';
const emit = defineEmits(['update:value']);
const [registerModal] = useModal();
const [registerForm, { getFieldsValue }] = useForm({
schemas: formSchemas,
showActionButtonGroup: false,
rowProps: { gutter: 10 },
baseColProps: { span: 12 },
});
const commandValue = ref('');
const handleGetValue = async () => {
const value = getFieldsValue();
console.log(value);
};
const handleOk = () => {
emit('update:value', unref(commandValue));
};
</script>
<template>
<BasicModal @register="registerModal" title="配置操作" @ok="handleOk">
<BasicForm @register="registerForm" class="create-tcp-command-form" />
<section>
<Button @click="handleGetValue" type="link" class="!px-0">生成预览</Button>
<div v-if="commandValue">
<div class="text-gray-400">Modbus 指令预览</div>
<code class="bg-dark-50 text-light-50 p-1 w-full block mt-1">{{ commandValue }}</code>
</div>
</section>
</BasicModal>
</template>
<style lang="less" scoped>
.create-tcp-command-form {
:deep(.ant-input-number) {
width: 100%;
min-width: 0;
}
}
</style>