Browse Source

处理设备编号:设备信息中保留设备编号,同步修改受此影响的功能和页面

liling 1 year ago
parent
commit
79e77a161c

+ 6 - 14
src/views/dashboard/index.vue

@@ -34,15 +34,13 @@
                 stripe
               >
                 <el-table-column
-                  prop="name"
-                  label="设备名称"
-                  width="150px"
+                  prop="serialNumber"
+                  label="设备编号"
                   :show-overflow-tooltip="true"
                 />
                 <el-table-column
                   prop="stateName"
                   label="检测状态"
-                  width="80px"
                 >
                   <template slot-scope="scope">
                     <el-tag :type="scope.row.state | formatState">{{ scope.row.stateName || '未知' }}</el-tag>
@@ -54,7 +52,6 @@
                 <el-table-column
                   prop="plans"
                   label="检测方案"
-                  width="220px"
                   tooltip-effect="dark"
                   :show-overflow-tooltip="true"
                 >
@@ -73,7 +70,7 @@
             <template slot-scope="scope">
               <el-link type="primary" :index="scope.row.deviceCheckModelName">查看</el-link>
             </template>
-          </el-table-column> -->
+          </el-table-column>
                 <el-table-column
                   prop="reportDate"
                   label="检测报告"
@@ -96,15 +93,10 @@
                   label="设备型号"
                   width="150px"
                 />
+                 -->
                 <el-table-column
-                  prop="submitDate"
-                  label="送检日期"
-                  width="120px"
-                />
-                <el-table-column
-                  prop="reportDate"
-                  label="报告日期"
-                  width="160px"
+                  prop="createDate"
+                  label="创建日期"
                 />
                 <!-- 隐藏 列 这里不用显示,但是在编辑的时候需要获取此数据 -->
                 <el-table-column

+ 1 - 1
src/views/device/check.vue

@@ -7,7 +7,7 @@
     <div class="check-container-inner">
       <div class="check-title">
         <div class="title-main">
-          {{ deviceGet.name }}
+          设备编号:{{ deviceGet.serialNumber||deviceGet.name }}
           <!-- <el-button icon="el-icon-plus" class="dark-button" size="mini" @click="test()">测试按钮</el-button> -->
         </div>
         <div class="title-lable">

+ 1 - 1
src/views/device/components/DeviceCheck.vue

@@ -64,7 +64,7 @@ export default {
     return {
       // 默认数据
       requestData: {
-        deviceDefaultName: '当前设备名称,加载中...',
+        deviceDefaultName: '当前设备编号,加载中...',
         deviceCurrentCheckValue: 'd1',
         deviceCurrentCheckOptions: [],
         deviceCurrentPlanValue: 'p1',

+ 21 - 121
src/views/device/components/DeviceConfig.vue

@@ -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

+ 22 - 110
src/views/device/components/DeviceList.vue

@@ -20,10 +20,9 @@
     <div class="search-bar">
       <div class="left">
         <div class="search-date item">
-          <!-- 检测日期 -->
-          <div class="title">检测日期:</div>
+          <div class="title">创建日期:</div>
           <el-date-picker
-            v-model="searchData.dateValue"
+            v-model="searchData.createdDate"
             size="mini"
             type="daterange"
             start-placeholder="开始日期"
@@ -48,45 +47,15 @@
         <br>
         <div class="search-device-name item">
           <!-- 设备名称 -->
-          <div class="title">设备名称:</div>
+          <div class="title">设备编号:</div>
           <el-input
-            v-model="searchData.name"
-            placeholder="请输入名称"
+            v-model="searchData.serialNumber"
+            placeholder="请输入设备编号"
             clearable
             size="mini"
             maxlength="32"
           />
         </div>
-        <div class="search-device-name item">
-          <!-- 送检厂家 -->
-          <div class="title">送检厂家:</div>
-          <el-input
-            v-model="searchData.vendorName"
-            placeholder="请输入厂家"
-            clearable
-            size="mini"
-            maxlength="32"
-          />
-        </div>
-        <div class="search-device-model item">
-          <!-- 设备型号 -->
-          <div class="title">设备型号:</div>
-          <el-input
-            v-model="searchData.modelName"
-            placeholder="请输入型号"
-            clearable
-            size="mini"
-            maxlength="32"
-          />
-          <!-- <el-select v-model="searchData.modelName" size="mini" filterable placeholder="请选择">
-            <el-option
-              v-for="item in deviceModelOptions"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value"
-            />
-          </el-select> -->
-        </div>
       </div>
       <div class="right">
         <div class="reset item">
@@ -132,26 +101,12 @@
             type="selection"
           />
           <el-table-column
-            prop="name"
-            label="设备名称"
-            width="200px"
+            prop="serialNumber"
+            label="设备编号"
           />
           <el-table-column
-            prop="stateName"
-            label="检测状态"
-            width="80px"
-          >
-            <template slot-scope="scope">
-              <el-tag :type="scope.row.state | formatState">{{ scope.row.stateName || '未知' }}</el-tag>
-              <!-- <el-tag v-if="scope.row.deviceCheckStatus == null ||scope.row.deviceCheckStatus == 'NEW'" type="danger">未检测</el-tag>
-              <el-tag v-if="scope.row.deviceCheckStatus == 'RUNNING'">检测中</el-tag>
-              <el-tag v-if="scope.row.deviceCheckStatus == 'TERMINATED'" type="info">已结束</el-tag> -->
-            </template>
-          </el-table-column>
-          <el-table-column
             prop="plans"
             label="检测方案"
-            width="220px"
           >
             <template slot-scope="scope">
               <!-- <el-link type="primary" @click="toBegin(scope.row)">{{ scope.row.deviceCheckProductType }}</el-link> -->
@@ -161,54 +116,23 @@
               </div>
             </template>
           </el-table-column>
-          <!-- <el-table-column
-            prop="deviceCheckModelName"
-            label="测点模型"
-          >
-            <template slot-scope="scope">
-              <el-link type="primary" :index="scope.row.deviceCheckModelName">查看</el-link>
-            </template>
-          </el-table-column> -->
           <el-table-column
-            prop="reportDate"
-            label="检测报告"
-            width="220px"
+            prop="stateName"
+            label="检测状态"
           >
             <template slot-scope="scope">
-              <div v-if="scope.row.reportDate==null || scope.row.reportDate==''" style="color:#999">[未生成报告] <el-button :id="`btn_devicetest_makereport${scope.$index}`" :ref="`btn_devicetest_makereport${scope.$index}`" data-controlcode="btn_devicetest_makereport" class="table-act" type="text" size="small" @click="creatReportClick(scope.row.id)">生成报告</el-button></div>
-              <!-- <div v-else :key="scope.row.id"><el-link type="primary" style="color:#6e6eea" @click="toSeeReport(scope.row)">{{ scope.row.reportName }}</el-link></div> -->
-              <div v-else :key="scope.row.id">
-                <div v-for="item in scope.row.plans" :key="item.id">
-
-                  <!-- <el-link type="primary" style="color:#6e6eea" @click="toSeeReport(scope.row)">{{ item.name }}</el-link> -->
-                  <el-link :ref="`btn_devicetest_expdetail_${scope.$index}`" type="primary" data-controlCode="btn_devicetest_expdetail" style="color:#6e6eea" @click="toGetReport(item)">{{ item.name }}</el-link>
-                </div>
-              </div>
+              <el-tag :type="scope.row.state | formatState">{{ scope.row.stateName || '未知' }}</el-tag>
+              <!-- <el-tag v-if="scope.row.deviceCheckStatus == null ||scope.row.deviceCheckStatus == 'NEW'" type="danger">未检测</el-tag>
+              <el-tag v-if="scope.row.deviceCheckStatus == 'RUNNING'">检测中</el-tag>
+              <el-tag v-if="scope.row.deviceCheckStatus == 'TERMINATED'" type="info">已结束</el-tag> -->
             </template>
           </el-table-column>
           <el-table-column
-            prop="vendorName"
-            label="送检厂家"
-          />
-          <el-table-column
-            prop="modelName"
-            label="设备型号"
-          />
-          <el-table-column
-            prop="submitDate"
-            label="送检日期"
-            width="120px"
+            prop="createdDate"
+            label="创建日期"
+            width="220px"
           />
           <el-table-column
-            prop="reportDate"
-            label="报告日期"
-            width="170px"
-          >
-            <!-- <template slot-scope="scope">
-              <el-link type="primary">{{ scope.row.reportDate }}</el-link>
-            </template> -->
-          </el-table-column>
-          <el-table-column
             fixed="right"
             label="操作"
             width="180"
@@ -407,11 +331,7 @@ export default {
         // 检测状态默认选项
         deviceCheckStatusDefaultValue: '0',
         // 默认设备名称
-        deviceNameDefaultValue: '',
-        // 设备型号默认选项
-        deviceModelDefaultValue: '',
-        // 送检厂家
-        deviceFromFactory: ''
+        serialNumberDefaultValue: ''
       },
       // 检测状态默认选项
       deviceCheckStatusOptions: [],
@@ -481,7 +401,7 @@ export default {
       // 网页加载完成后执行
       this.initFunctions()
       // 对表格中的操作列做了权限控制(根据权限可能会移除其中的按钮)后,会导致操作列的行高错位(原因是有固定列),需要再调用一次查询方法重绘一下表格才能恢复正常,原理不明,但确实能解决问题
-      this.search({})
+      this.search()
     })
   },
   methods: {
@@ -517,16 +437,12 @@ export default {
         // 通信协议 productType
         productType: this.protocolValue,
         // 建立日期 this.dateValue: start end
-        start: this.searchData.dateValue ? this.searchData.dateValue[0] : null,
-        end: this.searchData.dateValue ? this.searchData.dateValue[1] : null,
+        start: this.searchData.createdDate ? this.searchData.createdDate[0] : null,
+        end: this.searchData.createdDate ? this.searchData.createdDate[1] : null,
         // 检测状态
         state: this.searchData.state,
         // 设备名称
-        name: this.searchData.name,
-        // 设备型号
-        modelName: this.searchData.modelName,
-        // 送检厂家
-        vendorName: this.searchData.vendorName
+        serialNumber: this.searchData.serialNumber
       }
       searchDeviceList(pageObj, searchParams).then(response => {
         this.tabledataloading = false
@@ -547,11 +463,7 @@ export default {
         // 检测状态默认选项
         deviceCheckStatusDefaultValue: '0',
         // 默认设备名称
-        deviceNameDefaultValue: '',
-        // 设备型号默认选项
-        deviceModelDefaultValue: '',
-        // 送检厂家
-        deviceFromFactory: ''
+        serialNumberDefaultValue: ''
       }
       this.searchData = Object.assign({}, newsearchData)