提交 334d93d5 作者: dingtalk_nnkplh

修改学校图册,增加封面字段

上级 b81a75bb
......@@ -10,7 +10,6 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">学校:</label>
<div class="col-sm-8">
<!-- <input name="schoolId" class="form-control" type="text" required>-->
<select id="schoolId" class="form-control select2-multiple">
<option>请选择学校</option>
</select>
......@@ -22,6 +21,15 @@
<input name="atlasName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">图册封面:</label>
<input id="atlasCover" type="hidden" name="atlasCover">
<div class="col-sm-8">
<div class="file-loading">
<input id="singleFile" name="files" type="file">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">图册内容:</label>
<input id="atlasContent" type="hidden" name="atlasContent">
......@@ -76,6 +84,18 @@
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
// 单图上传
$("#singleFile").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
var rsp = data.response;
$("#atlasCover").val(rsp.fileName);
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
});
</script>
</body>
......
......@@ -21,12 +21,19 @@
<input name="atlasName" th:field="*{atlasName}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">图册封面:</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" th:field="*{atlasCover}">
<div class="file-loading">
<input id="singleFile" name="files" type="file">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">图册内容:</label>
<!-- <input id="atlasContent" type="hidden" name="atlasContent">-->
<div class="col-sm-8">
<input type="hidden" class="form-control" th:field="*{atlasContent}">
<!-- <div class="summernote" id="atlasContent"></div>-->
<div class="file-loading">
<input id="multipleFile" name="files" type="file" multiple>
</div>
......@@ -49,48 +56,9 @@
}
}
// $(function() {
// $('.summernote').each(function(i) {
// $('#' + this.id).summernote({
// lang: 'zh-CN',
// dialogsInBody: true,
// callbacks: {
// onChange: function(contents, $edittable) {
// $("input[name='" + this.id + "']").val(contents);
// },
// onImageUpload: function(files) {
// var obj = this;
// var data = new FormData();
// data.append("file", files[0]);
// $.ajax({
// type: "post",
// url: ctx + "common/upload",
// data: data,
// cache: false,
// contentType: false,
// processData: false,
// dataType: 'json',
// success: function(result) {
// if (result.code == web_status.SUCCESS) {
// $('#' + obj.id).summernote('insertImage', result.url);
// } else {
// $.modal.alertError(result.msg);
// }
// },
// error: function(error) {
// $.modal.alertWarning("图片上传失败。");
// }
// });
// }
// }
// });
// var content = $("input[name='" + this.id + "']").val();
// $('#' + this.id).summernote('code', content);
// })
// });
//初始化文件预览数据和文件上传附件
initUpload();
initUpload1();
//初始化方法
function initUpload() {
......@@ -167,6 +135,73 @@
$("#atlasContent").val(urlLinkNew);
console.log($("#atlasContent").val())
});
function initUpload1() {
var logoUrl = $("#atlasCover").val();//拿到图片路径
var preList = new Array();
var initialPreviewConfig = new Array();
//设置初始化区域值
if (logoUrl != null && logoUrl != ''){
var a = {
// caption : '主图'+(i+1),
// width: '120px',
url: '/common/del',
// key: i,
extra: {url: logoUrl}
}
preList.push(logoUrl);
initialPreviewConfig.push(a);
}
$("#singleFile").fileinput({
language: 'zh', //设置语言
uploadUrl: "/common/upload", //上传的地址,改成自己的
allowedFileExtensions:['bmp', 'gif', 'jpg', 'jpeg', 'png'],//接收的文件后缀
initialPreviewAsData:true,
initialPreview:preList,//预览图片
uploadAsync: true, //默认异步上传
showUpload: true, //是否显示上传按钮
showRemove : false, //显示移除按钮
showPreview : true, //是否显示预览
showCaption: false,//是否显示标题
browseClass: "btn btn-primary", //按钮样式
dropZoneEnabled: false,//是否显示拖拽区域
maxFileCount: 1, //表示允许同时上传的最大文件个数
maxFileSize:10 *1024 *1024,
messages: {maxFileSize:'文件上传的最大大小为 10MB',acceptFileTypes:'此文件是不支持的图片格式' },
enctype: 'multipart/form-data',
validateInitialCount:true,
msgFilesTooMany:5,
autoReplace:false,
initialPreviewConfig:initialPreviewConfig
});
$("#singleFile").on('fileuploaded', function (event, data, previewId, index) {
var rsp = data.response;
$("#atlasCover").val(rsp.fileName);
$("#singleFile").fileinput('destroy');//销毁fileUploadFileInput
initUpload1();//重新初始化文件预览数据和文件上传附件
$('#singleFile').fileinput('enable');//enable作用:destroy并重新初始化fileinput插件后,插件会处于disable状态
});
$('#singleFile').on('filepredelete', function(event, key, jqXHR, data) { //就是在删除原图片之前触发,而新选择的图片不会触发。能满足我们的要求。
console.log('Key = ' + key);
var logoUrl = $("#atlasCover").val();
var urlLinkNew = '';
var imgArr = logoUrl.split(",");
for ( var i = 0; i < imgArr.length; i++) {
if (i == key) continue;
if (urlLinkNew !=''){
urlLinkNew = urlLinkNew + "," + imgArr[i];
}else{
urlLinkNew = imgArr[i];
}
}
$("#atlasCover").val(urlLinkNew);
console.log($("#atlasCover").val())
});
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -29,6 +29,8 @@ public class TbSchoolAtlas extends BaseEntity
@Excel(name = "图册名称")
private String atlasName;
private String atlasCover;
/** 图册内容 */
@Excel(name = "图册内容")
private String atlasContent;
......@@ -100,6 +102,14 @@ public class TbSchoolAtlas extends BaseEntity
this.modifiedByDesc = modifiedByDesc;
}
public String getAtlasCover() {
return atlasCover;
}
public void setAtlasCover(String atlasCover) {
this.atlasCover = atlasCover;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
......@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="schoolId" column="school_id" />
<result property="atlasName" column="atlas_name" />
<result property="atlasCover" column="atlas_cover" />
<result property="atlasContent" column="atlas_content" />
<result property="creator" column="creator" />
<result property="createTime" column="create_time" />
......@@ -16,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTbSchoolAtlasVo">
select id, school_id, atlas_name, atlas_content, creator, create_time,
select id, school_id, atlas_name, atlas_cover, atlas_content, creator, create_time,
modified_by,update_time from tb_school_atlas
</sql>
......@@ -38,12 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="schoolId != null">school_id,</if>
<if test="atlasName != null and atlasName != ''">atlas_name,</if>
<if test="atlasCover != null and atlasCover != ''">atlas_cover,</if>
<if test="atlasContent != null and atlasContent != ''">atlas_content,</if>
create_time,creator
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="schoolId != null">#{schoolId},</if>
<if test="atlasName != null and atlasName != ''">#{atlasName},</if>
<if test="atlasCover != null and atlasCover != ''">#{atlasCover},</if>
<if test="atlasContent != null and atlasContent != ''">#{atlasContent},</if>
sysdate(),#{creator}
</trim>
......@@ -54,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="schoolId != null">school_id = #{schoolId},</if>
<if test="atlasName != null and atlasName != ''">atlas_name = #{atlasName},</if>
<if test="atlasCover != null and atlasCover != ''">atlas_cover = #{atlasCover},</if>
<if test="atlasContent != null and atlasContent != ''">atlas_content = #{atlasContent},</if>
modified_by=#{modifiedBy},
update_time=sysdate()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论