Commit a4aa1936 authored by p-wanping.song's avatar p-wanping.song

Merge branch 'develop' of http://git.censoft.com.cn/rongtong/ruoyi-ui into swp-develop

parents 17699257 ee16aa03
...@@ -144,7 +144,21 @@ export const dynamicRoutes = [ ...@@ -144,7 +144,21 @@ export const dynamicRoutes = [
path: 'index/:id(\\d+)', path: 'index/:id(\\d+)',
component: () => import('@/views/risk/plan/ledgerdata'), component: () => import('@/views/risk/plan/ledgerdata'),
name: 'ledgerdata', name: 'ledgerdata',
meta: { title: '台账数据', activeMenu: '/risk/plan/ledgerdata' } meta: { title: '任务详情', activeMenu: '/risk/plan/ledgerdata' }
}
]
},
{
path: '/risk/drawCanvas/index',
component: Layout,
hidden: true,
permissions: ['system:ledgerRoom:list'],
children: [
{
path: 'index/:id(\\d+)',
component: () => import('@/views/risk/drawCanvas/index'),
name: 'drawCanvas',
meta: { title: '四色图', activeMenu: '/risk/drawCanvas/index' }
} }
] ]
}, },
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<img src="../../assets/imgs/north.png" alt="" /> <img src="../../assets/imgs/north.png" alt="" />
</div> --> </div> -->
<grid-layout <grid-layout
id="gridView"
:layout.sync="layout" :layout.sync="layout"
:col-num="colNum" :col-num="colNum"
:row-height="30" :row-height="30"
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
@moved="movedEvent" @moved="movedEvent"
:style="{ :style="{
backgroundColor: item.c, backgroundColor: item.c,
border: item.type == 'thorough' ? 'none !important' : '' border: item.type == 'thorough' ? 'none !important' : '',
}" }"
> >
<span class="text" :class="item.w > item.h * 5 ? '' : 'rowText'">{{ <span class="text" :class="item.w > item.h * 5 ? '' : 'rowText'">{{
...@@ -36,19 +37,25 @@ ...@@ -36,19 +37,25 @@
<!-- <span class="remove" @click="removeItem(item.i)" v-if="item.i && isEdit">x</span> --> <!-- <span class="remove" @click="removeItem(item.i)" v-if="item.i && isEdit">x</span> -->
</grid-item> </grid-item>
</grid-layout> </grid-layout>
<el-row style="margin-top: 20px; margin-left: 20px">
<el-button type="primary" @click="getPdf">导 出</el-button>
<el-button @click="cancelDraw">取 消</el-button>
</el-row>
</div> </div>
</template> </template>
<script> <script>
import html2Canvas from "html2canvas";
import JsPDF from "jspdf";
import { GridLayout, GridItem } from "vue-grid-layout"; import { GridLayout, GridItem } from "vue-grid-layout";
import { ledgerRoomList ,getDictList} from "@/api/risk/draw"; import { ledgerRoomList, getDictList } from "@/api/risk/draw";
// 动态添加/删除 // 动态添加/删除
export default { export default {
name: "riskView", name: "riskView",
components: { components: {
GridLayout, GridLayout,
GridItem GridItem,
}, },
data() { data() {
return { return {
...@@ -78,14 +85,14 @@ export default { ...@@ -78,14 +85,14 @@ export default {
isBase: false, isBase: false,
baseName: "", baseName: "",
baseArr: [], baseArr: [],
layoutData: [] layoutData: [],
}; };
}, },
props: { props: {
isView: { isView: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
mounted() { mounted() {
// screenfull.toggle(this.$refs.mapbox); // screenfull.toggle(this.$refs.mapbox);
...@@ -110,6 +117,53 @@ export default { ...@@ -110,6 +117,53 @@ export default {
this.getRoomInfo(); this.getRoomInfo();
}, },
methods: { methods: {
getPdf() {
var title = "四色图";
// html2Canvas(document.querySelector('#pdfDom'), { //这是在界面上设置一个id
//只下载id为pdfDom的内容
html2Canvas(document.querySelector("#gridView"), {
//body是下载整个界面
useCORS: true, //是否尝试使用CORS从服务器加载图像
allowTaint: true,
dpi: 300, //解决生产图片模糊
// width: 490, //canvas宽度
// height: 240, //canvas高度
// x: 0, //x坐标
// y: 0, //y坐标
async: false, //是否异步解析和呈现元素
foreignObjectRendering: true, //是否在浏览器支持的情况下使用ForeignObject渲染
}).then(function (canvas) {
console.log(canvas);
let contentWidth = canvas.width;
let contentHeight = canvas.height;
let pageHeight = (contentWidth / 592.28) * 841.89; // 一页pdf显示html页面生成的canvas高度;
let leftHeight = contentHeight; //未生成pdf的html页面高度
let position = 0; //pdf页面偏移
//a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
let imgWidth = 595.28;
let imgHeight = (592.28 / contentWidth) * contentHeight;
let pageData = canvas.toDataURL("image/jpeg", 1.0);
let PDF = new JsPDF("", "pt", "a4");
// 有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
//当内容未超过pdf一页显示的范围,无需分页
if (leftHeight < pageHeight) {
PDF.addImage(pageData, "JPEG", 0, 0, imgWidth, imgHeight);
} else {
while (leftHeight > 0) {
PDF.addImage(pageData, "JPEG", 20, position, imgWidth, imgHeight);
leftHeight -= pageHeight;
position -= 841.89;
if (leftHeight > 0) {
PDF.addPage();
}
}
}
PDF.save(title + ".pdf");
});
},
cancelDraw() {
this.$router.go(-1);
},
orientationChange() { orientationChange() {
if (window.orientation === 180 || window.orientation === 0) { if (window.orientation === 180 || window.orientation === 0) {
console.log("竖屏状态!"); console.log("竖屏状态!");
...@@ -179,14 +233,14 @@ export default { ...@@ -179,14 +233,14 @@ export default {
}, },
getRoomInfo() { getRoomInfo() {
let data = { let data = {
floorId: this.$route.params.floorId ? this.$route.params.floorId : "4" floorId: this.$route.params.floorId ? this.$route.params.floorId : "4",
}; };
ledgerRoomList(data) ledgerRoomList(data)
.then(res => { .then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.layout = []; this.layout = [];
this.layoutData = res.data; this.layoutData = res.data;
res.data.forEach(item => { res.data.forEach((item) => {
item.position = JSON.parse(item.position); item.position = JSON.parse(item.position);
item.position.i = item.id; item.position.i = item.id;
item.position.id = item.id; item.position.id = item.id;
...@@ -198,49 +252,49 @@ export default { ...@@ -198,49 +252,49 @@ export default {
// //添加页面不显示颜色 // //添加页面不显示颜色
// item.position.c = "#e6e5e5"; // item.position.c = "#e6e5e5";
// } else { // } else {
/** /**
* 根据风险评分来匹配相应的颜色 * 根据风险评分来匹配相应的颜色
* score 风险评分字段 * score 风险评分字段
*/ */
// item.score = Number(item.score) // item.score = Number(item.score)
// if (item.score>=21 && item.score <= 27) { //优 // if (item.score>=21 && item.score <= 27) { //优
// item.position.c = this.colorList[3] // item.position.c = this.colorList[3]
// }else if(item.score>=14 && item.score <=20){ //良 // }else if(item.score>=14 && item.score <=20){ //良
// item.position.c = this.colorList[2] // item.position.c = this.colorList[2]
// }else if (item.score>=7&& item.score <= 13) { //中 // }else if (item.score>=7&& item.score <= 13) { //中
// item.position.c = this.colorList[1] // item.position.c = this.colorList[1]
// }else if (item.score>=0 && item.score <= 6) { //差 // }else if (item.score>=0 && item.score <= 6) { //差
// item.position.c = this.colorList[0] // item.position.c = this.colorList[0]
// } // }
item.position.c = this.colorList[Math.floor(Math.random() * 4)]; item.position.c = this.colorList[Math.floor(Math.random() * 4)];
// } // }
this.layout.push(item.position); this.layout.push(item.position);
}); });
// console.log('layout==>>',this.layout) // console.log('layout==>>',this.layout)
} }
}) })
.catch(err => { .catch((err) => {
console.log("err==>>", err); console.log("err==>>", err);
}); });
// getDictList({ // getDictList({
// dictType: "risk_plan_room_type" // dictType: "risk_plan_room_type"
// }).then(res => { // }).then(res => {
// this.roomArr = res.data; // this.roomArr = res.data;
// }); // });
// getDictList({ // getDictList({
// dictType: "risk_plan_base_room" // dictType: "risk_plan_base_room"
// }).then(res => { // }).then(res => {
// this.baseArr = res.data; // this.baseArr = res.data;
// }); // });
}, },
// 增加 // 增加
addItem() { addItem() {
if (this.layout.find(item => item.i == "")) { if (this.layout.find((item) => item.i == "")) {
Toast.fail({ Toast.fail({
title: "提示", title: "提示",
forbidClick: true, forbidClick: true,
message: "请先点击确定,保存当前房间信息" message: "请先点击确定,保存当前房间信息",
}); });
return; return;
} }
...@@ -253,11 +307,11 @@ export default { ...@@ -253,11 +307,11 @@ export default {
}, },
// 添加其他 // 添加其他
addOther() { addOther() {
if (this.layout.find(item => item.i == "")) { if (this.layout.find((item) => item.i == "")) {
Toast.fail({ Toast.fail({
title: "提示", title: "提示",
forbidClick: true, forbidClick: true,
message: "请先点击确定,保存当前房间信息" message: "请先点击确定,保存当前房间信息",
}); });
return; return;
} }
...@@ -271,11 +325,11 @@ export default { ...@@ -271,11 +325,11 @@ export default {
//添加基础设施 //添加基础设施
addBase() { addBase() {
if (this.layout.find(item => item.i == "")) { if (this.layout.find((item) => item.i == "")) {
Toast.fail({ Toast.fail({
title: "提示", title: "提示",
forbidClick: true, forbidClick: true,
message: "请先点击确定,保存当前房间信息" message: "请先点击确定,保存当前房间信息",
}); });
return; return;
} }
...@@ -294,7 +348,7 @@ export default { ...@@ -294,7 +348,7 @@ export default {
// console.log('this.layout==>>',this.layout) // console.log('this.layout==>>',this.layout)
}, },
// 调整大小后的事件 // 调整大小后的事件
resizedEvent: function(i, newH, newW) { resizedEvent: function (i, newH, newW) {
this.layOutItem.w = newW; this.layOutItem.w = newW;
this.layOutItem.h = newH; this.layOutItem.h = newH;
// console.log('layOutItem==>>',this.layOutItem) // console.log('layOutItem==>>',this.layOutItem)
...@@ -342,8 +396,8 @@ export default { ...@@ -342,8 +396,8 @@ export default {
this.roomName = value.dictValue; this.roomName = value.dictValue;
} }
this.showPicker = false; this.showPicker = false;
} },
} },
}; };
</script> </script>
...@@ -353,7 +407,7 @@ export default { ...@@ -353,7 +407,7 @@ export default {
} }
.wrap { .wrap {
/* height: 100vh; */ /* height: 100vh; */
width: 100vw; width: 100%;
position: relative; position: relative;
} }
.north { .north {
......
This diff is collapsed.
This diff is collapsed.
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