westdc-zf1/application/admin/views/scripts/data/attachmentsadd.phtml

117 lines
3.3 KiB
PHTML
Raw Normal View History

<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('数据管理');
$this->breadcrumb()->setSeparator(' > ');
2013-10-16 08:07:54 +00:00
$this->theme->AppendPlus($this,"uploadify");
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
2011-10-12 14:53:03 +00:00
<div id="rightPanel">
<div class="ctrlplan">
<a href="/admin/data/md/att/1/uuid/<?php echo $this->uuid;?>">返回元数据附件列表</a>
2013-10-16 08:07:54 +00:00
<a href="/data/<?php echo $this->uuid; ?>">查看元数据</a>
2012-12-01 10:59:14 +00:00
<a href="/admin/data/attachments/">返回附件管理</a>
</div>
<form action="#" method="POST" enctype='multipart/form-data'>
<input type="hidden" name="add" value="1" />
<input type="hidden" name="submit" value="1" />
<p>注:可选择多个文件<br />
2013-10-16 08:07:54 +00:00
<div id="datalist">
</div>
<input id="file_upload" name="Filedata" type="file" />
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
</p>
</form>
</div>
<script>
2013-10-16 08:07:54 +00:00
var _this = {
SessionID : '<?php echo session_id(); ?>'
};
var uploader;
var param;
param = {
"PHPSESSID" : _this.SessionID,
"multi" : 'yes'
};
$(function() {
$('#file_upload').uploadify({
'swf' : '/js/lib/uploadify/uploadify.swf',
'uploader' : '/admin/data/upload/<?php if(!empty($this->uuid)) echo "uuid/".$this->uuid; ?>',
'multi' : true,
'auto' : true,
'fileTypeExts' : '*',
'onUploadSuccess' : function(file, data, response) {
upload.onsuccess(file, data, response);
},
'onUploadStart' : function(file) {
$('#file_upload').uploadify('settings','formData',param);
}
});
});
var upload = {
onsuccess : function(file, data, response){
_data = $.parseJSON(data);
if(!$.isEmptyObject(_data.error))
{
alert(_data.error);
}else{
$('#datalist').append(upload.makeFileHtml(_data));
}
2013-10-16 08:07:54 +00:00
},
makeFileHtml : function(data){
return '<div class="alert alert-success">'
+ '<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
+ data.realname
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
+'</div>';
},
deleteFile : function(id){
$.ajax({
'type':"POST",
'url':'/admin/data/attachments/',
'data':'uuid=<?php echo $this->uuid?>&mdattdel='+id,
'success':function(data){
if(typeof(data) == 'undefined')
{
alert("数据源错误,请联系管理员");
return false;
}
if(!$.isEmptyObject(data.error))
{
alert(data.error);
return false;
}
},
'timeout': 30000,
'error': function(){
alert('附件删除出错');
}
});
}
};
$(document).ready(function() {
$.getJSON("/admin/data/getatts/uuid/<?php echo $this->uuid;?>", function(data) {
if(data)
{
$.each(data, function(key, val) {
2013-10-16 08:07:54 +00:00
$('#datalist').append(upload.makeFileHtml(val));
});
}
});
});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
}
</script>