pictures模块 新增了微信小程序二维码生成

This commit is contained in:
cuibaocheng 2021-06-25 17:54:36 +08:00
parent e0992a4e73
commit 574cd6075f
17 changed files with 425 additions and 123 deletions

View File

@ -19,7 +19,6 @@ import ink.wgink.pojo.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@ -40,9 +39,9 @@ public class PicturesTemplateController extends DefaultBaseController {
@Autowired
private SecurityComponent securityComponent;
@ApiOperation(value = "生成模板", notes = "生成模板")
@ApiOperation(value = "生成模板预览图", notes = "生成模板预览图")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", paramType = "String", example = "")
@ApiImplicitParam(name = "picturesTemplateCode", value = "picturesTemplateCode", paramType = "String", example = "模板编码")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("buiderpicturestemplate/{picturesTemplateCode}")
@ -50,10 +49,11 @@ public class PicturesTemplateController extends DefaultBaseController {
return picturesTemplateService.buiderPicturesTemplate(picturesTemplateCode);
}
@ApiOperation(value = "复制模板", notes = "复制模板")
@ApiOperation(value = "复制新的模板", notes = "复制新的模板")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", paramType = "String", example = "")
@ApiImplicitParam(name = "id", value = "id", paramType = "String", example = ""),
@ApiImplicitParam(name = "picturesTemplateCode", value = "picturesTemplateCode", paramType = "String", example = "新的编码"),
@ApiImplicitParam(name = "picturesTemplateTitle", value = "picturesTemplateTitle", paramType = "String", example = "新的标题")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("copypicturestemplate/{id}/{picturesTemplateCode}/{picturesTemplateTitle}")
@ -61,8 +61,7 @@ public class PicturesTemplateController extends DefaultBaseController {
return picturesTemplateService.copyPicturesTemplate(id, picturesTemplateCode, picturesTemplateTitle);
}
@ApiOperation(value = "更改显示方式", notes = "更改显示方式")
@ApiOperation(value = "更改显示开关状态", notes = "更改显示开关状态")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatepicturestemplatepublishstatus/{picturesTemplateId}/{picturesTemplatePublishStatus}")
@CheckRequestBodyAnnotation

View File

@ -42,7 +42,7 @@ public class PicturesTemplateAreaController extends DefaultBaseController {
@ApiOperation(value = "区域统一修改", notes = "区域统一修改接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "showTemplateAreaId", value = "大数据模块区域ID", paramType = "path")
@ApiImplicitParam(name = "picturesTemplateId", value = "模板ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatepicturestemplateareaall/{picturesTemplateId}")
@ -51,7 +51,7 @@ public class PicturesTemplateAreaController extends DefaultBaseController {
return picturesTemplateAreaService.updatePicturesTemplateAreaAll(picturesTemplateId, picturesTemplateAreaAllVO);
}
@ApiOperation(value = "修改大数据模块区域配置参数", notes = "修改大数据模块区域配置参数接口")
@ApiOperation(value = "修改大数据模块区域配置位置参数", notes = "修改大数据模块区域配置位置参数接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "showTemplateAreaId", value = "大数据模块区域ID", paramType = "path")
})

View File

@ -87,4 +87,8 @@ public interface IPicturesTemplateDao {
List<Map<String, Object>> querySqlAll(String sql) throws SearchException;
void updatePicturesTemplateContent(Map<String, Object> params) throws UpdateException;
void updatePicturesTemplatePicture(Map<String, Object> map) throws UpdateException;
void updatePictureTemplateStatus(Map<String, Object> params) throws UpdateException;
}

View File

@ -220,6 +220,10 @@ public class PicturesTemplateServiceImpl extends DefaultBaseService implements I
throw new SaveException("自定义宽度不能大于底图");
}
}
/**
* 默认为不发布
*/
picturesTemplateVO.setPicturesTemplatePublishStatus("0");
Map<String, Object> params = HashMapUtil.beanToMap(picturesTemplateVO);
params.put("picturesTemplateId", picturesTemplateId);
if (StringUtils.isBlank(token)) {
@ -287,7 +291,6 @@ public class PicturesTemplateServiceImpl extends DefaultBaseService implements I
* @param picturesTemplateVO
*/
private void updatePicturesTemplateInfo(String token, String picturesTemplateId, PicturesTemplateVO picturesTemplateVO) throws Exception {
Map<String, Object> query = new HashMap<String, Object>();
query.put("fileId", picturesTemplateVO.getPicturesTemplateBackgroundImage());
FilePO filePO = iFileService.getPO(query);
@ -509,13 +512,18 @@ public class PicturesTemplateServiceImpl extends DefaultBaseService implements I
@Override
public SuccessResultData buiderPicturesTemplate(String picturesTemplateCode) throws Exception {
FilePO file = new FilePO();
file.setFileName("测试FileName");
file.setFilePath("测试FilePath");
String fileId = iPicturesTemplateBuildingService.buildingPictures(picturesTemplateCode, file);
String base64 = iPicturesTemplateBuildingService.buildingPictures(picturesTemplateCode, null);
SuccessResultData<String> result = new SuccessResultData<String>("");
if(fileId != null ) {
result.setData(fileId);
if(base64 != null ) {
result.setData(base64);
/**
* 更新预览图
*/
PicturesTemplateDTO dto = picturesTemplateDao.getPicturesTemplateByCode(picturesTemplateCode);
Map<String, Object> map = new HashMap<String, Object>();
map.put("picturesTemplatePicture", base64);
map.put("picturesTemplateId", dto.getPicturesTemplateId());
picturesTemplateDao.updatePicturesTemplatePicture(map);
}
return result;
}

View File

@ -306,14 +306,21 @@ public class PicturesTemplateBuildingServiceImpl extends DefaultBaseService impl
for (PicturesTemplateAreaDTO areaDto : areaList) {
String content = "2".equals(areaDto.getTemplateAreaServerLink()) ? areaDto.getTemplateAreaFile() : areaDto.getTemplateAreaFontValue();
String index = areaDto.getTemplateAreaSource();
Field[] arr = bean.getClass().getDeclaredFields();
for (Field key : arr) {
key.setAccessible(true);
if (index.equals(key.getName())) {
if (key.getType() == String.class) {
if(key.get(bean) != null) {
if(!StringUtil.isEmpty(key.get(bean).toString())) {
content = key.get(bean).toString();
/**
* 1位占位区域 , 2为需要填充的区域
*/
if("2".equals(areaDto.getTemplateAreaType())){
if(bean != null) {
Field[] arr = bean.getClass().getDeclaredFields();
for (Field key : arr) {
key.setAccessible(true);
if (index.equals(key.getName())) {
if (key.getType() == String.class) {
if(key.get(bean) != null) {
if(!StringUtil.isEmpty(key.get(bean).toString())) {
content = key.get(bean).toString();
}
}
}
}
}
@ -346,6 +353,9 @@ public class PicturesTemplateBuildingServiceImpl extends DefaultBaseService impl
Map<String, Object> params = new HashMap<String, Object>();
params.put("fileId", dto.getPicturesTemplateBackgroundImage());
FilePO filePO = iFileService.getPO(params);
if(filePO == null) {
throw new Exception("背景图片丢失, 无法生成");
}
File backFile = new File(filePO.getFilePath());
return createImage(list, backFile, dto.getPicturesTemplateWidth().intValue(), dto.getPicturesTemplateHeight().intValue());
}

View File

@ -16,8 +16,19 @@
<result column="pictures_template_file" property="picturesTemplateFile"/>
<result column="pictures_template_back" property="picturesTemplateBack"/>
<result column="pictures_template_size" property="picturesTemplateSize"/>
<result column="pictures_template_picture" property="picturesTemplatePicture"/>
<result column="pictures_template_remark" property="picturesTemplateRemark"/>
</resultMap>
<update id="updatePicturesTemplatePicture" parameterType="map">
UPDATE
m_pictures_template
SET
pictures_template_picture = #{picturesTemplatePicture}
WHERE
pictures_template_id = #{picturesTemplateId} AND is_delete = 0
</update>
<update id="updatePicturesTemplateContent" parameterType="map">
UPDATE
m_pictures_template
@ -66,7 +77,9 @@
t1.pictures_template_id,
t1.pictures_template_file,
t1.pictures_template_back,
t1.pictures_template_size
t1.pictures_template_size,
t1.pictures_template_picture,
t1.pictures_template_remark
FROM
m_pictures_template t1
WHERE
@ -89,6 +102,8 @@
pictures_template_file,
pictures_template_back,
pictures_template_size,
pictures_template_picture,
pictures_template_remark,
creator,
gmt_create,
modifier,
@ -108,6 +123,8 @@
#{picturesTemplateFile},
#{picturesTemplateBack},
#{picturesTemplateSize},
'',
#{picturesTemplateRemark},
#{creator},
#{gmtCreate},
#{modifier},
@ -167,6 +184,9 @@
</if>
<if test="picturesTemplateSize != null and picturesTemplateSize != ''">
pictures_template_size = #{picturesTemplateSize},
</if>
<if test="picturesTemplateRemark != null and picturesTemplateRemark != ''">
pictures_template_remark = #{picturesTemplateRemark},
</if>
pictures_template_file = #{picturesTemplateFile},
modifier = #{modifier},
@ -190,7 +210,9 @@
t1.pictures_template_id,
t1.pictures_template_file,
t1.pictures_template_back,
t1.pictures_template_size
t1.pictures_template_size,
t1.pictures_template_picture,
t1.pictures_template_remark
FROM
m_pictures_template t1
WHERE
@ -217,7 +239,9 @@
t1.pictures_template_id,
t1.pictures_template_file,
t1.pictures_template_back,
t1.pictures_template_size
t1.pictures_template_size,
t1.pictures_template_picture,
t1.pictures_template_remark
FROM
m_pictures_template t1
WHERE

View File

@ -25,6 +25,8 @@
<result column="template_area_font_family" property="templateAreaFontFamily"/>
<result column="template_area_font_color" property="templateAreaFontColor"/>
<result column="template_area_font_value" property="templateAreaFontValue"/>
<result column="template_area_name" property="templateAreaName"/>
<result column="template_area_type" property="templateAreaType"/>
</resultMap>
<update id="updatePicturesTemplateAreaAll" parameterType="map">
@ -104,6 +106,8 @@
t1.template_area_font_family,
t1.template_area_font_color,
t1.template_area_font_value,
t1.template_area_name,
t1.template_area_type,
t2.pictures_template_code
FROM
m_pictures_template_area t1
@ -139,7 +143,9 @@
t1.template_area_font_bold,
t1.template_area_font_family,
t1.template_area_font_color,
t1.template_area_font_value
t1.template_area_font_value,
t1.template_area_name,
t1.template_area_type
FROM
m_pictures_template_area t1
WHERE
@ -178,6 +184,8 @@
template_area_font_family,
template_area_font_color,
template_area_font_value,
template_area_name,
template_area_type,
creator,
gmt_create,
modifier,
@ -204,6 +212,8 @@
#{templateAreaFontFamily},
#{templateAreaFontColor},
#{templateAreaFontValue},
#{templateAreaName},
#{templateAreaType},
#{creator},
#{gmtCreate},
#{modifier},
@ -266,6 +276,12 @@
</if>
<if test="templateAreaFontValue != null and templateAreaFontValue != ''">
template_area_font_value = #{templateAreaFontValue},
</if>
<if test="templateAreaName != null and templateAreaName != ''">
template_area_name = #{templateAreaName},
</if>
<if test="templateAreaType != null and templateAreaType != ''">
template_area_type = #{templateAreaType},
</if>
template_area_remark = #{templateAreaRemark},
template_area_file = #{templateAreaFile},
@ -293,7 +309,9 @@
t1.template_area_font_bold,
t1.template_area_font_family,
t1.template_area_font_color,
t1.template_area_font_value
t1.template_area_font_value,
t1.template_area_name,
t1.template_area_type
FROM
m_pictures_template_area t1
LEFT JOIN
@ -322,7 +340,9 @@
t1.template_area_font_bold,
t1.template_area_font_family,
t1.template_area_font_color,
t1.template_area_font_value
t1.template_area_font_value,
t1.template_area_name,
t1.template_area_type
FROM
m_pictures_template_area t1
LEFT JOIN
@ -353,7 +373,9 @@
t1.template_area_font_bold,
t1.template_area_font_family,
t1.template_area_font_color,
t1.template_area_font_value
t1.template_area_font_value,
t1.template_area_name,
t1.template_area_type
FROM
m_pictures_template_area t1
WHERE

View File

@ -9,12 +9,13 @@
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card" id="viewer">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
@ -90,6 +91,25 @@
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'picturesTemplateBackgroundImage', width: 100, title: '预览图', align:'center',
templet: function(row) {
var rowData = row[this.field];
var picturesTemplatePicture = row['picturesTemplatePicture'];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
var value = '<img style="height: 50px;width: 50px;" src="route/file/download/false/'+ rowData +'" >';
if(picturesTemplatePicture) {
value = '<img style="height: 50px;width: 50px;" src="' + picturesTemplatePicture + '">';
}
setTimeout(function() {
new Viewer(document.getElementById("viewer"),{
loop:true
});
}, 50);
return value;
}
},
{field: 'picturesTemplateCode', width: 100, title: '套版编码', align:'center',
templet: function(row) {
var rowData = row[this.field];
@ -99,7 +119,7 @@
return rowData;
}
},
{field: 'picturesTemplateTitle', width: 350, title: '套版标题', align:'center',
{field: 'picturesTemplateTitle', width: 200, title: '套版标题', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
@ -108,55 +128,73 @@
return rowData;
}
},
{field: 'picturesTemplateWidth', width: 150, title: '画板宽度', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData + 'px';
}
},
{field: 'picturesTemplateHeight', width: 150, title: '画板高度', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData + 'px';
}
},
{field: 'picturesTemplateBack', width: 150, title: '生成尺寸', align:'center',
/* {field: 'picturesTemplateWidth', width: 80, title: '画板宽度', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData + 'px';
}
},
{field: 'picturesTemplateHeight', width: 80, title: '画板高度', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData + 'px';
}
},*/
{field: 'picturesTemplateBack', width: 200, title: '生成尺寸', align:'center',
templet: function(row) {
var rowData = row[this.field];
var picturesTemplateHeight = row["picturesTemplateHeight"];
var picturesTemplateWidth = row["picturesTemplateWidth"];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
var rowStr = "";
if(rowData == "-1") {
return "自定义";
rowStr = "自定义尺寸";
}else if(rowData == "0") {
return "底图";
rowStr = "底图尺寸";
}else if(rowData == "4") {
return "A4(竖向)";
rowStr = "A4(竖向)";
}else if(rowData == "5") {
return "A5(竖向)";
rowStr = "A5(竖向)";
}else if(rowData == "6") {
return "A6(竖向)";
rowStr = "A6(竖向)";
}else if(rowData == "-4") {
return "A4(横向)";
rowStr = "A4(横向)";
}else if(rowData == "-5") {
return "A5(横向)";
rowStr = "A5(横向)";
}else if(rowData == "-6") {
return "A6(横向)";
rowStr = "A6(横向)";
}
rowStr = rowStr + "【" + picturesTemplateWidth + "*" + picturesTemplateHeight + "】";
return rowStr;
}
},
// {field: 'picturesTemplatePublishStatus', width: 150, fixed: 'right', title: '套版发布', align:'center',
// templet: function(row) {
// var rowData = row[this.field];
// return '<input type="checkbox" value="' + rowData + '" '+ ( rowData == 1 ? "checked" : "") + ' picturesTemplateId="'+ row.picturesTemplateId +'" lay-filter="picturesTemplatePublishStatusEvent" name="picturesTemplatePublishStatus" lay-skin="switch" lay-text="开启|关闭">';
// }
// },
{field:'picturesTemplatePublishTime', width:180, title: '发布时间', align:'center',
templet: function(row) {
var rowData = row[this.field];
return rowData;
}
},
{field:'picturesTemplatePublishStatus', width:120, title: '发布状态', fixed: 'right', align:'center',
templet: function(row) {
var rowData = row[this.field];
return '<input type="checkbox" value="' + rowData + '" '+ ( rowData == 1 ? "checked" : "") + ' picturesTemplateId="'+ row.picturesTemplateId +'" lay-filter="picturesTemplateCheckEvent" name="picturesTemplateCheck" lay-skin="switch" lay-text="已发布|未发布">';
}
},
{field:'picturesTemplateAreaEvent', width:120, title: '套版配置', fixed: 'right', align:'center',
templet: function(row) {
return '<button lay-event="picturesTemplateAreaEvent" type="button" class="layui-btn layui-btn-xs layui-btn-radius">编辑套版配置</button>';
@ -190,6 +228,21 @@
height: $win.height() - 90,
});
}
// 发布开关
form.on('switch(picturesTemplateCheckEvent)', function () {
var loadLayerIndex;
var obj = {};
top.restAjax.put(top.restAjax.path('api/picturestemplate/updatepicturestemplatepublishstatus/{picturesTemplateId}/{picturesTemplatePublishStatus}', [$(this).attr("picturesTemplateId"), this.checked]), obj, null, function(code, data) {
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
// 初始化日期
function initDate() {
// 日期选择

View File

@ -54,9 +54,12 @@
<!-- <input type="radio" lay-verify="required"name="picturesTemplateBack" value="1" lay-filter="picturesTemplateBackFilter" title="A1">-->
<!-- <input type="radio" lay-verify="required"name="picturesTemplateBack" value="2" lay-filter="picturesTemplateBackFilter" title="A2">-->
<!-- <input type="radio" lay-verify="required"name="picturesTemplateBack" value="3" lay-filter="picturesTemplateBackFilter" title="A3">-->
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="4" lay-filter="picturesTemplateBackFilter" title="A4(16K)">
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="5" lay-filter="picturesTemplateBackFilter" title="A5(32k)">
<input type="radio" lay-verify="required" name="picturesTemplateBack" value="6" lay-filter="picturesTemplateBackFilter" title="A6(64K)">
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="4" lay-filter="picturesTemplateBackFilter" title="A4(纵向)">
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="5" lay-filter="picturesTemplateBackFilter" title="A5(纵向)">
<input type="radio" lay-verify="required" name="picturesTemplateBack" value="6" lay-filter="picturesTemplateBackFilter" title="A6(纵向)">
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="-4" lay-filter="picturesTemplateBackFilter" title="A4(横向)">
<input type="radio" lay-verify="required"name="picturesTemplateBack" value="-5" lay-filter="picturesTemplateBackFilter" title="A5(横向)">
<input type="radio" lay-verify="required" name="picturesTemplateBack" value="-6" lay-filter="picturesTemplateBackFilter" title="A6(横向)">
<!-- <input type="radio" lay-verify="required" name="picturesTemplateBack" value="7" lay-filter="picturesTemplateBackFilter" title="A7">-->
<!-- <input type="radio" lay-verify="required" name="picturesTemplateBack" value="8" lay-filter="picturesTemplateBackFilter" title="A8">-->
<!-- <input type="radio" lay-verify="required" name="picturesTemplateBack" value="9" lay-filter="picturesTemplateBackFilter" title="A9">-->
@ -157,6 +160,12 @@
</script>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">套版说明</label>
<div class="layui-input-block">
<textarea id="picturesTemplateRemark" name="picturesTemplateRemark" class="layui-textarea" placeholder="请输入说明"></textarea>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">

View File

@ -23,18 +23,20 @@
.box .bg{width:100%;height:100%;background-color:orange;}
.box .coor{width:10px;height:10px;overflow:hidden;cursor:se-resize;position:absolute;right:0;bottom:0;background-color:red;z-index: 100;}
.box .content{position:absolute;left:50%;top:50%;z-index:99;text-align:center;font:bold 20px/1.5em simsun;color:black;font-size: 20px;transform: translate(-50%,-50%)}
#debug{position:absolute;right:10px;top:10px;z-index:88;border:1px solid #ccc;width:100px;height:100px;background:#fff;}
#toolbar{position:absolute;left:10px;top:10px;z-index:88;}
.bgTransparent{
background-color:transparent !important;
}
#toolbar{position:absolute;top:10px;z-index:88;}
</style>
</head>
<body id="pageArea" class="list">
<div id="toolbar" >
<textarea id="target" style="opacity: 0;"></textarea>
<div id="toolbar" style="margin-left:{{ (d.currentWindowWidth - 432) / 2 }}px;width:435px;" >
<button type="button" class="layui-btn" id="btnAdd" lay-filter="btnAdd">添加区域</button>
<button type="button" class="layui-btn layui-btn-primary" id="btnLock" lay-filter="btnLock">锁定区域</button>
<button type="button" class="layui-btn layui-btn-success" id="updateData" lay-filter="btnLock">快速修改</button>
<button type="button" class="layui-btn layui-btn-danger" lay-submit lay-filter="areaForm">快速预览</button>
<button type="button" class="layui-btn layui-btn-danger" lay-submit lay-filter="areaForm">生成预览图</button>
<textarea id="target" style="opacity: 0;"></textarea>
</div>
<div id="canvas" style="margin-left:{{d.marginLeft}}px;width:{{d.picturesTemplateWidth}}px;height:{{d.picturesTemplateHeight}}px;">
<img id="imgId" height="100%" width="100%" alt=""/>
@ -61,29 +63,13 @@
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
/**
* 监听Curl+S键, 快速生成预览图
* */
document.addEventListener('keydown', function(e){
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)){
e.preventDefault();
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/picturestemplate/buiderpicturestemplate/{picturesTemplateCode}', [picturesTemplateCode]), {}, null, function(code, data) {
if(code == 200) {
top.layer.msg('重新生成该模板下全部页面执行成功!',{
icon: 1,
time: 20000,
});
}else{
top.layer.msg('重新生成该模板下全部页面执行失败!',{
icon: 2,
time: 20000,
});
}
}, function(code, data) {
top.dialog.msg(data.msg, {time: 1000});
}, function() {
loadLayerIndex = top.dialog.msg('生成中...', {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
buiddingPicture();
}
});
@ -107,25 +93,97 @@
// 创建区域
function createBox(data){
var dataId = data.picturesTemplateAreaId || '';
var value = data.templateAreaSource || '区域';
var value = data.templateAreaName || '区域';
var color = data.templateAreaColor || '';
var height = data.templateAreaHeight || 0;
var width = data.templateAreaWidth || 0;
var pageX = data.templateAreaLeft || 0;
var pageY = data.templateAreaTop || 0;
var fontSize = data.templateAreaFontSize || 20;
var fontColor = data.templateAreaFontColor || "";
//更新计数器并记录当前计数
var curNum = num++;
//创建区域块
var pos = $("#canvas").position();
// background-image:url(route/file/download/false/'+ data.picturesModulePhoto +');
var box = $('<div id="'+dataId+'" class="box" rel="'+curNum+'" areaName="' + value + '" dataId="'+dataId+'" ><pre class="content" style="font-size:' +fontSize + 'px;color:'+color+';">'+value+'</pre><div class="bg transparent" style="background-color:'+color+'"></div><div class="coor transparent"></div></div>').css({
var box = $('<div tabindex="1" id="'+dataId+'" class="box" rel="'+curNum+'" areaName="' + value + '" dataId="'+dataId+'" ><pre class="content" style="font-size:' +fontSize + 'px;color:'+fontColor+';">'+value+'</pre><div class="bg transparent" style="background-color:'+color+'"></div><div class="coor transparent"></div></div>').css({
width : width,
height : height,
top : pageY > 0 ? pageY : (pos.top > 0 ? 0 : pos.top * -1 + 50),
left : pageX > 0 ? pageX : (pos.left > 0 ? 0 : pos.left * -1 + 30)
}).appendTo("#canvas");
//计算文本位置
/**
* 键盘控制位置移动 2021年6月22日16:33:34 由CBC新增
* */
$(document).on('keydown', '#' + dataId, function(e){
if(lock == true){
return
}
var x = Number($(this).css("left").replace("px",""));
var y = Number($(this).css("top").replace("px",""));
var w = $(this).width();
var h = $(this).height();
var id = $(this).attr("id");
var noChange = false;
// 向左移动
if (e.keyCode == 37 ){
e.preventDefault();
x = (x - 1) >= 0 ? x - 1 : 0;
if(x == 0) {
layer.msg("已到左侧边缘");
noChange = true;
}else{
$('#'+id).css("left", x + "px");
console.log("向左移动1: x坐标:"+ x +"y坐标:"+ y +"宽度:"+ w +"高度:"+ h +"id:"+ id);
}
}
// 向上移动
if (e.keyCode == 38 ){
e.preventDefault();
y = (y - 1) >= 0 ? y - 1 : 0;
if(y == 0) {
layer.msg("已到顶部边缘");
noChange = true;
}else{
$('#'+id).css("top", y + "px");
console.log("向上移动1: x坐标:"+ x +"y坐标:"+ y +"宽度:"+ w +"高度:"+ h +"id:"+ id);
}
}
// 向右移动
if (e.keyCode == 39 ){
e.preventDefault();
x = (x + 1) >= (dataFormData.picturesTemplateWidth - w ) ? ( dataFormData.picturesTemplateWidth - w + 1) : x + 1;
if(x > (dataFormData.picturesTemplateWidth - w)) {
layer.msg("已到右侧边缘");
noChange = true;
}else{
$('#'+id).css("left", x + "px");
console.log("向右移动1: x坐标:"+ x +"y坐标:"+ y +"宽度:"+ w +"高度:"+ h +"id:"+ id);
}
}
// 向下移动
if (e.keyCode == 40 ){
e.preventDefault();
y = (y + 1) >= (dataFormData.picturesTemplateHeight - h ) ? (dataFormData.picturesTemplateHeight - h + 1) : y + 1;
if(y > (dataFormData.picturesTemplateHeight - h) ) {
layer.msg("已到底部边缘");
noChange = true;
}else{
$('#'+id).css("top", y + "px");
console.log("向下移动1: x坐标:"+ x +"y坐标:"+ y +"宽度:"+ w +"高度:"+ h +"id:"+ id);
}
}
if(!noChange) {
var formData = {templateAreaLeft : x , templateAreaTop : y , templateAreaHeight : h , templateAreaWidth : w };
top.restAjax.put(top.restAjax.path('api/picturestemplatearea/updatepicturestemplateareapoint/{picturesTemplateAreaId}', [id]), formData, null, function(code, data) {
}, function(code, data) {
}, function() {
}, function() {
});
}
});
// 计算文本位置 , 改为通过css控制
// box.find('.content').css({
// marginLeft : box.find('.content').width()/2*-1,
// marginTop : box.find('.content').height()/2*-1
@ -133,25 +191,6 @@
//创建右键菜单
context.attach('.box[rel='+curNum+']', [
{header: '区域操作'},
// {text: '配置参数', action: function(e){
// e.preventDefault();
// //当前区域的id
// var areaName = $('.box[rel='+curNum+']').attr("areaName");
// var id = $('.box[rel='+curNum+']').attr("id");
// layer.open({
// type: 2,
// title: areaName,
// closeBtn: 1,
// area: ['60%', '98%'],
// shadeClose: false,
// anim: 2,
// content: top.restAjax.path('route/picturestemplatearea/updatepicturestemplateareadata?picturesTemplateAreaId={picturesTemplateAreaId}', [id]),
// end: function() {
// // location.reload();
// }
// });
// }
// },
{text: '修改区域', action: function(e){
e.preventDefault();
//当前区域的id
@ -274,7 +313,6 @@
}, 'call_up' : function(){
canvas.css('cursor', 'default');
}});
}).on('mousedown', '.box', function(e) {
if(lock) return;
var pos = $(this).position();
@ -283,13 +321,20 @@
e.stopPropagation();
}).on('mousedown', '.box .coor', function(e) {
var $box = $(this).parent();
/**
* 崔宝铖 2021年6月22日17:15:54 新增 innerX和innerY 用于拖拉拽超出区域判断
* */
var posix = {
'w': $box.width(),
'h': $box.height(),
'x': e.pageX,
'y': e.pageY
'y': e.pageY,
'innerX': Number($box.css("left").replace("px","")),
'innerY': Number($box.css("top").replace("px",""))
};
$.extend(document, {'move': true, 'call_down': function(e) {
console.log(posix);
console.log(e);
var width = Math.max(10, e.pageX - posix.x + posix.w);
var height = Math.max(10, e.pageY - posix.y + posix.h);
if(width > dataFormData.templateWidth) {
@ -316,9 +361,21 @@
}
return l;
}
/* $('.box').attr('tabindex', 1);
$(document).on('keydown', '.box', function(e){
if(lock == true){
return
}
id = $(this).attr("id");
alert(id);
// 左
if (e.keyCode == 37 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)){
e.preventDefault();
}
});*/
//修改设备点的x,y,width,height
//修改区域点的x,y,width,height
$(document).on('mouseup', '#canvas', function(e){
if(lock == true){
return
@ -328,6 +385,9 @@
var w = "";
var h = "";
var id = "";
// $(".box").keydown(function(){
// alert(1);
// });
$(".box").click(function(){
id = $(this).attr("id");
w = $(this).width();
@ -353,10 +413,12 @@
$(this).text("锁定区域");
lock = false;
$('.box .coor').show();
$('.bg').removeClass("bgTransparent");
}else{
$(this).text("解锁区域");
lock = true;
$('.box .coor').hide();
$('.bg').addClass("bgTransparent");
}
});
lock = false;
@ -409,7 +471,11 @@
var fileId = "";
// 获取高和宽
form.on('submit(areaForm)', function(formData) {
form.on('submit(areaForm)',function () {
buiddingPicture();
});
function buiddingPicture() {
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/picturestemplate/buiderpicturestemplate/{picturesTemplateCode}', [picturesTemplateCode]), {}, null, function(code, data) {
var currentWindowWidth = $(window).width();
@ -421,10 +487,10 @@
layer.open({
type: 0,
title: false,
btn: ['复制图片','下载原图','新窗口预览'],
btn: ['复制图片Base64','下载原图','新窗口预览'],
closeBtn: 1,
// area: [(dataFormData.templateWidth > currentWindowWidth ? currentWindowWidth / 10 * 9 : dataFormData.templateWidth )+ 'px', (dataFormData.templateHeight > currentWindowHeight ? currentWindowHeight / 10 * 9 : dataFormData.templateHeight) + 'px'],
area: ["1000px" , "700px"],
area: ["1000px" , "600px"],
shadeClose: true,
anim: 2,
btn1:function(data) {
@ -469,7 +535,7 @@
}, function() {
top.dialog.close(loadLayerIndex);
});
});
}
// 初始化内容
function initData() {
@ -490,7 +556,7 @@
});
var currentWindowWidth = $(window).width();
dataFormData.marginLeft = (currentWindowWidth - dataFormData.templateWidth) / 2;
dataFormData.currentWindowWidth = currentWindowWidth;
$("#target").css("margin-left", dataFormData.marginLeft);
// 初始化背景图
laytpl(document.getElementById("pageArea").innerHTML).render(dataFormData, function(html) {

View File

@ -160,6 +160,12 @@
</script>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">套版说明</label>
<div class="layui-input-block">
<textarea id="picturesTemplateRemark" name="picturesTemplateRemark" class="layui-textarea" placeholder="请输入说明"></textarea>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">

View File

@ -36,6 +36,14 @@
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<input type="hidden" id="templateAreaFile" name="templateAreaFile">
<div class="layui-form-item layui-row">
<div class="layui-col-lg12">
<label class="layui-form-label">字段名称<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="templateAreaName" name="templateAreaName" class="layui-input" value="" placeholder="请输入字段名称" >
</div>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg12">
<label class="layui-form-label">字段标识<span style="color: red">*</span></label>
@ -44,10 +52,17 @@
</div>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">填充方式<span style="color: red">*</span></label>
<div class="layui-input-block" >
<input type="radio" name="templateAreaType" value="1" title="占位区域【使用区域配置内容填充】" />
<input type="radio" name="templateAreaType" value="2" title="填充区域【使用外部传入内容填充】" />
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">区域颜色<span style="color: red">*</span></label>
<div class="layui-input-block" >
<input type="radio" name="templateAreaColor" value="orange" title="橙色" />
<input type="radio" name="templateAreaColor" value="orange" checked title="橙色" />
<input type="radio" name="templateAreaColor" value="red" title="红色" />
<input type="radio" name="templateAreaColor" value="blue" title="蓝色" />
<input type="radio" name="templateAreaColor" value="green" title="绿色" />
@ -115,7 +130,7 @@
<div class="layui-col-lg12">
<label class="layui-form-label">字体大小<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="number" id="templateAreaFontSize" name="templateAreaFontSize" value="25" class="layui-input" placeholder="请输入字体大小" >
<input type="number" id="templateAreaFontSize" name="templateAreaFontSize" value="15" class="layui-input" placeholder="请输入字体大小" >
</div>
</div>
</div>

View File

@ -37,6 +37,14 @@
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<input type="hidden" id="picturesTemplateId" name="picturesTemplateId" class="layui-input" >
<input type="hidden" id="templateAreaFile" name="templateAreaFile">
<div class="layui-form-item layui-row">
<div class="layui-col-lg12">
<label class="layui-form-label">字段名称<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="templateAreaName" name="templateAreaName" class="layui-input" value="" placeholder="请输入字段名称" >
</div>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg12">
<label class="layui-form-label">字段标识<span style="color: red">*</span></label>
@ -45,6 +53,13 @@
</div>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">填充方式<span style="color: red">*</span></label>
<div class="layui-input-block" >
<input type="radio" name="templateAreaType" value="1" title="占位区域【使用区域配置内容填充】" />
<input type="radio" name="templateAreaType" value="2" title="填充区域【使用外部传入内容填充】" />
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">区域颜色<span style="color: red">*</span></label>
<div class="layui-input-block" >
@ -116,7 +131,7 @@
<div class="layui-col-lg12">
<label class="layui-form-label">字体大小<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="number" id="templateAreaFontSize" name="templateAreaFontSize" value="25" class="layui-input" placeholder="请输入字体大小" >
<input type="number" id="templateAreaFontSize" name="templateAreaFontSize" value="15" class="layui-input" placeholder="请输入字体大小" >
</div>
</div>
</div>

View File

@ -47,6 +47,26 @@ public class PicturesTemplateDTO {
private String picturesTemplateBack;
@ApiModelProperty(name = "picturesTemplateSize", value = "自定义尺寸")
private String picturesTemplateSize;
@ApiModelProperty(name = "picturesTemplatePicture", value = "预览图")
private String picturesTemplatePicture;
@ApiModelProperty(name = "picturesTemplateRemark", value = "备注说明")
private String picturesTemplateRemark;
public String getPicturesTemplateRemark() {
return picturesTemplateRemark == null ? "" : picturesTemplateRemark;
}
public void setPicturesTemplateRemark(String picturesTemplateRemark) {
this.picturesTemplateRemark = picturesTemplateRemark;
}
public String getPicturesTemplatePicture() {
return picturesTemplatePicture == null ? "" : picturesTemplatePicture;
}
public void setPicturesTemplatePicture(String picturesTemplatePicture) {
this.picturesTemplatePicture = picturesTemplatePicture;
}
public String getPicturesTemplateSize() {
return picturesTemplateSize == null ? "" : picturesTemplateSize;

View File

@ -48,7 +48,7 @@ public class PicturesTemplateAreaDTO {
private String templateAreaFile;
@ApiModelProperty(name = "fileList", value = "区域插件集合")
private List<PicturesTemplateAreaFileDTO> fileList;
@ApiModelProperty(name = "templateAreaServerLink", value = "区域类型")
@ApiModelProperty(name = "templateAreaServerLink", value = "区域类型1:文字,2:图片,3:条形码,4:二维码,5:地图位置,6:小程序二维码")
private String templateAreaServerLink;
@ApiModelProperty(name = "templateAreaFontCenter", value = "文字位置")
private String templateAreaFontCenter;
@ -62,6 +62,26 @@ public class PicturesTemplateAreaDTO {
private String templateAreaFontColor;
@ApiModelProperty(name = "templateAreaFontValue", value = "示例文字")
private String templateAreaFontValue;
@ApiModelProperty(name = "templateAreaFontValue", value = "区域名称")
private String templateAreaName;
@ApiModelProperty(name = "templateAreaFontValue", value = "填充方式1:占位区域,2:填充区域")
private String templateAreaType;
public String getTemplateAreaName() {
return templateAreaName == null ? "" : templateAreaName;
}
public void setTemplateAreaName(String templateAreaName) {
this.templateAreaName = templateAreaName;
}
public String getTemplateAreaType() {
return templateAreaType == null ? "" : templateAreaType;
}
public void setTemplateAreaType(String templateAreaType) {
this.templateAreaType = templateAreaType;
}
public String getTemplateAreaFontCenter() {
return templateAreaFontCenter == null ? "" : templateAreaFontCenter;

View File

@ -47,6 +47,16 @@ public class PicturesTemplateVO {
private String picturesTemplateBack;
@ApiModelProperty(name = "picturesTemplateSize", value = "显示尺寸")
private String picturesTemplateSize;
@ApiModelProperty(name = "picturesTemplatePicture", value = "预览图")
private String picturesTemplatePicture;
public String getPicturesTemplatePicture() {
return picturesTemplatePicture == null ? "" : picturesTemplatePicture;
}
public void setPicturesTemplatePicture(String picturesTemplatePicture) {
this.picturesTemplatePicture = picturesTemplatePicture;
}
public String getPicturesTemplateSize() {
return picturesTemplateSize == null ? "" : picturesTemplateSize;

View File

@ -57,6 +57,27 @@ public class PicturesTemplateAreaVO {
private String templateAreaFontColor;
@ApiModelProperty(name = "templateAreaFontValue", value = "示例文字")
private String templateAreaFontValue;
@ApiModelProperty(name = "templateAreaFontValue", value = "区域名称")
private String templateAreaName;
@ApiModelProperty(name = "templateAreaFontValue", value = "填充方式1:占位区域,2:填充区域")
@CheckEmptyAnnotation(name = "填充方式")
private String templateAreaType;
public String getTemplateAreaName() {
return templateAreaName == null ? "" : templateAreaName;
}
public void setTemplateAreaName(String templateAreaName) {
this.templateAreaName = templateAreaName;
}
public String getTemplateAreaType() {
return templateAreaType == null ? "" : templateAreaType;
}
public void setTemplateAreaType(String templateAreaType) {
this.templateAreaType = templateAreaType;
}
public String getTemplateAreaFontCenter() {
return templateAreaFontCenter == null ? "" : templateAreaFontCenter;