Commit 5729f00a authored by 李苏's avatar 李苏 💬

调整

parent c71c03d6
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
name: 'AppMain', name: 'AppMain',
computed: { computed: {
cachedViews() { cachedViews() {
console.log(this.$store.state.tagsView,'this.$store.state.tagsView')
return this.$store.state.tagsView.cachedViews return this.$store.state.tagsView.cachedViews
}, },
key() { key() {
......
...@@ -23,8 +23,7 @@ router.beforeEach((to, from, next) => { ...@@ -23,8 +23,7 @@ router.beforeEach((to, from, next) => {
if (store.state.app.isInit==false) { if (store.state.app.isInit==false) {
store.commit('app/changeInit') store.commit('app/changeInit')
store.dispatch('GenerateRoutes').then(accessRoutes => { store.dispatch('GenerateRoutes').then(accessRoutes => {
console.log(accessRoutes,'添加权限accessRoutes') router.addRoutes(accessRoutes)
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
}) })
......
...@@ -14,7 +14,10 @@ import views from 'common' ...@@ -14,7 +14,10 @@ import views from 'common'
import vue from 'vue' import vue from 'vue'
import commonList from "common/src/commonList" import commonList from "common/src/commonList"
import erpList from "common/src/erpList" import erpList from "common/src/erpList"
import iotList from "common/src/iotList"
console.log(iotList,'iotList')
import dynamicRouter from 'common/src/utils/router/dynamic.js' import dynamicRouter from 'common/src/utils/router/dynamic.js'
import getFinallyRouter from 'common/src/utils/router/getFinallyRouter.js'
import { import {
treeToList treeToList
} from 'common/src/utils/router/dynamic.js' } from 'common/src/utils/router/dynamic.js'
...@@ -99,7 +102,7 @@ const permission = { ...@@ -99,7 +102,7 @@ const permission = {
commit('SET_SYSTEMNAME', systemName) commit('SET_SYSTEMNAME', systemName)
/* 构建新list放进列表切换*/ /* 构建新list放进列表切换*/
localStorage.setItem('appName', appName) localStorage.setItem('appName', appName)
localStorage.setItem('appType', res.data.appType||'') localStorage.setItem('appType', res.data.appType || '')
/* 存储system id list*/ /* 存储system id list*/
/* 将可切换系统存入store*/ /* 将可切换系统存入store*/
let systemInfo = res.data.systemInfo || [] let systemInfo = res.data.systemInfo || []
...@@ -141,6 +144,7 @@ const permission = { ...@@ -141,6 +144,7 @@ const permission = {
let newPowerRoutes = filter(powerRoutes) let newPowerRoutes = filter(powerRoutes)
let newCommonList = filter(commonList.list) let newCommonList = filter(commonList.list)
let newErpList = filter(erpList.list) let newErpList = filter(erpList.list)
let newIotList = filter(iotList.list)
/* 转化菜单格式*/ /* 转化菜单格式*/
let delArr = [] let delArr = []
let newmenus = [] let newmenus = []
...@@ -150,14 +154,17 @@ const permission = { ...@@ -150,14 +154,17 @@ const permission = {
newmenus.push(mi) newmenus.push(mi)
} }
}) })
// res.data=[... // res.data=[...
// newCommonList, ...newErpList, ...newPowerRoutes] // newCommonList, ...newErpList, ...newPowerRoutes]
res.data = dynamicRouter([...newCommonList, ...newErpList, ...newPowerRoutes], asymenus) || [... res.data = dynamicRouter([...newCommonList, ...newErpList,...newIotList, ...newPowerRoutes], asymenus) || [...
newCommonList, ...newErpList, ...newPowerRoutes newCommonList, ...newErpList,...newIotList, ...newPowerRoutes
] ]
res.data = getFinallyRouter(menus, res.data)
/* 重置首页路由*/ /* 重置首页路由*/
// let hompePage = treeToList([...newCommonList,...newErpList,...newPowerRoutes]).filter(item=>item.mkid==localStorage.getItem('homeMkid')) // let hompePage = treeToList([...newCommonList,...newErpList,...newPowerRoutes]).filter(item=>item.mkid==localStorage.getItem('homeMkid'))
let ttlist = treeToList([...newCommonList, ...newErpList, ...newPowerRoutes]) let ttlist = treeToList([...newCommonList, ...newErpList, ...newIotList,...newPowerRoutes])
let homePage = ttlist.filter(item => item.mkid == localStorage.getItem('homeMkid')) let homePage = ttlist.filter(item => item.mkid == localStorage.getItem('homeMkid'))
/* 替换首页*/ /* 替换首页*/
...@@ -185,30 +192,30 @@ const permission = { ...@@ -185,30 +192,30 @@ const permission = {
} }
/* 移除默认路由*/ /* 移除默认路由*/
let newHome = { let newHome = {
path: '', path: '',
component: Layout, component: Layout,
redirect: 'index', redirect: 'index',
hidden: true, hidden: true,
children: [{ children: [{
path: 'index', path: 'index',
component: homePage[0].component , component: homePage[0].component,
name: 'Index', name: 'Index',
meta: { meta: {
title: '首页', title: '首页',
icon: 'dashboard', icon: 'dashboard',
affix: true affix: true
} }
}] }]
} }
router.addRoutes([newHome]) router.addRoutes([newHome])
constantRoutes.push(newHome) constantRoutes.push(newHome)
}else{ } else {
let newHome= { let newHome = {
path: '', path: '',
component: Layout, component: Layout,
redirect: 'index', redirect: 'index',
hidden: true, hidden: true,
children: [{ children: [{
path: 'index', path: 'index',
component: () => import('@/views/index'), component: () => import('@/views/index'),
name: 'Index', name: 'Index',
...@@ -216,11 +223,11 @@ const permission = { ...@@ -216,11 +223,11 @@ const permission = {
title: '首页', title: '首页',
icon: 'dashboard', icon: 'dashboard',
affix: true affix: true
} }
}] }]
} }
router.addRoutes([newHome]) router.addRoutes([newHome])
constantRoutes.push(newHome) constantRoutes.push(newHome)
} }
...@@ -275,6 +282,8 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { ...@@ -275,6 +282,8 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
} else if (route.erpComponent) { } else if (route.erpComponent) {
route.component = loadErpView(route.component) route.component = loadErpView(route.component)
} else if (route.iotComponent) {
route.component = loadIotView(route.component)
} else { } else {
route.component = loadView(route.component) route.component = loadView(route.component)
} }
...@@ -378,6 +387,16 @@ export const loadErpView = (view) => { ...@@ -378,6 +387,16 @@ export const loadErpView = (view) => {
return (resolve) => require([`common/src/erpViews/${view}`], resolve) return (resolve) => require([`common/src/erpViews/${view}`], resolve)
} }
} }
export const loadIotView = (view) => {
/* 改为common路由*/
if (process.env.NODE_ENV === 'development') {
return (resolve) => require([`common/src/iotViews/${view}`], resolve)
} else {
// 使用 import 实现生产环境的路由懒加载
// return () => import(`@/views/${view}`)
return (resolve) => require([`common/src/iotViews/${view}`], resolve)
}
}
export default permission export default permission
<template>
<DefaultDialog :app='app'>
<div slot="form" style="display: flex;height: 70vh;">
</div>
<div slot="reFooter" class="refooter" >
<span slot="footer" class="dialog-footer" >
<el-button @click="app.showDialog=false">取 消</el-button>
<el-button type="primary" @click="save()">保 存</el-button>
</span>
</div>
</DefaultDialog>
</template>
<script>
export default {
props: {
app: {
type: Object,
default: ()=>{
return {}
}
}
},
async mounted() {
},
data() {
return {
}
},
methods: {
}
}
</script>
<style scoped>
</style>
<!--
* @Description:生成基础baseEdit组件,屏蔽不必要细节
* @Author: lisu lisu@gavelinfo.com
* @Date: 2024-09-19 10:47:46
* @LastEditors: lisu lisu@gavelinfo.com
* @LastEditTime: 2024-09-19 14:24:01
* @FilePath: /easyWork/static/baseEdit.vue
-->
<template>
<!-- prop 穿透赋值 -->
<BaseEdit v-bind="$attrs" :config='editConfig'>
<template #dialog="ctx">
<!-- 嵌入默认页面额外弹框的插槽 ctx.editPage来操作默认页面 -->
</template>
<template #toolbar="ctx">
<!-- 嵌入默认页面从表上方插槽 ctx.editPage来操作默认页面 -->
<!-- <el-button @click="demo(ctx.editPage)" size='mini' type="primary">示例按钮</el-button> -->
<!-- <AuxButton :dynamic='true' :queryParams="{
sbxxTreeId:that.form.sbxxTreeId,
zt:'N'
}" :component='Qxsj' rename='选择缺陷数据' code='dynamic' @save="saveQxsj" /> -->
</template>
</BaseEdit>
</template>
<script>
export default {
data() {
return {
editConfig: {
/* 生成form表单 */
editColItemList: [{
label: '编码',
prop: 'code',
span: 12,
type: 'input',
required: true,
},
{
label: '名称',
prop: 'name',
span: 12,
type: 'input',
required: true,
},
{
label: '备注',
prop: 'bz',
span: 24,
type: 'input'
},
],
/* 生成主从表,为空数组默认不展示 */
editTableTitle: [
// {
// title: "序号",
// field: "xh",
// width: 50,
// align: "center"
// },
// {
// title: "点检部位",
// field: "bw",
// width: 180,
// },
// {
// title: "点检项目",
// field: "project",
// width: 160
// },
// {
// title: "点检标准",
// field: "standard",
// width: 140
// },
],
/* 子表名,可选 同editTableTitle一起用*/
detailTable: ''
}
}
},
methods: {
/**
* @description:示例按钮
* @param {*} ctx操作edit实例内容
* @return {*}
* @author: lisu
*/
// demo(ctx){}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<div style=" height: calc(100vh - 84px);width: 100%;">
<!-- 上半部分,占整个高度的一半 -->
<div v-echartResize="()=>{
iotChart.resize();
}" ref="iotChart" style=" background-color: #f0f2f5;height: 50%;width: 100%;">
<!-- 上半部分内容 -->
</div>
<!-- 下半部分,占整个高度的一半 -->
<div style="height: 50%;width: 100%;display: flex;">
<!-- 左半部分,占下半部分宽度的70% -->
<div style=" background-color: #e6ebf1;width: 100%;height: 100%;">
<TablePager :operateButtons='false' :fePage='true' v-if="tp1Loading" ref="tp1" :app='this'>
</TablePager>
</div>
<!-- 右半部分,占下半部分宽度的30% -->
<!-- <div style="width: 30%;height: 100%; background-color: #f0f2f5;">
</div> -->
</div>
</div>
</template>
<script>
const id = '2C9577B7912B11DD0191C190E23F64DF'
export default {
name: 'RealChartConfigure',
mounted() {
// 初始化echarts
this.$nextTick(() => {
this.iotChart = this.$echarts.init(this.$refs.iotChart, 'dark')
const url = this.$route.meta.url
this.baseUrl = this.id = this.matchString(url)[0]
this.apiGetConfig()
this.timer = setInterval(() => {
this.apiGetConfig()
}, 5000)
})
},
beforeDestroy() {
clearInterval(this.timer)
this.timer = null
},
data() {
return {
timer: null,
iotChart: null,
id: '',
tp1Loading: false,
tableTitle: [],
// 特殊补充
powerObj: {},
queryParams: {},
rowKey: 'timeStamp',
baseUrl: id
}
},
methods: {
matchString(str) {
const regex = /\/([^/]+)\/index/g;
const matches = [];
let match;
while ((match = regex.exec(str)) !== null) {
matches.push(match[1]);
}
return matches;
},
apiGetConfig() {
this.$post(`realchart/qsztfx/config/${this.id}`).then(result => {
if (result["success"]) {
var config = result["data"]["config"];
var option = {
title: {
text: config.name,
left: 'center',
y: 10
},
tooltip: {
trigger: 'axis',
formatter: function(params) {
var text = new Date(params[0]["value"][0]).Format("yyyy-MM-dd hh:mm:ss") + "<br />";
$.each(params, function(i, param) {
var line = '';
line = param["seriesName"] + ": ";
line += param["value"][1];
text += line + "<br/>";
});
return text;
}
},
xAxis: {
type: 'time',
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
splitLine: {
show: false
},
},
series: []
};
this.iotChart.setOption(option);
/* 渲染图*/
this.apiGetSearchdata()
}
})
},
apiGetSearchdata() {
this.$post(`/realchart/qsztfx/searchdata/${this.id}`).then(res => {
/* 渲染echarts*/
var records = res['data']['trenddata'];
var datas = records['datas'];
var legend = [];
var series = [];
var list = [];
var timeGroup = {};
$.each(datas, function(i, data) {
legend.push(data["name"]);
var points = [];
$.each(data["points"], function(key, value) {
points.push([Number(key), parseFloat(value || 0).toFixed(1)])
})
series.push({
name: data["name"],
type: 'line',
showSymbol: false,
hoverAnimation: false,
data: points
});
var last = '';
for (var i in data["points"]) {
last = i;
}
list.push({
name: data["name"],
value: data["points"][last]
});
var metric = data["metric"];
$.each(data["points"], function(key, value) {
var obj = timeGroup[key] || {};
obj["time"] = new Date(Number(key)).Format("yyyy-MM-dd hh:mm:ss");
obj[metric] = value;
timeGroup[key] = obj;
});
});
var option = this.iotChart.getOption();
option.legend = {
orient: "vertical",
x: "right",
padding: 10,
show: true,
data: legend
};
option.series = series;
this.iotChart.setOption(option);
/* */
const trenddata = res.data.trenddata
const list02 = trenddata.datas
const title = [{
label: '时间',
prop: 'timeStamp',
width: 180,
// formatter:function(a,b,c) {
// let show =
// return show
// }
}]
list02.forEach(item => {
/* 首先构建title*/
title.push({
label: item.name,
prop: item.name,
width: 180,
})
})
this.tableTitle = title
/* 开始构建表格数据*/
const timeStampObj = {}
list02.forEach(item => {
const points = item.points
let name = item.name
Object.keys(points).forEach(key => {
if (timeStampObj[key]) {
timeStampObj[key][name] = points[key]
} else {
timeStampObj[key] = {}
timeStampObj[key][name] = points[key]
}
})
})
const data = Object.keys(timeStampObj).map(key => {
timeStampObj[key]['timeStamp'] = $moment(parseInt(key)).format('YYYY-MM-DD HH:mm:ss')
return timeStampObj[key]
})
data.reverse()
this.tp1Loading = true
this.$nextTick(() => {
this.$refs.tp1.total = data.length
this.$refs.tp1.fePageData = data
this.$refs.tp1.tableData = this.$refs.tp1.fePageDateShow()
// 禁用刷新
this.$refs.tp1.refresh = () => {
return false
}
})
})
},
}
}
</script>
<style scoped>
/* 可以在这里添加样式 */
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment