dedsudiyu 2 days ago
parent
commit
da63d48545

+ 49 - 0
src/api/utilsIndex.js

@@ -0,0 +1,49 @@
+import axios from 'axios'
+import { judgmentNetworkReturnAddress } from "@/utils/index";
+import md5 from "js-md5";
+
+//判定http或者https
+let urlText = window.location.href.split('://')[0]+'://';
+let specialDeviceUrl = urlText+'gzu.zjznai.com/specialdevice/api/internal/specialdevice/summary';
+let chemicalsUrl = urlText+'gzu.zjznai.com/chempurchase/api/internal/chemicals/inventory-summary';
+// let specialDeviceUrl = urlText+'lab.jftio.com/specialdevice/api/internal/specialdevice/summary';
+// let chemicalsUrl = urlText+'gzu.zjznai.com/chempurchase/api/internal/chemicals/inventory-summary';
+
+// let serviceKEY = 'd7355222c8ac972b06a23d4bd219bc03fcb12ea2ec700a1ad0932428edb5cd35'
+let serviceKEY = 'e87492df8710ff5b916021537e72fc0e8db092422b13d1998d299cc32d91df2c'
+
+
+// 创建专用 axios 实例(不带 Authorization,使用服务密钥鉴权)
+const serviceRequest = axios.create({ timeout: 15000 });
+
+/**
+ * 获取化学品库存汇总
+ * @param {string|number} [deptId] 学院ID,不传查全校
+ */
+export function getChemicalsInventorySummary(deptId) {
+  const params = {};
+  if (deptId) params.deptId = String(deptId);
+  return serviceRequest.get(chemicalsUrl, {
+    params,
+    headers: {
+      'X-Tenant-Id': '0',
+      'X-Service-Key': serviceKEY,
+    },
+  }).then(res => res.data);
+}
+
+/**
+ * 获取特种设备统计汇总
+ * @param {string} [deptName] 学院名称,不传查全校
+ */
+export function getSpecialDeviceSummary(deptName) {
+  const params = {};
+  if (deptName) params.deptName = deptName;
+  return serviceRequest.get(specialDeviceUrl, {
+    params,
+    headers: {
+      'X-Tenant-Id': '0',
+      'X-Service-Key': serviceKEY,
+    },
+  }).then(res => res.data);
+}

+ 8 - 6
src/components/LabStats/ChemicalsStats.vue

@@ -75,6 +75,7 @@
 
 <script>
 import { getChemicalStats } from '@/api'
+import { getChemicalsInventorySummary } from '@/api/utilsIndex'
 
 export default {
   name: 'ChemicalsStats',
@@ -104,15 +105,16 @@ export default {
     },
     async loadData() {
       try {
-        const d = await getChemicalStats()
+        // const d = await getChemicalStats()
+        const d = await getChemicalsInventorySummary()
         this.stats = {
-          totalAmount: d.totalSurplus || 0,
+          totalAmount: d.totalQuantityL || 0,
           unit: d.totalUnit || 'L',
-          controlledAmount: d.controlledSurplus || 0,
-          uncontrolledAmount: d.uncontrolledSurplus || 0,
+          controlledAmount: d.controlledQuantityL || 0,
+          uncontrolledAmount: d.uncontrolledQuantityL || 0,
           totalCategories: d.totalCategoryCount || 0,
-          controlledCategories: d.controlledCategoryCount || 0,
-          uncontrolledCategories: d.uncontrolledCategoryCount || 0
+          controlledCategories: d.controlledSpeciesCount || 0,
+          uncontrolledCategories: d.uncontrolledSpeciesCount || 0
         }
         this.controlledPct = d.controlledPercent || 0
         this.uncontrolledPct = d.uncontrolledPercent || 0

+ 26 - 7
src/components/LabStats/EquipmentStats.vue

@@ -21,7 +21,7 @@
           <div class="em-label">射线设备</div>
         </div>
         <div class="equip-mid-item">
-          <div class="em-value">{{ summary.usageRate }}<span class="em-unit"></span></div>
+          <div class="em-value">{{ summary.craneCount }}<span class="em-unit"></span></div>
           <div class="em-label">行车</div>
         </div>
       </div>
@@ -38,6 +38,7 @@
 <script>
 import * as echarts from 'echarts'
 import { getEquipmentStats } from '@/api'
+import { getSpecialDeviceSummary } from '@/api/utilsIndex'
 
 export default {
   name: 'EquipmentStats',
@@ -60,13 +61,31 @@ export default {
   methods: {
     async loadData() {
       try {
-        const res = await getEquipmentStats()
-        this.summary = res.data.summary
-        this.status = res.data.status
+        // const res = await getEquipmentStats()
+        const res = await getSpecialDeviceSummary()
+        // this.summary = res.data.summary
+        // this.status = res.data.status
+        this.summary = {
+          totalDevices:res.data.total,
+          totalHours:res.data.pressureVesselCount,
+          usageRate:res.data.radiationCount,
+          craneCount:res.data.craneCount,
+        }
+        this.status = {
+          idle:res.data.inspectedCount,
+          normal:res.data.dueSoonCount,
+          repair:res.data.overdueCount,
+        }
+        let list = [
+          {name:'压力容器', value:res.data.pressureVesselCount?res.data.pressureVesselCount:0},
+          {name:'射线设备', value:res.data.radiationCount?res.data.radiationCount:0},
+          {name:'行车', value:res.data.craneCount?res.data.craneCount:0},
+        ];
         if (this.chart) {
-          this.chart.setOption({ series: [{ data: res.data.categories.map(c => ({ name: c.name, value: c.value, itemStyle: { color: c.color } })) }] })
+          // this.chart.setOption({ series: [{ data: list.map(c => ({ name: c.name, value: c.value, itemStyle: { color: c.color } })) }] })
+          this.chart.setOption({ series: [{ data: list.map(c => ({ name: c.name, value: c.value, })) }] })
         } else {
-          this.$nextTick(() => this.initChart(res.data.categories))
+          this.$nextTick(() => this.initChart(list))
         }
       } catch (e) {
         console.error('EquipmentStats:', e)
@@ -98,7 +117,7 @@ export default {
           data: categories.map(c => ({
             name: c.name,
             value: c.value,
-            itemStyle: { color: c.color }
+            // itemStyle: { color: c.color }
           }))
         }]
       }