潘志宝
2024-11-22 df90c0c5cfa4de114798015b92120ad8ba8b4826
src/views/data/channel/opcua/OpcUaDeviceForm.vue
@@ -22,34 +22,57 @@
      <el-row>
        <el-col :span="12">
          <el-form-item label="安全策略" prop="securityPolicy">
            <el-input v-model="formData.securityPolicy" placeholder="请输入安全策略"/>
            <el-select v-model="formData.securityPolicy" placeholder="请选择">
              <el-option
                v-for="dict in getStrDictOptions(DICT_TYPE.OPCUA_SECURITY_POLICY)"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="安全模式" prop="securityMode">
            <el-input v-model="formData.securityMode" placeholder="请输入安全模式"/>
            <el-select v-model="formData.securityMode" placeholder="请选择">
              <el-option
                v-for="dict in getStrDictOptions(DICT_TYPE.OPCUA_SECURITY_MODE)"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </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-select v-model="formData.connectionType" placeholder="请选择">
              <el-option
                v-for="dict in getStrDictOptions(DICT_TYPE.OPCUA_CONNECTION_TYPE)"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </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-col :span="12">
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="安全证书路径" prop="certificatePath">
            <el-input v-model="formData.certificatePath" placeholder="请输入安全证书路径"/>
          </el-form-item>
@@ -57,8 +80,8 @@
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="连接方式" prop="connectInactivityTimeout">
            <el-input v-model="formData.connectInactivityTimeout" placeholder="请输入连接方式"/>
          <el-form-item label="不活动超时" prop="connectInactivityTimeout">
            <el-input v-model="formData.connectInactivityTimeout" placeholder="请输入不活动超时"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
@@ -76,6 +99,7 @@
</template>
<script lang="ts" setup>
import * as OpcUaApi from '@/api/data/channel/opcua'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
defineOptions({name: 'DataOpcUaDeviceForm'})
@@ -96,10 +120,14 @@
  password: undefined,
  certificatePath: undefined,
  connectInactivityTimeout: undefined,
  reconnectInterval: undefined,
  reconnectInterval: 5000,
})
const formRules = reactive({
  serverName: [{required: true, message: '服务名不能为空', trigger: 'blur'}],
  endpointUrl: [{required: true, message: '端点URL不能为空', trigger: 'blur'}],
  securityPolicy: [{required: true, message: '安全策略不能为空', trigger: 'blur'}],
  securityMode: [{required: true, message: '安全模式不能为空', trigger: 'blur'}],
  connectionType: [{required: true, message: '连接方式不能为空', trigger: 'blur'}],
})
const formRef = ref() // 表单 Ref
@@ -160,7 +188,7 @@
    password: undefined,
    certificatePath: undefined,
    connectInactivityTimeout: undefined,
    reconnectInterval: undefined,
    reconnectInterval: 5000,
  }
  formRef.value?.resetFields()
}