提交 b7a0dd76 编写于 作者: doc_wei's avatar doc_wei

feat: 文字模型修改

上级 9db63136
......@@ -57,12 +57,12 @@ layui.config({
mouseLineColor: "blue",
initData: initData,
headerMenuJson: [{
"icon": " fa fa-area-chart fa-fw",
"icon": " fa fa-wordpress fa-fw",
"title": "文字",
"id": "wordModel",
"children": wordModel
}, {
"icon": " fa fa-area-chart fa-fw",
"icon": " fa fa-photo-video fa-fw",
"title": "小图片",
"id": "imgModel",
"children": imgModel
......
......@@ -10,23 +10,26 @@ layui.config({
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'form'], function (exports) {
}).define(['window', 'jquery', 'winui', 'form', 'fileUpload'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form;
var usetableTemplate = $("#usetableTemplate").html();
var isPic = false; // 是否生成预览图
let id = GetUrlParam("id");
if (isNull(id)) {
sysDictDataUtil.showDictDataListByDictTypeCode(sysDictData["reportModeType"]["key"], 'radioTree', "typeBox", '', form);
skyeyeClassEnumUtil.showEnumDataListByClassName("commonEnable", 'radio', "enabled", '', form);
// 初始化上传
$("#logo").upload(systemCommonUtil.uploadCommon003Config('logo', 19, '', 1));
} else {
AjaxPostUtil.request({url: reportBasePath + "queryWordModelById", params: {id: id}, type: 'json', method: 'GET', callback:function(data) {
$("#name").val(data.bean.name);
$("#defaultWidth").val(data.bean.defaultWidth);
$("#defaultHeight").val(data.bean.defaultHeight);
// 初始化上传
$("#logo").upload(systemCommonUtil.uploadCommon003Config('logo', 20, data.bean.imgPath, 1));
sysDictDataUtil.showDictDataListByDictTypeCode(sysDictData["reportModeType"]["key"], 'radioTree', "typeBox", data.bean.typeId, form);
skyeyeClassEnumUtil.showEnumDataListByClassName("commonEnable", 'radio', "enabled", data.bean.enabled, form);
// 加载属性值
......@@ -49,13 +52,6 @@ layui.config({
form.render();
form.on('submit(formAddBean)', function (data) {
if (winui.verifyForm(data.elem)) {
if (!isPic) {
winui.window.msg("请先生成预览图", {icon: 2, time: 2000});
return false;
}
var oCanvas = document.getElementById("thecanvas");
var imgData = oCanvas.toDataURL();
AjaxPostUtil.request({url: reqBasePath + "common004", params: {images: imgData, type: 19}, type: 'json', callback:function(json1){
var rowTr = $("#useTable tr");
var tableData = new Array();
$.each(rowTr, function(i, item) {
......@@ -79,7 +75,7 @@ layui.config({
defaultHeight: $("#defaultHeight").val(),
wordModelAttrList: JSON.stringify(tableData),
typeId: dataShowType.getData('typeBox'),
imgPath: json1.bean.picUrl,
imgPath: $("#logo").find("input[type='hidden'][name='upload']").attr("oldurl"),
enabled: dataShowType.getData('enabled'),
id: isNull(id) ? '' : id
};
......@@ -87,16 +83,10 @@ layui.config({
parent.layer.close(index);
parent.refreshCode = '0';
}});
}});
}
return false;
});
// 生成图片
$("body").on("click", "#createPic", function() {
loadPic();
});
function loadPic() {
var styleStr = "";
$.each(choosePropertyList, function (key, value){
......@@ -104,38 +94,12 @@ layui.config({
styleStr += value.attrCode + ":" + value.defaultValue + ";";
}
});
var showPrit = '<font style="' + styleStr + '">Hello, Skyeye</font>';
$("#printPic").html(showPrit);
html2canvas($("#printPic"), {
onrendered: function(canvas) {
// 添加属性
canvas.setAttribute('id','thecanvas');
// 读取属性值
document.getElementById('images').innerHTML = '';
document.getElementById('images').appendChild(canvas);
$("#download").show();
isPic = true;
}
});
var wordBox = document.createElement("font");
wordBox.innerHTML = "Hello, Skyeye";
wordBox.style = styleStr;
$("#printPic")[0].appendChild(wordBox);
}
// 下载canvas图片
$("body").on("click", "#download", function() {
var oCanvas = document.getElementById("thecanvas");
var img_data1 = Canvas2Image.saveAsPNG(oCanvas, true).getAttribute('src');
saveFile(img_data1, 'richer.png');
});
// 保存文件函数
var saveFile = function(data, filename){
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
save_link.href = data;
save_link.download = filename;
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
save_link.dispatchEvent(event);
};
// 新增行
$("body").on("click", "#addRow", function() {
addRow();
......@@ -172,6 +136,7 @@ layui.config({
// 移除界面上的信息
$(item).parent().parent().remove();
});
loadPic();
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
......@@ -189,6 +154,7 @@ layui.config({
var thisRowNum = trId.replace("tr", "");
choosePropertyList[trId] = chooseItemMation;
$("#propertyId" + thisRowNum.toString()).val(choosePropertyList[trId].name);
loadPic();
}});
});
......
......@@ -5,7 +5,6 @@
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
<link href="../../assets/report/css/ruler.css" rel="stylesheet" />
</head>
<body>
<div style="margin:0 auto;padding:20px;">
......@@ -24,6 +23,12 @@
<div class="layui-input-block winui-radio" id="enabled">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">logo<i class="red">*</i></label>
<div class="layui-input-block">
<div class="upload" id="logo"></div>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">默认宽度<i class="red">*</i></label>
<div class="layui-input-block">
......@@ -68,24 +73,9 @@
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label" style="line-height: 45px">效果图<i class="red">*</i></label>
<div class="layui-col-xs8" style="line-height: 60px">
<div class="layui-col-xs10" id="printPic" style="width: 90px; height: 60px; text-align: center; line-height: 60px; background-color: white;">
<font>Hello, Skyeye</font>
</div>
<div class="layui-col-xs2">
<a href="javascript:;" class="layui-btn layui-btn-xs" id="createPic" style="margin-left: 10px;margin-top: 10px;">生成图片</a>
</div>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label" style="line-height: 45px">预览图<i class="red">*</i></label>
<div class="layui-col-xs6" style="line-height: 60px">
<div class="layui-col-xs10" id="images">
</div>
<div class="layui-col-xs2">
<a href="javascript:;" class="layui-btn layui-btn-xs" id="download" style="margin-left: 10px;margin-top: 10px; display: none">下载</a>
<label class="layui-form-label">效果图</label>
<div class="layui-input-block ver-center">
<div class="layui-col-xs12" id="printPic">
</div>
</div>
</div>
......@@ -120,11 +110,6 @@
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<!-- html2canvas将Dom节点在Canvas里边画出来 -->
<script src="../../assets/html2canvas/js/html2canvas.min.js"></script>
<!-- 将canvas图片保存成图片 -->
<script src="../../assets/html2canvas/js/canvas2image.js"></script>
<script src="../../assets/html2canvas/js/base64.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/reportWordModel/'}).use('reportWordModelWrite');
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册