瀏覽代碼

feature:增加蓝牙v2版本控制

liuzhenlin 2 周之前
父節點
當前提交
c673648525

+ 9 - 9
.env.development

@@ -10,19 +10,19 @@
 # 本地环境
 ENV = development
 # 本地环境接口地址
-VITE_API_URL = http://192.168.0.216:9957/
+VITE_API_URL = http://192.168.0.216:9954/
 VITE_API_WECHAT = /wechat/
 VITE_TENANT = default
 
 # 微服务地址
-VITE_ADMIN = dashoo.labsop.admin-50000
-VITE_WORKFLOW = dashoo.labsop.workflow-50000
-VITE_FINANCE = dashoo.labsop.finance-50000
-VITE_SCI = dashoo.labsop.scientific-50000
-VITE_INSTR_ADMIN = dashoo.labsop.apparatus-50000
-VITE_LEARNING = dashoo.labsop.learning-50000
-VITE_PLATFORM_API = dashoo.labsop.platform-50000
-VITE_LABORATORY: dashoo.labsop.laboratory-50000
+VITE_ADMIN = dashoo.labsop.admin-34000
+VITE_WORKFLOW = dashoo.labsop.workflow-34000
+VITE_FINANCE = dashoo.labsop.finance-34000
+VITE_SCI = dashoo.labsop.scientific-34000
+VITE_INSTR_ADMIN = dashoo.labsop.apparatus-34000
+VITE_LEARNING = dashoo.labsop.learning-34000
+VITE_PLATFORM_API = dashoo.labsop.platform-3400
+VITE_LABORATORY: dashoo.labsop.laboratory-34000
 
 #公共配置
 VITE_UPLOAD = http://192.168.0.218:9933/weedfs/upload

+ 1 - 0
components.d.ts

@@ -39,6 +39,7 @@ declare module 'vue' {
     VanPicker: typeof import('vant/es')['Picker']
     VanPickerGroup: typeof import('vant/es')['PickerGroup']
     VanPopup: typeof import('vant/es')['Popup']
+    VanPullRefresh: typeof import('vant/es')['PullRefresh']
     VanRadio: typeof import('vant/es')['Radio']
     VanRadioGroup: typeof import('vant/es')['RadioGroup']
     VanRow: typeof import('vant/es')['Row']

+ 2 - 1
src/constants/pageConstants.ts

@@ -219,9 +219,10 @@ export const SUPPORT_FILE_UPLOAD_TYPE_MAX = ".jpg,.jpeg,.png,.doc,.docx,.xls,.xl
 
 // 扫码跳转微信方法
 
-const APPID = 'wx979e7a671a498586'
+const APPID = 'wxf8d38a8ce6a4c0b4'
 
 const PATH = 'pages/appointList/user'
+
 export const scanCodeWxUrl = (terminal: string, type: InstSwitchType) => {
   // 将 terminal 和 type 作为 query 传入小程序,需进行编码避免特殊字符截断
   const query = encodeURIComponent(`terminal=${terminal}&type=${type}`)

+ 5 - 3
src/view/instr/appointList/SampleAppointList.vue

@@ -252,8 +252,10 @@ const handleCancelAppoint = (row: any) => {
       // on cancel
     })
 }
-const onLoad = async () => {
-  state.loading = true
+const onLoad = async (isRefresh = false) => {
+  if (!isRefresh) {
+    state.loading = true
+  }
   state.queryForm.instId = props.instId
 
   const [err, res]: any = await to(sampleApi.getList(state.queryForm))
@@ -294,7 +296,7 @@ defineExpose({
     // If called from parent for refresh, we should probably reset.
     // Let's modify logic slightly or just set pageNum to 1 and empty list
     state.appointList = []
-    onLoad()
+    return onLoad(true)
   }
 })
 </script>

+ 3 - 3
src/view/instr/appointList/adminAppointList/adminProgress.vue

@@ -82,7 +82,7 @@ export default {
       if (res?.data?.config.shortWarningEnable) {
         const shortWraningTime = this.getShortWraningTime(res?.data?.config.shortWarning, res?.data?.config.shortWarningUnit)
         if (useTime > shortWraningTime) {
-          if (row.controlMode === '30') {
+          if (row.controlMode === '30' || row.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = row
@@ -91,7 +91,7 @@ export default {
               .catch(() => {})
           }
         } else {
-          if (row.controlMode === '30') {
+          if (row.controlMode === '30' || row.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = row
@@ -101,7 +101,7 @@ export default {
           }
         }
       } else {
-        if (row.controlMode === '30') {
+        if (row.controlMode === '30' || row.controlMode === '60') {
           this.handleBluetoothOffLine()
         } else {
           this.curAppointInfo = row

+ 2 - 2
src/view/instr/appointList/adminAppointList/adminSoon.vue

@@ -9,7 +9,7 @@
             <van-button
               style="width:80px;height:30px;margin:0;font-size:14px"
               type="primary" size="small" :disabled="loading"
-              v-if="['10','20','30','50'].includes(v.controlMode)"
+              v-if="['10','20','30','50','60'].includes(v.controlMode)"
               v-auth="'h5-admin-get-on'"
               @click.native.stop="handleGetOn(v)">
               {{ v.controlMode == '10' ? '上机' : '扫码上机' }}
@@ -88,7 +88,7 @@ export default {
         const that = this
         const res = await useUserInfo().scanCode()
         that.handleDeCode(res, row, that.handleCodeInfo)
-      } else if (row.controlMode == '30') {
+      } else if (row.controlMode == '30' || row.controlMode == '60') {
         const that = this
         const res = await useUserInfo().scanCode()
         that.handleDeCode(res, row, that.handleBluetoothDeCode)

+ 4 - 2
src/view/instr/appointList/appointRecord/index.vue

@@ -101,8 +101,10 @@ export default {
       this.getInstList()
     },
     // 查询列表
-    async getInstList() {
-      this.listloading = true
+    async getInstList(isRefresh = false) {
+      if (!isRefresh) {
+        this.listloading = true
+      }
       const [err, res] = await to(myAppointApi.getAppointRecord(this.queryForm))
       this.listloading = false
       if (err) return

+ 24 - 8
src/view/instr/appointList/inProgress/index.vue

@@ -109,8 +109,10 @@ export default {
       this.getInstList()
     },
     // 查询列表
-    async getInstList() {
-      this.listloading = true
+    async getInstList(isRefresh = false) {
+      if (!isRefresh) {
+        this.listloading = true
+      }
       const [err, res] = await to(myAppointApi.inProgressList(this.queryForm))
       this.listloading = false
       if (err) return
@@ -132,7 +134,7 @@ export default {
       if (res?.data?.config.shortWarningEnable) {
         const shortWraningTime = this.getShortWraningTime(res?.data?.config.shortWarning, res?.data?.config.shortWarningUnit)
         if (useTime > shortWraningTime) {
-          if (row.controlMode === '30') {
+          if (row.controlMode === '30' || row.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = row
@@ -149,7 +151,7 @@ export default {
               })
           }
         } else {
-          if (row.controlMode === '30') {
+          if (row.controlMode === '30' || row.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = row
@@ -167,7 +169,7 @@ export default {
           }
         }
       } else {
-        if (row.controlMode === '30') {
+        if (row.controlMode === '30' || row.controlMode === '60') {
           this.handleBluetoothOffLine()
         } else {
           this.curAppointInfo = row
@@ -212,13 +214,27 @@ export default {
     },
     //蓝牙 重新解码函数,获取解码内容之后 执行跳转操作
     async handleBluetoothDeCode(content) {
+      let terminal = ''
       if (content.includes('id')) {
-        const terminal = JSON.parse(content)?.terminal
+        terminal = JSON.parse(content)?.terminal
+      } else {
+        terminal = content
+      }
+
+      this.loading = true
+      const [codeErr, codeRes] = await to(instApi.getBlueToothCode({ terminal }))
+      if (codeErr) {
+        this.loading = false
+        showNotify({ type: 'danger', message: '获取蓝牙码失败,请重试' })
+        return
+      }
+      if (codeRes?.code == 200 && codeRes.data?.code) {
+        this.loading = false
         const url = scanCodeWxUrl(terminal, 'EndRun')
         window.location.href = url
       } else {
-        const url = scanCodeWxUrl(content, 'EndRun')
-        window.location.href = url
+        this.loading = false
+        showNotify({ type: 'warning', message: '未获取到该设备的蓝牙配置,请联系管理员' })
       }
     },
     // 计算时间转分钟

+ 79 - 32
src/view/instr/appointList/index.vue

@@ -9,35 +9,38 @@
 <template>
   <!-- 页面内容 -->
   <div class="home">
-    <!-- <van-pull-refresh v-model="loading" @refresh="onRefresh"> -->
-          <van-tabs v-model:active="active" @click-tab="onClickTab">
-            <van-tab title="即将上机">
-              <div class="list-container">
-                <soon-geton v-if="active === 0" ref="soonGetonRef" />
-              </div>
-            </van-tab>
-            <van-tab title="正在上机">
-              <div class="list-container">
-                <in-progress v-if="active === 1" ref="inProgressRef" />
-              </div>
-            </van-tab>
-            <van-tab title="等待审核">
-              <div class="list-container">
-                <my-appoint v-if="active === 2" ref="myAppointRef" />
-              </div>
-            </van-tab>
-            <van-tab title="预约记录">
-              <div class="list-container">
-                <appoint-record v-if="active === 3" ref="recordRef" />
-              </div>
-            </van-tab>
-            <van-tab title="送样预约">
-              <div class="list-container">
-                <sample-appoint-list v-if="active === 4" ref="sampleAppointListRef" />
-              </div>
-            </van-tab>
-          </van-tabs>
-    <!-- </van-pull-refresh> -->
+    <van-tabs v-model:active="active" @click-tab="onClickTab">
+      <van-tab title="即将上机">
+        <van-pull-refresh v-model="loading" @refresh="onRefresh" class="list-container soon-geton-container">
+          <soon-geton v-if="active === 0" ref="soonGetonRef" />
+          <van-back-top v-if="active === 0" target=".soon-geton-container" />
+        </van-pull-refresh>
+      </van-tab>
+      <van-tab title="正在上机">
+        <van-pull-refresh v-model="loading" @refresh="onRefresh" class="list-container in-progress-container">
+          <in-progress v-if="active === 1" ref="inProgressRef" />
+          <van-back-top v-if="active === 1" target=".in-progress-container" />
+        </van-pull-refresh>
+      </van-tab>
+      <van-tab title="等待审核">
+        <van-pull-refresh v-model="loading" @refresh="onRefresh" class="list-container my-appoint-container">
+          <my-appoint v-if="active === 2" ref="myAppointRef" />
+          <van-back-top v-if="active === 2" target=".my-appoint-container" />
+        </van-pull-refresh>
+      </van-tab>
+      <van-tab title="预约记录">
+        <van-pull-refresh v-model="loading" @refresh="onRefresh" class="list-container record-container">
+          <appoint-record v-if="active === 3" ref="recordRef" />
+          <van-back-top v-if="active === 3" target=".record-container" />
+        </van-pull-refresh>
+      </van-tab>
+      <van-tab title="送样预约">
+        <van-pull-refresh v-model="loading" @refresh="onRefresh" class="list-container sample-container">
+          <sample-appoint-list v-if="active === 4" ref="sampleAppointListRef" />
+          <van-back-top v-if="active === 4" target=".sample-container" />
+        </van-pull-refresh>
+      </van-tab>
+    </van-tabs>
     <van-tabbar route :placeholder="true">
       <van-tabbar-item replace to="/home" icon="wap-home-o">首页</van-tabbar-item>
       <van-tabbar-item replace to="/instr-follow" icon="star">收藏仪器</van-tabbar-item>
@@ -96,9 +99,53 @@
 
     methods: {
       // 下拉刷新被触发
-      onRefresh() {
-        // this.initList()
-        this.loading = false
+      async onRefresh() {
+        this.loading = true
+        try {
+          switch (this.active) {
+            case 0:
+              if (this.$refs.soonGetonRef) {
+                this.$refs.soonGetonRef.queryForm.pageNum = 1
+                this.$refs.soonGetonRef.appointList = []
+                this.$refs.soonGetonRef.finished = false
+                await this.$refs.soonGetonRef.getInstList(true)
+              }
+              break
+            case 1:
+              if (this.$refs.inProgressRef) {
+                this.$refs.inProgressRef.queryForm.pageNum = 1
+                this.$refs.inProgressRef.appointList = []
+                this.$refs.inProgressRef.finished = false
+                await this.$refs.inProgressRef.getInstList(true)
+              }
+              break
+            case 2:
+              if (this.$refs.myAppointRef) {
+                this.$refs.myAppointRef.queryForm.pageNum = 1
+                this.$refs.myAppointRef.appointList = []
+                this.$refs.myAppointRef.finished = false
+                await this.$refs.myAppointRef.getInstList(true)
+              }
+              break
+            case 3:
+              if (this.$refs.recordRef) {
+                this.$refs.recordRef.queryForm.pageNum = 1
+                this.$refs.recordRef.appointList = []
+                this.$refs.recordRef.finished = false
+                await this.$refs.recordRef.getInstList(true)
+              }
+              break
+            case 4:
+              if (this.$refs.sampleAppointListRef) {
+                await this.$refs.sampleAppointListRef.onLoad()
+              }
+              break
+          }
+        } catch (e) {
+          console.error(e)
+        } finally {
+          this.loading = false
+        }
       },
       onClickTab(e) {
         this.active = e.name

+ 4 - 2
src/view/instr/appointList/myAppoint/index.vue

@@ -129,8 +129,10 @@
       },
 
       // 查询列表
-      async getInstList() {
-        this.listloading = true
+      async getInstList(isRefresh = false) {
+        if (!isRefresh) {
+          this.listloading = true
+        }
         const [err, res] = await to(myAppointApi.myAppoint(this.queryForm))
         this.listloading = false
         if (err) return

+ 34 - 8
src/view/instr/appointList/onlineInfo/index.vue

@@ -28,7 +28,7 @@
           <span class="fontSize14 bold">部门:</span>
         </div>
         <div>
-          <!-- <span class="fontSize14">{{ details?.deptName }}</span> -->
+          <span class="fontSize14">{{ details?.deptName }}</span>
         </div>
       </div>
       <div class="flex mb20">
@@ -125,6 +125,8 @@ const myAppointApi = useMyAppointApi()
 import instAppointApi from '/@/api/instr/instAppoint'
 import { useInstrApi } from '/@/api/instr'
 const instApi = useInstrApi()
+import { useUserApi } from '/@/api/system/user'
+const userApi = useUserApi()
 import to from 'await-to-js'
 import moment from 'moment'
 import { showConfirmDialog, showNotify } from 'vant'
@@ -166,7 +168,17 @@ export default {
       const [err, res] = await to(myAppointApi.appointDetails({ ...params }))
       if (err) return
       if (res.code == 200 && res.data) {
-        this.details = res.data
+        let detailsData = res.data
+        if (detailsData.userId) {
+          const [userErr, userRes] = await to(userApi.getUserInfo({ id: detailsData.userId }))
+          if (!userErr && userRes?.code === 200 && userRes.data) {
+            detailsData = {
+              ...detailsData,
+              deptName: userRes.data.userInfo.deptName || '-'
+            }
+          }
+        }
+        this.details = detailsData
       }
       console.log(this.details)
     },
@@ -184,7 +196,7 @@ export default {
       if (res?.data?.config.shortWarningEnable) {
         const shortWraningTime = this.getShortWraningTime(res?.data?.config.shortWarning, res?.data?.config.shortWarningUnit)
         if (useTime > shortWraningTime) {
-          if (this.details.controlMode === '30') {
+          if (this.details.controlMode === '30' || this.details.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = this.details
@@ -201,7 +213,7 @@ export default {
               })
           }
         } else {
-          if (this.details.controlMode === '30') {
+          if (this.details.controlMode === '30' || this.details.controlMode === '60') {
             this.handleBluetoothOffLine()
           } else {
             this.curAppointInfo = this.details
@@ -219,7 +231,7 @@ export default {
           }
         }
       } else {
-        if (this.details.controlMode === '30') {
+        if (this.details.controlMode === '30' || this.details.controlMode === '60') {
           this.handleBluetoothOffLine()
         } else {
           this.curAppointInfo = this.details
@@ -265,13 +277,27 @@ export default {
     },
     //蓝牙 重新解码函数,获取解码内容之后 执行跳转操作
     async handleBluetoothDeCode(content) {
+      let terminal = ''
       if (content.includes('id')) {
-        const terminal = JSON.parse(content)?.terminal
+        terminal = JSON.parse(content)?.terminal
+      } else {
+        terminal = content
+      }
+
+      this.loading = true
+      const [codeErr, codeRes] = await to(instApi.getBlueToothCode({ terminal }))
+      if (codeErr) {
+        this.loading = false
+        showNotify({ type: 'danger', message: '获取蓝牙码失败,请重试' })
+        return
+      }
+      if (codeRes?.code == 200 && codeRes.data?.code) {
+        this.loading = false
         const url = scanCodeWxUrl(terminal, 'EndRun')
         window.location.href = url
       } else {
-        const url = scanCodeWxUrl(content, 'EndRun')
-        window.location.href = url
+        this.loading = false
+        showNotify({ type: 'warning', message: '未获取到该设备的蓝牙配置,请联系管理员' })
       }
     },
     // 计算时间转分钟

+ 35 - 10
src/view/instr/appointList/soonGeton/index.vue

@@ -21,7 +21,7 @@
           </div>
           <div class="flex">
             <van-button style="width: 80px; height: 30px; margin: 0; font-size: 14px" class="scan-txt" type="primary"
-              size="small" :disabled="loading" v-if="['10', '20', '30', '50'].includes(v.controlMode)"
+              size="small" :disabled="loading" v-if="['10', '20', '30', '50','60'].includes(v.controlMode)"
               @click="handleGetOn(v)">
               {{ v.controlMode == '10' ? '上机' : '扫码上机' }}
             </van-button>
@@ -112,16 +112,25 @@ export default {
   mounted() {
     this.queryForm.pageNum = 1
     this.getInstList()
+    window.addEventListener('pageshow', this.onPageShow)
+  },
+  beforeUnmount() {
+    window.removeEventListener('pageshow', this.onPageShow)
   },
   methods: {
+    onPageShow(e) {
+      this.loading = false
+    },
     // 重新加载
     onLoad() {
       this.queryForm.pageNum++
       this.getInstList()
     },
     // 查询列表
-    async getInstList() {
-      this.listloading = true
+    async getInstList(isRefresh = false) {
+      if (!isRefresh) {
+        this.listloading = true
+      }
       const [err, res] = await to(myAppointApi.toGetonList(this.queryForm))
       this.listloading = false
       if (err) return
@@ -142,7 +151,7 @@ export default {
     },
     /**
      * 调起二维码扫码
-     * controlMode (10 不控制 20 电源控制(wifi) 30 电源控制(蓝牙) 50 电脑控制)
+     * controlMode (10 不控制 20 电源控制(wifi) 30 电源控制(蓝牙) 50 电脑控制 60 蓝牙V2
      */
     async handleScanCode(row) {
       this.curAppointInfo = row
@@ -164,7 +173,7 @@ export default {
         // 调起条码扫描
         const res = await useUserInfo().scanCode()
         that.handleDeCode(res, row, that.handleCodeInfo)
-      } else if (row.controlMode == '30') {
+      } else if (row.controlMode == '30' || row.controlMode == '60') {
         // 蓝牙
         // this.$refs.bluetoothRef.initBlue('open', row)
         // await useUserInfo().scanCode(0)
@@ -212,7 +221,10 @@ export default {
       } else {
         // 拿到解码信息(仪器编码)获取仪器id
         const [instErr, instRes] = await to(instApi.getIdByTerminal({ terminal: content }))
-        if (instErr) return
+        if (instErr) {
+          this.loading = false
+          return
+        }
         if (instRes.data.id == appointRow.instId) {
           this.handleGetOnByAppointId(appointRow.id)
         } else {
@@ -224,15 +236,28 @@ export default {
 
     //蓝牙 重新解码函数,获取解码内容之后 执行跳转操作
     async handleBluetoothDeCode(content) {
+      let terminal = ''
       if (content.includes('id')) {
-        const terminal = JSON.parse(content)?.terminal
+        terminal = JSON.parse(content)?.terminal
+      } else {
+        terminal = content
+      }
+
+      this.loading = true
+      const [codeErr, codeRes] = await to(instApi.getBlueToothCode({ terminal }))
+      if (codeErr) {
+        this.loading = false
+        showNotify({ type: 'danger', message: '获取蓝牙码失败,请重试' })
+        return
+      }
+      if (codeRes?.code == 200 && codeRes.data?.code) {
+        this.loading = false
         const url = scanCodeWxUrl(terminal, 'StartRun')
         window.location.href = url
       } else {
-        const url = scanCodeWxUrl(content, 'StartRun')
-        window.location.href = url
+        this.loading = false
+        showNotify({ type: 'warning', message: '未获取到该设备的蓝牙配置,请联系管理员' })
       }
-
     },
 
     // 上机