diff --git a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts index 8057c74..2350d53 100644 --- a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts +++ b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts @@ -556,7 +556,36 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } //生成word generatingDoc() { - console.log(666, $(".mainbox")) + changeImgToDataurl() + function changeImgToDataurl() { + let charImg = document.getElementsByTagName("img"); + console.log(charImg) + let imgURLs = ""; + for (let i = 0; i < charImg.length; i++) { + let imgURL = charImg[i].currentSrc; + getBase64(imgURL, charImg[i]); + } + } + function getBase64(url, charImg) { + let Img = new Image(); + Img.crossOrigin = "Anonymous";//跨域必须使用,且后台也得设置允许跨域 + let dataURL = ''; + Img.src = url; + Img.onload = function () { //要先确保图片完整获取到,这是个异步事件 + let canvas = document.createElement("canvas"), //创建canvas元素 + width = Img.width, //确保canvas的尺寸和图片一样 + height = Img.height; + canvas.width = width; + canvas.height = height; + canvas.getContext("2d").drawImage(Img, 0, 0, width, height); //将图片绘制到canvas中 + dataURL = canvas.toDataURL('image/jpg'); //转换图片为dataURL + condataurl ? condataurl(dataURL, charImg) : null; //调用回调函数 + }; + } + function condataurl(dataURL, charImg) { + charImg.src = dataURL; + } + $(".mainbox").wordExport('word文档'); } //原数据点击 diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.ts b/src/app/ui/collection-tools-plan/collection-tools.component.ts index a6dc2e4..f7d8d32 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -864,7 +864,7 @@ export class CollectionToolsPlanComponent implements OnInit { //保存建筑数据 // console.log('CompanyData',CompanyData) - CompanyData.data = "{\"图例\":{\"Id\":\"图例\",\"Name\":\"图例\",\"Angle\":0,\"Color\":\"#066EED80\",\"Point\":{\"x\":200,\"y\":200},\"Scale\":1,\"Width\":32,\"Border\":null,\"Height\":32,\"PivotX\":0,\"PivotY\":0,\"Enabled\":true,\"FloorId\":\"60d43256660b093f1c3b5aa5\",\"DrawMode\":null,\"FillMode\":null,\"GameMode\":0,\"ImageUrl\":null,\"FixedSize\":null,\"Thickness\":null,\"MultiPoint\":null,\"TemplateId\":null,\"FireElementId\":null,\"PropertyInfos\":[{\"Tag\":\"\",\"Order\":0,\"Enabled\":true,\"Visible\":true,\"Required\":false,\"RuleName\":\"\",\"RuleValue\":\"\",\"PhysicalUnit\":\"\",\"PropertyName\":\"列\",\"PropertyType\":2,\"PropertyValue\":\"2\"}],\"IsFromBuilding\":null,\"InteractiveMode\":null}}" + // CompanyData.data = "{\"图例\":{\"Id\":\"图例\",\"Name\":\"图例\",\"Angle\":0,\"Color\":\"#066EED80\",\"Point\":{\"x\":200,\"y\":200},\"Scale\":1,\"Width\":32,\"Border\":null,\"Height\":32,\"PivotX\":0,\"PivotY\":0,\"Enabled\":true,\"FloorId\":\"60d43256660b093f1c3b5aa5\",\"DrawMode\":null,\"FillMode\":null,\"GameMode\":0,\"ImageUrl\":null,\"FixedSize\":null,\"Thickness\":null,\"MultiPoint\":null,\"TemplateId\":null,\"FireElementId\":null,\"PropertyInfos\":[{\"Tag\":\"\",\"Order\":0,\"Enabled\":true,\"Visible\":true,\"Required\":false,\"RuleName\":\"\",\"RuleValue\":\"\",\"PhysicalUnit\":\"\",\"PropertyName\":\"列\",\"PropertyType\":2,\"PropertyValue\":\"2\"}],\"IsFromBuilding\":null,\"InteractiveMode\":null}}" this.http.post("/api/CompanyData", CompanyData, { params: {