Skip to content

Commit

Permalink
🦄 fix #22dropzonejs 定义错误提示,定义上传
Browse files Browse the repository at this point in the history
  • Loading branch information
nonacosa committed Feb 27, 2017
1 parent 6efab2b commit 165a5c2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 39 deletions.
41 changes: 11 additions & 30 deletions src/main/resources/static/admin/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,17 @@
*/
$.extend({
tale: function () {
},
constant:function(){ //常量池
return{
///-------文件常量----------
MAX_FILE_SIZE:2,//文件最大???MB
MAX_FILES:2,//一次队列最大文件数
}
}
});

/**
* tale alert删除 // todo: 减少耦合度,链式操作替代 2017-02-27
* @param options
*/
// $.tale.prototype.alert_del = function (options) {
// swal({
// title: options.title || '警告信息',
// text: options.text || "确定删除吗?",
// type: 'warning',
// showCancelButton: true,
// confirmButtonColor: '#3085d6',
// cancelButtonColor: '#d33',
// confirmButtonText: '确定',
// cancelButtonText: '取消'
// }).then(function () {
// $.post(options.url, options.parame, function (result) {
// if (result && result.success) {
// swal('提示信息', '删除成功', 'success');
// setTimeout(function () {
// window.location.reload();
// }, 2000);
// } else {
// swal("提示消息", result.msg, 'error');
// }
// });
// }).catch(swal.noop);
// };

});

/**
* 成功弹框
* @param options
Expand Down Expand Up @@ -158,4 +138,5 @@ $.tale.prototype.showLoading = function () {
*/
$.tale.prototype.hideLoading = function () {
$('#tale-loading') && $('#tale-loading').hide();
};
};

32 changes: 23 additions & 9 deletions src/main/resources/templates/admin/attach.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@
#dropzone {
margin-bottom: 3rem;
}

.dropzone {
border: 2px dashed #0087F7;
border-radius: 5px;
background: white;
}

.dropzone .dz-message {
font-weight: 400;
}

.dropzone .dz-message .note {
font-size: 0.8em;
font-weight: 200;
display: block;
margin-top: 1.4rem;
}

.attach-img {
width: 100px;
height: 100px;
border-radius: 10px;
box-shadow: 0px 0px 8px #333;
}

.attach-text {
font-size: 12px;
font-weight: 300;
}

.attach-img:hover {
background-color: #f9f9f9;
}
Expand Down Expand Up @@ -103,16 +109,24 @@ <h4 class="page-title">文件管理</h4>

$("#dropzone").dropzone({
url: "/admin/attach/upload",
init: function () {
this.on("success", function (file) {
console.log(file);
setTimeout(function () {
window.location.reload();
}, 200);
filesizeBase:1024,//定义字节算法 默认1000
maxFiles: $.constant().MAX_FILES,//最大文件数量
maxFilesize: $.constant().MAX_FILE_SIZE ,//MB
// acceptedFiles: ".js,.obj,.dae" //限制文件类型 image/*,application/pdf,.psd,.obj
fallback:function(){
tale.alertOkAndReload('暂不支持当前浏览器');
},
dictFileTooBig:'您的文件超过'+ $.constant().MAX_FILE_SIZE+'MB!',
dictInvalidInputType:'不支持您上传的类型',
dictMaxFilesExceeded:'您的文件超过'+ $.constant().MAX_FILES+'个!',
init: function() {
this.on("addedfile", function(file) {
tale.alertError('暂不支持您的浏览器长传!');
});
}
});


var clipboard = new Clipboard('button.copy', {
text: function (trigger) {
return $(trigger).attr('url');
Expand All @@ -128,13 +142,13 @@ <h4 class="page-title">文件管理</h4>

function delAttach(id) {
tale.alertConfirm({
title:'确定删除该附件吗?',
title: '确定删除该附件吗?',
then: function () {
tale.post({
url : '/admin/attach/delete',
url: '/admin/attach/delete',
data: {id: id},
success: function (result) {
if(result && result.success){
if (result && result.success) {
tale.alertOkAndReload('附件删除成功');
} else {
tale.alertError(result.msg || '附件删除失败');
Expand Down

0 comments on commit 165a5c2

Please sign in to comment.