From eb967d7573a8297e493d455dfce2c77319215990 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期三, 13 九月 2023 08:31:25 +0800
Subject: [PATCH] 注册页面中英文替换  修改电气管理顶部导航栏布局

---
 CanadaMes-ui/src/views/Electrical/alarm.vue |  147 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 97 insertions(+), 50 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/alarm.vue b/CanadaMes-ui/src/views/Electrical/alarm.vue
index 403bec5..946a1e2 100644
--- a/CanadaMes-ui/src/views/Electrical/alarm.vue
+++ b/CanadaMes-ui/src/views/Electrical/alarm.vue
@@ -2,23 +2,27 @@
   <div class="app">
     <!--闈㈠寘灞戝鑸尯鍩�-->
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
-      <router-link to="/home" tag="el-button" type="text">{{ $t('langHome') }}</router-link>
-      <el-button type="text">Electrical</el-button>
-      <router-link to="/Electrical/Parameter" tag="el-button" type="text">Parameter</router-link>
-      <router-link to="/Electrical/Action" tag="el-button" type="text">Action</router-link>
-      <router-link to="/Electrical/Sign" tag="el-button" type="text">Sign</router-link>
-      <router-link to="/Electrical/State" tag="el-button" type="text">State</router-link>
-      <router-link to="/Electrical/alarm" tag="el-button" type="text">Alarm</router-link>
+      <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') }}</router-link>
+    <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link>
+    <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') }}</router-link>
+    <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link>
+    <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') }}</router-link>
     </el-breadcrumb>
     <div>Alarm</div>
-    <!-- <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="{ messagepack }">
-        <div class="kuai_div" v-for="item in this.record.xyData" :key="item[1]">
-          <el-input v-model="item[1]" style="width: 240px;" class="in_mc"></el-input>
-          <el-switch v-model="item[0]" active-value="0" inactive-value="1"></el-switch>
-        </div>
-      </el-form> -->
+    <div class="block">
+      <span class="demonstration">鏃堕棿锛�</span>
+      <el-date-picker v-model="shijian1" type="datetime" placeholder="閫夋嫨鏃ユ湡鏃堕棿" align="right"
+        :picker-options="pickerOptions">
+      </el-date-picker>
+      ~
+      <el-date-picker v-model="shijian2" type="datetime" placeholder="閫夋嫨鏃ユ湡鏃堕棿" align="right"
+        :picker-options="pickerOptions">
+      </el-date-picker>
+      &nbsp;&nbsp;
+      <el-button type="primary" @click="selectTime()">{{ $t('Search') }}</el-button>
+    </div>
 
-    <el-table :data="localizedRoles" style="width: 100%;" height="590">
+    <el-table :data="localizedRoles" style="width: 100%;" height="550">
       <el-table-column prop="id" label="id" width="80">
       </el-table-column>
       <el-table-column prop="content" label="content">
@@ -32,7 +36,10 @@
 </template>
 
 <script >
-import { setAll } from "../../api/alarm";
+import { setAll, setTime } from "../../api/alarm";
+
+import moment from 'moment';
+//setTime
 import LanguageMixin from '../../lang/LanguageMixin'
 let socket;
 export default {
@@ -40,6 +47,7 @@
   mixins: [LanguageMixin],
   data () {
     return {
+      activeButton: '',
       record: {
         params: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 
@@ -47,11 +55,9 @@
 
       },
       roles: [],
-<<<<<<< HEAD
-      localizedRoles:[],
-=======
+
       localizedRoles: [],
->>>>>>> 36acd690614dd276428530a59f448c543bac52d4
+
       messagepack: {
         data: { taskname: "" }
       },
@@ -59,36 +65,57 @@
         data: "1",
         pageSize: 10
       },
+      pickerOptions: {
+        shortcuts: [{
+          text: '浠婂ぉ',
+          onClick (picker) {
+            picker.$emit('pick', new Date());
+          }
+        }, {
+          text: '鏄ㄥぉ',
+          onClick (picker) {
+            const date = new Date();
+            date.setTime(date.getTime() - 3600 * 1000 * 24);
+            picker.$emit('pick', date);
+          }
+        }, {
+          text: '涓�鍛ㄥ墠',
+          onClick (picker) {
+            const date = new Date();
+            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
+            picker.$emit('pick', date);
+          }
+        }],
 
+      },
+      shijian1: "",
+      shijian2: "",
     }
+
+
   },
   created () {
     this.init();
-    this.load();
+
+
+    if (this.shijian1 == "" || this.shijian2 == "") {
+      //鏌ヨ褰撳ぉ鎶ヨ淇℃伅
+      this.load();
+    }
+    else {
+      //鏍规嵁鏃堕棿鏌ヨ鎶ヨ淇℃伅
+      this.selectTime();
+    }
 
   },
   methods: {
-<<<<<<< HEAD
-    load() {
-  setAll().then(res => {
-    this.roles = res.data.list;
-    const language = this.$i18n.locale;
-    if (language === 'zh-CN') {
-      this.replaceChineseWithEnglish();
-    } else {
-      this.localizedRoles = [...this.roles];
-    }
-    console.log(this.localizedRoles);
-  });
-},
-replaceChineseWithEnglish() {
-  const translation = this.$t('translation');
-  this.localizedRoles = this.roles.map(role => ({
-    ...role,
-    content: translation[role.content] || role.content
-  }));
-},
-=======
+    onButtonClick() {
+      this.isButtonClicked = true; // 灏嗘寜閽鑹茶缃负钃濊壊
+      setTimeout(() => {
+        this.isButtonClicked = false; // 閲嶇疆鎸夐挳棰滆壊
+      }, 500); // 杩欓噷鐨�500姣鏄牴鎹偍甯屾湜鎸夐挳棰滆壊鎸佺画澶氶暱鏃堕棿鏉ュ畾鐨勶紝鍙互鏍规嵁闇�姹傝繘琛岃皟鏁�
+    },
+
     load () {
       setAll().then(res => {
         this.roles = res.data.list;
@@ -98,9 +125,27 @@
         } else {
           this.localizedRoles = [...this.roles];
         }
-        console.log(this.localizedRoles);
+        //console.log(this.localizedRoles);
+      });
+
+    },
+    selectTime () {
+      //moment闇�瑕佸崟鐙畨杞緷璧栵紝npm install moment
+      let sj1 = moment(this.shijian1).format('YYYY-MM-DD%20HH:mm');
+      let sj2 = moment(this.shijian2).format('YYYY-MM-DD%20HH:mm')
+      //璋冪敤setTime鏂规硶缁檙oles璧嬪��
+      setTime(sj1, sj2).then(res => {
+        this.roles = res.data.list;
+        //table涓殑鍐呭杩涜璇█杞崲
+        const language = this.$i18n.locale;
+        if (language === 'zh-CN') {
+          this.replaceChineseWithEnglish();
+        } else {
+          this.localizedRoles = [...this.roles];
+        }
       });
     },
+    //璇█杞崲
     replaceChineseWithEnglish () {
       const translation = this.$t('translation');
       this.localizedRoles = this.roles.map(role => ({
@@ -108,7 +153,7 @@
         content: translation[role.content] || role.content
       }));
     },
->>>>>>> 36acd690614dd276428530a59f448c543bac52d4
+
     init () {
       let viewname = "alarm";
 
@@ -130,13 +175,16 @@
         };
         //  娴忚鍣ㄧ鏀舵秷鎭紝鑾峰緱浠庢湇鍔$鍙戦�佽繃鏉ョ殑鏂囨湰娑堟伅
         socket.onmessage = function (msg) {
-
-          //console.log("鏀跺埌鏁版嵁====" + msg.data);
           let obj = JSON.parse(msg.data);
 
           this.record.params[0] = obj.arm;
           //姣忔璇锋眰鏇存柊鏁版嵁
-          this.load();
+          if (this.shijian1 == "" || this.shijian2 == "") {
+            this.load();
+          }
+          else {
+            this.selectTime();
+          }
           this.$forceUpdate();
         }.bind(this);
         //鍏抽棴浜嬩欢
@@ -150,10 +198,6 @@
       }
 
     },
-    send () {
-      this.messagepack.data = { taskname: "鍓嶇鍒板悗鍙�" };
-      socket?.send(JSON.stringify(this.messagepack));  // 灏嗙粍瑁呭ソ鐨刯son鍙戦�佺粰鏈嶅姟绔紝鐢辨湇鍔$杩涜杞彂
-    }
 
   }
 
@@ -193,4 +237,7 @@
 th div {
   text-align: center;
 }
+.blue-button {
+  background-color: skyblue;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0