695593266@qq.com 10 месяцев назад
Родитель
Сommit
b67000a1be

+ 9 - 0
src/api/ledgerAssets/equipment.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request';
+
+export async function getRealData(id) {
+  const res = await request.get(`/main/asset/getRealData/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 3 - 1
src/main.js

@@ -25,13 +25,14 @@ import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
 import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
 import seekPage from '@/components/seekPage';
 import fileMain from '@/components/addDoc/index.vue';
+import * as echarts from 'echarts';
 
 // // register globally
 import '@/icons';
 Vue.component('seekPage', seekPage);
 
 Vue.component('DictSelection', DictSelection);
-  Vue.component('fileMain', fileMain);
+Vue.component('fileMain', fileMain);
 Vue.config.productionTip = false;
 
 Vue.use(EleAdmin, {
@@ -44,6 +45,7 @@ Vue.use(EleAdmin, {
 });
 Vue.use(permission);
 Vue.use(VueClipboard);
+Vue.prototype.$echarts = echarts;
 
 let instance = null;
 

+ 42 - 10
src/views/ledgerAssets/components/details/InternetExtruder/InternetExtruder.vue

@@ -37,13 +37,21 @@
         </el-form>
       </div>
     </div>
-    <chart_temp :id="info.id"></chart_temp>
+    <!-- <chart_temp :id="info.id"></chart_temp>
     <chart_speed :id="info.id"></chart_speed>
     <chart_pressure :id="info.id"></chart_pressure>
     <runningDialog
       ref="runningDialog"
       :id="info.id"
       @succeed="getRealData"
+    ></runningDialog> -->
+    <chart_temp :id="id"></chart_temp>
+    <chart_speed :id="id"></chart_speed>
+    <chart_pressure :id="id"></chart_pressure>
+    <runningDialog
+      ref="runningDialog"
+      :id="id"
+      @succeed="getRealData"
     ></runningDialog>
   </div>
 </template>
@@ -53,15 +61,19 @@
   import chart_speed from './components/chart_speed.vue';
   import chart_temp from './components/chart_temp.vue';
   import runningDialog from '../components/runningDialog.vue';
-  // import { getRealData } from '@/api/ledgerAssets/equipment.js';
+  import { getRealData } from '@/api/ledgerAssets/equipment.js';
   // import mqtt from '../mixins/mqtt.js';
   // import { debounce } from 'lodash';
   export default {
     // mixins: [mqtt],
     props: {
-      info: {
-        type: Object,
-        default: {}
+      // info: {
+      //   type: Object,
+      //   default: {}
+      // },
+      id: {
+        type: String,
+        default: ''
       }
     },
     components: {
@@ -92,9 +104,17 @@
     computed: {
       // mqtt topic
       TOPIC() {
-        if (this.info.iotId) {
+        // if (this.info.iotId) {
+        //   return {
+        //     topic: `/${this.topIc_type}/${this.info.iotId}`,
+        //     qos: 0
+        //   };
+        // } else {
+        //   return null;
+        // }
+        if (this.id) {
           return {
-            topic: `/${this.topIc_type}/${this.info.iotId}`,
+            topic: `/${this.topIc_type}/${this.id}`,
             qos: 0
           };
         } else {
@@ -105,7 +125,7 @@
     created() {
       this.getRealData();
       if (this.TOPIC) {
-        this.mqttInit();
+        // this.mqttInit();
       }
     },
     methods: {
@@ -350,12 +370,24 @@
       async getRealData() {
         // await getRealData(this.info.id).then((res) => {
         //   let data = res.data;
-        //   console.log("实时数据", data);
+        //   console.log('实时数据', data);
         //   for (const item of data) {
         //     this.$set(this.realData, item.identifier, item);
         //   }
         // });
-        this.initGauge();
+        await getRealData(this.id).then((res) => {
+          let data = res;
+          console.log('实时数据', data);
+          for (const item of data) {
+            this.$set(this.realData, item.identifier, item);
+          }
+        });
+
+        setTimeout(() => {
+          this.$nextTick(() => {
+            this.initGauge();
+          });
+        }, 3000);
       },
       //  mqtt处理数据
       initMqttData(items) {

+ 19 - 19
src/views/ledgerAssets/components/details/InternetOther/index.vue

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-  // import { getRealData } from '@/api/ledgerAssets/equipment.js';
+  import { getRealData } from '@/api/ledgerAssets/equipment.js';
   import runningDialog from '../components/runningDialog.vue';
   export default {
     props: ['id'],
@@ -71,24 +71,24 @@
     methods: {
       // 请求实时数据
       async getRealData() {
-        // await getRealData(this.id).then(res => {
-        //   let order = [
-        //     'temp',
-        //     'o_temp',
-        //     'temp1',
-        //     'temp2',
-        //     'temp3',
-        //     'temp4',
-        //     'running_time',
-        //     'remain_time'
-        //   ]
-        //   let data = res.data.sort((a, b) => {
-        //     return order.indexOf(a.identifier) - order.indexOf(b.identifier)
-        //   })
-        //   for (const item of data) {
-        //     this.$set(this.realData, item.identifier, item)
-        //   }
-        // })
+        await getRealData(this.id).then(res => {
+          let order = [
+            'temp',
+            'o_temp',
+            'temp1',
+            'temp2',
+            'temp3',
+            'temp4',
+            'running_time',
+            'remain_time'
+          ]
+          let data = res.data.sort((a, b) => {
+            return order.indexOf(a.identifier) - order.indexOf(b.identifier)
+          })
+          for (const item of data) {
+            this.$set(this.realData, item.identifier, item)
+          }
+        })
       },
 
       handlsz() {

+ 15 - 13
src/views/ledgerAssets/components/details/internet.vue

@@ -7,11 +7,12 @@
       </div>
     </div>
     <!-- 挤压机 65 -->
-    <InternetExtruder :info="info" v-if="parentClassId == '65'" />
+    <!-- <InternetExtruder :info="info" v-if="parentClassId == '65'" /> -->
+    <InternetExtruder :id="id" />
     <!-- 干燥箱 57 -->
-    <InternetDryingBox :info="info" v-else-if="parentClassId == '57'" />
+    <!-- <InternetDryingBox :info="info" v-else-if="parentClassId == '57'" /> -->
     <!-- 其他设备 -->
-    <InternetOther v-else :id="id"></InternetOther>
+    <!-- <InternetOther v-else :id="id"></InternetOther> -->
   </div>
 </template>
 
@@ -19,7 +20,7 @@
   import InternetExtruder from './InternetExtruder/InternetExtruder';
   import InternetDryingBox from './InternetDryingBox/InternetDryingBox';
   import InternetOther from './InternetOther';
-  // import { getDetail } from '@/api/ledgerAssets/equipment';
+  import { getDetail } from '@/api/ledgerAssets/equipment';
   export default {
     props: ['id'],
     components: { InternetExtruder, InternetDryingBox, InternetOther },
@@ -34,18 +35,19 @@
       };
     },
     created() {
-      this.getInfo();
+      // this.getInfo();
     },
     methods: {
       getInfo() {
-        // getDetail({
-        //   id: this.id
-        // }).then((res) => {
-        //   this.info = res.data;
-        //   this.parentClassId = this.setParentClassId(
-        //     this.info.information.classificationUrlId
-        //   );
-        // });
+        console.log('id', this.id);
+        getDetail({
+          id: this.id
+        }).then((res) => {
+          this.info = res.data;
+          this.parentClassId = this.setParentClassId(
+            this.info.information.classificationUrlId
+          );
+        });
       },
       // 获取父类id
       setParentClassId(val) {

+ 2 - 1
vue.config.js

@@ -35,7 +35,8 @@ module.exports = {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.139:18086', // 粟
         // target: 'http://192.168.1.132:18086', // 徐
-        target: 'http://192.168.1.125:18086', //本
+        // target: 'http://192.168.1.125:18086', //本
+        target: 'http://192.168.1.25:18086',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''