对比新文件 |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | export interface KioDeviceVO { |
| | | id: string |
| | | instanceName: string |
| | | address: string |
| | | port: number |
| | | username: string |
| | | password: string |
| | | } |
| | | |
| | | export interface KioDevicePageReqVO extends PageParam { |
| | | instanceName?: string |
| | | address?: string |
| | | } |
| | | |
| | | // 查询KioDevice列表 |
| | | export const getKioDevicePage = (params: KioDevicePageReqVO) => { |
| | | return request.get({ url: '/data/channel/kio/device/page', params }) |
| | | } |
| | | |
| | | // 查询KioDevice详情 |
| | | export const getKioDevice = (id: number) => { |
| | | return request.get({ url: `/data/channel/kio/device/info/${id}`}) |
| | | } |
| | | |
| | | // 新增KioDevice |
| | | export const createKioDevice = (data: KioDeviceVO) => { |
| | | return request.post({ url: '/data/channel/kio/device/add', data }) |
| | | } |
| | | |
| | | // 修改KioDevice |
| | | export const updateKioDevice = (data: KioDeviceVO) => { |
| | | return request.put({ url: '/data/channel/kio/device/update', data }) |
| | | } |
| | | |
| | | // 删除KioDevice |
| | | export const deleteKioDevice = (id: number) => { |
| | | return request.delete({ url: '/data/channel/kio/device/delete?id=' + id }) |
| | | } |
对比新文件 |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | export interface OpcDaDeviceVO { |
| | | id: string |
| | | serverName: string |
| | | host: string |
| | | user: string |
| | | password: string |
| | | progId: string |
| | | clsId: string |
| | | } |
| | | |
| | | export interface OpcDaDevicePageReqVO extends PageParam { |
| | | serverName?: string |
| | | } |
| | | |
| | | // 查询OpcDaDevice列表 |
| | | export const getOpcDaDevicePage = (params: OpcDaDevicePageReqVO) => { |
| | | return request.get({ url: '/data/channel/opcda/device/page', params }) |
| | | } |
| | | |
| | | // 查询OpcDaDevice详情 |
| | | export const getOpcDaDevice = (id: number) => { |
| | | return request.get({ url: `/data/channel/opcda/device/info/${id}`}) |
| | | } |
| | | |
| | | // 新增OpcDaDevice |
| | | export const createOpcDaDevice = (data: OpcDaDeviceVO) => { |
| | | return request.post({ url: '/data/channel/opcda/device/add', data }) |
| | | } |
| | | |
| | | // 修改OpcDaDevice |
| | | export const updateOpcDaDevice = (data: OpcDaDeviceVO) => { |
| | | return request.put({ url: '/data/channel/opcda/device/update', data }) |
| | | } |
| | | |
| | | // 删除OpcDaDevice |
| | | export const deleteOpcDaDevice = (id: number) => { |
| | | return request.delete({ url: '/data/channel/opcda/device/delete?id=' + id }) |
| | | } |
对比新文件 |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | export interface OpcUaDeviceVO { |
| | | id: string |
| | | serverName: string |
| | | endpointUrl: string |
| | | securityPolicy: string |
| | | securityMode: string |
| | | connectionType: string |
| | | userName: string |
| | | password: string |
| | | certificatePath: string |
| | | connectInactivityTimeout: number |
| | | reconnectInterval: number |
| | | } |
| | | |
| | | export interface OpcUaDevicePageReqVO extends PageParam { |
| | | serverName?: string |
| | | } |
| | | |
| | | // 查询OpcUaDevice列表 |
| | | export const getOpcUaDevicePage = (params: OpcUaDevicePageReqVO) => { |
| | | return request.get({ url: '/data/channel/opcua/device/page', params }) |
| | | } |
| | | |
| | | // 查询OpcUaDevice详情 |
| | | export const getOpcUaDevice = (id: number) => { |
| | | return request.get({ url: `/data/channel/opcua/device/info/${id}`}) |
| | | } |
| | | |
| | | // 新增OpcUaDevice |
| | | export const createOpcUaDevice = (data: OpcUaDeviceVO) => { |
| | | return request.post({ url: '/data/channel/opcua/device/add', data }) |
| | | } |
| | | |
| | | // 修改OpcUaDevice |
| | | export const updateOpcUaDevice = (data: OpcUaDeviceVO) => { |
| | | return request.put({ url: '/data/channel/opcua/device/update', data }) |
| | | } |
| | | |
| | | // 删除OpcUaDevice |
| | | export const deleteOpcUaDevice = (id: number) => { |
| | | return request.delete({ url: '/data/channel/opcua/device/delete?id=' + id }) |
| | | } |
对比新文件 |
| | |
| | | <template> |
| | | <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> |
| | | <el-form |
| | | ref="formRef" |
| | | v-loading="formLoading" |
| | | :model="formData" |
| | | :rules="formRules" |
| | | label-width="120px" |
| | | > |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="实例名称" prop="instanceName"> |
| | | <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-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="端口" prop="port"> |
| | | <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-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-input type = "password" v-model="formData.password" placeholder="请输入密码" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="dialogVisible = false">取 消</el-button> |
| | | </template> |
| | | </Dialog> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as KioApi from '@/api/data/channel/kio' |
| | | |
| | | defineOptions({ name: 'DataKioDeviceForm' }) |
| | | |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | const dialogVisible = ref(false) // 弹窗的是否展示 |
| | | const dialogTitle = ref('') // 弹窗的标题 |
| | | const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
| | | const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
| | | const formData = ref({ |
| | | id: undefined, |
| | | instanceName: undefined, |
| | | address: undefined, |
| | | port: undefined, |
| | | username: undefined, |
| | | password: undefined, |
| | | }) |
| | | 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' }] |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | |
| | | /** 打开弹窗 */ |
| | | const open = async (type: string, id?: number) => { |
| | | dialogVisible.value = true |
| | | dialogTitle.value = t('action.' + type) |
| | | formType.value = type |
| | | resetForm() |
| | | // 修改时,设置数据 |
| | | if (id) { |
| | | formLoading.value = true |
| | | try { |
| | | formData.value = await KioApi.getKioDevice(id) |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | } |
| | | defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
| | | |
| | | /** 提交表单 */ |
| | | const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
| | | const submitForm = async () => { |
| | | // 校验表单 |
| | | if (!formRef) return |
| | | const valid = await formRef.value.validate() |
| | | if (!valid) return |
| | | // 提交请求 |
| | | formLoading.value = true |
| | | try { |
| | | const data = formData.value as unknown as KioApi.KioDeviceVO |
| | | if (formType.value === 'create') { |
| | | await KioApi.createKioDevice(data) |
| | | message.success(t('common.createSuccess')) |
| | | } else { |
| | | await KioApi.updateKioDevice(data) |
| | | message.success(t('common.updateSuccess')) |
| | | } |
| | | dialogVisible.value = false |
| | | // 发送操作成功的事件 |
| | | emit('success') |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 重置表单 */ |
| | | const resetForm = () => { |
| | | formData.value = { |
| | | id: undefined, |
| | | instanceName: undefined, |
| | | address: undefined, |
| | | port: undefined, |
| | | username: undefined, |
| | | password: undefined |
| | | } |
| | | formRef.value?.resetFields() |
| | | } |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <!-- 搜索 --> |
| | | <ContentWrap> |
| | | <el-form |
| | | class="-mb-15px" |
| | | :model="queryParams" |
| | | ref="queryFormRef" |
| | | :inline="true" |
| | | label-width="68px" |
| | | > |
| | | <el-form-item label="实例名称" prop="instanceName"> |
| | | <el-input |
| | | v-model="queryParams.instanceName" |
| | | placeholder="请输入实例名称" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button @click="handleQuery"> |
| | | <Icon icon="ep:search" class="mr-5px" /> |
| | | 搜索 |
| | | </el-button> |
| | | <el-button @click="resetQuery"> |
| | | <Icon icon="ep:refresh" class="mr-5px" /> |
| | | 重置 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | @click="openForm('create')" |
| | | v-hasPermi="['system:tenant:create']" |
| | | > |
| | | <Icon icon="ep:plus" class="mr-5px" /> |
| | | 新增 |
| | | </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </ContentWrap> |
| | | |
| | | <!-- 列表 --> |
| | | <ContentWrap> |
| | | <el-table v-loading="loading" :data="list"> |
| | | <el-table-column label="实例名称" align="center" prop="instanceName" /> |
| | | <el-table-column label="IP地址" align="center" prop="address" /> |
| | | <el-table-column label="端口" align="center" prop="port" /> |
| | | <el-table-column label="用户名" align="center" prop="username" /> |
| | | <el-table-column label="操作" align="center" min-width="110" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | @click="openForm('update', scope.row.id)" |
| | | v-hasPermi="['system:tenant:update']" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | link |
| | | type="danger" |
| | | @click="handleDelete(scope.row.id)" |
| | | v-hasPermi="['system:tenant:delete']" |
| | | > |
| | | 删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- 分页 --> |
| | | <Pagination |
| | | :total="total" |
| | | v-model:page="queryParams.pageNo" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </ContentWrap> |
| | | |
| | | <!-- 表单弹窗:添加/修改 --> |
| | | <KioDeviceForm ref="formRef" @success="getList" /> |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as KioApi from '@/api/data/channel/kio' |
| | | import KioDeviceForm from './KioDeviceForm.vue' |
| | | |
| | | defineOptions({name: 'DataKio'}) |
| | | |
| | | const message = useMessage() // 消息弹窗 |
| | | const {t} = useI18n() // 国际化 |
| | | |
| | | const loading = ref(true) // 列表的加载中 |
| | | const total = ref(0) // 列表的总页数 |
| | | const list = ref([]) // 列表的数据 |
| | | const queryParams = reactive({ |
| | | pageNo: 1, |
| | | pageSize: 10, |
| | | instanceName: undefined, |
| | | address: undefined |
| | | }) |
| | | const queryFormRef = ref() // 搜索的表单 |
| | | const exportLoading = ref(false) // 导出的加载中 |
| | | |
| | | /** 查询列表 */ |
| | | const getList = async () => { |
| | | loading.value = true |
| | | try { |
| | | const page = await KioApi.getKioDevicePage(queryParams) |
| | | list.value = page.list |
| | | total.value = page.total |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.pageNo = 1 |
| | | getList() |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value.resetFields() |
| | | handleQuery() |
| | | } |
| | | |
| | | /** 添加/修改操作 */ |
| | | const formRef = ref() |
| | | const openForm = (type: string, id?: number) => { |
| | | formRef.value.open(type, id) |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (id: number) => { |
| | | try { |
| | | // 删除的二次确认 |
| | | await message.delConfirm() |
| | | // 发起删除 |
| | | await KioApi.deleteKioDevice(id) |
| | | message.success(t('common.delSuccess')) |
| | | // 刷新列表 |
| | | await getList() |
| | | } catch { |
| | | } |
| | | } |
| | | |
| | | /** 初始化 **/ |
| | | onMounted(async () => { |
| | | await getList() |
| | | }) |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> |
| | | <el-form |
| | | ref="formRef" |
| | | v-loading="formLoading" |
| | | :model="formData" |
| | | :rules="formRules" |
| | | label-width="120px" |
| | | > |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="服务名" prop="serverName"> |
| | | <el-input v-model="formData.serverName" placeholder="请输入服务名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="IP" prop="host"> |
| | | <el-input v-model="formData.host" placeholder="请输入IP"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户名" prop="user"> |
| | | <el-input v-model="formData.user" 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-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备名" prop="progId"> |
| | | <el-input v-model="formData.progId" placeholder="请输入设备名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备注册表ID" prop="clsId"> |
| | | <el-input type="password" v-model="formData.clsId" placeholder="请输入设备注册表ID"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="dialogVisible = false">取 消</el-button> |
| | | </template> |
| | | </Dialog> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as OpcDaApi from '@/api/data/channel/opcda' |
| | | |
| | | defineOptions({name: 'DataOpcDaDeviceForm'}) |
| | | |
| | | const {t} = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | const dialogVisible = ref(false) // 弹窗的是否展示 |
| | | const dialogTitle = ref('') // 弹窗的标题 |
| | | const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
| | | const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
| | | const formData = ref({ |
| | | id: undefined, |
| | | serverName: undefined, |
| | | host: undefined, |
| | | user: undefined, |
| | | password: undefined, |
| | | progId: undefined, |
| | | clsId: undefined |
| | | }) |
| | | const formRules = reactive({ |
| | | serverName: [{required: true, message: '服务名不能为空', trigger: 'blur'}], |
| | | host: [{required: true, message: 'IP不能为空', trigger: 'blur'}], |
| | | user: [{required: true, message: '用户名不能为空', trigger: 'blur'}], |
| | | password: [{required: true, message: '密码不能为空', trigger: 'blur'}] |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | |
| | | /** 打开弹窗 */ |
| | | const open = async (type: string, id?: number) => { |
| | | dialogVisible.value = true |
| | | dialogTitle.value = t('action.' + type) |
| | | formType.value = type |
| | | resetForm() |
| | | // 修改时,设置数据 |
| | | if (id) { |
| | | formLoading.value = true |
| | | try { |
| | | formData.value = await OpcDaApi.getOpcDaDevice(id) |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | } |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | | |
| | | /** 提交表单 */ |
| | | const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
| | | const submitForm = async () => { |
| | | // 校验表单 |
| | | if (!formRef) return |
| | | const valid = await formRef.value.validate() |
| | | if (!valid) return |
| | | // 提交请求 |
| | | formLoading.value = true |
| | | try { |
| | | const data = formData.value as unknown as OpcDaApi.OpcDaDeviceVO |
| | | if (formType.value === 'create') { |
| | | await OpcDaApi.createOpcDaDevice(data) |
| | | message.success(t('common.createSuccess')) |
| | | } else { |
| | | await OpcDaApi.updateOpcDaDevice(data) |
| | | message.success(t('common.updateSuccess')) |
| | | } |
| | | dialogVisible.value = false |
| | | // 发送操作成功的事件 |
| | | emit('success') |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 重置表单 */ |
| | | const resetForm = () => { |
| | | formData.value = { |
| | | id: undefined, |
| | | serverName: undefined, |
| | | host: undefined, |
| | | user: undefined, |
| | | password: undefined, |
| | | progId: undefined, |
| | | clsId: undefined |
| | | } |
| | | formRef.value?.resetFields() |
| | | } |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <!-- 搜索 --> |
| | | <ContentWrap> |
| | | <el-form |
| | | class="-mb-15px" |
| | | :model="queryParams" |
| | | ref="queryFormRef" |
| | | :inline="true" |
| | | label-width="68px" |
| | | > |
| | | <el-form-item label="服务名" prop="serverName"> |
| | | <el-input |
| | | v-model="queryParams.serverName" |
| | | placeholder="请输入服务名" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button @click="handleQuery"> |
| | | <Icon icon="ep:search" class="mr-5px" /> |
| | | 搜索 |
| | | </el-button> |
| | | <el-button @click="resetQuery"> |
| | | <Icon icon="ep:refresh" class="mr-5px" /> |
| | | 重置 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | @click="openForm('create')" |
| | | v-hasPermi="['system:tenant:create']" |
| | | > |
| | | <Icon icon="ep:plus" class="mr-5px" /> |
| | | 新增 |
| | | </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </ContentWrap> |
| | | |
| | | <!-- 列表 --> |
| | | <ContentWrap> |
| | | <el-table v-loading="loading" :data="list"> |
| | | <el-table-column label="服务名" align="center" prop="serverName" /> |
| | | <el-table-column label="IP" align="center" prop="host" /> |
| | | <el-table-column label="用户名" align="center" prop="user" /> |
| | | <el-table-column label="设备名" align="center" prop="progId" /> |
| | | <el-table-column label="设备注册表ID" align="center" prop="clsId" /> |
| | | <el-table-column label="操作" align="center" min-width="110" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | @click="openForm('update', scope.row.id)" |
| | | v-hasPermi="['system:tenant:update']" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | link |
| | | type="danger" |
| | | @click="handleDelete(scope.row.id)" |
| | | v-hasPermi="['system:tenant:delete']" |
| | | > |
| | | 删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- 分页 --> |
| | | <Pagination |
| | | :total="total" |
| | | v-model:page="queryParams.pageNo" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </ContentWrap> |
| | | |
| | | <!-- 表单弹窗:添加/修改 --> |
| | | <OpcDaDeviceForm ref="formRef" @success="getList" /> |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as OpcDaApi from '@/api/data/channel/opcda' |
| | | import OpcDaDeviceForm from './OpcDaDeviceForm.vue' |
| | | |
| | | defineOptions({name: 'DataOpcDa'}) |
| | | |
| | | const message = useMessage() // 消息弹窗 |
| | | const {t} = useI18n() // 国际化 |
| | | |
| | | const loading = ref(true) // 列表的加载中 |
| | | const total = ref(0) // 列表的总页数 |
| | | const list = ref([]) // 列表的数据 |
| | | const queryParams = reactive({ |
| | | pageNo: 1, |
| | | pageSize: 10, |
| | | serverName: undefined |
| | | }) |
| | | const queryFormRef = ref() // 搜索的表单 |
| | | const exportLoading = ref(false) // 导出的加载中 |
| | | |
| | | /** 查询列表 */ |
| | | const getList = async () => { |
| | | loading.value = true |
| | | try { |
| | | const page = await OpcDaApi.getOpcDaDevicePage(queryParams) |
| | | list.value = page.list |
| | | total.value = page.total |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.pageNo = 1 |
| | | getList() |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value.resetFields() |
| | | handleQuery() |
| | | } |
| | | |
| | | /** 添加/修改操作 */ |
| | | const formRef = ref() |
| | | const openForm = (type: string, id?: number) => { |
| | | formRef.value.open(type, id) |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (id: number) => { |
| | | try { |
| | | // 删除的二次确认 |
| | | await message.delConfirm() |
| | | // 发起删除 |
| | | await OpcDaApi.deleteOpcDaDevice(id) |
| | | message.success(t('common.delSuccess')) |
| | | // 刷新列表 |
| | | await getList() |
| | | } catch { |
| | | } |
| | | } |
| | | |
| | | /** 初始化 **/ |
| | | onMounted(async () => { |
| | | await getList() |
| | | }) |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> |
| | | <el-form |
| | | ref="formRef" |
| | | v-loading="formLoading" |
| | | :model="formData" |
| | | :rules="formRules" |
| | | label-width="120px" |
| | | > |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="服务名" prop="serverName"> |
| | | <el-input v-model="formData.serverName" placeholder="请输入服务名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="端点URL" prop="endpointUrl"> |
| | | <el-input v-model="formData.endpointUrl" placeholder="请输入端点URL"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="安全策略" prop="securityPolicy"> |
| | | <el-input v-model="formData.securityPolicy" placeholder="请输入安全策略"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="安全模式" prop="securityMode"> |
| | | <el-input v-model="formData.securityMode" placeholder="请输入安全模式"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="连接方式" prop="connectionType"> |
| | | <el-input v-model="formData.connectionType" placeholder="请输入连接方式"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户名" prop="userName"> |
| | | <el-input v-model="formData.userName" placeholder="请输入用户名"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-input type="password" v-model="formData.password" placeholder="请输入密码"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="安全证书路径" prop="certificatePath"> |
| | | <el-input v-model="formData.certificatePath" placeholder="请输入安全证书路径"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="连接方式" prop="connectInactivityTimeout"> |
| | | <el-input v-model="formData.connectInactivityTimeout" placeholder="请输入连接方式"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="重连超时" prop="reconnectInterval"> |
| | | <el-input v-model="formData.reconnectInterval" placeholder="请输入重连超时"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="dialogVisible = false">取 消</el-button> |
| | | </template> |
| | | </Dialog> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as OpcUaApi from '@/api/data/channel/opcua' |
| | | |
| | | defineOptions({name: 'DataOpcUaDeviceForm'}) |
| | | |
| | | const {t} = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | const dialogVisible = ref(false) // 弹窗的是否展示 |
| | | const dialogTitle = ref('') // 弹窗的标题 |
| | | const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
| | | const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
| | | const formData = ref({ |
| | | id: undefined, |
| | | serverName: undefined, |
| | | endpointUrl: undefined, |
| | | securityPolicy: undefined, |
| | | securityMode: undefined, |
| | | connectionType: undefined, |
| | | userName: undefined, |
| | | password: undefined, |
| | | certificatePath: undefined, |
| | | connectInactivityTimeout: undefined, |
| | | reconnectInterval: undefined, |
| | | }) |
| | | const formRules = reactive({ |
| | | serverName: [{required: true, message: '服务名不能为空', trigger: 'blur'}], |
| | | }) |
| | | const formRef = ref() // 表单 Ref |
| | | |
| | | /** 打开弹窗 */ |
| | | const open = async (type: string, id?: number) => { |
| | | dialogVisible.value = true |
| | | dialogTitle.value = t('action.' + type) |
| | | formType.value = type |
| | | resetForm() |
| | | // 修改时,设置数据 |
| | | if (id) { |
| | | formLoading.value = true |
| | | try { |
| | | formData.value = await OpcUaApi.getOpcUaDevice(id) |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | } |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | | |
| | | /** 提交表单 */ |
| | | const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
| | | const submitForm = async () => { |
| | | // 校验表单 |
| | | if (!formRef) return |
| | | const valid = await formRef.value.validate() |
| | | if (!valid) return |
| | | // 提交请求 |
| | | formLoading.value = true |
| | | try { |
| | | const data = formData.value as unknown as OpcUaApi.OpcUaDeviceVO |
| | | if (formType.value === 'create') { |
| | | await OpcUaApi.createOpcUaDevice(data) |
| | | message.success(t('common.createSuccess')) |
| | | } else { |
| | | await OpcUaApi.updateOpcUaDevice(data) |
| | | message.success(t('common.updateSuccess')) |
| | | } |
| | | dialogVisible.value = false |
| | | // 发送操作成功的事件 |
| | | emit('success') |
| | | } finally { |
| | | formLoading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 重置表单 */ |
| | | const resetForm = () => { |
| | | formData.value = { |
| | | id: undefined, |
| | | serverName: undefined, |
| | | endpointUrl: undefined, |
| | | securityPolicy: undefined, |
| | | securityMode: undefined, |
| | | connectionType: undefined, |
| | | userName: undefined, |
| | | password: undefined, |
| | | certificatePath: undefined, |
| | | connectInactivityTimeout: undefined, |
| | | reconnectInterval: undefined, |
| | | } |
| | | formRef.value?.resetFields() |
| | | } |
| | | </script> |
对比新文件 |
| | |
| | | <template> |
| | | <!-- 搜索 --> |
| | | <ContentWrap> |
| | | <el-form |
| | | class="-mb-15px" |
| | | :model="queryParams" |
| | | ref="queryFormRef" |
| | | :inline="true" |
| | | label-width="68px" |
| | | > |
| | | <el-form-item label="服务名" prop="serverName"> |
| | | <el-input |
| | | v-model="queryParams.serverName" |
| | | placeholder="请输入服务名" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button @click="handleQuery"> |
| | | <Icon icon="ep:search" class="mr-5px" /> |
| | | 搜索 |
| | | </el-button> |
| | | <el-button @click="resetQuery"> |
| | | <Icon icon="ep:refresh" class="mr-5px" /> |
| | | 重置 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | @click="openForm('create')" |
| | | v-hasPermi="['system:tenant:create']" |
| | | > |
| | | <Icon icon="ep:plus" class="mr-5px" /> |
| | | 新增 |
| | | </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </ContentWrap> |
| | | |
| | | <!-- 列表 --> |
| | | <ContentWrap> |
| | | <el-table v-loading="loading" :data="list"> |
| | | <el-table-column label="服务名" align="center" prop="serverName" /> |
| | | <el-table-column label="端点URL" align="center" prop="endpointUrl" /> |
| | | <el-table-column label="安全策略" align="center" prop="securityPolicy" /> |
| | | <el-table-column label="安全模式" align="center" prop="securityMode" /> |
| | | <el-table-column label="连接方式" align="center" prop="connectionType" /> |
| | | <el-table-column label="用户名" align="center" prop="userName" /> |
| | | <el-table-column label="密码" align="center" prop="password" /> |
| | | <el-table-column label="安全证书路径" align="center" prop="certificatePath" /> |
| | | <el-table-column label="设备不活动超时时间" align="center" prop="connectInactivityTimeout" /> |
| | | <el-table-column label="重连超时" align="center" prop="reconnectInterval" /> |
| | | <el-table-column label="操作" align="center" min-width="110" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | @click="openForm('update', scope.row.id)" |
| | | v-hasPermi="['system:tenant:update']" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | link |
| | | type="danger" |
| | | @click="handleDelete(scope.row.id)" |
| | | v-hasPermi="['system:tenant:delete']" |
| | | > |
| | | 删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- 分页 --> |
| | | <Pagination |
| | | :total="total" |
| | | v-model:page="queryParams.pageNo" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </ContentWrap> |
| | | |
| | | <!-- 表单弹窗:添加/修改 --> |
| | | <OpcUaDeviceForm ref="formRef" @success="getList" /> |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import * as OpcUaApi from '@/api/data/channel/opcua' |
| | | import OpcUaDeviceForm from './OpcUaDeviceForm.vue' |
| | | |
| | | defineOptions({name: 'DataOpcUa'}) |
| | | |
| | | const message = useMessage() // 消息弹窗 |
| | | const {t} = useI18n() // 国际化 |
| | | |
| | | const loading = ref(true) // 列表的加载中 |
| | | const total = ref(0) // 列表的总页数 |
| | | const list = ref([]) // 列表的数据 |
| | | const queryParams = reactive({ |
| | | pageNo: 1, |
| | | pageSize: 10, |
| | | serverName: undefined |
| | | }) |
| | | const queryFormRef = ref() // 搜索的表单 |
| | | const exportLoading = ref(false) // 导出的加载中 |
| | | |
| | | /** 查询列表 */ |
| | | const getList = async () => { |
| | | loading.value = true |
| | | try { |
| | | const page = await OpcUaApi.getOpcUaDevicePage(queryParams) |
| | | list.value = page.list |
| | | total.value = page.total |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.pageNo = 1 |
| | | getList() |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value.resetFields() |
| | | handleQuery() |
| | | } |
| | | |
| | | /** 添加/修改操作 */ |
| | | const formRef = ref() |
| | | const openForm = (type: string, id?: number) => { |
| | | formRef.value.open(type, id) |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (id: number) => { |
| | | try { |
| | | // 删除的二次确认 |
| | | await message.delConfirm() |
| | | // 发起删除 |
| | | await OpcUaApi.deleteOpcUaDevice(id) |
| | | message.success(t('common.delSuccess')) |
| | | // 刷新列表 |
| | | await getList() |
| | | } catch { |
| | | } |
| | | } |
| | | |
| | | /** 初始化 **/ |
| | | onMounted(async () => { |
| | | await getList() |
| | | }) |
| | | </script> |