Browse Source

解决菜单变形的bug

wangqin
hui 12 months ago
parent
commit
7cba9843fb
  1. 19
      ruoyi-ui/src/views/JiHeExpressway/components/Adaptation.vue
  2. 46
      ruoyi-ui/src/views/JiHeExpressway/index.vue
  3. 4
      ruoyi-ui/src/views/JiHeExpressway/pages/datav/roadNet/index.vue
  4. 46
      ruoyi-ui/src/views/JiHeExpressway/pages/datav/roadNet/sensors.vue
  5. 4
      ruoyi-ui/vue.config.js

19
ruoyi-ui/src/views/JiHeExpressway/components/Adaptation.vue

@ -15,6 +15,11 @@ export default {
defaultHeight: { defaultHeight: {
type: Number, type: Number,
default: () => 1080 default: () => 1080
},
headerHeight: {
type: Number,
default: () => 68
} }
}, },
provide() { provide() {
@ -33,10 +38,10 @@ export default {
computed: { computed: {
transformStyle() { transformStyle() {
const obj = {}; const obj = {};
obj["transform"] = `scaleX(${this.scale.scaleX}) scaleY(${this.scale.scaleY})`; obj["transform"] = `scaleX(${this.scale.scaleX}) scaleY(${this.scale.scaleY})`;
obj["width"] = this.defaultWidth + "px"; obj["width"] = this.defaultWidth + "px";
obj["height"] = this.defaultHeight + "px"; obj["height"] = this.defaultHeight - this.headerHeight + "px";
obj["top"] = this.headerHeight + "px";
// obj.top = `calc(50% - ${(this.defaultHeight / 2) * this.scaleY}px)`; // obj.top = `calc(50% - ${(this.defaultHeight / 2) * this.scaleY}px)`;
// obj.left = `calc(50% - ${(this.defaultWidth / 2) * this.scaleX}px)`; // obj.left = `calc(50% - ${(this.defaultWidth / 2) * this.scaleX}px)`;
@ -46,12 +51,16 @@ export default {
return this.scale return this.scale
} }
}, },
watch:{
headerHeight(){
}
},
methods: { methods: {
initScale() { initScale() {
let winW = window.innerWidth; let winW = window.innerWidth;
let winH = window.innerHeight; let winH = window.innerHeight - this.headerHeight;
this.setScale(this.scale.scaleX = winW / this.defaultWidth, this.scale.scaleY = winH / this.defaultHeight) this.setScale(this.scale.scaleX = winW / this.defaultWidth, this.scale.scaleY = winH / (this.defaultHeight - this.headerHeight))
}, },
setScale(scaleX, scaleY) { setScale(scaleX, scaleY) {
const cssGlobalVariable = [ const cssGlobalVariable = [
@ -141,7 +150,7 @@ body {
<style lang="scss" scoped> <style lang="scss" scoped>
.Adaptation { .Adaptation {
transition: all 0.15s linear; transition: all 0.15s linear;
position: absolute; position: fixed;
transform-origin: 0 0; transform-origin: 0 0;
} }
</style> </style>

46
ruoyi-ui/src/views/JiHeExpressway/index.vue

@ -1,12 +1,12 @@
<template> <template>
<Adaptation class="pageBox"> <div class="pageBox">
<HeaderMenu @onChange="handleChange" class="header" /> <HeaderMenu @onChange="handleChange" class="header" :style="headerStyle"/>
<div class="content"> <Adaptation class="content" :headerHeight="headerHeight">
<Transition name="fade"> <Transition name="fade">
<router-view v-if="isShowContent" /> <router-view v-if="isShowContent" />
</Transition> </Transition>
</div> </Adaptation>
</Adaptation> </div>
</template> </template>
<script> <script>
@ -19,14 +19,29 @@ export default {
name: "ji_ze_gao_su", name: "ji_ze_gao_su",
components: { components: {
HeaderMenu, HeaderMenu,
Adaptation, Adaptation
// ...modules // ...modules
}, },
data() { data() {
return { return {
isShowContent:false isShowContent:false,
headerHeight:68,
header: {
scale: 1,
originW: 1920,
originH: 68
},
}; };
}, },
computed:{
headerStyle(){
return {
width : `${this.header.originW}px`,
height : `${this.header.originH}px`,
transform : `scale(${this.header.scale}, ${this.header.scale})`
}
}
},
mounted(){ mounted(){
getBoardBaseData().then(res => { getBoardBaseData().then(res => {
this.isShowContent = true; this.isShowContent = true;
@ -34,8 +49,18 @@ export default {
// Promise.all()getBoardBaseData().then(()=>{ // Promise.all()getBoardBaseData().then(()=>{
// this.isShowContent = true ; // this.isShowContent = true ;
// }); // });
window.addEventListener(
"resize",
_.debounce(this.calcHeaderScale.bind(this), 360)
);
this.calcHeaderScale();
}, },
methods: { methods: {
calcHeaderScale(){
let winW = window.innerWidth;
this.header.scale = winW / this.header.originW;
this.headerHeight = this.header.scale * this.header.originH;
},
handleChange(activeMenu) { handleChange(activeMenu) {
this.$route.path != activeMenu.path && this.$router.push(activeMenu.path); this.$route.path != activeMenu.path && this.$router.push(activeMenu.path);
} }
@ -66,15 +91,14 @@ export default {
} }
.header { .header {
height: 68px; position: fixed;
transform-origin: left top;
left: 0; top:0; z-index: 1000;
} }
.content { .content {
flex: 1;
height: 0;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
position: relative;
pointer-events: none; pointer-events: none;
::v-deep { ::v-deep {

4
ruoyi-ui/src/views/JiHeExpressway/pages/datav/roadNet/index.vue

@ -316,7 +316,7 @@ h4, p, ul,li{ margin: 0; padding:0;}
flex-basis: 816px; display: flex; flex-direction: column; justify-content: space-between; flex-basis: 816px; display: flex; flex-direction: column; justify-content: space-between;
} }
.share{ .share{
height: 420px; display: flex; justify-content: center; align-items: center; flex:1.2; margin-bottom: 46px; display: flex; justify-content: center; align-items: center;
.arrow{ transform: rotateZ(90deg); left: 48%; top:calc(100% + 8px);} .arrow{ transform: rotateZ(90deg); left: 48%; top:calc(100% + 8px);}
.shareCon{ .shareCon{
background-image: url(./img/ShareAll.svg); background-position: center center; background-size: contain; background-repeat: no-repeat; width: 756px; height: 245px; display: flex; align-items: center; justify-content: center; position: relative; background-image: url(./img/ShareAll.svg); background-position: center center; background-size: contain; background-repeat: no-repeat; width: 756px; height: 245px; display: flex; align-items: center; justify-content: center; position: relative;
@ -340,7 +340,7 @@ h4, p, ul,li{ margin: 0; padding:0;}
} }
.apply{ .apply{
height: 390px; display: flex; flex-wrap: wrap; padding: 40px 45px; align-content: stretch; flex: 1; display: flex; flex-wrap: wrap; padding: 40px 45px; align-content: stretch;
.applyUnit{ flex-basis: 25%; display: flex; flex-direction: column; justify-content: center; align-items: center; .applyUnit{ flex-basis: 25%; display: flex; flex-direction: column; justify-content: center; align-items: center;
.con{ width: 140px; text-align: center; align-items: center; justify-content: center; .con{ width: 140px; text-align: center; align-items: center; justify-content: center;
h4, p{ font-family: PangMenZhengDao; font-size: 15px; line-height: 22px; margin: 0; padding:0; h4, p{ font-family: PangMenZhengDao; font-size: 15px; line-height: 22px; margin: 0; padding:0;

46
ruoyi-ui/src/views/JiHeExpressway/pages/datav/roadNet/sensors.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="compBox"> <div class="compBox">
<div id="container" class="compCon"> <div id="container" class="compCon" ref="canvas">
</div> </div>
</div> </div>
</template> </template>
@ -12,22 +12,34 @@ export default {
name: 'sensors', name: 'sensors',
data(){ data(){
return { return {
graph:null
} }
}, },
components: { components: {
}, },
mounted(){ mounted(){
this.initGraph(); this.refresh();
window.addEventListener("resize",
_.debounce(this.refresh.bind(this), 1000)
)
}, },
methods: { methods: {
initGraph(){ refresh(){
let _this = this;
this.$nextTick(() => {
_this.initGraph(_this.$refs["canvas"].offsetHeight);
})
},
initGraph(canvasHeight){
let unitH = 42;
let average = unitH + (canvasHeight - unitH*13)/12;
Graph.registerNode( Graph.registerNode(
'sensor', 'sensor',
{ {
width: 180, width: 180,
height: 42, height: unitH,
markup: [ markup: [
{ {
tagName: 'rect', tagName: 'rect',
@ -97,8 +109,12 @@ export default {
}, },
true, true,
) )
if(this.graph){
const graph = new Graph({ this.graph.clearCells();
this.graph = null;
}
this.graph = new Graph({
container: document.getElementById('container'), container: document.getElementById('container'),
autoResize: true, autoResize: true,
grid: false, grid: false,
@ -114,8 +130,8 @@ export default {
}) })
function createSub(x, y, title) { const createSub = (x, y, title) => {
return graph.addNode({ return this.graph.addNode({
x, x,
y, y,
shape: 'sensor', shape: 'sensor',
@ -132,8 +148,8 @@ export default {
}) })
} }
function link(source, target, vertices) { const link = (source, target, vertices) => {
return graph.addEdge({ return this.graph.addEdge({
source: { source: {
cell: source, cell: source,
anchor: { anchor: {
@ -153,7 +169,7 @@ export default {
}) })
} }
const main = graph.addNode({ const main = this.graph.addNode({
shape: 'circle', shape: 'circle',
x: 310, x: 310,
y: 80, y: 80,
@ -184,7 +200,7 @@ export default {
] ]
subItems.forEach((item, index) => { subItems.forEach((item, index) => {
let temp = createSub(0, index * 68, item); let temp = createSub(0, index * average, item);
link(main, temp); link(main, temp);
}) })
@ -219,7 +235,7 @@ export default {
// }, // },
// ]) // ])
// graph.zoomToFit({ padding: 0, maxScale: 1, mainScale: 1 }) // this.graph.zoomToFit({ padding: 0, maxScale: 1, mainScale: 1 })

4
ruoyi-ui/vue.config.js

@ -51,8 +51,8 @@ module.exports = {
// target: `http://10.0.81.204:8087`, //现场后台 刘文阁 // target: `http://10.0.81.204:8087`, //现场后台 刘文阁
// target: `http://10.168.69.255:8087`, //正晨后台 连现场物联 刘文阁 // target: `http://10.168.69.255:8087`, //正晨后台 连现场物联 刘文阁
// target: `http://10.168.78.135:8087`, //王钦 // target: `http://10.168.78.135:8087`, //王钦
target: `http://10.168.66.196:8087`, //正晨后台 连现场物联 刘文阁2 // target: `http://10.168.66.196:8087`, //正晨后台 连现场物联 刘文阁2
// target: `http://10.168.68.42:8087`, //王思祥 target: `http://10.168.68.42:8087`, //王思祥
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: "", ["^" + process.env.VUE_APP_BASE_API]: "",

Loading…
Cancel
Save