Browse Source

设备详情返回和查询失败处理

jxing 4 years ago
parent
commit
fe3646f762
2 changed files with 303 additions and 183 deletions
  1. 302 182
      src/views/AssetDetail.vue
  2. 1 1
      src/views/overview/index.vue

+ 302 - 182
src/views/AssetDetail.vue

@@ -1,65 +1,121 @@
 <template>
-  <div class='asset-detail' v-show="isFinish >= 2">
-    <van-nav-bar :title="isMaintenanceShow || isRepairShow?'设备详情':'设备信息'" @click-left='backPage' @click-right='handleRightClick'>
+  <div class="asset-detail" v-show="isFinish >= 2">
+    <van-nav-bar
+      :title="isMaintenanceShow || isRepairShow ? '设备详情' : '设备信息'"
+      @click-left="backPage"
+      @click-right="handleRightClick"
+    >
       <template #left>
         <van-icon name="arrow-left" size="18" color="#333333" />
       </template>
       <template #right v-if="active == 1 || active == 2">
-        <i class='iconfont wanda-scan'></i>
+        <i class="iconfont wanda-scan"></i>
       </template>
     </van-nav-bar>
     <div class="asset-information" v-if="!isMaintenanceShow && !isRepairShow">
       <Information :data="informationData" />
     </div>
-    <van-tabs v-else v-model='active' class='other-tabs' color='#025BAA' @change='changeTab' title-active-color='#025BAA'
-      :line-width='60'>
-      <van-tab title='设备信息'>
+    <van-tabs
+      v-else
+      v-model="active"
+      class="other-tabs"
+      color="#025BAA"
+      @change="changeTab"
+      title-active-color="#025BAA"
+      :line-width="60"
+    >
+      <van-tab title="设备信息">
         <Information :data="informationData" />
       </van-tab>
-      <van-tab v-if="isMaintenanceShow" title='重要维保'>
-        <RepairMaintenance ref="maintenance" type="maintenance" :list="maintenanceData" @onSearch="getData" />
+      <van-tab v-if="isMaintenanceShow" title="重要维保">
+        <RepairMaintenance
+          ref="maintenance"
+          type="maintenance"
+          :list="maintenanceData"
+          @onSearch="getData"
+        />
       </van-tab>
-      <van-tab v-if="isRepairShow" title='重要维修'>
-        <RepairMaintenance ref="repair" type="repair" :list="repairData" @onSearch="getData" />
+      <van-tab v-if="isRepairShow" title="重要维修">
+        <RepairMaintenance
+          ref="repair"
+          type="repair"
+          :list="repairData"
+          @onSearch="getData"
+        />
       </van-tab>
     </van-tabs>
 
     <!-- 点击头部筛选,出现的右侧弹窗 -->
-    <van-popup class='m-popup-container' v-model='showPopup' position='right'>
-      <div class='m-popup'>
+    <van-popup class="m-popup-container" v-model="showPopup" position="right">
+      <div class="m-popup">
         <!-- 是否更换配件 -->
-        <div class='system'>
-          <h1 class='title'>是否更换配件</h1>
-          <div class='system-btn-container'>
-            <div class='system-btn' v-for='(item,index) in sfghpjList' :key='index'>
-              <van-button class='m-btn' :class='item.active' @click='isChangeParts(item)'>{{item.text}}</van-button>
+        <div class="system">
+          <h1 class="title">是否更换配件</h1>
+          <div class="system-btn-container">
+            <div
+              class="system-btn"
+              v-for="(item, index) in sfghpjList"
+              :key="index"
+            >
+              <van-button
+                class="m-btn"
+                :class="item.active"
+                @click="isChangeParts(item)"
+                >{{ item.text }}</van-button
+              >
             </div>
           </div>
         </div>
-        <div class='divider'></div>
+        <div class="divider"></div>
         <!-- 填报日期 -->
-        <div class='sbss'>
-          <h1 class='title'>填报日期</h1>
-          <div class='system-btn-container'>
-            <div class='system-btn' v-for='(item,index) in fillinList' :key='index'>
-              <van-button class='m-btn' :class='item.active' @click='changeFillinDate(item)'>{{item.text}}</van-button>
+        <div class="sbss">
+          <h1 class="title">填报日期</h1>
+          <div class="system-btn-container">
+            <div
+              class="system-btn"
+              v-for="(item, index) in fillinList"
+              :key="index"
+            >
+              <van-button
+                class="m-btn"
+                :class="item.active"
+                @click="changeFillinDate(item)"
+                >{{ item.text }}</van-button
+              >
             </div>
           </div>
         </div>
-        <div class='divider'></div>
+        <div class="divider"></div>
         <!-- 验收日期 -->
-        <div class='sbss'>
-          <h1 class='title'>验收日期</h1>
-          <div class='system-btn-container'>
-            <div class='system-btn' v-for='(item,index) in acceptanceList' :key='index'>
-              <van-button class='m-btn' :class='item.active' @click='changeAcceptanceDate(item)'>{{item.text}}
+        <div class="sbss">
+          <h1 class="title">验收日期</h1>
+          <div class="system-btn-container">
+            <div
+              class="system-btn"
+              v-for="(item, index) in acceptanceList"
+              :key="index"
+            >
+              <van-button
+                class="m-btn"
+                :class="item.active"
+                @click="changeAcceptanceDate(item)"
+                >{{ item.text }}
               </van-button>
             </div>
           </div>
         </div>
-        <div class='footer'>
-          <van-button size='large' color='#025BAA' plain type='info' @click='reset'>重置</van-button>
-          <van-button size='large' color='#025BAA' type='info' @click='confirm'>确定</van-button>
+        <div class="footer">
+          <van-button
+            size="large"
+            color="#025BAA"
+            plain
+            type="info"
+            @click="reset"
+            >重置</van-button
+          >
+          <van-button size="large" color="#025BAA" type="info" @click="confirm"
+            >确定</van-button
+          >
         </div>
       </div>
     </van-popup>
@@ -69,21 +125,28 @@
 /**
  * 设备详情
  */
-import Vue from 'vue'
-import { mapGetters } from 'vuex'
-import { NavBar, Tab, Tabs, Popup, Button } from 'vant'
-import Information from "@/components/assetDetail/Information.vue"
-import RepairMaintenance from "@/components/assetDetail/RepairMaintenance.vue"
-import { queryEquipmentList } from '@/api/equipmentList.js'
-import { getUpdateDetail1, getUpdateDetail4 } from '@/api/overview'
-import moment from 'moment'
-Vue.use(NavBar).use(Tab).use(Tabs).use(Popup).use(Button)
+import Vue from "vue";
+import { mapGetters } from "vuex";
+import { NavBar, Tab, Tabs, Popup, Button, Toast } from "vant";
+import Information from "@/components/assetDetail/Information.vue";
+import RepairMaintenance from "@/components/assetDetail/RepairMaintenance.vue";
+import { queryEquipmentList } from "@/api/equipmentList.js";
+import { getUpdateDetail1, getUpdateDetail4 } from "@/api/overview";
+import moment from "moment";
+Vue.use(NavBar).use(Tab).use(Tabs).use(Popup).use(Button).use(Toast);
 export default {
-  name: 'AssetDetail',
+  name: "AssetDetail",
   props: {},
   components: { Information, RepairMaintenance },
   computed: {
-    ...mapGetters(['plazaId', 'fmapID', 'haveFengMap', 'bunkObj', 'floorsArr', 'categoryId']),
+    ...mapGetters([
+      "plazaId",
+      "fmapID",
+      "haveFengMap",
+      "bunkObj",
+      "floorsArr",
+      "categoryId",
+    ]),
   },
   data() {
     return {
@@ -95,71 +158,84 @@ export default {
       maintenanceData: [],
       repairData: [],
       sfghpjList: [
-        { text: '是', value: 1, active: 'active' },
-        { text: '否', value: 0, active: '' },
+        { text: "是", value: 1, active: "active" },
+        { text: "否", value: 0, active: "" },
       ],
       fillinList: [
-        { text: '全部', value: 0, active: 'active' },
-        { text: '7天', value: 1, active: '' },
-        { text: '15天', value: 2, active: '' },
-        { text: '30天', value: 3, active: '' },
-        { text: '6个月', value: 4, active: '' },
-        { text: '1年', value: 5, active: '' }
+        { text: "全部", value: 0, active: "active" },
+        { text: "7天", value: 1, active: "" },
+        { text: "15天", value: 2, active: "" },
+        { text: "30天", value: 3, active: "" },
+        { text: "6个月", value: 4, active: "" },
+        { text: "1年", value: 5, active: "" },
       ],
       acceptanceList: [
-        { text: '全部', value: 0, active: 'active' },
-        { text: '7天', value: 1, active: '' },
-        { text: '15天', value: 2, active: '' },
-        { text: '30天', value: 3, active: '' },
-        { text: '6个月', value: 4, active: '' },
-        { text: '1年', value: 5, active: '' }
+        { text: "全部", value: 0, active: "active" },
+        { text: "7天", value: 1, active: "" },
+        { text: "15天", value: 2, active: "" },
+        { text: "30天", value: 3, active: "" },
+        { text: "6个月", value: 4, active: "" },
+        { text: "1年", value: 5, active: "" },
       ],
       isFinish: 0,
       isParts: 1,
       fillinDate: 0,
-      acceptanceDate: 0
-    }
+      acceptanceDate: 0,
+    };
   },
   props: {},
-  beforeMount() { },
-  mounted() {
-
-  },
+  beforeMount() {},
+  mounted() {},
   methods: {
     backPage() {
-      this.$router.go(-1)
+      if (this.$route.query.first) {
+        this.$router.push({ path: "/" });
+      } else {
+        this.$router.go(-1);
+      }
     },
     /**
      * 点击右侧筛选
      */
     handleRightClick() {
-      this.showPopup = true
+      this.showPopup = true;
     },
     changeTab(active) {
-      console.log(this.active)
+      console.log(this.active);
     },
     // 查询设备信息/维修/维保数据
     getData() {
-      if (this.active === 1) {//维保
+      if (this.active === 1) {
+        //维保
         this.getMaintenanceData();
-      } else if (this.active === 2) {//维修
+      } else if (this.active === 2) {
+        //维修
         this.getRepairData();
       }
     },
     // 查询设备信息数据
     getInformationData() {
       let data = {
-        plazaId: this.plazaId,
-        keyword: `${this.$route.query.assetid}:assetid;`
-      },
-        postParams = {}
-      queryEquipmentList({ data, postParams }).then(res => {
+          plazaId: this.plazaId,
+          keyword: `${this.$route.query.assetid}:assetid;`,
+        },
+        postParams = {};
+      queryEquipmentList({ data, postParams }).then((res) => {
         if (res.data.result == "success" && res.data.data && res.data.data[0]) {
           this.informationData = res.data.data[0];
           this.getMaintenanceData(true);
           this.getRepairData(true);
+        } else {
+          Toast({
+            message: "未查询到该设备内容!",
+            type: "fail",
+            duration: 1000,
+            onClose: () => {
+              this.$router.push({ path: "/" });
+            }
+          });
         }
-      })
+      });
     },
     // 查询维保数据
     getMaintenanceData(first) {
@@ -169,86 +245,108 @@ export default {
           plazaId: this.plazaId,
           onlyMainAsset: false, //仅查询重要维修/维保
           ismodel: this.isParts, //是否更换配件
-        }
+        };
         //查询关键字(重要事项记录)
         if (this.$refs.maintenance && this.$refs.maintenance.keyword) {
-          getParams.keyword = `${this.$refs.maintenance.keyword}:matters`
+          getParams.keyword = `${this.$refs.maintenance.keyword}:matters`;
         }
         //填报日期
         switch (this.fillinDate) {
           // 七天
           case 1:
-            getParams.reportdateStartDate = moment().subtract(7, 'days').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(7, "days")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 15天
           case 2:
-            getParams.reportdateStartDate = moment().subtract(15, 'days').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(15, "days")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 30天
           case 3:
-            getParams.reportdateStartDate = moment().subtract(1, 'months').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(1, "months")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 6个月
           case 4:
-            getParams.reportdateStartDate = moment().subtract(6, 'years').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(6, "years")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 一年
           case 5:
-            getParams.reportdateStartDate = moment().subtract(1, 'years').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(1, "years")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 默认 全部
           default:
-            break
+            break;
         }
         //验收日期
         switch (this.acceptanceDate) {
           // 七天
           case 1:
-            getParams.sjjssjStartDate = moment().subtract(7, 'days').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(7, "days")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 15天
           case 2:
-            getParams.sjjssjStartDate = moment().subtract(15, 'days').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(15, "days")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 30天
           case 3:
-            getParams.sjjssjStartDate = moment().subtract(1, 'months').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(1, "months")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 6个月
           case 4:
-            getParams.sjjssjStartDate = moment().subtract(6, 'years').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(6, "years")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 一年
           case 5:
-            getParams.sjjssjStartDate = moment().subtract(1, 'years').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(1, "years")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 默认 全部
           default:
-            break
+            break;
         }
-        getUpdateDetail1({ getParams }).then(res => {
+        getUpdateDetail1({ getParams }).then((res) => {
           if (res.data && res.data.length) {
-            this.maintenanceData = res.data
+            this.maintenanceData = res.data;
           } else {
-            this.maintenanceData = []
+            this.maintenanceData = [];
+          }
+          if (first) {
+            this.isFinish++;
           }
-          if (first) { this.isFinish++ }
           if (first && !this.maintenanceData.length) {
-            this.isMaintenanceShow = false
+            this.isMaintenanceShow = false;
           }
-        })
+        });
       } else {
-        console.error("缺少设备编号!")
+        console.error("缺少设备编号!");
       }
     },
     // 查询维修数据
@@ -259,146 +357,168 @@ export default {
           plazaId: this.plazaId,
           onlyMainAsset: false, //仅查询重要维修/维保
           ismodel: this.isParts, //是否更换配件
-        }
+        };
         //查询关键字(重要事项记录)
         if (this.$refs.repair && this.$refs.repair.keyword) {
-          getParams.keyword = `${this.$refs.repair.keyword}:matters`
+          getParams.keyword = `${this.$refs.repair.keyword}:matters`;
         }
         //填报日期
         switch (this.fillinDate) {
           // 七天
           case 1:
-            getParams.reportdateStartDate = moment().subtract(7, 'days').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(7, "days")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 15天
           case 2:
-            getParams.reportdateStartDate = moment().subtract(15, 'days').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(15, "days")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 30天
           case 3:
-            getParams.reportdateStartDate = moment().subtract(1, 'months').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(1, "months")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 6个月
           case 4:
-            getParams.reportdateStartDate = moment().subtract(6, 'years').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(6, "years")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 一年
           case 5:
-            getParams.reportdateStartDate = moment().subtract(1, 'years').format('YYYYMMDD000000')
-            getParams.reportdateEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.reportdateStartDate = moment()
+              .subtract(1, "years")
+              .format("YYYYMMDD000000");
+            getParams.reportdateEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 默认 全部
           default:
-            break
+            break;
         }
         //验收日期
         switch (this.acceptanceDate) {
           // 七天
           case 1:
-            getParams.sjjssjStartDate = moment().subtract(7, 'days').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(7, "days")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 15天
           case 2:
-            getParams.sjjssjStartDate = moment().subtract(15, 'days').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(15, "days")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 30天
           case 3:
-            getParams.sjjssjStartDate = moment().subtract(1, 'months').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(1, "months")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 6个月
           case 4:
-            getParams.sjjssjStartDate = moment().subtract(6, 'years').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(6, "years")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 一年
           case 5:
-            getParams.sjjssjStartDate = moment().subtract(1, 'years').format('YYYYMMDD000000')
-            getParams.sjjssjEndDate = moment().format('YYYYMMDD000000')
-            break
+            getParams.sjjssjStartDate = moment()
+              .subtract(1, "years")
+              .format("YYYYMMDD000000");
+            getParams.sjjssjEndDate = moment().format("YYYYMMDD000000");
+            break;
           // 默认 全部
           default:
-            break
+            break;
         }
-        getUpdateDetail4({ getParams }).then(res => {
+        getUpdateDetail4({ getParams }).then((res) => {
           if (res.data && res.data.length) {
-            this.repairData = res.data
+            this.repairData = res.data;
           } else {
-            this.repairData = []
+            this.repairData = [];
+          }
+          if (first) {
+            this.isFinish++;
           }
-          if (first) { this.isFinish++ }
           if (first && !this.repairData.length) {
-            this.isRepairShow = false
+            this.isRepairShow = false;
           }
-        })
+        });
       } else {
-        console.error("缺少设备编号!")
+        console.error("缺少设备编号!");
       }
     },
     // 修改是否更换配件
     isChangeParts(data) {
-      console.log(data)
+      console.log(data);
       this.isParts = data.value;
       this.sfghpjList.map((item) => {
-        item.active = ''
+        item.active = "";
         if (item.value === data.value) {
-          item.active = 'active'
+          item.active = "active";
         }
-      })
+      });
     },
     // 修改填报日期
     changeFillinDate(data) {
-      console.log(data)
+      console.log(data);
       this.fillinDate = data.value;
       this.fillinList.map((item) => {
-        item.active = ''
+        item.active = "";
         if (item.value === data.value) {
-          item.active = 'active'
+          item.active = "active";
         }
-      })
+      });
     },
     // 修改验收日期
     changeAcceptanceDate(data) {
-      console.log(data)
+      console.log(data);
       this.acceptanceDate = data.value;
       this.acceptanceList.map((item) => {
-        item.active = ''
+        item.active = "";
         if (item.value === data.value) {
-          item.active = 'active'
+          item.active = "active";
         }
-      })
+      });
     },
     /**
      * 重置
      */
     reset() {
       this.sfghpjList.map((item, index) => {
-        item.active = '';
+        item.active = "";
         if (index === 0) {
-          item.active = 'active';
+          item.active = "active";
           this.isParts = item.value;
         }
-      })
+      });
       this.fillinList.map((item, index) => {
-        item.active = '';
+        item.active = "";
         if (index === 0) {
-          item.active = 'active';
+          item.active = "active";
           this.fillinDate = item.value;
         }
-      })
+      });
       this.acceptanceList.map((item, index) => {
-        item.active = '';
+        item.active = "";
         if (index === 0) {
-          item.active = 'active';
+          item.active = "active";
           this.acceptanceDate = item.value;
         }
-      })
+      });
       this.getData();
       this.showPopup = false;
     },
@@ -411,17 +531,17 @@ export default {
     },
   },
   watch: {
-    '$route.query.assetid': {
+    "$route.query.assetid": {
       handler(assetid) {
         if (assetid) {
-          this.getInformationData()
+          this.getInformationData();
         }
       },
       immediate: true,
-      deep: true
-    }
+      deep: true,
+    },
   },
-}
+};
 </script>
 <style lang='less' scoped>
 .asset-detail {

+ 1 - 1
src/views/overview/index.vue

@@ -422,7 +422,7 @@ export default {
                     margin-top: 12px;
                     display: flex;
                     .left {
-                        width: 75spx;
+                        width: 75px;
                         color: #666;
                         font-size: 14px;
                     }