RuoYi/zt-admin/src/main/resources/templates/advert/info/add.html

136 lines
4.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增广告位')" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dict-add">
<input id="bannerPicUrl" name="bannerPicUrl" type="hidden"/>
<div class="form-group">
<label class="col-sm-3 control-label is-required">广告标题:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="bannerTitle" id="bannerTitle" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">广告位类型:</label>
<div class="col-sm-8">
<select name="bannerType" class="form-control m-b" th:with="type=${@dict.getType('sys_banner_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">广告跳转地址:</label>
<div class="col-sm-8">
<textarea name="address" maxlength="500" class="form-control" rows="3"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">广告位图片:</label>
<div class="col-sm-8">
<div class="file-loading">
<input id="multipleFile" name="files" type="file" multiple>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<textarea id="remark" name="remark" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script type="text/javascript">
var prefix = ctx + "advert/info";
<!-- $("#form-dict-add").validate({-->
<!-- rules:{-->
<!-- dictSort:{-->
<!-- digits:true-->
<!-- },-->
<!-- },-->
<!-- focusCleanup: true-->
<!-- });-->
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-dict-add').serialize());
}
}
$(function () {
// TODO: 上传
// 多图上传
var cacheImgs = {};
$("#multipleFile").fileinput({
uploadUrl: ctx + 'common/uploadsBanner',
showUploadedThumbs: true,
showUpload: false,
uploadAsync: false
}).on('filebatchuploadsuccess', function (event, data, previewId, index) {
console.log('filebatchuploadsuccess', event, data, previewId, index);
var rsp = data.response;
var urls = rsp.newFileNames || '';
var value = $("#bannerPicUrl").val() || '';
var list = [];
if (value) {
var list = value.split(',');
}
list = list.concat(urls.split(','))
$("#lpFilesName").val(list.join(','));
var a = $("#bannerPicUrl").val();
alert(rsp.newFileNames);
alert(a);
}).on('fileuploaded', function (event, data, previewId, index) {
cacheImgs[previewId] = data.response.newFileNames;
var rsp = data.response;
var value = $("#bannerPicUrl").val() || '';
var list = [];
var res = [];
var r_val = rsp.newFileNames;
var list = value.split(',');
list.forEach(function (item) {
if ((item !== r_val) && (item !=='') ) {
res.push(item);
}
})
res.push(r_val);
console.log('end', res);
$("#lpFilesName").val(res);
var c = $("#bannerPicUrl").val();
console.log('fileuploaded c:', c);
}).on('filesuccessremove', function (event, data, previewId, index) {
var urls = cacheImgs[data];
delete cacheImgs[data];
var value = $("#bannerPicUrl").val() || '';;
var list = value.split(',');
var res = [];
list.forEach(function (item) {
if ((item !== urls) && (item !=='')) {
res.push(item);
}
})
$("#lpFilesName").val(res);
var d = $("#bannerPicUrl").val();
console.log('filesuccessremove d:', d);
}).on('filecleared', function (event, data, msg) {
alert('全部删除');
$("#bannerPicUrl").val('');
})
});
</script>
</body>
</html>