|
@@ -5,14 +5,9 @@
|
|
|
<div class="form-sub-title">
|
|
|
带*为必填项
|
|
|
</div>
|
|
|
+ <!--
|
|
|
<div class="device-name">
|
|
|
<div class="lable-title"><span>*</span>设备名称</div>
|
|
|
- <!-- <div v-if="deviceDefaultPictures" class="test-img">测试图片
|
|
|
- <div v-for="url in deviceDefaultPictures" :key="url" class="test-img-item">
|
|
|
- <img :src="url">
|
|
|
- -{{ url }}-
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
<div class="lable">
|
|
|
<el-input
|
|
|
v-model="requestData.name"
|
|
@@ -22,8 +17,21 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ -->
|
|
|
+ <div class="device-sn">
|
|
|
+ <div class="lable-title"><span>*</span>设备编号</div>
|
|
|
+ <div class="lable">
|
|
|
+ <el-input
|
|
|
+ v-model="requestData.serialNumber"
|
|
|
+ placeholder="请输入设备编号"
|
|
|
+ clearable
|
|
|
+ maxlength="32"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="device-detail">
|
|
|
<div class="left">
|
|
|
+ <!--
|
|
|
<div class="check-date">
|
|
|
<div class="lable-title"><span>*</span>送检时间</div>
|
|
|
<div class="lable">
|
|
@@ -59,7 +67,7 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- <div class="device-productionDate">
|
|
|
+ <div class="device-productionDate">
|
|
|
<div class="lable-title"><span>*</span>出厂日期</div>
|
|
|
<div class="lable">
|
|
|
<el-date-picker
|
|
@@ -71,7 +79,7 @@
|
|
|
value-format="yyyy-MM-dd"
|
|
|
/>
|
|
|
</div>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
<div class="protocol-value">
|
|
|
<div class="lable-title"><span>*</span>设备类型</div>
|
|
|
<div class="lable">
|
|
@@ -84,29 +92,7 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <!-- 设备地址添加功能 鲜总说先注释 聊天记录: 这个设备地址保存不上,我看 topic 这个参数没有用,我把设备地址存这个参数对吗? -->
|
|
|
- <!-- <div class="device-address">
|
|
|
- <div class="lable-title">设备地址</div>
|
|
|
- <div class="lable">
|
|
|
- <el-input
|
|
|
- v-model="requestData.topic"
|
|
|
- placeholder="请输入设备地址"
|
|
|
- clearable
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
- <!-- 设备编号 没确定参数名称,直接不提交 -->
|
|
|
- <!-- <div class="device-sn">
|
|
|
- <div class="lable-title">设备编号</div>
|
|
|
- <div class="lable">
|
|
|
- <el-input
|
|
|
- v-model="requestData.parity"
|
|
|
- placeholder="请输入设备编号"
|
|
|
- clearable
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
+ </div>-->
|
|
|
</div>
|
|
|
<div class="right">
|
|
|
<div v-if="requestData.productType=='MODBUS_RTU'" class="device-com">
|
|
@@ -267,6 +253,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <!--
|
|
|
<div v-if="loadPictures==3" class="photo-list">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="8">
|
|
@@ -323,6 +310,7 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
+ -->
|
|
|
<!-- 底部按钮 -->
|
|
|
<div class="bottom-button">
|
|
|
<div class="cancel-device">
|
|
@@ -340,11 +328,10 @@
|
|
|
|
|
|
<script>
|
|
|
import { saveDeviceConfig, getDevicePicture, postPicture } from '@/api/device'
|
|
|
-import UploadPhoto from './UploadPhoto'
|
|
|
import { httpGet } from '@/api/common-action'
|
|
|
// import router from '@/router'
|
|
|
export default {
|
|
|
- components: { UploadPhoto },
|
|
|
+ components: { },
|
|
|
props: {
|
|
|
className: {
|
|
|
type: String,
|
|
@@ -451,54 +438,10 @@ export default {
|
|
|
this.loadPictures = this.loadPictures + 1
|
|
|
}
|
|
|
)
|
|
|
- // catch 那里已经计算过一次了,不需要再计算一次
|
|
|
- // .finally(
|
|
|
- // fr => {
|
|
|
- // this.loadPictures = this.loadPictures + 1
|
|
|
- // console.log('getDevicePicture fr=', fr)
|
|
|
- // console.log('getDevicePicture fr loadPictures=', this.loadPictures)
|
|
|
- // }
|
|
|
- // )
|
|
|
- // console.log('getDevicePicture loadPictures', this.loadPictures)
|
|
|
- // 只是 index ===3 无法稳定保证所有图片都完成加载
|
|
|
}
|
|
|
-
|
|
|
- // this.requestData = {
|
|
|
- // deviceCheckId: response.id,
|
|
|
- // deviceName: response.name, // 设备名称
|
|
|
- // deviceCheckDate: response.reportDate, // 出厂日期
|
|
|
- // deviceCheckFactory: response.vendorName, // 送检厂家
|
|
|
- // deviceModel: response.modelName, // 设备型号
|
|
|
- // deviceProductionDate: response.submitDate, // 送检时间
|
|
|
- // deviceComValue: response.devName, // 串口
|
|
|
- // deviceComOptions: [],
|
|
|
- // deviceBaudValue: response.baudRate, // 波特率
|
|
|
- // deviceBaudOptions: [],
|
|
|
- // deviceCheckbitValue: response.parity, // 校验位
|
|
|
- // deviceCheckbitOptions: [],
|
|
|
- // deviceProtocolValue: response.productType, // 设备类型
|
|
|
- // deviceAddress: response.unitAddr, // 设备地址
|
|
|
- // deviceSn: response.parity, // 设备编号 - 未确认
|
|
|
- // deviceIp: response.ipAddr, // IP
|
|
|
- // devicePortValue: response.ipPort, // 端口
|
|
|
- // deviceDatabitValue: response.dataBits, // 数据位
|
|
|
- // deviceDatabitOptions: [],
|
|
|
- // deviceStopbitValue: response.stopBits, // 停止位
|
|
|
- // deviceStopbitOptions: [],
|
|
|
- // devicePassword: response.password, // 密码
|
|
|
- // deviceUsername: response.username, // 用户名
|
|
|
- // deviceTopic: response.topic, // 订阅主题
|
|
|
- // deviceStatus: response.status // 设备状态
|
|
|
- // }
|
|
|
})
|
|
|
} else {
|
|
|
- // 如果是新建设备,直接显示图片上传组件
|
|
|
- // this.isPicturesLoaded = true
|
|
|
this.loadPictures = 3
|
|
|
- // 如果是新建设备,给设备一个默认的设备类型值,以及和它对应的默认参数值
|
|
|
- // console.log('this.options.deviceProtocolOptions typeof =', typeof this.options.deviceProtocolOptions)
|
|
|
- // console.log('this.options.deviceProtocolOptions=', this.options.deviceProtocolOptions)
|
|
|
-
|
|
|
if (this.options.deviceProtocolOptions.length > 0) {
|
|
|
this.requestData.productType = this.options.deviceProtocolOptions[1].id
|
|
|
this.requestData.ipAddr = '127.0.0.1'
|
|
@@ -523,25 +466,11 @@ export default {
|
|
|
|
|
|
// 删除照片
|
|
|
removePicture(photoName) {
|
|
|
- // 接口 删除图片 /test/project/:project/picture/:filename
|
|
|
- // 试图优化删除逻辑
|
|
|
- // delRecord(`/test/project/${this.currentDeviceId}/picture/${photoName}`).then(res => {
|
|
|
- // console.log('removePicture 删除成功 photoName=', photoName)
|
|
|
- // // this.deviceDefaultPictures.splice(photoName, 1)
|
|
|
- // delete this.deviceDefaultPictures['p' + photoName]
|
|
|
- // // console.log('thisdeviceDefaultPictures', this.deviceDefaultPictures)
|
|
|
- // this.photoUpdateKey[photoName] = new Date().getTime()
|
|
|
- // this.$forceUpdate()
|
|
|
- // })
|
|
|
delete this.deviceDefaultPictures['p' + photoName]
|
|
|
this.delPhotoArr.push(photoName)
|
|
|
// console.log('thisdeviceDefaultPictures', this.deviceDefaultPictures)
|
|
|
this.photoUpdateKey[photoName] = new Date().getTime()
|
|
|
this.$forceUpdate()
|
|
|
- // delRecord(`/test/project/${this.currentDeviceId}/picture/${photoName}`).then(res => {
|
|
|
- // console.log('removePicture 删除成功 photoName=', photoName)
|
|
|
- // // this.deviceDefaultPictures.splice(photoName, 1)
|
|
|
- // })
|
|
|
},
|
|
|
// 删除未保存图片
|
|
|
delphoto(photoName) {
|
|
@@ -555,47 +484,18 @@ export default {
|
|
|
|
|
|
// 提交设备基本信息
|
|
|
submitDeviceConfig() {
|
|
|
- // console.log('devicePictureUploads=', this.devicePictureUploads)
|
|
|
if (
|
|
|
- this.isNull(this.requestData.name, '请输入设备名称') ||
|
|
|
- this.isNull(this.requestData.submitDate, '请选择送检时间') ||
|
|
|
- this.isNull(this.requestData.vendorName, '请输入送检厂家') ||
|
|
|
- this.isNull(this.requestData.modelName, '请输入设备型号') ||
|
|
|
- // this.isNull(this.requestData.reportDate, '请输入出厂日期') ||
|
|
|
- this.isNull(this.requestData.productType, '请选择设备类型')
|
|
|
+ this.isNull(this.requestData.serialNumber, '请输入设备编号')
|
|
|
) {
|
|
|
// 如果有任何一个值为空,则直接返回,不提交数据
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // 检查图片是否全部上传, sureNum.length === 3
|
|
|
- // console.log('this.deviceDefaultPictures.length', this.deviceDefaultPictures)
|
|
|
- // const sureNum = this.deviceDefaultPictures.filter(item => item)
|
|
|
- if (Object.values(this.deviceDefaultPictures).length !== 3) {
|
|
|
- return this.$message({
|
|
|
- message: '请上传照片',
|
|
|
- type: 'error',
|
|
|
- offset: window.screen.height / 3
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 转换成后端能接收的json名称
|
|
|
- // console.log('submitDeviceConfig requestData = ', this.requestData)
|
|
|
const deviceSubmitData = this.clearSubmitData(this.requestData)
|
|
|
// console.log('submitDeviceConfig deviceSubmitData = ', deviceSubmitData)
|
|
|
deviceSubmitData.id = this.currentDeviceId || null
|
|
|
deviceSubmitData.devName = this.devName || '/dev/ttyUSB0'
|
|
|
-
|
|
|
- // console.log('saveDeviceConfig deviceSubmitData=', deviceSubmitData)
|
|
|
// 参数合法,数据提交到后端,到下一步
|
|
|
saveDeviceConfig(deviceSubmitData).then(response => {
|
|
|
- // console.log('saveDeviceConfig response=', response)
|
|
|
- // 上传照片
|
|
|
- // devicePictureUploads
|
|
|
- // this.devicePictureUploads
|
|
|
- this.devicePictureUploads.forEach((fileItem, phtoName) => {
|
|
|
- this.submitPhoto(fileItem, phtoName, response.id)
|
|
|
- })
|
|
|
this.$emit('changeDeviceId', response.id * 1)
|
|
|
// 到下一步
|
|
|
let currentStep = this.currentStep
|