Commit 70616aef authored by daniel's avatar daniel

perf(公告模块优化): 公告模块优化

parent 5622bf4a
...@@ -33,5 +33,9 @@ public class News implements Serializable { ...@@ -33,5 +33,9 @@ public class News implements Serializable {
@JsonIgnore @JsonIgnore
private Date updateDate; private Date updateDate;
private String path;
private String appId;
private String lat;
private String lng;
private int openType;
} }
\ No newline at end of file
...@@ -257,6 +257,7 @@ ...@@ -257,6 +257,7 @@
<select id="getCmptFromEnroll" resultType="com.dlbridge.jadp.plugins.cmpt.dao.model.Cmpt"> <select id="getCmptFromEnroll" resultType="com.dlbridge.jadp.plugins.cmpt.dao.model.Cmpt">
select cmptName,date_format(startTime,'%Y-%m-%d %H:%i:%s') startTime, select cmptName,date_format(startTime,'%Y-%m-%d %H:%i:%s') startTime,
date_format(ifnull(endTime,now()),'%Y-%m-%d %H:%i:%s') endTime,type as cmptType, date_format(ifnull(endTime,now()),'%Y-%m-%d %H:%i:%s') endTime,type as cmptType,
logo,
b.city as city, b.city as city,
b.province as province, b.province as province,
b.area as area, b.area as area,
......
...@@ -70,6 +70,7 @@ public class NewsController { ...@@ -70,6 +70,7 @@ public class NewsController {
@ResponseBody @ResponseBody
public Result save(News news) { public Result save(News news) {
News newDb = newsService.save(news); News newDb = newsService.save(news);
log.info("保存数据 ",newDb.toString());
return Result.success().setContent(newDb); return Result.success().setContent(newDb);
} }
......
This diff is collapsed.
...@@ -586,6 +586,10 @@ ...@@ -586,6 +586,10 @@
6: { 6: {
label: '图片', label: '图片',
placeholder: '请输入图片地址', placeholder: '请输入图片地址',
},
7: {
label: '地图',
placeholder: '请输入地址和经纬度',
} }
}, },
typeOptions: [ typeOptions: [
...@@ -612,6 +616,10 @@ ...@@ -612,6 +616,10 @@
{ {
name: '图片', name: '图片',
value: 6, value: 6,
},
{
name: '地图',
value: 7,
} }
], ],
statusType: { statusType: {
......
// 定义 typeDesc 映射
const typeDesc = {
0: {
label: '文本',
placeholder: '请输入文本内容',
},
1: {
label: '网页',
placeholder: '请输入网页地址',
},
2: {
label: '小程序',
placeholder: '请输入小程序地址',
},
3: {
label: '短连接',
placeholder: '请输入短连接地址',
},
4: {
label: '页面',
placeholder: '请输入页面地址',
},
5: {
label: '文档',
placeholder: '请输入文档地址',
},
6: {
label: '图片',
placeholder: '请输入图片地址',
},
7: {
label: '地图',
placeholder: '请输入地址和经纬度',
}
};
$(document).ready(function () { $(document).ready(function () {
editor = UE.getEditor('container'); editor = UE.getEditor('container');
...@@ -10,6 +45,12 @@ $(document).ready(function () { ...@@ -10,6 +45,12 @@ $(document).ready(function () {
} }
let linkUrl = $('#linkUrl').val(); let linkUrl = $('#linkUrl').val();
var content = editor.getContent(); var content = editor.getContent();
// 新增字段
const openType = $('#openType').val();
const path = $('#path').val();
const lat = $('#lat').val();
const lng = $('#lng').val();
const appId = $('#appId').val();
if (!content) { if (!content) {
layer.alert("内容不能为空!"); layer.alert("内容不能为空!");
return; return;
...@@ -19,29 +60,37 @@ $(document).ready(function () { ...@@ -19,29 +60,37 @@ $(document).ready(function () {
type: 'post', type: 'post',
data: { data: {
linkUrl, linkUrl,
id: $('.edit-container').attr('data-id'), title: title, content: editor.getContent(), userId: 1, id: $('.edit-container').attr('data-id'),
cmptId: getCId(), cover: $('#file-cover').attr('data-src'), type: $('input[name="type"]:checked').val() title: title,
appId:appId,
content: editor.getContent(),
userId: 1,
cmptId: getCId(),
cover: $('#file-cover').attr('data-src'),
type: $('input[name="type"]:checked').val(),
// 新增的字段
openType: openType,
path: path,
lat: lat,
lng: lng
}, },
success: function (data) { success: function (data) {
layer.msg('保存成功') layer.msg('保存成功')
console.log(data); window.location.reload();
$('.edit-container').attr('data-id', data.content.id); // $('.edit-container').attr('data-id', data.content.id);
// var length = $('.container .item').length;
// var copy = null;
var length = $('.container .item').length; // if (length == 0) {
var copy = null; // copy = $('.copy').clone().clone();
if (length == 0) { // } else {
copy = $('.copy').clone().clone(); // copy = $('.item').last().clone();
} else { // $('.item[data-id="' + data.content.id + '"]').remove();
copy = $('.item').last().clone(); // }
$('.item[data-id="' + data.content.id + '"]').remove(); // $(copy).find('.title').text(data.content.title);
// $(copy).find('.type').text(data.content.type == 1 ? '通知' : "赛训");
} // $(copy).attr('data-id', data.content.id);
$(copy).find('.title').text(data.content.title); // $(copy).show()
$(copy).find('.type').text(data.content.type == 1 ? '通知' : "赛训"); // $('.container').append($(copy));
$(copy).attr('data-id', data.content.id);
$(copy).show()
$('.container').append($(copy));
} }
}) })
}); });
...@@ -79,6 +128,7 @@ $(document).ready(function () { ...@@ -79,6 +128,7 @@ $(document).ready(function () {
function () { function () {
delNews(id, function () { delNews(id, function () {
obj.remove(); obj.remove();
window.location.reload();
}); });
}, function () { }, function () {
...@@ -102,12 +152,7 @@ $(document).ready(function () { ...@@ -102,12 +152,7 @@ $(document).ready(function () {
success:function (data) { success:function (data) {
if(data.code == 200){ if(data.code == 200){
layer.msg('保存成功'); layer.msg('保存成功');
if($('#newsAlias').val() == '' || $('#newsAlias').val() == undefined){ window.location.reload();
$('.news-title').empty();
$('.news-title').append("<span class=\"no-name\">未命名</span>");
}else{
$('.news-title').text($('#newsAlias').val());
}
$('.edit-mask,.edit-dialog').fadeOut(); $('.edit-mask,.edit-dialog').fadeOut();
} }
} }
...@@ -119,7 +164,42 @@ $(document).ready(function () { ...@@ -119,7 +164,42 @@ $(document).ready(function () {
$('#newsAlias').val(); $('#newsAlias').val();
$('.edit-mask,.edit-dialog').fadeIn(); $('.edit-mask,.edit-dialog').fadeIn();
}) })
// 监听select选项
// 监听 openType 变化
$('#openType').change(function() {
const openType = $(this).val();
updateViews(openType);
});
}); });
// 显示/隐藏必要的参数
function updateViews(openType=0){
const desc = typeDesc[openType];
if (desc) {
// 修改 path 的 label 和 placeholder
$('#path').prev('label').text(desc.label);
$('#path').attr('placeholder', desc.placeholder);
if (openType == '0') { // 地图类型
$('#path-input').addClass('hidden');
} else {
$('#path-input').removeClass('hidden');
}
if (openType == '2') { // 地图类型
$('#appId-input').removeClass('hidden');
} else {
$('#appId-input').addClass('hidden');
}
// 根据类型显示/隐藏经纬度输入框
if (openType == '7') { // 地图类型
$('#lat-input').removeClass('hidden');
$('#lng-input').removeClass('hidden');
} else {
$('#lat-input').addClass('hidden');
$('#lng-input').addClass('hidden');
}
}
}
//文件上传处理 //文件上传处理
function uploadFile(obj) { function uploadFile(obj) {
...@@ -167,12 +247,17 @@ function getNews(id) { ...@@ -167,12 +247,17 @@ function getNews(id) {
$('#title').val(data.content.title) $('#title').val(data.content.title)
$('#linkUrl').val(data.content.linkUrl) $('#linkUrl').val(data.content.linkUrl)
$('input[name="type"][value=' + data.content.type + ']').attr('checked', true) $('input[name="type"][value=' + data.content.type + ']').attr('checked', true)
$('#openType').val(data.content.openType);
$('#path').val(data.content.path);
$('#lat').val(data.content.lat);
$('#lng').val(data.content.lng);
$('#appId').val(data.content.appId);
updateViews(data.content.openType)
if (data.content.cover) { if (data.content.cover) {
$('.cover').css('background-image', "url(" + data.content.cover + ")") $('.cover').css('background-image', "url(" + data.content.cover + ")")
$('.icon-cover').remove(); $('.icon-cover').remove();
$('#file-cover').attr('data-src', data.content.cover) $('#file-cover').attr('data-src', data.content.cover)
} }
editor.setContent(data.content.content) editor.setContent(data.content.content)
} }
layer.closeAll(); layer.closeAll();
......
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