|
|
@@ -17,9 +17,6 @@
|
|
|
</a-row>
|
|
|
</a-card>
|
|
|
|
|
|
- <a-card title="测试form" >
|
|
|
- <form-pro></form-pro>
|
|
|
- </a-card>
|
|
|
<a-card style="margin-top: 20px;">
|
|
|
<a-row justify="space-between" >
|
|
|
<a-col :span="20" >
|
|
|
@@ -66,6 +63,7 @@
|
|
|
title="确实要删除吗?"
|
|
|
ok-text="确定"
|
|
|
cancel-text="取消"
|
|
|
+ @confirm="delDevice(record.id)"
|
|
|
>
|
|
|
<a href="#">删除</a>
|
|
|
</a-popconfirm>
|
|
|
@@ -81,9 +79,9 @@
|
|
|
@cancel="state.visible = false"
|
|
|
@ok="ok"
|
|
|
>
|
|
|
- <a-form >
|
|
|
- <a-form-item label="所属产品" >
|
|
|
- <a-select v-model="deviceState.deviceLabel" v-bind="validateInfosDeviceState.deviceLabel" >
|
|
|
+ <a-form :labelCol="{span: 6}" :wrapperCol="{span: 14}" >
|
|
|
+ <a-form-item label="所属产品" v-bind="validateInfosDeviceState.modelId" >
|
|
|
+ <a-select v-model:value="deviceState.modelId" >
|
|
|
<a-select-option
|
|
|
v-for="item in state.modelList"
|
|
|
:key="item.id"
|
|
|
@@ -93,20 +91,23 @@
|
|
|
</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
- <a-form-item label="设备标识码" >
|
|
|
- <a-input v-model:value="searchState.deviceStatus" />
|
|
|
+ <a-form-item label="设备标识码" v-bind="validateInfosDeviceState.deviceCode" >
|
|
|
+ <a-input v-model:value="deviceState.deviceCode" />
|
|
|
</a-form-item>
|
|
|
<a-form-item label="设备名称" >
|
|
|
- <a-input v-model:value="searchState.deviceStatus" />
|
|
|
+ <a-input v-model:value="deviceState.deviceLabel" />
|
|
|
</a-form-item>
|
|
|
<a-form-item label="设备认证类型" >
|
|
|
- <a-input v-model:value="searchState.deviceStatus" />
|
|
|
+ <a-radio-group v-model:value="deviceState.deviceAuthType">
|
|
|
+ <a-radio value="SECRET">密钥认证</a-radio>
|
|
|
+ <a-radio value="X509CERT">x509证书</a-radio>
|
|
|
+ </a-radio-group>
|
|
|
</a-form-item>
|
|
|
- <a-form-item label="所属产品" >
|
|
|
- <a-input v-model:value="searchState.deviceStatus" />
|
|
|
+ <a-form-item label="密匙" v-if="deviceState.deviceAuthType === DeviceAuthTypeEnum.SECRET " >
|
|
|
+ <a-input-password v-model:value="deviceState.deviceSecret" />
|
|
|
</a-form-item>
|
|
|
- <a-form-item label="所属产品" >
|
|
|
- <a-input v-model:value="searchState.deviceStatus" />
|
|
|
+ <a-form-item label="确认密匙" v-if="deviceState.deviceAuthType === DeviceAuthTypeEnum.SECRET ">
|
|
|
+ <a-input-password v-model:value="deviceState.confirmSecret" />
|
|
|
</a-form-item>
|
|
|
</a-form>
|
|
|
</a-modal>
|
|
|
@@ -115,7 +116,8 @@
|
|
|
<script lang="ts" setup >
|
|
|
import { DeviceContriller, ModelController } from '@/controller/index'
|
|
|
import { onMounted, reactive } from 'vue'
|
|
|
-import { Form } from 'ant-design-vue'
|
|
|
+import { Form, message } from 'ant-design-vue'
|
|
|
+import { DeviceAuthTypeEnum } from '@/enum/common'
|
|
|
|
|
|
const useForm = Form.useForm
|
|
|
|
|
|
@@ -193,21 +195,36 @@ const searchState = reactive({
|
|
|
|
|
|
const deviceState = reactive({
|
|
|
id: '',
|
|
|
+ modelId: '',
|
|
|
deviceLabel: '',
|
|
|
deviceCode: '',
|
|
|
deviceDescription: '',
|
|
|
- deviceNodeType: '',
|
|
|
+ deviceAuthType: DeviceAuthTypeEnum.SECRET,
|
|
|
modelLabel: '',
|
|
|
- deviceStatus: ''
|
|
|
+ deviceSecret: '',
|
|
|
+ confirmSecret: ''
|
|
|
})
|
|
|
|
|
|
const { resetFields, validate, validateInfos } = useForm(searchState, {})
|
|
|
|
|
|
-const { resetFields: resetFieldsDevice, validate: validateDevice, validateInfos: validateInfosDeviceState } = useForm(deviceState, {})
|
|
|
+const { resetFields: resetFieldsDevice, validate: validateDevice, validateInfos: validateInfosDeviceState } = useForm(deviceState, reactive({
|
|
|
+ modelId: [{ required: true, message: '请选择所属产品' }],
|
|
|
+ deviceCode: [{ required: true, message: '请填写设备码' }]
|
|
|
+}))
|
|
|
+
|
|
|
+const delDevice = async (id: string) => {
|
|
|
+ await DeviceContriller.del(id)
|
|
|
+ getDevicePage()
|
|
|
+}
|
|
|
|
|
|
const ok = () => {
|
|
|
- validate().then(async () => {
|
|
|
+ if (deviceState.deviceAuthType === DeviceAuthTypeEnum.SECRET && deviceState.deviceSecret !== deviceState.confirmSecret) {
|
|
|
+ message.warn('两次密匙输入不同')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ validateDevice().then(async () => {
|
|
|
await DeviceContriller.post(deviceState)
|
|
|
+ state.visible = false
|
|
|
})
|
|
|
}
|
|
|
|