From 5741383ca0a6b2ecf84980eb7f44164a56483bc8 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期三, 06 九月 2023 16:52:18 +0800
Subject: [PATCH] 1、增加 vuex 路由标签切换 ,并且保留页面数据 2、PlcParameter.java Plcaction.java 增加读写分开 , 睡眠间隔时间不同 3、增加权限列表中英文json 以及提示框、弹窗等
---
CanadaMes-ui/src/views/role/index.vue | 28 +
CanadaMes-ui/src/store/index.js | 24 +
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java | 12
CanadaMes-ui/src/views/Electrical/Parameter.vue | 91 ++--
CanadaMes-ui/src/views/power/index.vue | 64 +-
CanadaMes-ui/src/views/user/index.vue | 7
CanadaMes-ui/src/layout/tag.vue | 93 ++--
CanadaMes-ui/src/layout/index.vue | 265 ++++++--------
CanadaMes-ui/src/lang/locales/zh-CN.json | 54 ++
CanadaMes-ui/run.bat | 5
CanadaMes-ui/src/store/module/tags.js | 21
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java | 82 ++++
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | 6
CanadaMes-ui/src/views/Electrical/Action.vue | 105 +++--
CanadaMes-ui/src/lang/locales/en-US.json | 54 ++
springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java | 2
springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java | 129 ++++--
17 files changed, 664 insertions(+), 378 deletions(-)
diff --git a/CanadaMes-ui/run.bat b/CanadaMes-ui/run.bat
new file mode 100644
index 0000000..f2d44dc
--- /dev/null
+++ b/CanadaMes-ui/run.bat
@@ -0,0 +1,5 @@
+@echo off
+echo Starting frontend development server...
+cd /d %~dp0 // 鍒囨崲鍒板綋鍓嶆壒澶勭悊鑴氭湰鎵�鍦ㄧ殑鐩綍
+cd ..\CanadaMes-ui // 鍋囪CanadaMes-ui鍦ㄤ笌鎵瑰鐞嗚剼鏈浉鍚岀殑鐩綍涓�
+npm run serve
\ No newline at end of file
diff --git a/CanadaMes-ui/src/lang/locales/en-US.json b/CanadaMes-ui/src/lang/locales/en-US.json
index 3ae9217..c91ba66 100644
--- a/CanadaMes-ui/src/lang/locales/en-US.json
+++ b/CanadaMes-ui/src/lang/locales/en-US.json
@@ -69,5 +69,57 @@
"paginationPrev": "Previous",
"paginationPager": "{currentPage}/{pageCount}",
"paginationNext": "Next",
- "paginationJumper": "Jump to"
+ "paginationJumper": "Jump to",
+ "breadcrumb": {
+ "home": "Home",
+ "permissionManagement": "Permission Management",
+ "permissionList": "Permission List"
+ },
+ "search": {
+ "placeholder": "Enter keywords"
+ },
+ "button": {
+ "addPermission": "Add Permission",
+ "cancel": "Cancel",
+ "confirm": "Confirm"
+ },
+ "table": {
+ "role": "Role",
+ "permissionDescription": "Permission Description",
+ "permissionValue": "Permission Value",
+ "createTime": "Create Time",
+ "isActive": "Is Active",
+ "operation": "Operation"
+ },
+ "tooltip": {
+ "edit": "Edit",
+ "delete": "Delete"
+ },
+ "dialog": {
+ "addPermission": "Add Permission",
+ "editPermission": "Edit Permission"
+ },
+ "form": {
+ "role": "Role",
+ "select": "Please Select",
+ "permission": "Permission",
+ "isActive": "Is Active"
+ },
+ "鎿嶄綔": "Operation",
+ "鏈夋晥": "Valid",
+ "鏃犳晥": "Invalid",
+ "璇疯緭鍏ュ悕绉�": "Please enter a name",
+ "闀垮害鍦� 2 鍒� 15 涓瓧绗�": "Length between 2 and 15 characters",
+ "璇疯緭鍏ョ姸鎬�": "Please enter the status",
+ "娣诲姞瑙掕壊": "Add Role",
+ "淇敼瑙掕壊": "Edit Role",
+ "鍒犻櫎瑙掕壊": "Delete Role",
+ "姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?": "This operation will permanently delete the role. Continue?",
+ "鎻愮ず": "Reminder",
+ "纭畾": "Confirm",
+ "鍙栨秷": "Cancel",
+ "娣诲姞瑙掕壊鎴愬姛": "Successfully added role",
+ "鏇存柊鐘舵�佹垚鍔�": "Successfully updated status",
+ "淇敼瑙掕壊鎴愬姛": "Successfully modified role",
+ "鍒犻櫎瑙掕壊鎴愬姛": "Successfully deleted role"
}
\ No newline at end of file
diff --git a/CanadaMes-ui/src/lang/locales/zh-CN.json b/CanadaMes-ui/src/lang/locales/zh-CN.json
index be273d6..7d56999 100644
--- a/CanadaMes-ui/src/lang/locales/zh-CN.json
+++ b/CanadaMes-ui/src/lang/locales/zh-CN.json
@@ -72,6 +72,58 @@
"paginationPrev": "涓婁竴椤�",
"paginationPager": "{currentPage}/{pageCount}",
"paginationNext": "涓嬩竴椤�",
- "paginationJumper": "璺宠嚦"
+ "paginationJumper": "璺宠嚦",
+ "breadcrumb": {
+ "home": "棣栭〉",
+ "permissionManagement": "鏉冮檺绠$悊",
+ "permissionList": "鏉冮檺鍒楄〃"
+ },
+ "search": {
+ "placeholder": "璇疯緭鍏ュ叧閿瓧"
+ },
+ "button": {
+ "addPermission": "娣诲姞鏉冮檺",
+ "cancel": "鍙栨秷",
+ "confirm": "纭"
+ },
+ "table": {
+ "role": "瑙掕壊",
+ "permissionDescription": "鏉冮檺鎻忚堪",
+ "permissionValue": "鏉冮檺鍊�",
+ "createTime": "鍒涘缓鏃堕棿",
+ "isActive": "鏄惁婵�娲�",
+ "operation": "鎿嶄綔"
+ },
+ "tooltip": {
+ "edit": "淇敼",
+ "delete": "鍒犻櫎"
+ },
+ "dialog": {
+ "addPermission": "娣诲姞鏉冮檺",
+ "editPermission": "缂栬緫鏉冮檺"
+ },
+ "form": {
+ "role": "瑙掕壊",
+ "select": "璇烽�夋嫨",
+ "permission": "鏉冮檺",
+ "isActive": "鏄惁婵�娲�"
+ },
+ "鎿嶄綔": "鎿嶄綔",
+ "鏈夋晥": "鏈夋晥",
+ "鏃犳晥": "鏃犳晥",
+ "璇疯緭鍏ュ悕绉�": "璇疯緭鍏ュ悕绉�",
+ "闀垮害鍦� 2 鍒� 15 涓瓧绗�": "闀垮害鍦� 2 鍒� 15 涓瓧绗�",
+ "璇疯緭鍏ョ姸鎬�": "璇疯緭鍏ョ姸鎬�",
+ "娣诲姞瑙掕壊": "娣诲姞瑙掕壊",
+ "淇敼瑙掕壊": "淇敼瑙掕壊",
+ "鍒犻櫎瑙掕壊": "鍒犻櫎瑙掕壊",
+ "姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?": "姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?",
+ "鎻愮ず": "鎻愮ず",
+ "纭畾": "纭畾",
+ "鍙栨秷": "鍙栨秷",
+ "娣诲姞瑙掕壊鎴愬姛": "娣诲姞瑙掕壊鎴愬姛",
+ "鏇存柊鐘舵�佹垚鍔�": "鏇存柊鐘舵�佹垚鍔�",
+ "淇敼瑙掕壊鎴愬姛": "淇敼瑙掕壊鎴愬姛",
+ "鍒犻櫎瑙掕壊鎴愬姛": "鍒犻櫎瑙掕壊鎴愬姛"
}
\ No newline at end of file
diff --git a/CanadaMes-ui/src/layout/index.vue b/CanadaMes-ui/src/layout/index.vue
index f886453..8ae46e0 100644
--- a/CanadaMes-ui/src/layout/index.vue
+++ b/CanadaMes-ui/src/layout/index.vue
@@ -1,29 +1,27 @@
<template>
<el-container style="flex: 1;">
-
<div style="width: 200px;background-color: #222f3e" :style="{width: isCollapse?'70px':'250px'}">
<el-aside :width="isCollapse?'70px':'250px'">
<el-col :gutter="20">
<el-row :span="4">
<div class="logo" @click="goToHome">
- <div class="sys-name" v-show="!isCollapse">{{ $t('northglassMESsystem') }}</div>
-</div>
+ <div class="sys-name" v-show="!isCollapse">{{ $t('northglassMESsystem') }}</div>
+ </div>
</el-row>
<el-row :span="20">
<el-menu :default-active="activePath" class="el-menu-vertical-demo"
- background-color="#222f3e" text-color="#fff" active-text-color="#ffd04b"
- :collapse="isCollapse" :unique-opened="true"
- :collapse-transition="false" :router="true">
- <el-menu-item index="/" @click="goToHome">
- <template slot="title">
- <!--鍥炬爣-->
- <i class="el-icon-menu"></i>
- <!--鏂囨湰-->
- <span>{{ $t('home') }}</span>
- </template>
-</el-menu-item>
-
- <!--涓�绾ц彍鍗�-->
+ background-color="#222f3e" text-color="#fff" active-text-color="#ffd04b"
+ :collapse="isCollapse" :unique-opened="true"
+ :collapse-transition="false" :router="true">
+ <el-menu-item index="/" @click="goToHome">
+ <template slot="title">
+ <!--鍥炬爣-->
+ <i class="el-icon-menu"></i>
+ <!--鏂囨湰-->
+ <span>{{ $t('home') }}</span>
+ </template>
+ </el-menu-item>
+ <!--涓�绾ц彍鍗�-->
<el-submenu :index="item.id.toString()" v-for="item in menuList" :key="item.id">
<!--涓�绾ц彍鍗曟ā鏉垮尯鍩�-->
<template slot="title">
@@ -35,7 +33,7 @@
<!--浜岀骇鑿滃崟-->
<el-menu-item :index="'/'+menu.router"
v-for="menu in item.menuLists" :key="menu.id"
- @click="saveNavState('/'+menu.router)" @select="saveNavState" :default-active="$route.path">
+ @click="addTag(menu.router)">
<template slot="title">
<!--鍥炬爣-->
<i :class="menu.icon"></i>
@@ -43,76 +41,71 @@
<span>{{ menu.name }}</span>
</template>
</el-menu-item>
-
</el-submenu>
-
</el-menu>
</el-row>
</el-col>
</el-aside>
</div>
- <el-container >
-
- <el-header class="header-container" >
-
+ <el-container>
+ <el-header class="header-container">
- <div class="tagContainer" >
- <tag v-for="(tag, index) in tags" :key="index" :tag="tag" @removeTag="removeTag"></tag>
- </div>
<el-menu :default-active="activePath1" class="el-menu-demo" mode="horizontal"
background-color="#576574" text-color="#fff" active-text-color="#ffd04b">
- <div class="header-left" >
- <el-button :icon="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'" @click="toggleCollapse" style="height:30px"></el-button>
- </div>
- <template >
- <el-submenu index="1" class="custom-submenu" >
-
- <template slot="title">
- <el-avatar src="../assets/emi.png" style="width:30px;height:30px;margin-top:2px;">
- </el-avatar>
- </template>
- <el-menu-item index="1-1" @click="logout" >{{ $t('exit') }}</el-menu-item>
- <el-menu-item index="1-2" @click="showChangePasswordDialog" >{{ $t('changePassword') }}</el-menu-item>
- </el-submenu>
- </template>
+ <div class="header-left">
+ <el-button :icon="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'" @click="toggleCollapse" style="height:30px"></el-button>
+ </div>
+ <div class="tagContainer">
+ <tag v-for="(tag, index) in tags" :key="index" :tag="tag" @removeTag="removeTag(index)" @switchTag="switchTag(index)"></tag>
+ <!-- <el-button icon="el-icon-circle-close" class="close-all-btn" @click="removeAllTags"></el-button> -->
+ </div>
<template>
- <el-dialog title="淇敼瀵嗙爜" :visible.sync="dialogVisible" width="30%" s>
- <el-form ref="form" :model="formData" label-width="100px" >
- <el-form-item label="鏃у瘑鐮�">
- <el-input v-model="formData.oldPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="鏂板瘑鐮�">
- <el-input v-model="formData.newPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="纭鏂板瘑鐮�">
- <el-input v-model="formData.confirmPassword" type="password" show-password></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">鍙栨秷</el-button>
- <el-button type="primary" @click="savePassword">淇濆瓨</el-button>
- </div>
- </el-dialog>
-</template>
+ <el-submenu index="1" class="custom-submenu">
+ <template slot="title">
+ <el-avatar src="../assets/emi.png" style="width:30px;height:30px;margin-top:2px;"></el-avatar>
+ </template>
+ <el-menu-item index="1-1" @click="logout">{{ $t('exit') }}</el-menu-item>
+ <el-menu-item index="1-2" @click="showChangePasswordDialog">{{ $t('changePassword') }}</el-menu-item>
+ </el-submenu>
+ </template>
+ <template>
+ <el-dialog title="淇敼瀵嗙爜" :visible.sync="dialogVisible" width="30%">
+ <el-form ref="form" :model="formData" label-width="100px">
+ <el-form-item label="鏃у瘑鐮�">
+ <el-input v-model="formData.oldPassword" type="password" show-password></el-input>
+ </el-form-item>
+ <el-form-item label="鏂板瘑鐮�">
+ <el-input v-model="formData.newPassword" type="password" show-password></el-input>
+ </el-form-item>
+ <el-form-item label="纭鏂板瘑鐮�">
+ <el-input v-model="formData.confirmPassword" type="password" show-password></el-input>
+ </el-form-item>
+ </el-form>
+ <div slot="footer" class="dialog-footer">
+ <el-button @click="dialogVisible = false">鍙栨秷</el-button>
+ <el-button type="primary" @click="savePassword">淇濆瓨</el-button>
+ </div>
+ </el-dialog>
+ </template>
</el-menu>
</el-header>
<el-main>
- <router-view/>
+ <keep-alive>
+ <router-view/>
+ </keep-alive>
</el-main>
</el-container>
</el-container>
</template>
-
-
<script>
-import {selectList} from '../api/menuList'
-import {changePassword} from '../api/user'
-import {removeToken} from "../utils/auth";
+import { selectList } from '../api/menuList'
+import { changePassword } from '../api/user'
+import { removeToken } from "../utils/auth";
import LanguageMixin from '../lang/LanguageMixin'
import { mapState, mapMutations } from 'vuex';
- import Tag from '../layout/tag.vue';
- import store from '../store';
+import Tag from '../layout/tag.vue';
+import store from '../store';
export default {
name: "Layout",
@@ -120,7 +113,6 @@
mixins: [LanguageMixin],
data() {
return {
-
activeTag: '', // 褰撳墠婵�娲荤殑鏍囩
dialogVisible: false,
formData: {
@@ -128,7 +120,6 @@
newPassword: '',
confirmPassword: ''
},
-
menuList: [],
isCollapse: false,
activePath: '',
@@ -139,13 +130,13 @@
}
}
},
- components: {
- Tag
- },
+ components: {
+ Tag
+ },
created() {
selectList(this.menuListForm).then(res => {
this.menuList = res.data
-
+
const language = this.$i18n.locale;
if (language === 'en-US') {
this.replaceChineseWithEnglish(this.menuList);
@@ -163,29 +154,24 @@
this.$router.push('/login')
},
goToHome() {
- this.$router.push('/home');
- },
- // 浣跨敤 mapMutations 杈呭姪鍑芥暟璋冪敤 Store 涓殑 mutations
- ...mapMutations('tags', ['addTag', 'removeTag']),
- // 鍒囨崲鏍囩鏃惰Е鍙戠殑鏂规硶
- saveNavState(activePath) {
- window.sessionStorage.setItem('activePath', activePath);
-
- const menuItem = this.menuList.find(item => item.menuLists.some(menu => menu.router === activePath));
- if (menuItem) {
- const submenuItem = menuItem.menuLists.find(menu => menu.router === activePath);
- if (submenuItem) {
- const tag = submenuItem.name;
- this.$store.commit('tags/addTag', tag); // 璋冪敤 Vuex Store 涓殑 addTag mutation
- }
- }
+ this.$router.push('/home');
},
- // 鍏抽棴鏍囩鏃惰Е鍙戠殑鏂规硶
- removeTag(tag) {
- this.removeTag(tag); // 浠� Vuex Store 涓Щ闄ゆ爣绛�
- },
-
+ ...mapMutations('tags', ['addTag', 'removeTag', 'switchTag']),
+ addTag(router) {
+ let submenuItem;
+ const menuItem = this.menuList.find(item => item.menuLists.some(menu => menu.router === router));
+ if (menuItem) {
+ submenuItem = menuItem.menuLists.find(menu => menu.router === router);
+ }
+ if (submenuItem) {
+ const tag = submenuItem.router;
+ this.$store.commit('tags/addTag', tag);
+ }
+},
+ removeTag(index) {
+ this.$store.commit('tags/removeTag', index); // 浠� Vuex Store 涓Щ闄ゆ爣绛�
+ },
showChangePasswordDialog() {
this.dialogVisible = true;
},
@@ -200,25 +186,16 @@
console.log(res.data);
this.$message.success('瀵嗙爜淇敼鎴愬姛');
removeToken()
- this.$router.push('/login')
-
+ this.$router.push('/login')
}).catch(() => {
});
this.dialogVisible = false;
},
-
-
-
-
-
toggleCollapse: function () {
this.isCollapse = !this.isCollapse;
},
- // saveNavState: function (activePath) {
- // window.sessionStorage.setItem('activePath', activePath)
- // },
replaceChineseWithEnglish(menuData) {
// 瀹氫箟涓嫳鏂囧鐓у叧绯诲璞�
const translation = {
@@ -232,7 +209,8 @@
'鏉冮檺绠$悊': 'PermissionManagement',
'鏉冮檺鍒楄〃': 'PermissionList',
'瑙掕壊绠$悊': 'RoleManagement',
- '瑙掕壊鍒楄〃': 'RoleList'
+ '瑙掕壊鍒楄〃': 'RoleList',
+ '鐢垫皵绠$悊': 'Electrical management'
// 鏍规嵁瀹為檯闇�姹傜户缁坊鍔犲鐓у叧绯�
};
@@ -242,79 +220,78 @@
subMenu.name = translation[subMenu.name] || subMenu.name;
});
});
-
-
+ }
+ },
+ watch: {
+ '$route'(to) {
+ // 鍒囨崲璺敱鏃舵洿鏂版縺娲荤殑鏍囩
+ const tag = this.menuList.some(item => item.menuLists.some(menu => '/' + menu.router === to.path));
+ if (tag) {
+ this.activeTag = tag;
+ }
}
}
- }
-
-
+}
</script>
<style scoped lang="less">
-// .header-container {
-// display: flex;
-// justify-content: flex-start;
-// height: 10px; /* 璁剧疆杈冨皬鐨勯珮搴� */
-// }
-
.custom-submenu {
- height: 90px !important;
+ height: 90px !important;
}
.header-container {
-
- height: 30px !important; /* 璁剧疆杈冨皬鐨勯珮搴� */
- }
+
+ height: 30px !important; /* 璁剧疆杈冨皬鐨勯珮搴� */
+}
.header-left {
- margin-right: auto;
-
+ margin-right: auto;
+
}
.el-aside {
- height: 100vh;
- background-color: #222f3e;
- line-height: 200px;
+ height: 100vh;
+ background-color: #222f3e;
+ line-height: 200px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
- width: 200px;
- min-height: 400px;
+ width: 200px;
+ min-height: 400px;
}
.el-menu-demo {
- display: flex;
- width: 100%;
- height: 100%;
- justify-content: flex-end;
- align-items: center;
+ display: flex;
+ width: 100%;
+ height: 100%;
+ justify-content: flex-end;
+ align-items: center;
}
.el-menu-vertical-demo {
- border: 0;
+ border: 0;
}
.logo {
- background-color: #222f3e;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 60px;
+ background-color: #222f3e;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 60px;
- .sys-name {
- font-size: 20px;
- color: #ffffff;
- margin-left: 10px;
- }
+ .sys-name {
+ font-size: 20px;
+ color: #ffffff;
+ margin-left: 10px;
+ }
}
.el-header {
- background-color: #576574;
+ background-color: #576574;
}
-</style>
+</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/layout/tag.vue b/CanadaMes-ui/src/layout/tag.vue
index ccf38fd..01a1b7d 100644
--- a/CanadaMes-ui/src/layout/tag.vue
+++ b/CanadaMes-ui/src/layout/tag.vue
@@ -1,59 +1,70 @@
<template>
- <div class="tagContainer">
- <div v-for="(tag, index) in tags" :key="index" class="tagItem">
- {{ tag }}
- <span class="closeBtn" @click="removeTag(index)">x</span>
+ <keep-alive>
+ <div
+ class="tag"
+ :class="{ active: isActive }"
+ @click="switchTag(tag)">
+ <span>{{ tag }}</span>
+ <i class="el-icon-close" @click.stop="removeTag(tag)"></i>
</div>
- </div>
+ </keep-alive>
</template>
<script>
-import { mapState, mapMutations } from 'vuex';
-
export default {
+ props: {
+ tag: {
+ type: String,
+ required: true
+ },
+ activeTag: {
+ type: String,
+ required: true
+ }
+ },
computed: {
- ...mapState('tags', { // 杩欓噷娣诲姞浜� 'tags' 妯″潡鐨勫懡鍚嶇┖闂村墠缂�
- tags: state => state.tags.tags
- })
+ isActive() {
+ return this.tag === this.activeTag;
+ },
+ tagData() {
+ return this.$store.getters.getTagData(this.tag);
+ }
},
methods: {
- ...mapMutations('tag', ['removeTag']),
- saveNavState(activePath) {
- window.sessionStorage.setItem('activePath', activePath);
+ removeTag(tag) {
+ this.$emit('removeTag', tag);
+ },
+ switchTag(tag) {
+ this.$emit('switchTag', tag);
+ this.$router.push('/' + tag); // 鍒囨崲鍒版寚瀹氳矾鐢�
+}
- const menuItem = this.menuList.find(item => item.menuLists.some(menu => menu.router === activePath));
- if (menuItem) {
- const submenuItem = menuItem.menuLists.find(menu => menu.router === activePath);
- if (submenuItem) {
- const tag = submenuItem.name;
- this.addTag(tag); // 娣诲姞鏍囩鍒� Vuex Store
- }
- }
- }
}
}
</script>
<style scoped>
-.tagContainer {
- display: flex;
- flex-wrap: wrap;
- margin-bottom: 10px;
-}
-
-.tagItem {
- background-color: #eee;
+.tag {
+ display: inline-block;
+ margin-right: 10px;
+ padding: 4px 10px;
border-radius: 4px;
- padding: 4px 8px;
- margin-right: 8px;
- margin-bottom: 8px;
- display: flex;
- align-items: center;
-}
-
-.closeBtn {
- margin-left: 4px;
- color: red;
+ background-color: #f0f0f0;
cursor: pointer;
}
-</style>
+
+.tag.active {
+ background-color: #409eff;
+ color: #fff;
+}
+
+.tag span {
+ margin-right: 5px;
+}
+
+.tag i {
+ margin-left: 5px;
+ font-size: 12px;
+ cursor: pointer;
+}
+</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/store/index.js b/CanadaMes-ui/src/store/index.js
index 150cead..9b88426 100644
--- a/CanadaMes-ui/src/store/index.js
+++ b/CanadaMes-ui/src/store/index.js
@@ -10,5 +10,29 @@
modules: {
tags,
},
+ state: {
+ tagData: {} // 瀛樺偍鏍囩鏁版嵁鐨勫璞�
+ },
+ mutations: {
+ // 鏇存柊鏍囩鏁版嵁
+ updateTagData(state, payload) {
+ state.tagData[payload.tag] = payload.data;
+ }
+ },
+ actions: {
+ // 寮傛鎿嶄綔鏇存柊鏍囩鏁版嵁
+ updateTagDataAsync({ commit }, payload) {
+ // 鎵ц寮傛鎿嶄綔锛屾瘮濡傚彂閫佽姹傝幏鍙栨暟鎹�
+ // 鐒跺悗閫氳繃commit瑙﹀彂mutation鏉ユ洿鏂版暟鎹�
+ setTimeout(() => {
+ commit('updateTagData', payload);
+ }, 1000);
+ }
+ },
+ getters: {
+ getTagData: (state) => (tag) => {
+ return state.tagData[tag] || null; // 鑾峰彇鎸囧畾鏍囩鐨勬暟鎹�
+ }
+ }
// 鍏朵粬閰嶇疆
});
diff --git a/CanadaMes-ui/src/store/module/tags.js b/CanadaMes-ui/src/store/module/tags.js
index 3e3b974..a16623a 100644
--- a/CanadaMes-ui/src/store/module/tags.js
+++ b/CanadaMes-ui/src/store/module/tags.js
@@ -1,6 +1,6 @@
const state = {
tags: []
-};
+}
const mutations = {
addTag(state, tag) {
@@ -8,15 +8,20 @@
state.tags.push(tag);
}
},
- removeTag(state, tag) {
- const index = state.tags.indexOf(tag);
- if (index !== -1) {
- state.tags.splice(index, 1);
- }
+ removeTag(state, index) {
+ state.tags.splice(index, 1);
+ },
+ removeAllTags(state) {
+ state.tags = [];
+ },
+ switchTag(tag) {
+ this.$emit('switchTag', tag);
+ this.$router.push('/' + tag); // 娣诲姞杩欒浠g爜浠ュ垏鎹㈣矾鐢�
}
-};
+}
export default {
+ namespaced: true,
state,
mutations
-};
\ No newline at end of file
+}
diff --git a/CanadaMes-ui/src/views/Electrical/Action.vue b/CanadaMes-ui/src/views/Electrical/Action.vue
index 48df874..e546681 100644
--- a/CanadaMes-ui/src/views/Electrical/Action.vue
+++ b/CanadaMes-ui/src/views/Electrical/Action.vue
@@ -12,11 +12,15 @@
</el-breadcrumb>
<div>Action</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.name">
+ <!-- <div class="kuai_div" v-for="item in record.xyData" :key="item.value">
<el-input v-model="item.name" style="width: 240px;" class="in_mc"></el-input>
- <!-- <el-input v-model="item[0]" style="width: 80px;"></el-input> -->
<el-switch v-model="item.value" active-value="0" inactive-value="1"></el-switch>
- </div>
+ </div> -->
+
+ <div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
+ <el-input v-model="item.name" style="width: 240px;" class="in_mc" readonly></el-input>
+ <el-switch v-model="item.value" active-value="1" inactive-value="0" @change="send()"></el-switch>
+ </div>
</el-form>
@@ -31,7 +35,7 @@
data () {
return {
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],
+ params: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
canshu: [
'D01 VFD conveyor',
'D02 VFD conveyor',
@@ -61,13 +65,34 @@
'B02 YV UP DOWN',
],
xyData: [
- { name: 'D01 VFD conveyor', value: 0 },
- { name: "D02 VFD conveyor", value: 0 },
- { name: "D03 VFD conveyor", value: 0 },
- { name: "D04 VFD conveyor", value: 0 },
- { name: "B01 B02 TRAVEL JOG Velocity", value: 0 },
- { name: "conveyor Velocity(Manual)", value: 0 },
- ],
+ { name: 'D01 VFD conveyor', value: "0" },
+ { name: 'D02 VFD conveyor', value: "0" },
+ { name: 'D03 VFD conveyor', value: "1" },
+ { name: 'D04 VFD conveyor', value: "0" },
+ { name: 'D05 VFD conveyor', value: "0" },
+ { name: 'D06 VFD conveyor', value: "0" },
+ { name: 'A01 VFD conveyor', value: "0" },
+ { name: 'A02 VFD conveyor', value: "0" },
+ { name: 'B01 VFD conveyor', value: "0" },
+ { name: 'B02 VFD conveyor', value: "0" },
+ { name: 'A01 SERVE TURN JOG+', value: "0" },
+ { name: 'A02 SERVE TURN JOG-', value: "0" },
+ { name: 'A01 SERVE TRAVEL JOG+', value: "0" },
+ { name: 'A02 SERVE TRAVEL JOG-', value: "0" },
+ { name: 'B01 SERVE TRAVEL JOG+', value: "0" },
+ { name: 'B02 SERVE TRAVEL JOG-', value: "0" },
+ { name: 'A01 SERVE TURN POS', value: "0" },
+ { name: 'A02 SERVE TURN POS', value: "0" },
+ { name: 'A01 SERVE TRAVEL POS', value: "0" },
+ { name: 'A02 SERVE TRAVEL POS', value: "0" },
+ { name: 'B01 SERVE TRAVEL POS', value: "0" },
+ { name: 'B02 SERVE TRAVEL POS', value: "0" },
+ { name: 'B01 YV TURN', value: "0" },
+ { name: 'B01 YV UP DOWN', value: "0" },
+ { name: 'B02 YV TURN', value: "0" },
+ { name: 'B02 YV UP DOWN', value: "0" },
+]
+,
},
@@ -86,7 +111,7 @@
},
methods: {
init () {
- let viewname = "Action";
+ let viewname = "action";
if (typeof (WebSocket) == "undefined") {
console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
@@ -105,25 +130,26 @@
console.log("websocket宸叉墦寮�");
};
// 娴忚鍣ㄧ鏀舵秷鎭紝鑾峰緱浠庢湇鍔$鍙戦�佽繃鏉ョ殑鏂囨湰娑堟伅
- socket.onmessage = function (msg) {
+ socket.onmessage = (msg) => {
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
- //console.log("鏀跺埌鏁版嵁====" + msg.data);
- let obj = JSON.parse(msg.data);
+ let obj = JSON.parse(msg.data);
+ this.record.params[0] = obj.params[0];
- this.record.params[0] = obj.acion[0].join(",");
- this.record.params[0] = this.record.params[0].split(",");
+ for (let a = 0; a <= this.record.params[0].length - 1; a++) {
+ if (!this.record.xyData[a]) {
+ this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a].toString() };
+ } else {
+ this.record.xyData[a].value = this.record.params[0][a].toString();
+ }
+ }
- for (let a = 0; a <= this.record.params.length - 1; a++) {
- // if (!this.record.xyData[a]) {
- // this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
- // } else {
- // this.record.xyData[a].value = this.record.params[0][a];
- // }
- this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
- }
- console.log(this.record.xyData)
- this.$forceUpdate();
- }.bind(this);
+ console.log(this.record.xyData);
+ this.$forceUpdate();
+};
+
//鍏抽棴浜嬩欢
socket.onclose = function () {
console.log("websocket宸插叧闂�");
@@ -135,10 +161,11 @@
}
},
- send () {
- this.messagepack.data = { taskname: "鍓嶇鍒板悗鍙�" };
- socket?.send(JSON.stringify(this.messagepack)); // 灏嗙粍瑁呭ソ鐨刯son鍙戦�佺粰鏈嶅姟绔紝鐢辨湇鍔$杩涜杞彂
- }
+ send() {
+ this.messagepack.data = this.record.xyData.map(item => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
+ console.log(this.messagepack);
+ socket?.send(JSON.stringify(this.messagepack));
+}
}
@@ -161,16 +188,18 @@
border: none;
- .el-input__inner {
+
+
+
+}
+.el-input__inner {
border: 1 solid black;
}
-
-}
-
.in_mc {
- .el-input__inner {
+
+}
+.el-input__inner {
border: none;
}
-}
</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter.vue b/CanadaMes-ui/src/views/Electrical/Parameter.vue
index c514efc..85fce27 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter.vue
@@ -8,6 +8,7 @@
<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>
</el-breadcrumb>
<div>Parameter</div>
@@ -16,8 +17,8 @@
<el-button type="primary" @click="send()">涓嬪彂鍙傛暟</el-button>
</div>
<div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
- <el-input style="width: 280px;" class="in_mc" v-model="item.name" readonly></el-input>
- <el-input v-model="item.value" style="width: 80px;"></el-input>
+ <el-input style="width: 280px;" class="in_mc" v-model="item.name" readonly></el-input>
+ <el-input v-model.number="item.value" style="width: 80px;" @input="handleChange(index, $event.target.value)"></el-input>
</div>
</el-form>
</div>
@@ -32,20 +33,21 @@
return {
record: {
params: [100, 200, 10, 10, 10, 10],
- xyData: [{ name: "conveyor Velocity(Auto SLOW)", value: 100 },
- { name: "B01 B02 TRAVEL POS Velocity AUTO", value: 10 },
- { name: "B01 B02 TRAVEL JOG Velocity", value: 10 },
- { name: "conveyor Velocity(Manual)", value: 10},
- { name: "B01 B02 TRAVEL JOG Velocity", value: 10},
- { name: "conveyor Velocity(Manual)", value: 10 }],
- canshu: [
- 'conveyor Velocity(Auto SLOW)',
- 'B01 B02 TRAVEL POS Velocity AUTO',
- 'B01 B02 TRAVEL JOG Velocity',
- 'conveyor Velocity(Manual)',
- 'B01 B02 TRAVEL JOG Velocity',
- 'conveyor Velocity(Manual)'
+ xyData: [
+ { name: "conveyor Velocity(Auto FAST)", value: 0 },
+ { name: "conveyor Velocity(Auto SLOW)", value: 0 },
+ { name: "conveyor Velocity(Manual)", value: 0 },
+ { name: "A01 A02 TURN JOG Velocity", value: 0 },
+ { name: "A01 A02 TRAVEL JOG Velocity", value: 0 },
+ { name: "B01 B02 TRAVEL JOG Velocity", value: 0 },
+ { name: "A01 A02 TURN POS Velocity AUTO", value: 0 },
+ { name: "A01 A02 TURN POS Velocity manual", value: 0 },
+ { name: "A01 A02 TRAVEL POS Velocity AUTO", value: 0 },
+ { name: "A01 A02 TRAVEL POS Velocity manual", value: 0 },
+ { name: "B01 B02 TRAVEL POS Velocity AUTO", value: 0 },
+ { name: "B01 B02 TRAVEL POS Velocity manual", value: 0 }
],
+ canshu: []
},
messagepack: {
data: { taskname: "" }
@@ -53,21 +55,19 @@
queryInfo: {
data: "1",
pageSize: 10
- },
}
+ };
},
created() {
this.initWebSocket();
},
methods: {
initWebSocket() {
- let viewname = "action";
+ let viewname = "Parameter";
- if (typeof WebSocket == "undefined") {
+ if (typeof WebSocket === "undefined") {
console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
} else {
- //console.log("鎮ㄧ殑娴忚鍣ㄦ敮鎸乄ebSocket");
-
let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
if (socket != null) {
@@ -85,24 +85,24 @@
// 鏀跺埌娑堟伅
socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
-
- let obj = JSON.parse(msg.data);
- this.record.params[0] = obj.params[0];
-
- for (let a = 0; a <= this.record.params[0].length - 1; a++) {
- if (!this.record.xyData[a]) {
- this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
- } else {
- this.record.xyData[a].value = this.record.params[0][a];
- }
- }
-
- console.log(this.record.xyData);
- this.$forceUpdate();
-};
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
+
+ let obj = JSON.parse(msg.data);
+ this.record.params[0] = obj.params[0];
+
+ for (let a = 0; a <= this.record.params[0].length - 1; a++) {
+ if (!this.record.xyData[a]) {
+ this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
+ } else {
+ this.record.xyData[a].value = this.record.params[0][a];
+ }
+ }
+
+ console.log(this.record.xyData);
+ this.$forceUpdate();
+ };
// 鍏抽棴浜嬩欢
socket.onclose = function () {
@@ -112,16 +112,19 @@
// 鍙戠敓閿欒浜嬩欢
socket.onerror = function () {
console.log("websocket鍙戠敓浜嗛敊璇�");
- }
+ };
}
},
send() {
- this.messagepack.data = this.record.xyData.map(item => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
- console.log(this.messagepack);
- socket?.send(JSON.stringify(this.messagepack));
-}
+ this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
+ console.log(this.messagepack);
+ socket?.send(JSON.stringify(this.messagepack));
+ },
+ handleChange(index, value) {
+ this.record.xyData[index].value = value;
}
}
+ };
</script>
<style>
@@ -149,4 +152,4 @@
#btn_div .el-button {
float: right;
}
- </style>
+ </style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/power/index.vue b/CanadaMes-ui/src/views/power/index.vue
index 567af94..7488cf8 100644
--- a/CanadaMes-ui/src/views/power/index.vue
+++ b/CanadaMes-ui/src/views/power/index.vue
@@ -2,32 +2,32 @@
<div class="app">
<!--闈㈠寘灞戝鑸尯鍩�-->
<el-breadcrumb separator-class="el-icon-arrow-right">
- <el-breadcrumb-item :to="{ path: '/home' }">棣栭〉</el-breadcrumb-item>
- <el-breadcrumb-item>鏉冮檺绠$悊</el-breadcrumb-item>
- <el-breadcrumb-item>鏉冮檺鍒楄〃</el-breadcrumb-item>
+ <el-breadcrumb-item :to="{ path: '/home' }">{{$t('breadcrumb.home')}}</el-breadcrumb-item>
+ <el-breadcrumb-item>{{$t('breadcrumb.permissionManagement')}}</el-breadcrumb-item>
+ <el-breadcrumb-item>{{$t('breadcrumb.permissionList')}}</el-breadcrumb-item>
</el-breadcrumb>
<!--鍗$墖瑙嗗浘鍖哄煙-->
<el-card class="el-card">
<el-row :gutter="20">
<!--鎼滅储涓庢坊鍔犲尯鍩�-->
<el-col :span="6">
- <el-input placeholder="璇疯緭鍏ユ潈闄愬悕绉�" v-model="queryInfo.name" clearable @clear="getPowerList()">
+ <el-input :placeholder="$t('search.placeholder')" v-model="queryInfo.name" clearable @clear="getPowerList()">
<el-button slot="append" icon="el-icon-search" @click="getPowerList()"></el-button>
</el-input>
</el-col>
<!--娣诲姞鍖哄煙-->
<el-col :span="4">
- <el-button type="primary" @click="showAddDialog">娣诲姞鏉冮檺</el-button>
+ <el-button type="primary" @click="showAddDialog">{{$t('button.addPermission')}}</el-button>
</el-col>
</el-row>
<!--鏉冮檺鍒楄〃鍖哄煙-->
<el-table :data="powerList.records" border stripe>
<el-table-column label="#" type="index"></el-table-column>
- <el-table-column label="瑙掕壊" prop="role.name"></el-table-column>
- <el-table-column label="鏉冮檺鎻忚堪" prop="permission.description"></el-table-column>
- <el-table-column label="鏉冮檺鍊�" prop="permission.name"></el-table-column>
- <el-table-column label="鍒涘缓鏃堕棿" prop="createTime"></el-table-column>
- <el-table-column label="鏄惁鐢熸晥">
+ <el-table-column :label="$t('table.role')" prop="role.name"></el-table-column>
+ <el-table-column :label="$t('table.permissionDescription')" prop="permission.description"></el-table-column>
+ <el-table-column :label="$t('table.permissionValue')" prop="permission.name"></el-table-column>
+ <el-table-column :label="$t('table.createTime')" prop="createTime"></el-table-column>
+ <el-table-column :label="$t('table.isActive')">
<template slot-scope="scope">
<el-switch :active-value=1
:inactive-value=0
@@ -36,15 +36,15 @@
</el-switch>
</template>
</el-table-column>
- <el-table-column label="鎿嶄綔">
+ <el-table-column :label="$t('table.operation')">
<template slot-scope="scope">
<!--淇敼-->
- <el-tooltip effect="dark" content="淇敼" placement="top" :enterable="false">
+ <el-tooltip effect="dark" :content="$t('tooltip.edit')" placement="top" :enterable="false">
<el-button type="primary" icon="el-icon-edit" size="mini"
@click="showEditDialog(scope.row)"></el-button>
</el-tooltip>
<!--鍒犻櫎-->
- <el-tooltip effect="dark" content="鍒犻櫎" placement="top" :enterable="false">
+ <el-tooltip effect="dark" :content="$t('tooltip.delete')" placement="top" :enterable="false">
<el-button type="danger" icon="el-icon-delete" size="mini"
@click="removeById(scope.row)"></el-button>
</el-tooltip>
@@ -64,14 +64,14 @@
</el-card>
<!--娣诲姞鏉冮檺鐨勫璇濇-->
<el-dialog
- title="娣诲姞鏉冮檺"
+ :title="$t('dialog.addPermission')"
:visible.sync="addDialogVisible"
width="50%"
@close="addDialogClosed">
<!--鍐呭涓讳綋鍖哄煙-->
<el-form :model="addPowerForm" :rules="powerRules" ref="powerRef" label-width="70px">
- <el-form-item label="瑙掕壊" prop="roleId">
- <el-select filterable v-model="addPowerForm.roleId" placeholder="璇烽�夋嫨">
+ <el-form-item :label="$t('form.role')" prop="roleId">
+ <el-select filterable v-model="addPowerForm.roleId" :placeholder="$t('form.select')">
<el-option v-for="item in roleList"
:key="item.id"
:value="item.id"
@@ -79,8 +79,8 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="鏉冮檺" prop="permissionId">
- <el-select filterable v-model="addPowerForm.permissionId" placeholder="璇烽�夋嫨">
+ <el-form-item :label="$t('form.permission')" prop="permissionId">
+ <el-select filterable v-model="addPowerForm.permissionId" :placeholder="$t('form.select')">
<el-option v-for="item in permissionList"
:key="item.id"
:value="item.id"
@@ -88,8 +88,8 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="鏄惁鐢熸晥" prop="state">
- <el-select v-model="addPowerForm.state" placeholder="璇烽�夋嫨">
+ <el-form-item :label="$t('form.isActive')" prop="state">
+ <el-select v-model="addPowerForm.state" :placeholder="$t('form.select')">
<el-option v-for="(item,index) in options"
:key="index"
:value="item.value"
@@ -99,19 +99,19 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
- <el-button @click="addDialogVisible = false">鍙� 娑�</el-button>
- <el-button type="primary" @click="addPower">纭� 瀹�</el-button>
+ <el-button @click="addDialogVisible = false">{{$t('button.cancel')}}</el-button>
+ <el-button type="primary" @click="addPower">{{$t('button.confirm')}}</el-button>
</span>
</el-dialog>
<!--淇敼鏉冮檺鐨勫璇濇-->
<el-dialog
- title="淇敼鏉冮檺"
+ :title="$t('dialog.editPermission')"
:visible.sync="editDialogVisible"
width="50%">
<!--鍐呭涓讳綋鍖哄煙-->
<el-form :model="editRoleForm" :rules="powerRules" ref="powerRef" label-width="70px">
- <el-form-item label="瑙掕壊" prop="roleId">
- <el-select filterable v-model="editRoleForm.roleId" placeholder="璇烽�夋嫨">
+ <el-form-item :label="$t('form.role')" prop="roleId">
+ <el-select filterable v-model="editRoleForm.roleId" :placeholder="$t('form.select')">
<el-option v-for="item in roleList"
:key="item.id"
:value="item.id"
@@ -119,8 +119,8 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item filterable label="鏉冮檺" prop="permissionId">
- <el-select v-model="editRoleForm.permissionId" placeholder="璇烽�夋嫨">
+ <el-form-item filterable :label="$t('form.permission')" prop="permissionId">
+ <el-select v-model="editRoleForm.permissionId" :placeholder="$t('form.select')">
<el-option v-for="item in permissionList"
:key="item.id"
:value="item.id"
@@ -128,8 +128,8 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="鏄惁鐢熸晥" prop="state">
- <el-select v-model="editRoleForm.state" placeholder="璇烽�夋嫨">
+ <el-form-item :label="$t('form.isActive')" prop="state">
+ <el-select v-model="editRoleForm.state" :placeholder="$t('form.select')">
<el-option v-for="(item,index) in options"
:key="index"
:value="item.value"
@@ -139,8 +139,8 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
- <el-button @click="editDialogVisible = false">鍙� 娑�</el-button>
- <el-button type="primary" @click="editRoleInfo">纭� 瀹�</el-button>
+ <el-button @click="editDialogVisible = false">{{$t('button.cancel')}}</el-button>
+ <el-button type="primary" @click="editRoleInfo">{{$t('button.confirm')}}</el-button>
</span>
</el-dialog>
</div>
@@ -150,9 +150,11 @@
import {getById, removeById, saveOrUpdate, selectPage} from "../../api/rolePermission";
import {select} from "../../api/role";
import {selectPermission} from "../../api/permission";
+import LanguageMixin from '../../lang/LanguageMixin'
export default {
name: "Power",
+ mixins: [LanguageMixin],
data() {
return {
queryInfo: {
diff --git a/CanadaMes-ui/src/views/role/index.vue b/CanadaMes-ui/src/views/role/index.vue
index ebcc35a..c663906 100644
--- a/CanadaMes-ui/src/views/role/index.vue
+++ b/CanadaMes-ui/src/views/role/index.vue
@@ -137,12 +137,13 @@
addRoleForm: {
state: 1
},
+
// 淇敼鐨勮鑹插璞�
editRoleForm: {},
// 娣诲姞瑙掕壊鐨勯獙璇佽鍒�
addRoleRules: {
name: [
- {required: true, message: '璇疯緭鍏ュ悕绉�', trigger: 'blur'},
+ {required: true, message: '璇疯緭鍏ュ悕绉�', trigger: 'blur'},
{min: 2, max: 15, message: '闀垮害鍦� 2 鍒� 15 涓瓧绗�', trigger: 'blur'}
],
state: [
@@ -177,7 +178,8 @@
},
stateChange(info) {
saveOrUpdate(info).then(() => {
- this.$message.success("鏇存柊鐘舵�佹垚鍔�")
+ const 鏇存柊鐘舵�佹垚鍔� = this.$t('鏇存柊鐘舵�佹垚鍔�');
+ this.$message.success(鏇存柊鐘舵�佹垚鍔�)
});
},
@@ -195,7 +197,8 @@
this.getRoleList();
// 闅愯棌娣诲姞瑙掕壊瀵硅瘽妗�
this.addDialogVisible = false;
- this.$message.success("娣诲姞瑙掕壊鎴愬姛");
+ const 娣诲姞瑙掕壊鎴愬姛 = this.$t('娣诲姞瑙掕壊鎴愬姛');
+ this.$message.success(娣诲姞瑙掕壊鎴愬姛);
});
})
},
@@ -220,26 +223,33 @@
this.getRoleList();
// 闅愯棌娣诲姞瑙掕壊瀵硅瘽妗�
this.editDialogVisible = false;
- this.$message.success("淇敼瑙掕壊鎴愬姛");
+ const 淇敼瑙掕壊鎴愬姛 = this.$t('淇敼瑙掕壊鎴愬姛');
+ this.$message.success(淇敼瑙掕壊鎴愬姛);
});
})
},
// 鏍规嵁id鍒犻櫎瑙掕壊淇℃伅
removeById(role) {
// 寮规璇㈤棶鐢ㄦ埛鏄惁鍒犻櫎瑙掕壊
- this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
+ const 姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹叉槸鍚︾户缁� = this.$t('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?');
+ const 鎻愮ず = this.$t('鎻愮ず');
+ const 纭畾 = this.$t('纭畾');
+ const 鍙栨秷 = this.$t('鍙栨秷');
+ this.$confirm(姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヨ鑹叉槸鍚︾户缁�, 鎻愮ず, {
+ confirmButtonText: 纭畾,
+ cancelButtonText: 鍙栨秷,
type: 'warning'
}).then(() => {
// 鍒犻櫎瑙掕壊
removeById({id: role.id}).then(() => {
// 閲嶆柊鑾峰彇瑙掕壊鍒楄〃
this.getRoleList();
- this.$message.success("鍒犻櫎瑙掕壊鎴愬姛");
+ const 鍒犻櫎瑙掕壊鎴愬姛 = this.$t('鍒犻櫎瑙掕壊鎴愬姛');
+ this.$message.success(鍒犻櫎瑙掕壊鎴愬姛);
});
}).catch(() => {
- this.$message('宸插彇娑堝垹闄�');
+ const 宸插彇娑堝垹闄� = this.$t('宸插彇娑堝垹闄�');
+ this.$message(宸插彇娑堝垹闄�);
});
}
}
diff --git a/CanadaMes-ui/src/views/user/index.vue b/CanadaMes-ui/src/views/user/index.vue
index b2bf51c..c91da6e 100644
--- a/CanadaMes-ui/src/views/user/index.vue
+++ b/CanadaMes-ui/src/views/user/index.vue
@@ -11,11 +11,11 @@
<el-row :gutter="20">
<!--鎼滅储涓庢坊鍔犲尯鍩�-->
<el-col :span="6">
- <el-input placeholder="璇疯緭鍏ョ敤鎴峰悕绉�" v-model="queryInfo.username" clearable @clear="getUserList">
+ <el-input :placeholder= "$t('langUsernamePlaceholder')" v-model="queryInfo.username" clearable @clear="getUserList">
</el-input>
</el-col>
<el-col :span="6">
- <el-input placeholder="璇疯緭鍏ラ偖绠�" v-model="queryInfo.email" clearable @clear="getUserList">
+ <el-input :placeholder="$t('langEmailPlaceholder')" v-model="queryInfo.email" clearable @clear="getUserList">
</el-input>
</el-col>
<!--鎼滅储鎸夐挳-->
@@ -74,8 +74,7 @@
:page-sizes="[6, 12, 18, 24]"
:page-size="queryInfo.pageSize"
:total="userList.total"
- :prev-text="$t('pagination.prev')"
- :next-text="$t('pagination.next')"
+
:pager-count="7"
:layout="layout"
>
diff --git a/springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java b/springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java
index ac10b17..9f03c3a 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java
@@ -2,8 +2,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
+
public class AuthorityApplication {
public static void main(String[] args) {
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
index b8382f2..bf88fbb 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -26,12 +26,12 @@
// 鎺ㄩ�佸埌鍓嶇
// Parameter
- JSONObject jsonObject = new JSONObject();
- jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, });
- WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
- if (sendwServer != null) {
- sendwServer.sendMessage(jsonObject.toString());
- }
+// JSONObject jsonObject = new JSONObject();
+// jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, });
+// WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
+// if (sendwServer != null) {
+// sendwServer.sendMessage(jsonObject.toString());
+// }
// Action
// JSONObject jsonObject2 = new JSONObject();
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
new file mode 100644
index 0000000..b7c1ae4
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
@@ -0,0 +1,82 @@
+package com.example.springboot.component;
+
+import cn.hutool.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlcParameter extends Thread {
+ private static final int SEND_INTERVAL = 10000;
+ private static final int WRITE_INTERVAL = 100;
+
+ @Override
+
+ public void run() {
+ try {
+ // 鍙戦�佷竴娆℃秷鎭�
+ sendMessages();
+
+ // 寤惰繜涓�娈垫椂闂�
+ Thread.sleep(SEND_INTERVAL);
+
+ while (true) {
+ // 鍐欏叆PLC
+ writeToPlc();
+ Thread.sleep(WRITE_INTERVAL);
+
+ // 鍙戦�佹秷鎭�
+ sendMessages();
+ Thread.sleep(SEND_INTERVAL);
+ }
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendMessages() {
+ WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
+ if (sendwServer != null) {
+ List<Short> paramlist = S7control.getinstance().ReadWord("DB100.DBW", 12);
+ JSONObject jsonObject = new JSONObject();
+// new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}
+ jsonObject.append("params", new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0});
+ sendwServer.sendMessage(jsonObject.toString());
+ }
+ }
+
+ private void writeToPlc() {
+ WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter");
+ if (webSocketServer != null) {
+ List<String> messages = webSocketServer.getMessages();
+
+ String addressList = "DB100.DBW0";
+
+ if (!messages.isEmpty()) {
+ // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
+ String lastMessage = messages.get(messages.size() - 1);
+ System.out.println("messages锛�" + messages);
+ String[] parts = lastMessage.split(",");
+ List<Short> messageValues = new ArrayList<>();
+ for (String part : parts) {
+ try {
+ // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
+ String cleanedPart = part.replaceAll("[^0-9-]", "");
+ short value = Short.parseShort(cleanedPart.trim());
+ messageValues.add(value);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ e.printStackTrace();
+ }
+ }
+
+ // 灏嗘秷鎭�煎啓鍏� PLC
+ S7control.getinstance().WriteWord(addressList, messageValues);
+ System.out.println("messageValues锛�" + messageValues);
+ System.out.println("addressList锛�" + addressList);
+ // 娓呯┖娑堟伅鍒楄〃
+ webSocketServer.clearMessages();
+ }
+ }
+ }
+}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
index d8ffaea..4fc251a 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
@@ -6,69 +6,96 @@
import java.util.List;
public class Plcaction extends Thread {
+ private static final long SEND_INTERVAL = 2000; // 鍙戦�佹秷鎭殑鏃堕棿闂撮殧
+ private static final long WRITE_INTERVAL = 100; // 鍐欏叆PLC鐨勬椂闂撮棿闅�
+
@Override
public void run() {
- while (this != null) {
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ try {
+ // 鍙戦�佷竴娆℃秷鎭�
+ sendMessages();
+
+ // 寤惰繜涓�娈垫椂闂�
+ Thread.sleep(SEND_INTERVAL);
+
+ while (true) {
+ // 鍐欏叆PLC
+ writeToPlc();
+ Thread.sleep(WRITE_INTERVAL);
+
+ // 鍙戦�佹秷鎭�
+ sendMessages();
+ Thread.sleep(SEND_INTERVAL);
}
- List<Short> paramlist = S7control.getinstance().ReadWord("DB100.DBW", 12);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendMessages() {
+ WebSocketServer sendwServer = WebSocketServer.sessionMap.get("action");
+ if (sendwServer != null) {
+
+ List<Boolean> paramlist = S7control.getinstance().ReadBits("DB100.DBW", 12);
+ // new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}
JSONObject jsonObject = new JSONObject();
- jsonObject.append("params", paramlist);
- WebSocketServer sendwServer = WebSocketServer.sessionMap.get("action");
- if (sendwServer != null) {
- sendwServer.sendMessage(jsonObject.toString());
- }
+ jsonObject.append("params", new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0});
- WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("action");
- if (webSocketServer != null) {
- List<String> messages = webSocketServer.getMessages();
+ sendwServer.sendMessage(jsonObject.toString());
+ }
- String addressList = "DB100.DBW0";
-// addressList.add("DB100.DBW0");
-// addressList.add("DB100.DBW2");
-// addressList.add("DB100.DBW4");
-// addressList.add("DB100.DBW6");
-// addressList.add("DB100.DBW8");
-// addressList.add("DB100.DBW10");
-// addressList.add("DB100.DBW12");
-// addressList.add("DB100.DBW14");
-// addressList.add("DB100.DBW16");
-// addressList.add("DB100.DBW18");
-// addressList.add("DB100.DBW20");
-// addressList.add("DB100.DBW22");
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
- String lastMessage = messages.get(messages.size() - 1);
- System.out.println("messages锛�" + messages);
- String[] parts = lastMessage.split(",");
- List<Short> messageValues = new ArrayList<>();
- for (String part : parts) {
- try {
- // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
- String cleanedPart = part.replaceAll("[^0-9-]", "");
- short value = Short.parseShort(cleanedPart.trim());
- messageValues.add(value);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
- e.printStackTrace();
- }
+
+ }
+
+ private void writeToPlc() {
+ WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("action");
+ if (webSocketServer != null) {
+ List<String> messages = webSocketServer.getMessages();
+
+ String addressList = "DB100.DBW0";
+
+ if (!messages.isEmpty()) {
+ // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
+ String lastMessage = messages.get(messages.size() - 1);
+ System.out.println("messages锛�" + messages);
+ String[] parts = lastMessage.split(",");
+ List<Integer> messageValues = new ArrayList<>();
+ for (String part : parts) {
+ try {
+ // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
+ String cleanedPart = part.replaceAll("[^0-9-]", "");
+ Integer value = Integer.parseInt(cleanedPart.trim());
+ messageValues.add(value);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓烘暣鏁扮被鍨嬶紝鍒欏拷鐣ヨ閮ㄥ垎
+ e.printStackTrace();
}
-
- // 灏嗘秷鎭�煎啓鍏� PLC
-// S7control.getinstance().WriteWord(addressList, messageValues);
- System.out.println("messageValues锛�" + messageValues);
- System.out.println("addressList锛�" + addressList);
- // 娓呯┖娑堟伅鍒楄〃
- messages.clear();
}
+
+ // 灏嗘秷鎭�艰浆鎹负甯冨皵鍒楄〃
+ List<Boolean> messageBooleans = new ArrayList<>();
+ for (Integer value : messageValues) {
+ messageBooleans.add(value == 0 ? true : false);
+ }
+
+ // 灏嗗竷灏斿垪琛ㄥ啓鍏� PLC
+ S7control.getinstance().WriteBit(addressList, messageBooleans);
+ System.out.println("messageValues锛�" + messageBooleans);
+ System.out.println("addressList锛�" + addressList);
+
+ // 娓呯┖娑堟伅鍒楄〃
+ webSocketServer.clearMessages();
}
}
}
-}
+
+ private List<Boolean> paramList() {
+ // 鑾峰彇鍙傛暟鍒楄〃鐨勯�昏緫
+
+ return new ArrayList<>(); // 鍋囪杩斿洖绌哄垪琛�
+ }
+}
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
index 6886357..a931db3 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -1,5 +1,6 @@
package com.example.springboot.config;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
@@ -7,10 +8,14 @@
import com.example.springboot.component.PlcHold;
import com.example.springboot.component.Plcaction;
+import com.example.springboot.component.PlcParameter;
@Component
@Order(1)
+
public class AppRunnerConfig implements ApplicationRunner {
+
+
@Override
public void run(ApplicationArguments args) throws Exception {
// TODO Auto-generated method stub
@@ -19,6 +24,7 @@
new PlcHold().start();
new Plcaction().start();
+ new PlcParameter().start();
--
Gitblit v1.8.0