浏览代码

fix: update

lkd9698906@163.com 1 年之前
父节点
当前提交
d420fe54f2
共有 3 个文件被更改,包括 139 次插入62 次删除
  1. 7 7
      src/pages/device/list/Index.vue
  2. 123 52
      src/pages/mine/wifi/Index.vue
  3. 9 3
      src/pages/mine/wifi/data.ts

+ 7 - 7
src/pages/device/list/Index.vue

@@ -81,13 +81,14 @@
               </div>
             </div>
           </template>
-          <van-cell clickable :to="'/device/detail/'+item.mac">
+          <van-cell >
+            <!-- clickable :to="'/device/detail/'+item.mac" -->
             <div style="text-align: left;">
               <!-- 第一行 -->
               <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
                 <div style="font-weight: bold; color: #000;">
                   <span>住院号:</span>
-                  <span>{{ item.data.patientCode.value }}</span>
+                  <span>{{ item?.patientCode }}</span>
                   <!-- <span v-if="item.username" style="color: #000;">{{item.username}}</span>
                   <span v-else>未知用户</span> -->
                 </div>
@@ -121,7 +122,7 @@
               </div>
               <!-- 第四行 -->
               <div style="display: flex; justify-content: space-between;">
-                <div v-if="item.data.lat" style="display: flex; color: #000;" @click.stop="onLocation(item.mac)">
+                <div v-if="item?.lat" style="display: flex; color: #000;" @click.stop="onLocation(item.mac)">
                   <div>
                     <van-icon name="static/images/icon-location2.png" size="1.5rem" />
                   </div>
@@ -273,13 +274,12 @@
         const pages = Math.ceil(total / page.pageSize);
         console.log(pages);
         console.log(dataArr)
-        
         if(page.pageNum == 1){
           dataList.value.splice(0, dataList.value.length);
         }
-        for(let i = 0; i < dataArr.length; i++){
-          dataArr[i].data = JSON.parse(dataArr[i].data)
-        }
+        // for(let i = 0; i < dataArr.length; i++){
+        //   dataArr[i] = JSON.parse(dataArr[i])
+        // }
         dataList.value.push(...dataArr);
         page.pages = pages
         page.total = total

+ 123 - 52
src/pages/mine/wifi/Index.vue

@@ -47,8 +47,8 @@
             :size="46"
           />
           <van-cell
-            :title="item.address"
-            :label="item.port"
+            :title="item.platform === '阿里云' ? (item.productKey) : (item.address + ':' + item.port)"
+            :label="item.platform"
             style="margin: 0.625rem 0 0 1rem"
           >
             <van-button
@@ -123,7 +123,13 @@
     </div>
   </div>
   <!-- wifi配置信息 -->
-  <van-action-sheet v-model:show="wifiAction" :title="wifiTitle"  @cancel="handleCancel('wifi')">
+  <van-action-sheet
+    v-if="wifiAction"
+    v-model:show="wifiAction"
+    :title="wifiTitle"
+    @cancel="handleCancel('wifi')"
+    :close-on-click-overlay="false"
+  >
     <div class="form">
       <van-form @submit="onWifiSubmit">
         <van-cell-group inset>
@@ -161,7 +167,13 @@
     </div>
   </van-action-sheet>
   <!-- 对接配置信息 -->
-  <van-action-sheet v-model:show="addressAction" :title="addressTitle" @cancel="handleCancel('address')">
+  <van-action-sheet
+    v-if="addressAction"
+    v-model:show="addressAction"
+    :title="addressTitle"
+    @cancel="handleCancel('address')"
+    :close-on-click-overlay="false"
+  >
     <div class="form">
       <van-form @submit="onAddressSubmit">
         <van-cell-group inset>
@@ -184,6 +196,35 @@
           </van-cell>
           <van-cell>
             <van-field
+              v-model="addressInfo.platform"
+              name="platform "
+              label="对接平台"
+              placeholder="请选择对接平台"
+              @click="showPlatfromPicker = true"
+            />
+            <van-popup
+              v-model:show="showPlatfromPicker"
+              round
+              position="bottom"
+            >
+              <van-picker
+                :columns="platformColumns"
+                @cancel="showPlatfromPicker = false"
+                @confirm="onConfirmPlatfrom"
+              />
+            </van-popup>
+          </van-cell>
+          <van-cell>
+            <van-field
+              v-if="addressInfo.platform === '阿里云'"
+              v-model="addressInfo.productKey"
+              name="productKey"
+              label="产品编码"
+              placeholder="请输入产品编码"
+              :rules="[{ required: true, message: '请输入产品编码' }]"
+            />
+            <van-field
+              v-else
               v-model="addressInfo.address"
               name="address"
               label="对接地址"
@@ -192,6 +233,14 @@
             />
           </van-cell>
           <van-cell>
+            <!-- <van-field
+              v-if="addressInfo.platform === '阿里云'"
+              v-model="addressInfo.productSecret"
+              name="productSecret"
+              label="产品密钥"
+              placeholder="请输入产品密钥"
+              :rules="[{ required: true, message: '请输入产品密钥' }]"
+            /> -->
             <van-field
               v-model="addressInfo.port"
               name="port"
@@ -200,22 +249,6 @@
               :rules="[{ required: true, message: '请输入对接端口' }]"
             />
           </van-cell>
-          <van-cell>
-            <van-field
-              v-model="addressInfo.platform"
-              name="platform "
-              label="对接平台"
-              placeholder="请选择对接平台"
-              @click="showPicker = true"
-            />
-            <van-popup v-model:show="showPicker" round position="bottom">
-              <van-picker
-                :columns="platformColumns"
-                @cancel="showPicker = false"
-                @confirm="onConfirm"
-              />
-            </van-popup>
-          </van-cell>
         </van-cell-group>
         <div style="margin: 0.25rem 10%; width: 80%">
           <van-button round block type="primary" native-type="submit">
@@ -237,7 +270,7 @@ import "vant/es/dialog/style";
 import { refreshCurrentRoute } from "@/router";
 import { useStoreOfUserInfo } from "@/store/userInfo";
 import { v4 as uuidv4 } from "uuid";
-import { selColumns, platformColumns } from './data';
+import { selColumns, platformColumns } from "./data";
 const userInfo = useStoreOfUserInfo();
 
 const cusNavigation = ref();
@@ -251,6 +284,7 @@ const addressInfo = ref({} as any); // 对接信息
 const wifiDatas = ref<Array<any>>([]); // WIFI信息列表
 const addressDatas = ref<Array<any>>([]); // WIFI信息列表
 const showPicker = ref(false);
+const showPlatfromPicker = ref(false);
 
 const validator8 = (val: string | any[]) =>
   val && val.length > 8 ? false : true;
@@ -260,6 +294,21 @@ const validator20 = (val: string | any[]) =>
 // 提交WIFI信息
 function onSubmit() {
   formData.value.wifi = JSON.stringify(wifiDatas.value);
+  addressDatas?.value?.forEach((item: any) => {
+    switch(item.platform){
+      case '阿里云':
+        item.platform = "1"
+        break;
+      case '驼人':
+         item.platform = "2"
+        break;
+      case '本地':
+        item.platform = "3"
+        break;
+      default:
+        break;
+    }
+  });
   formData.value.address = JSON.stringify(addressDatas.value);
   post_promise({ url: "/userConfig/config", data: formData.value }).then(
     (res) => {
@@ -277,58 +326,65 @@ function onSubmit() {
 }
 
 // 类型选项
-const onConfirm = ( selectedOptions: any ) => {
-      showPicker.value = false;
-      addressInfo.value.networkType = selectedOptions.selectedValues[0];
-    };
+const onConfirm = (selectedOptions: any) => {
+  showPicker.value = false;
+  addressInfo.value.networkType = selectedOptions.selectedValues[0];
+};
 
-    // 失焦去空格
-    function handleBlur () {
-      wifiInfo.value.name = wifiInfo.value.name.trim();
-    }
-    // 取消动作面板清空信息
-    function handleCancel(flag : any) {
-      if(flag === 'wifi'){
-        wifiInfo.value = {};
-      }else {
-        addressInfo.value = {};
-      }
-    }
+// 平台类型选项
+const onConfirmPlatfrom = (selectedOptions: any) => {
+  showPlatfromPicker.value = false;
+  addressInfo.value.platform = selectedOptions.selectedValues[0];
+};
+
+// 失焦去空格
+function handleBlur() {
+  wifiInfo.value.name = wifiInfo.value.name.trim();
+}
+// 取消动作面板清空信息
+function handleCancel(flag: any) {
+  if (flag === "wifi") {
+    wifiInfo.value = {};
+    wifiAction.value = false;
+  } else {
+    addressInfo.value = {};
+    addressAction.value = false;
+  }
+}
 // wifi修改及新增确认
 function onWifiSubmit() {
-  let tip = '新增';
+  let tip = "新增";
   if (wifiInfo.value && wifiInfo.value.id) {
-    for (let i = 0, len = wifiDatas.value.length - 1; i < len; i++) {
+    for (let i = 0; i < wifiDatas.value.length; i++) {
       if (wifiDatas.value[i].id === wifiInfo.value.id) {
         wifiDatas.value[i] = wifiInfo.value;
-        tip = '编辑'
+        tip = "编辑";
       }
     }
   } else {
     wifiInfo.value = { ...wifiInfo.value, id: uuidv4() };
     wifiDatas.value.push(wifiInfo.value);
   }
-  showToast('WIFI信息'+tip+'成功,保存后生效')
+  showToast("WIFI信息" + tip + "成功,保存后生效");
   wifiAction.value = false;
   wifiInfo.value = {};
 }
 
 // 对接配置确认
 function onAddressSubmit() {
-  let tip = '新增';
+  let tip = "新增";
   if (addressInfo.value && addressInfo.value.id) {
-    for (let i = 0, len = addressDatas.value.length - 1; i < len; i++) {
+    for (let i = 0; i < addressDatas.value.length; i++) {
       if (addressDatas.value[i].id === addressInfo.value.id) {
         addressDatas.value[i] = addressInfo.value;
-        tip = '编辑'
+        tip = "编辑";
       }
     }
-  }else {
+  } else {
     addressInfo.value = { ...addressInfo.value, id: uuidv4() };
     addressDatas.value.push(addressInfo.value);
-    
   }
-  showToast('对接配置'+tip+'成功,保存后生效')
+  showToast("对接配置" + tip + "成功,保存后生效");
   addressAction.value = false;
   addressInfo.value = {};
 }
@@ -347,11 +403,11 @@ function handleAdd(addType: string) {
 // 编辑wifi信息
 function handleEdit(editType: string, record: any) {
   if (editType === "wifi") {
-    wifiInfo.value = {...record};
+    wifiInfo.value = { ...record };
     wifiTitle.value = "编辑WIFI配置";
     wifiAction.value = true;
   } else {
-    addressInfo.value = {...record};
+    addressInfo.value = { ...record };
     addressTitle.value = "编辑对接配置";
     addressAction.value = true;
   }
@@ -407,6 +463,21 @@ function getWifiInfo() {
           formData.value = result.data;
           wifiDatas.value = JSON.parse(result.data.wifi);
           addressDatas.value = JSON.parse(result.data.address);
+          addressDatas?.value?.forEach((item: any)=>{
+            switch(item.platform){
+              case '1':
+                item.platform = "阿里云"
+                break;
+              case '2':
+                 item.platform = "驼人"
+                break;
+              case '3':
+                item.platform = "本地"
+                break;
+              default:
+                break;
+            }
+          })
         }
       })
       .catch((err) => {
@@ -455,9 +526,9 @@ function getWifiInfo() {
   }
 }
 
-.wifi-name{
+.wifi-name {
   white-space: nowrap;
-    text-overflow: ellipsis;
-    overflow: hidden;
+  text-overflow: ellipsis;
+  overflow: hidden;
 }
 </style>

+ 9 - 3
src/pages/mine/wifi/data.ts

@@ -4,8 +4,14 @@ export const selColumns = [
     {text: '4G', value: '4G'},
 ]
 
+// export const platformColumns = [
+//     {text: '阿里云', value: '1'},
+//     {text: '驼人', value: '2'},
+//     {text: '本地', value: '3'},
+// ]
+
 export const platformColumns = [
-    {text: '1', value: '阿里云'},
-    {text: '2', value: '驼人'},
-    {text: '3', value: '本地'},
+    {text: '阿里云', value: '阿里云'},
+    {text: '驼人', value: '驼人'},
+    {text: '本地', value: '本地'},
 ]