2024-11-06 20:31:07 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-tabs type="border-card">
|
|
|
|
|
|
<el-tab-pane label="设备台账信息">
|
|
|
|
|
|
<div class="form-grid">
|
|
|
|
|
|
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' :disabled="false">
|
2024-11-15 16:31:48 +08:00
|
|
|
|
<el-divider >设备信息</el-divider>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-row :gutter="24" >
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="设备名称" prop="name" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.name' placeholder="请输入设备名称"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='设备类型' prop='devType' :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-select v-model="formContent.devType" clearable placeholder="请选择设备类型">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Type')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
2024-11-15 16:31:48 +08:00
|
|
|
|
:value="item.id"
|
2024-11-12 18:56:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-15 16:31:48 +08:00
|
|
|
|
<el-form-item label='设备模式' prop='pattern' :label-width="100">
|
2024-11-18 16:02:19 +08:00
|
|
|
|
<el-select v-model="formContent.pattern" clearable placeholder="请选择设备模式" disabled>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Pattern')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.id"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
|
|
</el-row>
|
2024-11-15 16:31:48 +08:00
|
|
|
|
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-row :gutter="24" >
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='生产厂商' prop='manufacturer' :label-width="100">
|
2024-11-14 19:24:36 +08:00
|
|
|
|
<el-select v-model="formContent.manufacturer" clearable placeholder="请选择生产厂商">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Manufacturers')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
2024-11-15 16:31:48 +08:00
|
|
|
|
:value="item.id"
|
2024-11-12 18:56:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="生产日期" prop="createDate" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-date-picker
|
|
|
|
|
|
v-model="formContent.createDate"
|
|
|
|
|
|
placeholder="请选择生产日期"
|
|
|
|
|
|
:disabled-date="disabledDate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="出厂编号" prop="createId" placeholder="请输入出厂编号" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model="formContent.createId" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24" >
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="固件版本" prop="hardwareVersion" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model="formContent.hardwareVersion" placeholder="请输入固件版本"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="软件版本" prop="softwareVersion" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model="formContent.softwareVersion" placeholder="请输入软件版本"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
2024-11-15 16:31:48 +08:00
|
|
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-divider >参数信息</el-divider>
|
|
|
|
|
|
<el-row :gutter="24" >
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-col :span="8">
|
2024-11-15 16:31:48 +08:00
|
|
|
|
<el-form-item label="设备通道数" prop="devChns" :label-width="100">
|
|
|
|
|
|
<el-select v-model="formContent.devChns" clearable placeholder="请选择设备通道数">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Chns')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.code"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
|
<el-form-item label="额定电压(V)" prop="devVolt" :label-width="100">
|
|
|
|
|
|
<el-select v-model="formContent.devVolt" clearable placeholder="请选择额定电压">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Volt')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.code"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
2024-11-15 16:31:48 +08:00
|
|
|
|
<el-col :span="8">
|
|
|
|
|
|
<el-form-item label="额定电流(A)" prop="devCurr" :label-width="100">
|
|
|
|
|
|
<el-select v-model="formContent.devCurr" clearable placeholder="请选择额定电流">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Curr')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.code"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24" >
|
2024-11-15 16:31:48 +08:00
|
|
|
|
<el-col :span="8">
|
|
|
|
|
|
<el-form-item label='通讯协议' prop='protocol' :label-width="100">
|
|
|
|
|
|
<el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议" @change="handleEncryptionChange">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Protocol')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.id"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="IP地址" prop="ip" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<IPAddress v-model:value="formContent.ip"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label="端口号" prop="port" placeholder="请输入端口号" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model="formContent.port" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
2024-11-15 16:31:48 +08:00
|
|
|
|
|
2024-11-12 18:56:33 +08:00
|
|
|
|
</el-row>
|
2024-11-15 16:31:48 +08:00
|
|
|
|
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-row :gutter="24" >
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='是否加密' prop='encryptionFlag' :label-width="100">
|
2024-11-14 11:34:25 +08:00
|
|
|
|
<el-select v-model="formContent.encryptionFlag" clearable placeholder="请选择是否加密" @change="handleEncryptionChange">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-option label="是" :value="1"></el-option>
|
|
|
|
|
|
<el-option label="否" :value="0"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8" v-if="IsPasswordShow">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='识别码' prop='series' clearable placeholder="请输入识别码" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.series' show-password/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8" v-if="IsPasswordShow">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='密钥' prop='devKey' clearable placeholder="请输入密钥" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.devKey' show-password/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24" v-if="DevIsShow">
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='样品编号' prop='sampleID' clearable placeholder="请输入样品编号" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.sampleID' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='送样日期' prop='arrivedDate' :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-date-picker
|
|
|
|
|
|
v-model="formContent.arrivedDate"
|
|
|
|
|
|
placeholder="请选择送样日期"
|
|
|
|
|
|
:disabled-date="disabledDate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24" v-if="MonIsShow">
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='所属地市' prop='cityName' clearable placeholder="请输入所属地市" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.cityName' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='所属供电公司' prop='gDName' clearable placeholder="请输入所属供电公司" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.gDName' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="8">
|
2024-11-14 20:36:54 +08:00
|
|
|
|
<el-form-item label='所属电站' prop='subName' clearable placeholder="请输入所属电站" :label-width="100">
|
2024-11-12 18:56:33 +08:00
|
|
|
|
<el-input v-model='formContent.subName' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-tab-pane>
|
2024-11-21 15:30:42 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 监测点台账信息 tab pane -->
|
|
|
|
|
|
<MonitorTable :MonIsShow="MonIsShow"/>
|
2024-11-12 18:56:33 +08:00
|
|
|
|
</el-tabs>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
<template #footer>
|
|
|
|
|
|
<div >
|
|
|
|
|
|
<el-button @click='close()'>取 消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click='save()'>保存</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
</template>
|
2024-11-14 19:33:33 +08:00
|
|
|
|
<script setup lang='ts'>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
import IPAddress from '@/components/IpAddress/index.vue'
|
|
|
|
|
|
import { dialogBig } from '@/utils/elementBind'
|
2024-11-18 09:02:57 +08:00
|
|
|
|
import { type Device } from '@/api/device/interface/device'
|
2024-11-14 19:33:33 +08:00
|
|
|
|
import { ElMessage, type FormItemRule } from 'element-plus'
|
2024-11-18 09:02:57 +08:00
|
|
|
|
import { addPqDev, updatePqDev } from '@/api/device/device'
|
2024-11-14 19:33:33 +08:00
|
|
|
|
import { computed, reactive, type Ref, ref } from 'vue'
|
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
|
|
|
|
|
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
|
|
|
|
|
|
// 使用 dayjs 库格式化
|
|
|
|
|
|
import dayjs from 'dayjs'
|
2024-11-21 15:30:42 +08:00
|
|
|
|
import MonitorTable from '@/views/machine/device/components/monitorTab.vue';
|
2024-11-06 20:31:07 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
const MonIsShow = ref(false)
|
|
|
|
|
|
const DevIsShow = ref(false)
|
|
|
|
|
|
const IsPasswordShow = ref(false)
|
|
|
|
|
|
const dictStore = useDictStore()
|
2024-11-21 14:42:26 +08:00
|
|
|
|
const mode = ref()
|
2024-11-14 19:33:33 +08:00
|
|
|
|
// 定义弹出组件元信息
|
|
|
|
|
|
const dialogFormRef = ref()
|
|
|
|
|
|
const disabledDate = (time: Date) => {
|
2024-11-07 11:29:28 +08:00
|
|
|
|
return time.getTime() > Date.now()
|
|
|
|
|
|
}
|
2024-11-14 20:49:21 +08:00
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
function useMetaInfo() {
|
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
const titleType = ref('add')
|
|
|
|
|
|
const formContent = ref<Device.ResPqDev>({
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
2024-11-21 14:42:26 +08:00
|
|
|
|
pattern:mode.value,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
devType:'',
|
2024-11-14 20:36:54 +08:00
|
|
|
|
devChns:1,
|
|
|
|
|
|
devVolt:57.74,
|
|
|
|
|
|
devCurr:1,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
manufacturer: '',
|
|
|
|
|
|
createDate: '',
|
|
|
|
|
|
createId: '',
|
|
|
|
|
|
hardwareVersion: '',
|
|
|
|
|
|
softwareVersion: '',
|
2024-11-15 16:31:48 +08:00
|
|
|
|
protocol: 'MMS',
|
2024-11-06 20:31:07 +08:00
|
|
|
|
ip: '',
|
2024-11-14 20:36:54 +08:00
|
|
|
|
port: 102,
|
2024-11-14 11:34:25 +08:00
|
|
|
|
encryptionFlag: 1,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
reCheckNum:0,
|
|
|
|
|
|
state: 1,
|
|
|
|
|
|
})
|
|
|
|
|
|
return { dialogVisible, titleType, formContent }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
|
|
|
|
|
// 清空formContent
|
|
|
|
|
|
const resetFormContent = () => {
|
|
|
|
|
|
formContent.value = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
2024-11-21 14:42:26 +08:00
|
|
|
|
pattern:mode.value,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
devType:'',
|
2024-11-14 20:36:54 +08:00
|
|
|
|
devChns:1,
|
|
|
|
|
|
devVolt:57.74,
|
|
|
|
|
|
devCurr:1,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
manufacturer: '',
|
|
|
|
|
|
createDate: '',
|
|
|
|
|
|
createId: '',
|
|
|
|
|
|
hardwareVersion: '',
|
|
|
|
|
|
softwareVersion: '',
|
2024-11-15 16:31:48 +08:00
|
|
|
|
protocol: 'MMS',
|
2024-11-06 20:31:07 +08:00
|
|
|
|
ip: '',
|
2024-11-14 20:36:54 +08:00
|
|
|
|
port: 102,
|
2024-11-14 11:34:25 +08:00
|
|
|
|
encryptionFlag: 1,
|
2024-11-06 20:31:07 +08:00
|
|
|
|
reCheckNum:0,
|
|
|
|
|
|
state: 1,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-14 20:36:54 +08:00
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
let dialogTitle = computed(() => {
|
|
|
|
|
|
return titleType.value === 'add' ? '新增被检设备' : '编辑被检设备'
|
|
|
|
|
|
})
|
2024-11-07 11:29:28 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
// 定义表单校验规则
|
|
|
|
|
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
|
|
|
|
|
devType: [{ required: true, message: '设备类型必选!', trigger: 'change' }],
|
|
|
|
|
|
pattern: [{ required: true, message: '设备模式必填!', trigger: 'blur' }],
|
|
|
|
|
|
name: [{ required: true, message: '设备名称必填!', trigger: 'blur' }],
|
2024-11-07 15:13:53 +08:00
|
|
|
|
devChns: [{ required: true, message: '设备通道数必填!', trigger: 'blur' },
|
|
|
|
|
|
// 指定正则,此处是数字正则
|
|
|
|
|
|
{ pattern: /^[1-9]\d*$/, message: '设备通道数为大于1的整数', trigger: 'blur' }],
|
|
|
|
|
|
devVolt: [{ required: true, message: '额定电压必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^\d+(\.\d+)?$/, message: '额定电压格式错误', trigger: 'blur' }],
|
|
|
|
|
|
devCurr: [{ required: true, message: '额定电流必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^\d+(\.\d+)?$/, message: '额定电流格式错误', trigger: 'blur' }],
|
2024-11-06 20:31:07 +08:00
|
|
|
|
createDate: [{ required: true, message: '生产日期必填!', trigger: 'blur' }],
|
|
|
|
|
|
createId: [{ required: true, message: '出厂编号必填!', trigger: 'blur' }],
|
|
|
|
|
|
hardwareVersion: [{ required: true, message: '固件版本必填!', trigger: 'blur' }],
|
|
|
|
|
|
softwareVersion: [{ required: true, message: '软件版本必填!', trigger: 'blur' }],
|
2024-11-07 11:29:28 +08:00
|
|
|
|
ip:[{ required: true, message: 'IP地址必填!', trigger: 'blur' } ,
|
2024-11-07 15:13:53 +08:00
|
|
|
|
{ pattern: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/, message: 'IP地址格式错误', trigger: 'blur' }],
|
|
|
|
|
|
port:[{ required: true, message: '端口号必填!', trigger: 'blur' },
|
2024-11-14 20:36:54 +08:00
|
|
|
|
{ pattern: /^(6553[0-5]|655[0-2][0-9]|64[0-9]{3}|[1-5]?[0-9]{1,4})$/, message: '端口号范围0到65535的整数', trigger: 'blur' }],
|
2024-11-06 20:31:07 +08:00
|
|
|
|
manufacturer: [{ required: true, message: '生产厂家必选!', trigger: 'change' }],
|
2024-11-14 11:34:25 +08:00
|
|
|
|
encryptionFlag: [{ required: true, message: '是否加密必选!', trigger: 'change' }],
|
2024-11-07 15:13:53 +08:00
|
|
|
|
protocol: [{ required: true, message: '通讯协议必选!', trigger: 'change' }],
|
2024-11-26 15:41:20 +08:00
|
|
|
|
// series: [],
|
|
|
|
|
|
// devKey: []
|
|
|
|
|
|
series : [
|
|
|
|
|
|
{ required: true, message: '请输入识别码', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
devKey : [
|
|
|
|
|
|
{ required: true, message: '请输入密钥', trigger: 'blur' }
|
|
|
|
|
|
],
|
2024-11-14 20:36:54 +08:00
|
|
|
|
})
|
2024-11-06 20:31:07 +08:00
|
|
|
|
|
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
// 清空dialogForm中的值
|
|
|
|
|
|
resetFormContent()
|
|
|
|
|
|
// 重置表单
|
|
|
|
|
|
dialogFormRef.value?.resetFields()
|
2024-11-15 16:31:48 +08:00
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存数据
|
|
|
|
|
|
const save = () => {
|
2024-11-26 15:41:20 +08:00
|
|
|
|
try {
|
2024-11-06 20:31:07 +08:00
|
|
|
|
dialogFormRef.value?.validate(async (valid: boolean) => {
|
2024-11-15 09:38:25 +08:00
|
|
|
|
|
|
|
|
|
|
if (formContent.value.encryptionFlag === 1) {
|
|
|
|
|
|
handleEncryptionChange(1)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
handleEncryptionChange(0)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
if (valid) {
|
2024-11-07 11:29:28 +08:00
|
|
|
|
formContent.value.createDate = dayjs(formContent.value.createDate).format('YYYY-MM-DD');
|
2024-11-07 15:13:53 +08:00
|
|
|
|
if (formContent.value.arrivedDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
formContent.value.arrivedDate = dayjs(formContent.value.arrivedDate).format('YYYY-MM-DD');
|
|
|
|
|
|
}
|
2024-11-06 20:31:07 +08:00
|
|
|
|
if (formContent.value.id) {
|
2024-11-14 18:26:34 +08:00
|
|
|
|
await updatePqDev(formContent.value);
|
|
|
|
|
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
2024-11-26 15:41:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// 新增需要把设备模式转成字典ID
|
|
|
|
|
|
const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.value.pattern);
|
|
|
|
|
|
if (patternItem) {
|
|
|
|
|
|
formContent.value.pattern = patternItem.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 新增需要把通讯协议转成字典ID
|
|
|
|
|
|
const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.value.protocol);
|
|
|
|
|
|
if (protocolItem) {
|
|
|
|
|
|
formContent.value.protocol = protocolItem.id;
|
|
|
|
|
|
}
|
2024-11-14 18:26:34 +08:00
|
|
|
|
await addPqDev(formContent.value);
|
|
|
|
|
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
|
|
|
|
|
|
2024-11-06 20:31:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
close()
|
|
|
|
|
|
// 刷新表格
|
|
|
|
|
|
await props.refreshTable!()
|
2024-11-12 18:56:33 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('验证过程中出现错误', err)
|
2024-11-06 20:31:07 +08:00
|
|
|
|
}
|
2024-11-14 19:33:33 +08:00
|
|
|
|
}
|
2024-11-12 18:56:33 +08:00
|
|
|
|
|
2024-11-18 16:02:19 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
// 打开弹窗,可能是新增,也可能是编辑
|
2024-11-21 14:42:26 +08:00
|
|
|
|
const open = (sign: string, data: Device.ResPqDev,currentMode: string) => {
|
|
|
|
|
|
mode.value = currentMode
|
|
|
|
|
|
titleType.value = sign
|
|
|
|
|
|
dialogVisible.value = true
|
2024-11-15 09:38:25 +08:00
|
|
|
|
|
2024-11-21 14:42:26 +08:00
|
|
|
|
if( currentMode ==='比对式'){
|
2024-11-15 09:38:25 +08:00
|
|
|
|
DevIsShow.value = false
|
|
|
|
|
|
MonIsShow.value = true
|
|
|
|
|
|
}else{
|
|
|
|
|
|
DevIsShow.value = true
|
|
|
|
|
|
MonIsShow.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
if (data.encryptionFlag === 1) {
|
|
|
|
|
|
handleEncryptionChange(1)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
handleEncryptionChange(0)
|
2024-11-06 20:31:07 +08:00
|
|
|
|
}
|
2024-11-14 20:49:21 +08:00
|
|
|
|
if (data.id) {
|
|
|
|
|
|
formContent.value = { ...data }
|
|
|
|
|
|
} else {
|
|
|
|
|
|
resetFormContent()
|
|
|
|
|
|
handleEncryptionChange(1)
|
|
|
|
|
|
}
|
2024-11-26 15:41:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 重置表单
|
|
|
|
|
|
dialogFormRef.value?.resetFields()
|
2024-11-14 20:49:21 +08:00
|
|
|
|
}
|
2024-11-12 18:56:33 +08:00
|
|
|
|
const handleEncryptionChange = (value: number) => {
|
|
|
|
|
|
// 根据是否加密来显示或隐藏识别码和密钥
|
|
|
|
|
|
if(value === 1){
|
|
|
|
|
|
IsPasswordShow.value = true
|
2024-11-26 15:41:20 +08:00
|
|
|
|
|
2024-11-12 18:56:33 +08:00
|
|
|
|
}else
|
|
|
|
|
|
{
|
2024-11-26 15:41:20 +08:00
|
|
|
|
IsPasswordShow.value = false
|
|
|
|
|
|
// formContent.value.series = ''
|
|
|
|
|
|
// formContent.value.devKey = ''
|
|
|
|
|
|
// rules.value.series = [];
|
|
|
|
|
|
// rules.value.devKey = [];
|
2024-11-12 18:56:33 +08:00
|
|
|
|
}
|
2024-11-14 19:33:33 +08:00
|
|
|
|
}
|
2024-11-12 18:56:33 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
// 对外映射
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
refreshTable: (() => Promise<void>) | undefined;
|
|
|
|
|
|
}>()
|
2024-11-12 18:56:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-07 11:29:28 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
</script>
|