This commit is contained in:
wty 2022-10-11 14:02:14 +08:00
commit a7eed2d33b
22 changed files with 464 additions and 214 deletions

View File

@ -18,11 +18,11 @@ export function getGifCode(data) {
}) })
} }
export function getInfo(token) { export function getInfo() {
return request({ return request({
url: '/vue-admin-template/user/info', url: '/user/getSession',
method: 'get', method: 'get',
params: { token } params: {}
}) })
} }

View File

Before

Width:  |  Height:  |  Size: 3.7 MiB

After

Width:  |  Height:  |  Size: 3.7 MiB

View File

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

View File

@ -35,7 +35,7 @@ export default {
}, },
async logout() { async logout() {
await this.$store.dispatch('user/logout') await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`) this.$router.push('/login')
} }
} }
} }

View File

@ -32,7 +32,7 @@ export default {
'sidebar' 'sidebar'
]), ]),
routes() { routes() {
return this.$router.options.routes return this.$store.state.user.routes
}, },
activeMenu() { activeMenu() {
const route = this.$route const route = this.$route

View File

@ -2,11 +2,13 @@
* @Author: 龚祖望 573413756@qq.com * @Author: 龚祖望 573413756@qq.com
* @Date: 2022-05-16 09:16:41 * @Date: 2022-05-16 09:16:41
* @LastEditors: 龚祖望 573413756@qq.com * @LastEditors: 龚祖望 573413756@qq.com
* @LastEditTime: 2022-09-16 10:39:39 * @LastEditTime: 2022-10-09 15:28:49
* @FilePath: \dashengda\src\permission.js * @FilePath: \dashengda\src\permission.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import router from './router' import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style import 'nprogress/nprogress.css' // progress bar style
import { getToken } from '@/utils/auth' // get token from cookie import { getToken } from '@/utils/auth' // get token from cookie
@ -31,8 +33,31 @@ router.beforeEach(async(to, from, next) => {
next({ path: '/overview' }) next({ path: '/overview' })
NProgress.done() NProgress.done()
} else { } else {
next() const corpName = store.getters.corpName
NProgress.done() if (corpName) {
next()
NProgress.done()
} else {
try {
const res = await store.dispatch('user/getInfo')
store.dispatch('user/generateRoutes', res).then(() => {
router.addRoutes(store.getters.asyncRouters)
next()
}).catch(async err => {
// remove token and go to login page to re-login
await store.dispatch('user/resetToken')
Message.error(err || 'Has Error')
next(`/login?redirect=${to.path}`)
NProgress.done()
})
} catch (error) {
// remove token and go to login page to re-login
await store.dispatch('user/resetToken')
Message.error(error || 'Has Error')
next(`/login?redirect=${to.path}`)
NProgress.done()
}
}
} }
} else { } else {
/* has no token*/ /* has no token*/

View File

@ -75,6 +75,26 @@ export const constantRoutes = [
component: () => import('@/views/solution/qianjiang'), component: () => import('@/views/solution/qianjiang'),
hidden: true hidden: true
}, },
{
path: '/configuration/development',
component: () => import('@/views/configuration/development'),
hidden: true
},
{
path: '/configuration/transferStation',
component: () => import('@/views/configuration/transferStation'),
hidden: true
},
{
path: '/configuration/AiCity',
component: () => import('@/views/configuration/AiCity'),
hidden: true
},
{
path: '/configuration/bridgeMachine',
component: () => import('@/views/configuration/bridgeMachine'),
hidden: true
},
{ {
path: '/login', path: '/login',
component: () => import('@/views/login/index'), component: () => import('@/views/login/index'),
@ -176,37 +196,43 @@ export const constantRoutes = [
} }
] ]
}, },
// {
// path: '/configuration',
// component: Layout,
// name: 'Configuration',
// meta: { title: '组态管理', icon: 'configuration' },
// children: [
// {
// path: 'development',
// name: 'Development',
// component: () => import('@/views/configuration/development'),
// meta: { title: '组态开发' }
// },
// {
// path: 'transferStation',
// name: 'TransferStation',
// component: () => import('@/views/configuration/transferStation'),
// meta: { title: '变电站' }
// },
// {
// path: 'aicity',
// name: 'AiCity',
// component: () => import('@/views/configuration/AiCity'),
// meta: { title: '智慧城市' }
// },
// {
// path: 'bridgeMachine',
// name: 'BridgeMachine',
// component: () => import('@/views/configuration/bridgeMachine'),
// meta: { title: '大方架桥机' }
// }
// ]
// },
{ {
path: '/configuration', path: '/configureApp',
component: Layout, component: Layout,
name: 'Configuration', name: 'configureApp',
meta: { title: '组态管理', icon: 'configuration' }, meta: { title: '组态应用', icon: 'configuration', disabled: true }
children: [
{
path: 'development',
name: 'Development',
component: () => import('@/views/configuration/development'),
meta: { title: '组态开发' }
},
{
path: 'transferStation',
name: 'TransferStation',
component: () => import('@/views/configuration/transferStation'),
meta: { title: '变电站' }
},
{
path: 'aicity',
name: 'AiCity',
component: () => import('@/views/configuration/AiCity'),
meta: { title: '智慧城市' }
},
{
path: 'bridgeMachine',
name: 'BridgeMachine',
component: () => import('@/views/configuration/bridgeMachine'),
meta: { title: '大方架桥机' }
}
]
}, },
{ {
path: '/log', path: '/log',
@ -228,48 +254,36 @@ export const constantRoutes = [
} }
] ]
}, },
{
path: '/data',
component: Layout,
name: 'Data',
meta: { title: '数据管理', icon: 'data' },
children: [
{
path: 'realTime',
name: 'RealTime',
component: () => import('@/views/data/realTime/index'),
meta: { title: '实时数据' }
},
{
path: 'history',
name: 'History',
component: () => import('@/views/data/history/index'),
meta: { title: '历史数据' }
},
{
path: 'value',
name: 'Value',
component: () => import('@/views/data/value/index'),
meta: { title: '数据价值' }
}
]
},
// {
// path: 'external-link',
// component: Layout,
// children: [
// {
// path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
// meta: { title: 'External Link', icon: 'link' }
// }
// ]
// },
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true } { path: '*', redirect: '/404', hidden: true }
] ]
export const asyncRouter = [{
path: '/data',
component: Layout,
name: 'Data',
meta: { title: '数据管理', icon: 'data', permission: ['dashengda'] },
children: [
{
path: 'realTime',
name: 'RealTime',
component: () => import('@/views/data/realTime/index'),
meta: { title: '实时数据', permission: ['dashengda'] }
},
{
path: 'history',
name: 'History',
component: () => import('@/views/data/history/index'),
meta: { title: '历史数据', permission: ['dashengda'] }
},
{
path: 'value',
name: 'Value',
component: () => import('@/views/data/value/index'),
meta: { title: '数据价值', permission: ['dashengda'] }
}
]
}]
const createRouter = () => new Router({ const createRouter = () => new Router({
mode: 'history', // require service support mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
@ -277,6 +291,7 @@ const createRouter = () => new Router({
}) })
const router = createRouter() const router = createRouter()
router.addRoutes(asyncRouter)
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() { export function resetRouter() {

View File

@ -4,6 +4,9 @@ const getters = {
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
name: state => state.user.name, name: state => state.user.name,
corpName: state => state.user.corpName corpName: state => state.user.corpName,
abbrCorpName: state => state.user.abbrCorpName,
asyncRouters: state => state.user.asyncRouters,
routes: state => state.user.routes
} }
export default getters export default getters

View File

@ -2,20 +2,50 @@
* @Author: 龚祖望 573413756@qq.com * @Author: 龚祖望 573413756@qq.com
* @Date: 2022-05-16 09:16:41 * @Date: 2022-05-16 09:16:41
* @LastEditors: 龚祖望 573413756@qq.com * @LastEditors: 龚祖望 573413756@qq.com
* @LastEditTime: 2022-08-31 20:21:28 * @LastEditTime: 2022-10-09 15:39:05
* @FilePath: \dashengda\src\store\modules\user.js * @FilePath: \dashengda\src\store\modules\user.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import { login, logout } from '@/api/user' import { login, logout, getInfo } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth' import { getToken, setToken, removeToken } from '@/utils/auth'
import { resetRouter } from '@/router' import { resetRouter, constantRoutes, asyncRouter } from '@/router'
function filterAsyncRouter(routerMap, roles) {
const accessedRouters = routerMap.filter(route => {
if (hasPermission([roles.permissions], route)) {
if (route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, roles)
}
return true
}
return false
})
return accessedRouters
}
function hasPermission(permission, route) {
if (route.meta && route.meta.permission) {
let flag = true
for (let i = 0; i < permission.length; i++) {
flag = route.meta.permission.includes(permission[i])
if (flag) {
return true
}
}
return false
}
return true
}
const getDefaultState = () => { const getDefaultState = () => {
return { return {
token: getToken(), token: getToken(),
name: '', name: '',
avatar: '', avatar: '',
corpName: '浙江大胜达包装股份有限公司' corpName: '',
abbrCorpName: '',
permissions: [],
asyncRouters: []
} }
} }
@ -33,6 +63,19 @@ const mutations = {
}, },
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
state.avatar = avatar state.avatar = avatar
},
SET_CORPNAME: (state, corpName) => {
state.corpName = corpName
},
SET_ABBRCORPNAME: (state, abbrCorpName) => {
state.abbrCorpName = abbrCorpName
},
SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions
},
SET_ROUTERS: (state, asyncRouters) => {
state.asyncRouters = asyncRouters
state.routes = [...constantRoutes, ...asyncRouters]
} }
} }
@ -42,7 +85,6 @@ const actions = {
const { username, password } = userInfo const { username, password } = userInfo
const data = { username, password } const data = { username, password }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// console.log('res', res)
login(data).then(res => { login(data).then(res => {
if (res.code === '200000') { if (res.code === '200000') {
setToken('success') setToken('success')
@ -57,26 +99,26 @@ const actions = {
}) })
}, },
// // get user info // get user info
// getInfo({ commit, state }) { getInfo({ commit, state }) {
// return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// getInfo(state.token).then(response => { getInfo(state.token).then(response => {
// const { data } = response const { data } = response
// if (!data) { if (!data) {
// return reject('Verification failed, please Login again.') return reject('Verification failed, please Login again.')
// } }
// const { name, avatar } = data
// const { name, avatar } = data commit('SET_CORPNAME', data.corpname)
commit('SET_ABBRCORPNAME', data.abbrcorpname)
// commit('SET_NAME', name) commit('SET_PERMISSIONS', [data.permissions])
// commit('SET_AVATAR', avatar) resolve(data)
// resolve(data) }).catch(error => {
// }).catch(error => { reject(error)
// reject(error) })
// }) })
// }) },
// },
// user logout // user logout
logout({ commit, state }) { logout({ commit, state }) {
@ -99,6 +141,14 @@ const actions = {
commit('RESET_STATE') commit('RESET_STATE')
resolve() resolve()
}) })
},
generateRoutes({ commit }, roles) {
return new Promise(resolve => {
const accessedRouters = filterAsyncRouter(asyncRouter, roles)
console.log('accessedRouters', accessedRouters)
commit('SET_ROUTERS', accessedRouters)
resolve()
})
} }
} }

View File

@ -48,6 +48,28 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
<div
class="menu"
:class="{ active: current === 4 }"
style="padding: 0 20px"
>
<el-dropdown @command="tpPage">
<span class="menu"> 组态开发 </span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
command="/configuration/development"
>流程规划</el-dropdown-item>
<el-dropdown-item
command="/configuration/transferStation"
>变电站</el-dropdown-item>
<el-dropdown-item
command="/configuration/AiCity"
>智慧城市</el-dropdown-item>
<el-dropdown-item
command="/configuration/bridgeMachine"
>大方架桥机</el-dropdown-item>
</el-dropdown-menu></el-dropdown>
</div>
<div <div
class="menu" class="menu"
:class="{ active: current === 3 }" :class="{ active: current === 3 }"
@ -169,7 +191,6 @@ export default {
} }
}, },
tpPage(router) { tpPage(router) {
console.log('toPage', router)
this.$router.push({ path: router }) this.$router.push({ path: router })
} }
} }
@ -201,8 +222,7 @@ export default {
right: 120px; right: 120px;
top: 3px; top: 3px;
background-color: rgba(95, 155, 241, 0.39); background-color: rgba(95, 155, 241, 0.39);
width: 700px;
width: 600px;
.menu { .menu {
height: 70px; height: 70px;
line-height: 70px; line-height: 70px;

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<iframe id="ifm" style="margin-top:-130px;height: 90vh;border: medium none" src="https://t.le5le.com/?id=6128887203582f00012b8a14" width="100%" :height="iframeHeight" /> <iframe id="ifm" style="margin-top:-75px;border: medium none" src="https://t.le5le.com/?id=6128887203582f00012b8a14" width="100%" :height="iframeHeight" />
</div> </div>
</template> </template>
@ -8,7 +8,7 @@
export default { export default {
computed: { computed: {
iframeHeight() { iframeHeight() {
return window.innerHeight - 185 return window.innerHeight + 30
} }
} }
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<iframe id="ifm" style="margin-top:-130px;height: 90vh;border: medium none" src="https://t.le5le.com/?id=61c98f99311360740ed7a18e" width="100%" :height="iframeHeight" /> <iframe id="ifm" style="margin-top:-75px;border: medium none" src="https://t.le5le.com/?id=61c98f99311360740ed7a18e" width="100%" :height="iframeHeight" />
</div> </div>
</template> </template>
@ -8,7 +8,8 @@
export default { export default {
computed: { computed: {
iframeHeight() { iframeHeight() {
return window.innerHeight - 185 console.log('height', window.innerHeight)
return window.innerHeight + 30
} }
} }
} }

View File

@ -156,7 +156,7 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
.home { .home {
height: calc(100vh - 50px); height: 100vh;
} }
.avater{ .avater{
display: none; display: none;

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<iframe id="ifm" style="margin-top:-130px;height: 90vh;border: medium none" src="https://t.le5le.com/?id=6318527c288d77e4cee1a1bd" width="100%" :height="iframeHeight" /> <iframe id="ifm" style="margin-top:-75px;border: medium none" src="https://t.le5le.com/?id=6318527c288d77e4cee1a1bd" width="100%" :height="iframeHeight" />
</div> </div>
</template> </template>
@ -8,7 +8,7 @@
export default { export default {
computed: { computed: {
iframeHeight() { iframeHeight() {
return window.innerHeight - 185 return window.innerHeight + 30
} }
}, },
mounted() { mounted() {

View File

@ -250,55 +250,56 @@ export default {
setInterval(this.animation, 3000) setInterval(this.animation, 3000)
}, },
methods: { methods: {
getData() { async getData() {
getCount().then(res => { const unprocessedAlarmData = await getCount()
this.unprocessedAlarmNum = res.data const alarmLevelData = await getAlarmLevelCount()
}) const runStatusData = await getRunStatusCount()
getAlarmLevelCount().then(res => { const typeCountData = await getTypeCount()
const level0Num = res.data.filter(item => item.alarm_level === 0)[0]?.count || 0
const level1Num = res.data.filter(item => item.alarm_level === 1)[0]?.count || 0 this.unprocessedAlarmNum = unprocessedAlarmData.data
const level2Num = res.data.filter(item => item.alarm_level === 2)[0]?.count || 0
const level3Num = res.data.filter(item => item.alarm_level === 3)[0]?.count || 0 const level0Num = alarmLevelData.data.filter(item => item.alarm_level === 0)[0]?.count || 0
const alarmData = [{ const level1Num = alarmLevelData.data.filter(item => item.alarm_level === 1)[0]?.count || 0
value: level0Num, const level2Num = alarmLevelData.data.filter(item => item.alarm_level === 2)[0]?.count || 0
name: '紧急' const level3Num = alarmLevelData.data.filter(item => item.alarm_level === 3)[0]?.count || 0
}, { const alarmData = [{
value: level1Num, value: level0Num,
name: '重要' name: '紧急'
}, { }, {
value: level2Num, value: level1Num,
name: '次要' name: '重要'
}, { }, {
value: level3Num, value: level2Num,
name: '提示' name: '次要'
}] }, {
this.alarmTotalNum = res.data.reduce((pre, cur) => pre + cur.count, 0) value: level3Num,
this.options[1].series[0].data = alarmData name: '提示'
}) }]
getRunStatusCount().then(res => { this.alarmTotalNum = alarmLevelData.data.reduce((pre, cur) => pre + cur.count, 0)
const status0Num = res.data.filter(item => item.runstatus === 0)[0]?.count || 0 this.options[1].series[0].data = alarmData
const status1Num = res.data.filter(item => item.runstatus === 1)[0]?.count || 0
const status2Num = res.data.filter(item => item.runstatus === 2)[0]?.count || 0 const status0Num = runStatusData.data.filter(item => item.runstatus === 0)[0]?.count || 0
const runstatusData = [{ const status1Num = runStatusData.data.filter(item => item.runstatus === 1)[0]?.count || 0
value: status0Num, const status2Num = runStatusData.data.filter(item => item.runstatus === 2)[0]?.count || 0
name: '运行' const runstatusData = [{
}, { value: status0Num,
value: status1Num, name: '运行'
name: '待机' }, {
}, { value: status1Num,
value: status2Num, name: '待机'
name: '警告' }, {
}] value: status2Num,
this.runningNum = status0Num name: '警告'
this.options[2].series[0].data = runstatusData }]
}) this.runningNum = status1Num
getTypeCount().then(res => { this.options[2].series[0].data = runstatusData
const typeData = res.data.map(item => {
return { name: item.type, value: item.count } const typeData = typeCountData.data.map(item => {
}) return { name: item.type, value: item.count }
this.options[0].series[0].data = typeData
this.terminalTotalNum = res.data.reduce((pre, cur) => pre + cur.count, 0)
}) })
this.options[0].series[0].data = typeData
this.terminalTotalNum = typeCountData.data.reduce((pre, cur) => pre + cur.count, 0)
this.myCharts.forEach((chart, index) => { this.myCharts.forEach((chart, index) => {
chart.setOption(this.options[index]) chart.setOption(this.options[index])
}) })

View File

@ -142,7 +142,6 @@ export default {
watch: { watch: {
$route: { $route: {
handler: function(route) { handler: function(route) {
console.log('route', route)
this.redirect = route.query && route.query.redirect this.redirect = route.query && route.query.redirect
}, },
immediate: true immediate: true

View File

@ -2,7 +2,7 @@
* @Author: 龚祖望 573413756@qq.com * @Author: 龚祖望 573413756@qq.com
* @Date: 2022-05-16 09:16:41 * @Date: 2022-05-16 09:16:41
* @LastEditors: 龚祖望 573413756@qq.com * @LastEditors: 龚祖望 573413756@qq.com
* @LastEditTime: 2022-07-21 11:08:30 * @LastEditTime: 2022-10-09 15:42:31
* @FilePath: \dashengda\src\views\dashboard\index.vue * @FilePath: \dashengda\src\views\dashboard\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
@ -10,10 +10,10 @@
<div class="dashboard-container"> <div class="dashboard-container">
<swiper ref="mySwiper" :options="swiperOption" style="width:100%"> <swiper ref="mySwiper" :options="swiperOption" style="width:100%">
<swiper-slide> <swiper-slide>
<img class="slide-img" src="@/assets/images/slide1.png"> <img class="slide-img" :src="slide1">
</swiper-slide> </swiper-slide>
<swiper-slide> <swiper-slide>
<img class="slide-img" src="@/assets/images/slide2.png"> <img class="slide-img" :src="slide2">
</swiper-slide> </swiper-slide>
<swiper-slide> <swiper-slide>
<img class="slide-img" src="@/assets/images/slide3.png"> <img class="slide-img" src="@/assets/images/slide3.png">
@ -38,11 +38,25 @@ export default {
delay: 3000, delay: 3000,
disableOnInteraction: false disableOnInteraction: false
} }
} },
slide1: null,
slide2: null
} }
}, },
computed: { computed: {
...mapGetters(['name']) ...mapGetters(['abbrCorpName'])
},
created() {
switch (this.abbrCorpName) {
case '大胜达':
this.slide1 = require('@/assets/images/dashengda-slide1.png')
this.slide2 = require('@/assets/images/dashengda-slide2.png')
break
case '杭萧钢构':
this.slide1 = require('@/assets/images/hangxiao-slide1.png')
this.slide2 = require('@/assets/images/hangxiao-slide2.png')
break
}
}, },
mounted() { mounted() {
const imgs = document.getElementsByClassName('slide-img') const imgs = document.getElementsByClassName('slide-img')

View File

@ -6,7 +6,7 @@
style="align-items: baseline; margin-bottom: 30px" style="align-items: baseline; margin-bottom: 30px"
> >
<div class="header"> <div class="header">
<h1 class="title">大胜达PLC管理</h1> <h1 class="title">{{ abbrCorpName+'PLC管理' }}</h1>
<span class="date">{{ date }}</span> <span class="date">{{ date }}</span>
</div> </div>
</el-row> </el-row>
@ -172,7 +172,7 @@
:value="item" :value="item"
/> />
</el-select> </el-select>
<span v-else>{{ form.baud_rate }}</span> <span v-else>{{ form.socketConfig.baud_rate }}</span>
</el-form-item> </el-form-item>
<el-form-item label="校验位:"> <el-form-item label="校验位:">
<el-select v-if="add" v-model="form.socketConfig.check_mode"> <el-select v-if="add" v-model="form.socketConfig.check_mode">
@ -182,7 +182,7 @@
:value="item" :value="item"
/> />
</el-select> </el-select>
<span v-else>{{ form.check_mode }}</span> <span v-else>{{ form.socketConfig.check_mode }}</span>
</el-form-item> </el-form-item>
<el-form-item label="停止位:"> <el-form-item label="停止位:">
<el-select v-if="add" v-model="form.socketConfig.stop_bits"> <el-select v-if="add" v-model="form.socketConfig.stop_bits">
@ -192,7 +192,7 @@
:value="item" :value="item"
/> />
</el-select> </el-select>
<span v-else>{{ form.stop_bits }}</span> <span v-else>{{ form.socketConfig.stop_bits }}</span>
</el-form-item> </el-form-item>
<el-form-item label="数位号:"> <el-form-item label="数位号:">
<el-select v-if="add" v-model="form.socketConfig.data_bits"> <el-select v-if="add" v-model="form.socketConfig.data_bits">
@ -202,7 +202,7 @@
:value="item" :value="item"
/> />
</el-select> </el-select>
<span v-else>{{ form.data_bits }}</span> <span v-else>{{ form.socketConfig.data_bits }}</span>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -311,15 +311,15 @@
<el-table-column v-if="form.brand === 'mufg'" align="center" label="监控时间" prop="monitoring_timer" /> <el-table-column v-if="form.brand === 'mufg'" align="center" label="监控时间" prop="monitoring_timer" />
</el-table> </el-table>
<el-row v-if="add" type="flex" justify="space-between" style="width:60%;margin: 20px auto 0;"> <el-row v-if="add" type="flex" justify="space-between" style="width:60%;margin: 20px auto 0;">
<div> <div class="table_btn">
<img src="@/assets/images/plus_orange.png" width="35px" @click="addParam"> <img src="@/assets/images/plus_orange.png" width="35px" @click="addParam">
<p>添加</p> <p>添加</p>
</div> </div>
<div> <div class="table_btn">
<img src="@/assets/images/minus_orange.png" width="35px" @click="removeParam"> <img src="@/assets/images/minus_orange.png" width="35px" @click="removeParam">
<p>删除</p> <p>删除</p>
</div> </div>
<div> <div class="table_btn">
<img src="@/assets/images/remove_orange.png" width="35px" @click="removeAllParam"> <img src="@/assets/images/remove_orange.png" width="35px" @click="removeAllParam">
<p>清空</p> <p>清空</p>
</div> </div>
@ -348,7 +348,9 @@
label-width="130px" label-width="130px"
> >
<el-form-item label="配方名称:"> <el-form-item label="配方名称:">
<el-input v-if="add" v-model="form.productName" /> <el-input v-if="add" v-model="form.productName">
<template slot="prepend">{{ productPreName }}</template>
</el-input>
<span v-else>{{ form.productName }}</span> <span v-else>{{ form.productName }}</span>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -360,7 +362,7 @@
class="dialog_btn" class="dialog_btn"
@click="lastStep" @click="lastStep"
>上一步</el-button> >上一步</el-button>
<el-button class="dialog_btn primary" @click="nextStep">{{ <el-button v-if="!(active ===2 && !add)" class="dialog_btn primary" @click="nextStep">{{
active === 2 ? '保存' : '下一步' active === 2 ? '保存' : '下一步'
}}</el-button> }}</el-button>
</el-row> </el-row>
@ -371,6 +373,7 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import { getList, add, remove } from '@/api/terminal/plc' import { getList, add, remove } from '@/api/terminal/plc'
export default { export default {
@ -444,6 +447,21 @@ export default {
currentIndex: -1 currentIndex: -1
} }
}, },
computed: {
...mapGetters(['abbrCorpName']),
productPreName() {
let pre = ''
switch (this.abbrCorpName) {
case '大胜达':
pre = 'dsd-'
break
case '杭萧钢构':
pre = 'hxgg-'
break
}
return pre
}
},
mounted() { mounted() {
this.date = new Date().toLocaleDateString() this.date = new Date().toLocaleDateString()
this.getList() this.getList()
@ -510,6 +528,7 @@ export default {
}, },
nextStep() { nextStep() {
if (this.active === 2) { if (this.active === 2) {
this.form.productName = this.productPreName + this.form.productName
add(this.form).then(res => { add(this.form).then(res => {
if (res.code === '200000') { if (res.code === '200000') {
this.getList() this.getList()
@ -576,12 +595,6 @@ export default {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
color: rgba(0, 0, 0, 0.85); color: rgba(0, 0, 0, 0.85);
} }
.el-input {
line-height: 4;
}
.el-button:hover,.el-button:focus {
background-color: #fff;
}
.step2_params{ .step2_params{
.el-form-item__label{ .el-form-item__label{
color: #ff4e00; color: #ff4e00;
@ -595,6 +608,9 @@ export default {
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-button:hover,.el-button:focus {
background-color: #fff;
}
.header { .header {
font-family: Lato; font-family: Lato;
.title { .title {
@ -627,7 +643,7 @@ export default {
font-size: 20px; font-size: 20px;
font-family: Microsoft YaHei; font-family: Microsoft YaHei;
font-weight: bold; font-weight: bold;
margin: 10px; margin: 10px 0;
} }
.remove_icon { .remove_icon {
font-size: 18px; font-size: 18px;
@ -975,6 +991,9 @@ export default {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
margin: 0; margin: 0;
} }
.table_btn{
cursor: pointer;
}
} }
.step3_tab { .step3_tab {
position: relative; position: relative;

View File

@ -2,9 +2,9 @@
<div class="app-container" style="min-height: calc(100vh - 50px);"> <div class="app-container" style="min-height: calc(100vh - 50px);">
<el-row type="flex" justify="space-between" style="align-items: baseline;margin-bottom: 30px;"> <el-row type="flex" justify="space-between" style="align-items: baseline;margin-bottom: 30px;">
<div class="header"> <div class="header">
<h1 class="title">大胜达现有设备接入</h1> <h1 class="title">{{ abbrCorpName+'现有设备接入' }}</h1>
<span class="date">{{ date }}</span> <span class="date">{{ date }}</span>
<span class="device_num">{{ '共'+activeList.length + '个设备' }}</span> <span class="device_num">{{ '共'+(activeList.length+disactiveList.length) + '个设备' }}</span>
</div> </div>
<el-button type="primary" style="height: fit-content" @click="selectCompany">切换企业</el-button> <el-button type="primary" style="height: fit-content" @click="selectCompany">切换企业</el-button>
</el-row> </el-row>
@ -82,7 +82,7 @@
<el-form-item label="设备序列号:" prop="no"> <el-form-item label="设备序列号:" prop="no">
<el-input v-model="form.no" /> <el-input v-model="form.no" />
</el-form-item> </el-form-item>
<el-form-item label="设备描述:" prop="desc"> <el-form-item label="设备描述:" prop="devicedesc">
<el-input v-model="form.devicedesc" /> <el-input v-model="form.devicedesc" />
</el-form-item> </el-form-item>
<el-form-item label="设备状态:" prop="activestatus"> <el-form-item label="设备状态:" prop="activestatus">
@ -101,6 +101,7 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import { remove, getList, add, active } from '@/api/terminal/add' import { remove, getList, add, active } from '@/api/terminal/add'
export default { export default {
@ -117,32 +118,32 @@ export default {
devicedesc: '', devicedesc: '',
activestatus: 0 activestatus: 0
}, },
productList: [ // productList: [
{ // {
name: '彩印车间', // name: '',
src: require('@/assets/images/device.png'), // src: require('@/assets/images/device.png'),
color: '#00CCF2', // color: '#00CCF2',
val: 0 // val: 0
}, // },
{ // {
name: '生产车间', // name: '',
src: require('@/assets/images/device2.png'), // src: require('@/assets/images/device2.png'),
color: '#FAB05A', // color: '#FAB05A',
val: 1 // val: 1
}, // },
{ // {
name: '成型车间', // name: '',
src: require('@/assets/images/device3.png'), // src: require('@/assets/images/device3.png'),
color: '#46D5A0', // color: '#46D5A0',
val: 2 // val: 2
}, // },
{ // {
name: '打包车间', // name: '',
src: require('@/assets/images/device4.png'), // src: require('@/assets/images/device4.png'),
color: '#9090F2', // color: '#9090F2',
val: 3 // val: 3
} // }
], // ],
deviceList: [ deviceList: [
{ {
name: 'RV400-NPU16T-5G-AR100', name: 'RV400-NPU16T-5G-AR100',
@ -172,12 +173,102 @@ export default {
} }
} }
}, },
computed: {
...mapGetters(['abbrCorpName']),
productList() {
let res
if (this.abbrCorpName === '杭萧钢构') {
res = [{
name: '数字工厂',
src: require('@/assets/images/device.png'),
color: '#00CCF2',
val: 0
}]
}
if (this.abbrCorpName === '大胜达') {
res = [
{
name: '彩印车间',
src: require('@/assets/images/device.png'),
color: '#00CCF2',
val: 0
},
{
name: '生产车间',
src: require('@/assets/images/device2.png'),
color: '#FAB05A',
val: 1
},
{
name: '成型车间',
src: require('@/assets/images/device3.png'),
color: '#46D5A0',
val: 2
},
{
name: '打包车间',
src: require('@/assets/images/device4.png'),
color: '#9090F2',
val: 3
}
]
}
return res
}
},
mounted() { mounted() {
this.date = new Date().toLocaleDateString() this.date = new Date().toLocaleDateString()
this.getList(0) this.getList(0)
this.getList(1) this.getList(1)
// this.randomData()
}, },
methods: { methods: {
// randomData() {
// for (let i = 16; i < 17; i++) {
// const productname = this.productList[0].name
// const src = this.productList[0].src
// const color = this.productList[0].color
// const randomDeviceNum = Math.round(Math.random() * 10) % 5
// const type = this.deviceList[randomDeviceNum].name
// const no = 'S' + String(i).padStart(2, '0')
// const desc = ['', '', '', 'H', '', '', '', '', '', '', '线', '']
// const len = desc.length
// const devicedesc = desc[i % len]
// const temp = {
// src, productname, type, no, devicedesc, color
// }
// const runstatus = Math.round(Math.random() * 10) % 2 + 1
// const statusdesc = runstatus === 0 ? '' : runstatus === 1 ? '' : ''
// const dataTemplate = {
// runstatus,
// statusdesc,
// kernel: 'rt-thread kenel',
// webversion: '1.0',
// ipaddr: '192.168.131.29',
// netmask: '255.255.254.0',
// gateway: '192.168.130.1',
// dnsserver0: '10.0.110.21',
// dnsserver1: '10.0.110.20',
// topic: '/broadcast/hf6mzwdVnJg/989898',
// serveraddr: 'zwdVnJg.iot-as-mqtt.cn-shanghai.aliyuncs.com',
// serverport: '1883',
// username: 'test1&hf6mzwdVnJg',
// clientid: '123|securemode=3,signmethod=hmacsha1|',
// privateserveraddr: '192.168.131.30',
// privateserverport: '9898',
// privateserverusername: 'admin'
// }
// add({
// productname, type, no, devicedesc, activestatus: 0, ...dataTemplate
// }).then(res => {
// }).catch(err => {
// })
// this.disactiveList.push(temp)
// }
// },
selectCompany() { selectCompany() {
this.$message.warning('暂无权限') this.$message.warning('暂无权限')
}, },
@ -194,6 +285,7 @@ export default {
}, },
chooseCard(list) { chooseCard(list) {
list.forEach(item => { list.forEach(item => {
console.log('productList', this.productList)
const temp = this.productList.filter(product => product.name === item.productname) const temp = this.productList.filter(product => product.name === item.productname)
item.color = temp[0].color item.color = temp[0].color
item.src = temp[0].src item.src = temp[0].src
@ -321,10 +413,14 @@ export default {
.delete-icon, .delete-icon,
.add-icon { .add-icon {
position: absolute; position: absolute;
right: 10px; right: 5px;
bottom: 10px; bottom: 5px;
cursor: pointer; cursor: pointer;
} }
.add-icon{
right: -4px;
bottom: -4px;
}
.device-icon { .device-icon {
vertical-align: middle; vertical-align: middle;
margin-right: 10px; margin-right: 10px;

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-card> <el-card v-if="abbrCorpName === '大胜达'">
<img src="@/assets/images/compass.png" class="compass"></img> <img src="@/assets/images/compass.png" class="compass"></img>
<div class="workshop"> <div class="workshop">
<div class="elec-terminal fm100" @click="showDialog('A000001')"> <div class="elec-terminal fm100" @click="showDialog('A000001')">
@ -79,6 +79,7 @@
</div> </div>
</div></el-card> </div></el-card>
<iframe v-else src="http://115.236.53.226:9898/home" width="100%" class="ifm" />
<!-- 设备详情弹窗 --> <!-- 设备详情弹窗 -->
<el-dialog title="设备监控详情" :visible.sync="visible" :top="dialogTop"> <el-dialog title="设备监控详情" :visible.sync="visible" :top="dialogTop">
<div class="card_detail"> <div class="card_detail">
@ -102,7 +103,7 @@
<div class="temper">{{ current.temper }}<span class="unit">°C</span></div> <div class="temper">{{ current.temper }}<span class="unit">°C</span></div>
<p>{{ '内存使用率:'+current.cpuRate+'%' }}</p> <p>{{ '内存使用率:'+current.cpuRate+'%' }}</p>
<p>{{ '线程数:'+current.threadNum }}</p> <p>{{ '线程数:'+current.threadNum }}</p>
<p>{{ '耗电量:'+current.elec+'kW·h' }}</p> <p>{{ '功率:2W' }}</p>
<p class="location">{{ current.location }}</p> <p class="location">{{ current.location }}</p>
</div> </div>
</div> </div>
@ -123,6 +124,7 @@
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import Antenna from './components/Antenna' import Antenna from './components/Antenna'
export default { export default {
components: { Antenna }, components: { Antenna },
@ -580,6 +582,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['abbrCorpName']),
dialogTop() { dialogTop() {
return window.innerHeight > 880 ? '15vh' : '20px' return window.innerHeight > 880 ? '15vh' : '20px'
} }
@ -646,6 +649,10 @@ export default {
float: right; float: right;
} }
} }
.ifm{
height: 900px;
border: medium none
}
.workshop { .workshop {
position: relative; position: relative;
background: url(~@/assets/images/workshop.png) no-repeat; background: url(~@/assets/images/workshop.png) no-repeat;