Commit 6da433d7 authored by daniel's avatar daniel

feat(upload+richtext): 文件上传调整+富文本后端渲染

parent 717c777b
......@@ -18,7 +18,8 @@
del_flag AS "delFlag",
icon,
dead_time AS deadTime,
open_type AS openType
open_type AS openType,
content
FROM gk_cmptsetting a
WHERE a.id = #{id}
and a.del_flag = '0'
......@@ -243,7 +244,7 @@
</update>
<select id="queryFuncs" resultType="com.dlbridge.jadp.plugins.cmpt.bean.Func">
select id,cmptid cmptId,name,type,visibility,seq,app_id appId,url,name_web nameWeb,`status`,icon,open_type openType,dead_time deadTime,start_time startTime,need_time needTime
select id,cmptid cmptId,name,type,visibility,seq,app_id appId,url,name_web nameWeb,`status`,icon,open_type openType,dead_time deadTime,start_time startTime,need_time needTime,content
from gk_cmptsetting
where cmptid = #{cmptId} and visibility=1 and del_flag=0 and status>0
order by seq
......@@ -251,7 +252,7 @@
</select>
<select id="queryAllFuncs" resultType="com.dlbridge.jadp.plugins.cmpt.bean.Func">
select id,cmptid cmptId,name,type,visibility,seq,app_id appId,url,name_web nameWeb,`status`,icon,open_type openType,dead_time deadTime,start_time startTime,need_time needTime
select id,cmptid cmptId,name,type,visibility,seq,app_id appId,url,name_web nameWeb,`status`,icon,open_type openType,dead_time deadTime,start_time startTime,need_time needTime,content
from gk_cmptsetting
where cmptid = #{cmptId} and visibility=1 and del_flag=0 and status=1
order by seq
......
......@@ -123,6 +123,7 @@
,type
,status
,module_id AS moduleId
,content
FROM
gksite.gk_rich_text
WHERE
......
package com.dlbridge.jadp.plugins.cmpt.dao.model;
import lombok.Data;
import org.springframework.data.annotation.Transient;
@Data
public class RichText {
......@@ -13,6 +14,9 @@ public class RichText {
private Integer moduleId;
private String title;
private String address;
// 链接地址
@Transient
private String url;
private Double lng;
private Double lat;
private String content;
......
......@@ -119,4 +119,8 @@ public class RichTextService {
return new ArrayList();
}
}
public RichText getById(String id){
return richTextMapper.getById(id).get(0);
}
}
\ No newline at end of file
package com.dlbridge.jadp.plugins.cmpt.web;
import com.dlbridge.feign.GeexekScoreService;
import com.dlbridge.feign.bean.News;
import com.dlbridge.jadp.common.interceptor.PageView;
import com.dlbridge.jadp.plugins.cmpt.bean.CmptSettingTemplate;
import com.dlbridge.jadp.plugins.cmpt.bean.FuncSetting;
......@@ -13,10 +14,7 @@ import com.dlbridge.jadp.plugins.cmpt.service.*;
import com.neusoft.www.utils.web.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;
......@@ -129,6 +127,14 @@ public class CmptSettingController {
return "ok";
}
@RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
public ModelAndView page(@PathVariable("id") String id, ModelAndView mv) {
mv.setViewName("cmpt/detail");
CmptSetting cmptSetting = cmptSettingService.getCmptSettingById(id);
mv.addObject("news", cmptSetting);
return mv;
}
/**
* 修改赛事活动启用状态
*/
......
......@@ -38,6 +38,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@Log4j2
......@@ -468,8 +469,29 @@ public class MicroApiController {
@ApiOperation(value = "赛事功能模块列表", notes = "赛事功能模块列表", tags = "赛事页面")
public Result<List<Func>> func(@PathVariable("cmptId") int cmpId,
HttpServletRequest request) {
String enrollId = request.getParameter("enrollId");
// String enrollId = request.getParameter("enrollId");
List<Func> list = cmptSetting.queryFuncs(cmpId);
list=list
.stream()
.filter(v -> {
if (v.getNeedTime() == null || v.getNeedTime() != 1) {
return true; // 不需要时间校验的直接保留
}
Date now = new Date();
// 检查开始时间条件(如果有)
boolean startValid = v.getStartTime() == null || !now.before(v.getStartTime());
// 检查结束时间条件(如果有)
boolean endValid = v.getDeadTime() == null || now.before(v.getDeadTime());
// 必须同时满足开始和结束时间条件
return startValid && endValid;
})
.collect(Collectors.toList());
list.forEach(v -> {
if(v.getOpenType().equals(0)){
v.setUrl(serverURL + "gk/cmpt/cmptSetting/page/" + v.getId());
}
});
/* if (StringUtils.isBlank(enrollId)) {
list = cmptSetting.queryAllFuncs(cmpId); // 查询 可对外的
} else { // 绑定后
......
......@@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -28,6 +29,9 @@ public class RichTextController {
@Resource
private RichTextService richTextService;
@Value("${server.url.https}")
private String serverURL;
@PostMapping(value = "/add")
@ApiOperation(value = "自助服务管理新增", notes = "自助服务管理新增", tags = "自助服务")
public Result addRichText(@RequestBody RichText richText) {
......@@ -73,8 +77,11 @@ public class RichTextController {
public Result<List<RichText>> getRichTextList(@RequestBody RichTextBean richTextBean, @PathVariable("page") int page, @PathVariable("pageSize") int pageSize) {
List<RichText> richTextList = richTextService.getPage(richTextBean,page-1,pageSize);
//int fromIndex = pointService.getOffset(pageNo, pageCount);
//richTextList = JoyfulRichTextService.subList(richTextList, fromIndex, fromIndex + pageCount);
richTextList.forEach(v -> {
if(v.getType().equals(0)){
v.setUrl(serverURL + "gk/service/page/" + v.getId());
}
});
return Result.success().setContent(richTextList);
}
......
package com.dlbridge.jadp.plugins.cmpt.web;
import com.dlbridge.jadp.common.interceptor.PageView;
import com.dlbridge.jadp.plugins.cmpt.bean.CmptScoreRule;
import com.dlbridge.jadp.plugins.cmpt.dao.model.Cmpt;
import com.dlbridge.jadp.plugins.cmpt.service.CmptScoreRuleService;
import com.dlbridge.jadp.plugins.cmpt.dao.model.CmptSetting;
import com.dlbridge.jadp.plugins.cmpt.dao.model.RichText;
import com.dlbridge.jadp.plugins.cmpt.service.CmptService;
import com.dlbridge.jadp.plugins.cmpt.service.RemoteService;
import com.neusoft.www.utils.web.Result;
import com.dlbridge.jadp.plugins.cmpt.service.RichTextService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
@Controller
@Log4j2
......@@ -27,6 +25,9 @@ public class ServiceSettingController {
@Resource
private CmptService cmptService;
@Resource
private RichTextService richTextService;
@RequestMapping("index/{cmptId}")
@PageView
public ModelAndView servicePage(@PathVariable("cmptId") Integer cmptId, ModelAndView mv) {
......@@ -37,4 +38,15 @@ public class ServiceSettingController {
return mv;
}
@RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
public ModelAndView page(@PathVariable("id") String id, ModelAndView mv) {
mv.setViewName("cmpt/detail");
RichText richText = richTextService.getById(id);
mv.addObject("news", richText);
return mv;
}
}
......@@ -42,6 +42,14 @@
<link rel="stylesheet" href="${ctxStatic}/layer/skin/layer.css">
<link rel="stylesheet" href="/static/cmpt/score.css?<%=System.currentTimeMillis()%>">
<style>
.layui-layer-title {
color: white;
}
.layui-layer-btn {
color: white;
}
.action {
display: flex;
flex-direction: row;
......@@ -560,7 +568,7 @@
}
var reads = new FileReader();
reads.readAsDataURL(file);
reads.onload = function () {
reads.onload = () => {
//将处理完的图片文件上传到阿里云服务器
//上传LOGO图片
var formData = new FormData();
......@@ -574,7 +582,8 @@
success: function (res) {
if (res.code == 200) {
layer.msg('上传成功', { icon: 1, time: 1500 });
app.$data.module.icon = res.content
this.module.icon = res.content
this.$forceUpdate()
}
},
beforeSend: () => {
......
......@@ -238,6 +238,21 @@
background-size: auto;
}
.file-cover {
width: 680px;
height: 232px;
background: rgba(247, 247, 247, 1);
border-radius: 4px;
border: 1px solid rgba(238, 238, 238, 1);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
background-repeat: no-repeat;
background-position: center;
background-size: auto;
}
input,
textarea {
outline: none;
......@@ -273,6 +288,14 @@
background-repeat: no-repeat;
}
.file-icon-cover {
width: 34px;
height: 34px;
background-image: url("/static/images/icon_cover.png");
background-size: 100%;
background-repeat: no-repeat;
}
.icon-add {
display: inline-block;
width: 16px;
......@@ -442,8 +465,23 @@
</select>
</div>
</div>
<div class="input-group hidden" id="path-input" style="height: 120px;margin-bottom: 10px;">
<label for="">路径</label>
<div class="input-group hidden" id="file-upload"
style="margin-top: 8px;margin-bottom: 30px;height: 240px">
<label id="file-input">上传<br><span
style="font-size: 16px;color: #ce3939;margin-top: 20px">
<span
style="font-size: 12px;display: inline-block;border-radius: 50%;height: 18px;width: 18px;background: #ce3939;color: white;text-align: center;">注</span>
<span style="display: inline">上传对应<br />的文件</span></span></label>
<div style="float: right;">
<div class="file-cover">
<span class="file-icon-cover"></span>
</div>
<input id="file-doc" type="file" style="display: none"
onchange="uploadImageOrDocFile(this)">
</div>
</div>
<div class="input-group" id="path-input" style="height: 120px;margin-bottom: 10px;">
<label id="link-label" for="">链接</label>
<div>
<textarea style="float: right;" class="title-area" type="text"
placeholder="外链填写后,优先展示外链信息公众号必选绑定小程序" id="path" cols="50"
......
......@@ -357,21 +357,20 @@
</span>
</div>
</div>
<div class="func" v-if="letter.openType != 0&&![5,6].includes(letter.openType)">
<div class="func">
<span class="title-new">{{typeDesc[letter.openType].label}}</span>
<div style="position: relative;width: 400px">
<input class="input" type="text" v-model="letter.url"
<input id="link" class="input" type="text" v-model="letter.url"
:placeholder="typeDesc[letter.openType].placeholder">
</div>
</div>
<div class="func" v-if="[5,6].includes(letter.openType)">
<span class="title-new">{{typeDesc[letter.openType].label}}</span>
<span class="title-new">上传{{typeDesc[letter.openType].label}}</span>
<div>
<label for="url">
<div v-if="!letter.url" class="cover">
<div class="cover">
<span class="icon-cover"></span>
</div>
<span v-else>{{letter.url}}</span>
</label>
<input id="url" type="file" style="display: none" @change="uploadFile">
</div>
......@@ -620,7 +619,7 @@
}
var reads = new FileReader();
reads.readAsDataURL(file);
reads.onload = function () {
reads.onload = () => {
//将处理完的图片文件上传到阿里云服务器
//上传LOGO图片
var formData = new FormData();
......@@ -633,8 +632,10 @@
processData: false,
success: (res) => {
if (res.code == 200) {
this.letter.icon = res.content;
layer.msg('上传成功', { icon: 1, time: 1500 });
app.$data.letter.icon = res.content
this.$forceUpdate(); // 强制更新视图
}
},
beforeSend: () => {
......@@ -650,15 +651,18 @@
//文件上传处理
uploadFile(obj) {
file = obj.target.files[0];
if (this.letter.openType === 6 && file.type && file.type.indexOf("image") == -1) {
return layer.msg('请上传图片', { icon: 5 })
if (file.type && file.type.indexOf("image") == -1 && this.letter.openType == 6) {
layer.msg('请上传图片', { icon: 5 })
return;
}
if (this.letter.openType === 5 && file.type && (file.type.indexOf(".pdf") === -1 || file.type.indexOf(".doc") === -1)) {
return layer.msg('请上传 pdf或doc文档', { icon: 5 })
// 文档
if (file.type && !['.docx', '.xlsx', '.pptx'].includes(file.name.slice(file.name.lastIndexOf('.'))) && this.letter.openType == 5) {
layer.msg('请上传文档', { icon: 5 })
return;
}
var reads = new FileReader();
reads.readAsDataURL(file);
reads.onload = function () {
reads.onload = () => {
//将处理完的图片文件上传到阿里云服务器
//上传LOGO图片
var formData = new FormData();
......@@ -671,8 +675,11 @@
processData: false,
success: (res) => {
if (res.code == 200) {
this.letter.url = res.content;
layer.msg('上传成功', { icon: 1, time: 1500 });
app.$data.letter.url = res.content
$("#link").val(res.content)
this.$forceUpdate(); // 强制更新视图
}
},
beforeSend: () => {
......
......@@ -56,6 +56,14 @@
}
.layui-layer-title {
color: white;
}
.layui-layer-btn {
color: white;
}
.action div {
display: flex;
flex-direction: row;
......@@ -648,7 +656,7 @@
}
var reads = new FileReader();
reads.readAsDataURL(file);
reads.onload = function () {
reads.onload = () => {
//将处理完的图片文件上传到阿里云服务器
//上传LOGO图片
var formData = new FormData();
......@@ -662,7 +670,8 @@
success: function (res) {
if (res.code == 200) {
layer.msg('上传成功', { icon: 1, time: 1500 });
app.$data.service.imgUrl = res.content
this.service.imgUrl = res.content
this.$forceUpdate()
}
},
beforeSend: () => {
......
......@@ -23,11 +23,11 @@ const typeDesc = {
},
5: {
label: '文档',
placeholder: '请输入文档地址',
placeholder: '请输入文档地址或点击上方上传',
},
6: {
label: '图片',
placeholder: '请输入图片地址',
placeholder: '请输入图片地址或点击上方上传',
},
7: {
label: '地图',
......@@ -37,7 +37,6 @@ const typeDesc = {
$(document).ready(function () {
editor = UE.getEditor('container');
$('#save').click(function () {
var title = $('#title').val();
if (!title) {
......@@ -100,6 +99,9 @@ $(document).ready(function () {
$('.cover').click(function () {
$('#file').trigger('click');
});
$('.file-cover').click(function () {
$('#file-doc').trigger('click');
});
$('.back').click(function () {
$('.container').show();
......@@ -181,18 +183,18 @@ function updateViews(openType = 0) {
// 修改 path 的 label 和 placeholder
$('#path').prev('label').text(desc.label);
$('#path').attr('placeholder', desc.placeholder);
if (openType == '0') { // 地图类型
if (openType == '0') { //
$('#path-input').addClass('hidden');
} else {
$('#path-input').removeClass('hidden');
}
if (openType == '2') { // 地图类型
if (openType == '2') { //
$('#appId-input').removeClass('hidden');
} else {
$('#appId-input').addClass('hidden');
}
// 根据类型显示/隐藏经纬度输入框
if (openType == '7') { // 地图类型
if (openType == '7') { //
$('#lat-input').removeClass('hidden');
$('#lng-input').removeClass('hidden');
} else {
......@@ -201,6 +203,12 @@ function updateViews(openType = 0) {
}
}
// 显示上传的弹框
if (["5", "6"].includes(openType)) {
$('#file-upload').removeClass('hidden');
} else {
$('#file-upload').addClass('hidden');
}
}
//文件上传处理
......@@ -218,13 +226,13 @@ function uploadFile(obj) {
var formData = new FormData();
formData.append("file", file);
$.ajax({
url: uploadFile, /*接口域名地址*/
url: uploadUrl, /*接口域名地址*/
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function (res) {
if (res.code == "1") {
if (res.code == 200) {
layer.msg('上传成功', { icon: 1, time: 1500 });
$('#file-cover').attr('data-src', res.content);
$('#file-cover').attr('data-src', res.content);
......@@ -235,6 +243,47 @@ function uploadFile(obj) {
})
};
}
//文件上传处理
function uploadImageOrDocFile(obj) {
var reads = new FileReader();
const openType = $('#openType').val();
file = obj.files[0];
if (file.type && file.type.indexOf("image") == -1 && openType == 6) {
layer.msg('请上传图片', { icon: 5 })
return;
}
// 文档
if (file.type && !['.docx', '.xlsx', '.pptx'].includes(file.name.slice(file.name.lastIndexOf('.'))) && openType == 5) {
layer.msg('请上传文档', { icon: 5 })
return;
}
reads.readAsDataURL(file);
reads.onload = function (e) {
//将处理完的图片文件上传到阿里云服务器
//上传LOGO图片
var formData = new FormData();
formData.append("file", file);
$.ajax({
url: uploadUrl, /*接口域名地址*/
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function (res) {
if (res.code == 200) {
layer.msg('上传成功', { icon: 1, time: 1500 });
// 正确的方式 - 使用val()方法
$("#path").val(res.content);
if (openType == 6) {
$('.file-cover').css('background-image', 'url(' + res.content + ')')
$('.file-icon-cover').remove();
}
}
}
})
};
}
function getNews(id) {
layer.load(2)
......
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