| | |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="实例名称" prop="instanceName"> |
| | | <el-input v-model="formData.instanceName" placeholder="请输入实例名称" /> |
| | | <el-input v-model="formData.instanceName" placeholder="请输入实例名称"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="IP地址" prop="address"> |
| | | <el-input v-model="formData.address" placeholder="请输入IP地址" /> |
| | | <el-input v-model="formData.address" placeholder="请输入IP地址"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="端口" prop="port"> |
| | | <el-input v-model="formData.port" placeholder="请输入端口" /> |
| | | <el-input v-model="formData.port" placeholder="请输入端口"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户名" prop="username"> |
| | | <el-input v-model="formData.username" placeholder="请输入用户名" /> |
| | | <el-input v-model="formData.username" placeholder="请输入用户名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-input type = "password" v-model="formData.password" placeholder="请输入密码" /> |
| | | <el-input type="password" v-model="formData.password" placeholder="请输入密码"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </Dialog> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as KioApi from '@/api/data/channel/kio' |
| | | import * as KioApi from '@/api/data/channel/kio' |
| | | import {isIP, isPositiveInteger} from '@/utils/validate' |
| | | |
| | | defineOptions({ name: 'DataKioDeviceForm' }) |
| | | defineOptions({name: 'DataKioDeviceForm'}) |
| | | |
| | | const { t } = useI18n() // 国际化 |
| | | const {t} = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | const dialogVisible = ref(false) // 弹窗的是否展示 |
| | | const dialogTitle = ref('') // 弹窗的标题 |
| | |
| | | username: undefined, |
| | | password: undefined, |
| | | }) |
| | | const validateIP = (rule, value, callback) => { |
| | | if (!isIP(value)) { |
| | | callback(new Error('IP地址不正确')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | const validateNum = (rule, value, callback) => { |
| | | if (!isPositiveInteger(value)) { |
| | | callback(new Error('格式不正确')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | const formRules = reactive({ |
| | | instanceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }], |
| | | address: [{ required: true, message: 'IP地址不能为空', trigger: 'blur' }], |
| | | port: [{ required: true, message: '端口不能为空', trigger: 'blur' }], |
| | | username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }], |
| | | password: [{ required: true, message: '密码不能为空', trigger: 'blur' }] |
| | | instanceName: [{required: true, message: '设备名称不能为空', trigger: 'blur'}], |
| | | address: [ |
| | | {required: true, message: 'IP地址不能为空', trigger: 'blur'}, |
| | | {validator: validateIP, trigger: 'blur'} |
| | | ], |
| | | port: [ |
| | | {required: true, message: '端口不能为空', trigger: 'blur'}, |
| | | {validator: validateNum, trigger: 'blur'} |
| | | ], |
| | | username: [{required: true, message: '用户名不能为空', trigger: 'blur'}], |
| | | password: [{required: true, message: '密码不能为空', trigger: 'blur'}] |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | | |
| | | /** 提交表单 */ |
| | | const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |