🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
路径:D:\ireport365\ireport365.war\js\enduser\designer\vs-designer.js 在这里改个方法 判断是背景色还是渐变色 如图的位置 搜索ReportPageTemplateListCtrl应该可以找到 ![](https://box.kancloud.cn/0279eb3360217a8dfed0912a3918d1af_850x649.png) ``` // 判断是渐变色还是背景图片 m.compileAttachmentStyleUrl = function(p,t,jb) { // console.log(t) if(t){ return jb } // console.log(p) if (p == null || p === "/" || p === "/null") { return "" } return "url('" + attachmentPrefix + m.compileUrl(p) + "')" }; ``` 添加渐变色配置项 在2500行 大概 位置如图 ![](https://box.kancloud.cn/84f74c2933d858e6237705116d616d85_921x889.png) ``` { name: "bgColor", title: { text: "背景渐变色" }, elements: [{ title: "开启渐变色", type: "switch", bind: "GradualChange", on: vsLang.on, off: vsLang.off },{ title: vsLang.bg_color+"(1)", type: "colorpicker", bind: "backgroundOne", show: function() { return g.$parent.configingReportPage != null && g.$parent.configingReportPage.config.GradualChange }, }, { title: vsLang.bg_color+"(2)", type: "colorpicker", bind: "backgroundTow", show: function() { return g.$parent.configingReportPage != null && g.$parent.configingReportPage.config.GradualChange }, },{ title: "渐变方向", type: "configSlide", bind: "backgrouneDeg", show: function() { return g.$parent.configingReportPage != null && g.$parent.configingReportPage.config.GradualChange }, config: { slideStart: 0, slideEnd: 360 } },] }, ``` 监听配置属性 位置如图 搜索onComponentRendered方法下面 ![](https://box.kancloud.cn/830cda9ca9869ccf29fe9bac891ff467_829x695.png) ``` // 渐变色开关 l.$watch("$parent.currentReportPage.designContent.config.GradualChange", function(v, u) { // console.log(v) if (v != null && u != null) { if (!v) { l.$parent.currentReportPage.designContent.config.GradualChange = false; } else { l.$parent.currentReportPage.designContent.config.GradualChange = v; } } }); // end // 监听背景渐变色 l.$watch("$parent.currentReportPage.designContent.config.backgroundOne", function(v, u) { // console.log(v) if (v != null && u != null) { if (!v) { l.$parent.currentReportPage.designContent.config.backgroundOne = "#ffffff"; } else { l.$parent.currentReportPage.designContent.config.backgroundOne = v; var deg = l.$parent.currentReportPage.designContent.config.backgrouneDeg; l.$parent.currentReportPage.designContent.config.jianbian ='linear-gradient('+deg+'deg,'+v+','+l.$parent.currentReportPage.designContent.config.backgroundTow+')' } } }); l.$watch("$parent.currentReportPage.designContent.config.backgroundTow", function(v, u) { // console.log(v) if (v != null && u != null) { if (!v) { l.$parent.currentReportPage.designContent.config.backgroundTow = "#ffffff"; } else { l.$parent.currentReportPage.designContent.config.backgroundTow = v; var deg = l.$parent.currentReportPage.designContent.config.backgrouneDeg; l.$parent.currentReportPage.designContent.config.jianbian ='linear-gradient('+deg+'deg,'+l.$parent.currentReportPage.designContent.config.backgroundOne+','+v+')' } } }); l.$watch("$parent.currentReportPage.designContent.config.backgrouneDeg", function(v, u) { // console.log(v) if (v != null && u != null) { if (!v) { l.$parent.currentReportPage.designContent.config.backgrouneDeg = 0; } else { l.$parent.currentReportPage.designContent.config.backgrouneDeg = v; l.$parent.currentReportPage.designContent.config.jianbian ='linear-gradient('+v+'deg,'+l.$parent.currentReportPage.designContent.config.backgroundOne+','+l.$parent.currentReportPage.designContent.config.backgroundTow+')' console.log(l.$parent.currentReportPage.designContent.config.jianbian) } } }); // end ``` 设置页 路径:D:\ireport365\ireport365.war\template\designer\main.html 如下图位置 整行复制吧 防止出错 ![](https://box.kancloud.cn/6162bd8ba7a66c801c0fe09ea8eee087_1064x508.png) ``` <div id="simulator" ng-init="initCtrl()" ng-controller="SimulatorCtrl" ng-style="{'background-size':currentReportPage.designContent.config.backgroundSize.x+' '+currentReportPage.designContent.config.backgroundSize.y, 'background-position':currentReportPage.designContent.config.backgroundPosition.x+' '+currentReportPage.designContent.config.backgroundPosition.y, 'background-image':compileAttachmentStyleUrl(currentReportPage.designContent.config.backgroundImage,currentReportPage.designContent.config.GradualChange,currentReportPage.designContent.config.jianbian), 'background-repeat':currentReportPage.designContent.config.backgroundRepeat,'background-color':currentReportPage.designContent.config.backgroundColor}"> ``` 分享页 路径:D:\ireport365\ireport365.war\WEB-INF\classes\system-resource\report-template.html 位置如图 整行复制吧 防止出错 ![](https://box.kancloud.cn/34142fd8dae54064d792e4b1ffe3fb1b_940x525.png) ``` <body onload="beginLoadScript()" ng-controller="AppCtrl" ng-style="{'background-size':reportPage.config.backgroundSize.x+' '+reportPage.config.backgroundSize.y, 'background-position':reportPage.config.backgroundPosition.x+' '+reportPage.config.backgroundPosition.y, 'background-image':reportPage.config.GradualChange ? reportPage.config.jianbian : 'url('+compileImageUrl(attachmentPrefix+reportPage.config.backgroundImage)+')', 'background-repeat':reportPage.config.backgroundRepeat,'background-color':reportPage.config.backgroundColor}"> ```