You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
5.0 KiB
HTML

<!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"/>
<th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-pda_version-add">
<div class="form-group">
<label class="col-sm-3 control-label">版本号:</label>
<div class="col-sm-8">
<input name="versionCode" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">版本名:</label>
<div class="col-sm-8">
<input name="versionName" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">信息:</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" name="modifyContent">
<div class="summernote" id="modifyContent"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">位置:</label>
<div class="col-sm-8">
<input type="hidden" id="downloadUrl" name="downloadUrl">
<div class="file-loading">
<input id="apkFile" name="file" type="file">
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
var prefix = ctx + "pda/pda_version"
$("#form-pda_version-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($("#downloadUrl").val() === '') {
$.modal.alertWarning("请先上传APK文件");
return false;
}
var data = {
versionCode: $("input[name='versionCode']").val(),
versionName: $("input[name='versionName']").val(),
modifyContent: $("input[name='modifyContent']").val(),
downloadUrl: $("#downloadUrl").val()
};
$.operate.save(prefix + "/add", data);
}
// $(".file-upload").fileinput({
// uploadUrl: ctx + 'common/upload',
// maxFileCount: 1,
// autoReplace: true
// }).on('fileuploaded', function (event, data, previewId, index) {
// $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
// }).on('fileremoved', function (event, id, index) {
// $("input[name='" + event.currentTarget.id + "']").val('')
// })
$(function() {
// APK文件上传
$("#apkFile").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true,
uploadExtraData: { fileType: "apk" }
}).on('fileuploaded', function (event, data) {
// 上传成功,将服务器返回的相对路径写入隐藏字段
$("#downloadUrl").val(data.response.url);
}).on('fileremoved', function () {
$("#downloadUrl").val('');
});
$('.summernote').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("图片上传失败。");
}
});
}
}
});
});
</script>
</body>
</html>