创建版本
This commit is contained in:
@@ -0,0 +1,344 @@
|
||||
<?php namespace Gdoo\File\Controllers;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Session;
|
||||
use URL;
|
||||
|
||||
use Gdoo\File\Models\Attachment;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class AttachmentController extends DefaultController
|
||||
{
|
||||
public $permission = ['preview', 'download', 'draft', 'fileinfo', 'create', 'uploader', 'delete', 'show'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$PHPSESSID = Request::get('PHPSESSID');
|
||||
if ($PHPSESSID) {
|
||||
Session::setId($PHPSESSID);
|
||||
Session::start();
|
||||
}
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文件到草稿
|
||||
*/
|
||||
public function draftAction()
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
$file = Request::file('Filedata');
|
||||
$mime_type = $this->setting['upload_type'];
|
||||
$validator = Validator::make(
|
||||
array('file' => $file),
|
||||
array('file' => 'mimes:'.$mime_type)
|
||||
);
|
||||
|
||||
if ($validator->passes()) {
|
||||
// 上传文件的模块名
|
||||
$module = Request::get('module');
|
||||
|
||||
$path = $module.'/'.date('Y/m');
|
||||
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
|
||||
// 扩展名称
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
if ($uploadSuccess) {
|
||||
// 数据库写入
|
||||
$draft = new Attachment;
|
||||
$draft->name = mb_strtolower($file->getClientOriginalName());
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->save();
|
||||
return $draft->id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看文件
|
||||
*/
|
||||
public function fileinfoAction()
|
||||
{
|
||||
$id = Request::get('id', 0);
|
||||
$type = Request::get('type', 0);
|
||||
$ismobile = Request::get('ismobile', 0);
|
||||
if ($id > 0) {
|
||||
|
||||
$file = Attachment::where('id', $id)->first();
|
||||
$path = upload_path($file->path);
|
||||
|
||||
if (!is_file($path)) {
|
||||
return $this->json('文件不存在。');
|
||||
}
|
||||
|
||||
//$isimg = '|jpg|png|gif|bmp|jpeg|', '|'.$ext.'|';
|
||||
//$isoffice = '|doc|docx|xls|xlsx|ppt|pptx|pdf|', '|'.$ext.'|';
|
||||
//$isbianju = '|doc|docx|xls|xlsx|ppt|pptx|', '|'.$ext.'|';
|
||||
//$isyulan = ',txt,log,html,htm,js,php,php3,mp4,md,cs,sql,java,json,css,asp,aspx,shtml,cpp,c,vbs,jsp,xml,bat,ini,conf,sh,', ','.$ext.',';
|
||||
|
||||
$isview = 0;
|
||||
$isimg = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
||||
if (in_array($file['type'], $isimg)) {
|
||||
$isview = 1;
|
||||
}
|
||||
|
||||
if ($type == 1) {
|
||||
return $this->json([
|
||||
'url' => url('file/attachment/download', ['id' => $id]),
|
||||
'fileext' => $file['type'],
|
||||
'type' => $type,
|
||||
'filename' => $file['name'],
|
||||
'isview' => $isview,
|
||||
], true);
|
||||
}
|
||||
|
||||
if ($type == 0) {
|
||||
|
||||
if ($isview) {
|
||||
return $this->json([
|
||||
'url' => url('file/attachment/preview', ['id' => $id]),
|
||||
'fileext' => $file['type'],
|
||||
'filename' => $file['name'],
|
||||
'isview' => $isview,
|
||||
], true);
|
||||
} else {
|
||||
return $this->json('此'.$file['type'].'类型文件不支持在线预览');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAction()
|
||||
{
|
||||
$id = Request::get('id', 0);
|
||||
if ($id > 0) {
|
||||
$row = Attachment::where('id', $id)->first();
|
||||
if ($row->path) {
|
||||
$file = upload_path($row->path);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
$row->delete();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function uploaderAction()
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$upload_type = $this->setting['upload_type'];
|
||||
$upload_max = $this->setting['upload_max'] * (1024 * 1024);
|
||||
|
||||
$gets = Request::all();
|
||||
$file = Request::file('file');
|
||||
|
||||
// 上传文件开始
|
||||
if ($file->isValid()) {
|
||||
$size = $file->getSize();
|
||||
$name = $file->getClientOriginalName();
|
||||
$extension = strtolower($file->getClientOriginalExtension());
|
||||
//$name = $paths['filename'];
|
||||
//$extension = strtolower($name);
|
||||
//$_FILES['Filedata']['size']
|
||||
|
||||
// 保存附件的表名
|
||||
$table = empty($gets['model']) ? 'attachment' : $gets['model'];
|
||||
|
||||
// 获取当前要传的基础路径
|
||||
$path = empty($gets['path']) ? date('Y/m') : $gets['path'].date('/Y/m');
|
||||
|
||||
// 附件存放目录
|
||||
$upload_path = upload_path($path);
|
||||
/*
|
||||
if(!is_dir($upload_path)) {
|
||||
mkdir($upload_path, 0755, true);
|
||||
}
|
||||
*/
|
||||
// 附件新名字
|
||||
$filename = date('ymdhi').str_random(4).".".$extension;
|
||||
|
||||
if (in_array($extension, explode(',', $upload_type))) {
|
||||
// 移动文件
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
$data = [
|
||||
'title' => $name,
|
||||
'path' => $path,
|
||||
'type' => $extension,
|
||||
'name' => $filename,
|
||||
'size' => $size,
|
||||
'add_time' => time(),
|
||||
'add_user_id' => Auth::id(),
|
||||
];
|
||||
|
||||
$insert_id = DB::table($table)->insertGetId($data);
|
||||
$data['id'] = $insert_id;
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
||||
$query = Request::all();
|
||||
$SERVER_URL = url("file/attachment/uploader", $query);
|
||||
return $this->render([
|
||||
'SERVER_URL' => $SERVER_URL,
|
||||
]);
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
$upload_type = $this->setting['upload_type'];
|
||||
$upload_max = $this->setting['upload_max']*(1024*1024);
|
||||
|
||||
$gets = Request::all();
|
||||
|
||||
// 上传文件开始
|
||||
if (Request::file('Filedata')->isValid()) {
|
||||
$file = Request::file('Filedata');
|
||||
$size = $file->getSize();
|
||||
$name = $file->getClientOriginalName();
|
||||
$extension = strtolower($file->getClientOriginalExtension());
|
||||
//$name = $paths['filename'];
|
||||
//$extension = strtolower($name);
|
||||
//$_FILES['Filedata']['size']
|
||||
|
||||
// 保存附件的表名
|
||||
$table = empty($gets['model']) ? 'attachment' : $gets['model'];
|
||||
|
||||
// 获取当前要传的基础路径
|
||||
$path = empty($gets['path']) ? date('Y/m') : $gets['path'].date('/Y/m');
|
||||
|
||||
// 附件存放目录
|
||||
$upload_path = upload_path($path);
|
||||
/*
|
||||
if(!is_dir($upload_path)) {
|
||||
mkdir($upload_path, 0755, true);
|
||||
}
|
||||
*/
|
||||
// 附件新名字
|
||||
$filename = date('ymdhi').str_random(4).".".$extension;
|
||||
|
||||
if (in_array($extension, explode(',', $upload_type))) {
|
||||
// 移动文件
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
$insert_id = DB::table($table)->insertGetId([
|
||||
'title' => $name,
|
||||
'path' => $path,
|
||||
'type' => $extension,
|
||||
'name' => $filename,
|
||||
'size' => $size,
|
||||
'add_time' => time(),
|
||||
'add_user_id' => Auth::id(),
|
||||
]);
|
||||
return response($insert_id);
|
||||
}
|
||||
}
|
||||
return response('0');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if ($gets['id'] > 0) {
|
||||
$table = empty($gets['model']) ? 'attachment' : $gets['model'];
|
||||
$row = DB::table($table)->find($gets['id']);
|
||||
|
||||
if (is_array($row)) {
|
||||
$file = upload_path($row['path'].'/'.$row['name']);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
DB::table($table)->where('id', $row['id'])->delete();
|
||||
return '1';
|
||||
}
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
|
||||
// 预览文件
|
||||
public function showAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$model = Request::get('model');
|
||||
$model = empty($model) ? 'attachment' : $model;
|
||||
|
||||
$row = DB::table($model)->where('id', $id)->first();
|
||||
|
||||
if (empty($row)) {
|
||||
return $this->error('文件不存在。');
|
||||
}
|
||||
|
||||
$image = upload_path($row['path'].'/'.$row['name']);
|
||||
|
||||
if (is_file($image)) {
|
||||
// 打开文件
|
||||
$data = file_get_contents($image);
|
||||
// 输入文件标签
|
||||
Header('Content-type:image/'.$row['type']);
|
||||
// 输出文件内容
|
||||
echo $data;
|
||||
exit;
|
||||
} else {
|
||||
return $this->error('文件不存在。');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览文件
|
||||
*/
|
||||
public function previewAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
$file = Attachment::where('id', $id)->first();
|
||||
$stream = URL::to('uploads').'/'.$file->path.'/'.$file->name;
|
||||
|
||||
if (in_array($file->type, array('jpg', 'gif', 'png'))) {
|
||||
$view = 'image';
|
||||
} else {
|
||||
return $this->error('此格式不支持预览。');
|
||||
}
|
||||
return $this->display([
|
||||
'stream' => $stream,
|
||||
], 'attachment.image');
|
||||
}
|
||||
|
||||
// 下载文件
|
||||
public function downloadAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$row = DB::table('attachment')->where('id', $id)->first();
|
||||
if (empty($row)) {
|
||||
return $this->json('附件不存在。');
|
||||
}
|
||||
|
||||
$file = upload_path($row['path']);
|
||||
if (is_file($file)) {
|
||||
// 下载文件
|
||||
return response()->download($file, $row['name']);
|
||||
} else {
|
||||
return $this->json('文件不存在。');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php namespace Gdoo\File\Controllers;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\File\Models\Certificate;
|
||||
|
||||
class CertificateController extends DefaultController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'file_certificate',
|
||||
'referer' => 1,
|
||||
'search' => [],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '下载',
|
||||
'action' => 'download',
|
||||
'display' => 1,
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
$item['size'] = human_filesize($item['size']);
|
||||
return $item;
|
||||
});
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Certificate::$tabs;
|
||||
$header['bys'] = Certificate::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
$name = Request::get('name');
|
||||
$mime_type = $this->setting['upload_type'];
|
||||
$validator = Validator::make(
|
||||
['file' => $file, 'name' => $name],
|
||||
['file' => 'mimes:'.$mime_type, 'name' => 'required']
|
||||
);
|
||||
if ($validator->passes()) {
|
||||
$path = 'certificate/'.date('Y/m');
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
// 扩展名称
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
if ($uploadSuccess) {
|
||||
// 数据库写入
|
||||
$draft = new Certificate;
|
||||
//$draft->name = mb_strtolower($file->getClientOriginalName());
|
||||
$draft->name = $name;
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->save();
|
||||
return $this->json('文件上传成功。', true);
|
||||
}
|
||||
} else {
|
||||
return $this->json($validator->errors()->first());
|
||||
}
|
||||
return $this->json('文件不能为空。');
|
||||
}
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
public function downloadAction()
|
||||
{
|
||||
$id = (int) Request::get('id', 0);
|
||||
$row = DB::table('file_certificate')->where('id', $id)->first();
|
||||
if (empty($row)) {
|
||||
return $this->error('附件不存在。');
|
||||
}
|
||||
$filename = upload_path($row['path']);
|
||||
if (is_file($filename)) {
|
||||
// 打开文件
|
||||
$name = mb_convert_encoding($row['name'], "gbk", "UTF-8");
|
||||
$file = fopen($filename, "r");
|
||||
DB::table('file_certificate')->where('id', $id)->increment('hits');
|
||||
// 输入文件标签
|
||||
Header("Content-type: application/octet-stream");
|
||||
Header("Accept-Ranges: bytes");
|
||||
Header("Accept-Length: " . filesize($filename));
|
||||
Header("Content-Disposition: attachment; filename=" . $name.'.'.$row['type']);
|
||||
// 输出文件内容
|
||||
echo fread($file, filesize($filename));
|
||||
fclose($file);
|
||||
exit;
|
||||
} else {
|
||||
return $this->error('附件文件不存在。');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = (array)Request::get('id');
|
||||
$rows = DB::table('file_certificate')->whereIn('id', $id)->get();
|
||||
if ($rows->isEmpty()) {
|
||||
return $this->json('附件不存在。');
|
||||
} else {
|
||||
foreach($rows as $row) {
|
||||
$path = upload_path($row['path']);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
DB::table('file_certificate')->where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
return $this->json('文件删除成功。', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
<?php namespace Gdoo\File\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Index\Models\Share;
|
||||
use Gdoo\File\Models\File;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class FileController extends DefaultController
|
||||
{
|
||||
public $permission = ['index', 'common', 'share', 'receive', 'receivedata', 'folder', 'upload', 'sharing'];
|
||||
|
||||
public $folders = [
|
||||
['id' => 'common', 'name' => '公共云盘'],
|
||||
['id' => 'index', 'name' => '个人云盘'],
|
||||
['id' => 'share', 'name' => '我共享的'],
|
||||
['id' => 'receive','name' => '我收到的'],
|
||||
];
|
||||
|
||||
public function index1Action()
|
||||
{
|
||||
$rows = [
|
||||
['id' => 'common', 'name' => '公共云盘'],
|
||||
['id' => 'personal', 'name' => '个人云盘'],
|
||||
['id' => 'share', 'name' => '我共享的'],
|
||||
['id' => 'receive', 'name' => '我收到的'],
|
||||
];
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建文件夹
|
||||
public function folderAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$model = File::findOrNew($gets['id']);
|
||||
$model->fill($gets)->save();
|
||||
return $this->json('reload', true);
|
||||
}
|
||||
|
||||
$row = File::find($gets['id']);
|
||||
$row['parent_id'] = $gets['parent_id'];
|
||||
$row['folder'] = $gets['folder'];
|
||||
return $this->render([
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
// 共享操作
|
||||
public function sharingAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
|
||||
$file = File::find($gets['id']);
|
||||
$type = $file['folder'] == 1 ? 'folder' : 'file';
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$share_data = [
|
||||
'source_id' => $gets['id'],
|
||||
'source_type' => $type,
|
||||
'receive_id' => $gets['receive_id'],
|
||||
'receive_name' => $gets['receive_name'],
|
||||
];
|
||||
|
||||
$share = Share::getItem($type, $gets['id']);
|
||||
if (empty($share)) {
|
||||
Share::addItem($share_data);
|
||||
} else {
|
||||
Share::editItem($type, $gets['id'], $share_data);
|
||||
}
|
||||
|
||||
return $this->json('reload', true);
|
||||
}
|
||||
|
||||
$row = Share::getItem($type, $gets['id']);
|
||||
$row['id'] = $gets['id'];
|
||||
return $this->render([
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
public function uploadAction()
|
||||
{
|
||||
$parent_id = Request::get('parent_id', 0);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('Filedata');
|
||||
$mime_type = $this->setting['upload_type'];
|
||||
$validator = Validator::make(
|
||||
['file' => $file],
|
||||
['file' => 'mimes:'.$mime_type]
|
||||
);
|
||||
|
||||
if ($validator->passes()) {
|
||||
$path = 'file/'.date('Y/m');
|
||||
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
|
||||
// 扩展名称
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
if ($uploadSuccess) {
|
||||
// 数据库写入
|
||||
$draft = new File;
|
||||
$draft->parent_id = $parent_id;
|
||||
$draft->name = mb_strtolower($file->getClientOriginalName());
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->save();
|
||||
return $draft->id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return $this->render([
|
||||
'parent_id' => $parent_id,
|
||||
]);
|
||||
}
|
||||
|
||||
// 个人云盘
|
||||
public function indexAction()
|
||||
{
|
||||
$search = search_form([
|
||||
'referer' => 1,
|
||||
], []);
|
||||
|
||||
$user_id = auth()->id();
|
||||
|
||||
$parent_id = Request::get('parent_id', 0);
|
||||
|
||||
$rows = DB::table('file')
|
||||
->where('parent_id', $parent_id)
|
||||
->where('public', 0)
|
||||
->where('created_id', $user_id)
|
||||
->orderBy('folder', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
// 获取文件夹路径
|
||||
$parents = DB::table('file')
|
||||
->where('public', 0)
|
||||
->where('folder', 1)
|
||||
->where('created_id', $user_id)
|
||||
->get();
|
||||
|
||||
$parents = array_nest($parents);
|
||||
|
||||
$breadcrumb = [];
|
||||
if ($parent_id) {
|
||||
$paths = $parents[$parent_id]['parent'];
|
||||
foreach ($paths as $path) {
|
||||
$breadcrumb[] = ['name' => $parents[$path]['name'], 'id' => $path];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'breadcrumb' => $breadcrumb,
|
||||
'parent_id' => $parent_id,
|
||||
'folders' => $this->folders,
|
||||
]);
|
||||
}
|
||||
|
||||
// 共享给我的
|
||||
public function receiveAction()
|
||||
{
|
||||
$user_id = auth()->id();
|
||||
$shares = Share::getItemsSourceBy(['folder', 'file'], $user_id)->pluck('created_id');
|
||||
$rows = DB::table('user')->whereIn('id', $shares)->paginate();
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
]);
|
||||
}
|
||||
|
||||
// 共享给我的
|
||||
public function receivedataAction()
|
||||
{
|
||||
$search = search_form([
|
||||
'referer' => 1,
|
||||
], []);
|
||||
|
||||
$user_id = Request::get('user_id');
|
||||
$parent_id = Request::get('parent_id');
|
||||
|
||||
// 共享的全部文件和文件夹
|
||||
$shares = Share::getItemsCreatedBy(['folder', 'file'], $user_id)
|
||||
->pluck('source_id')
|
||||
->toArray();
|
||||
|
||||
$model = DB::table('file')
|
||||
->where('public', 0)
|
||||
->where('created_id', $user_id);
|
||||
|
||||
if ($parent_id) {
|
||||
$model->where('parent_id', $parent_id);
|
||||
} else {
|
||||
$model->whereIn('id', $shares);
|
||||
}
|
||||
|
||||
$rows = $model->orderBy('folder', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
// 获取全部文件夹
|
||||
$parents = DB::table('file')
|
||||
->where('public', 0)
|
||||
->where('folder', 1)
|
||||
->where('created_id', $user_id)
|
||||
->get();
|
||||
|
||||
// 生成树形数组
|
||||
$parents = array_nest($parents);
|
||||
|
||||
$_shares = array_flip($shares);
|
||||
|
||||
$shared = [];
|
||||
|
||||
// 获取已经共享的文件夹和文件编号
|
||||
foreach ($parents as $parent) {
|
||||
if ($_shares[$parent['id']]) {
|
||||
$shared = array_merge($shared, $parent['child']);
|
||||
}
|
||||
}
|
||||
|
||||
$breadcrumb = [];
|
||||
|
||||
if ($parent_id) {
|
||||
// 点开了文件夹
|
||||
$paths = $parents[$parent_id]['parent'];
|
||||
// 获取文件夹所有父节编号
|
||||
foreach ($paths as $path) {
|
||||
// 有一种情况共享文件夹是子文件夹,必须排除没有共享的父节点
|
||||
if (in_array($path, $shared)) {
|
||||
$breadcrumb[] = ['name' => $parents[$path]['name'], 'id' => $path];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user = $row = DB::table('user')->where('id', $user_id)->first();
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'breadcrumb' => $breadcrumb,
|
||||
'parent_id' => $parent_id,
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
// 我共享的
|
||||
public function shareAction()
|
||||
{
|
||||
$search = search_form([
|
||||
'referer' => 1,
|
||||
], []);
|
||||
|
||||
$user_id = Request::get('user_id', auth()->id());
|
||||
|
||||
// 共享的全部文件和文件夹
|
||||
$shares = Share::getItemsCreatedBy(['folder', 'file'], $user_id)
|
||||
->pluck('source_id')
|
||||
->toArray();
|
||||
|
||||
$parent_id = Request::get('parent_id');
|
||||
|
||||
$model = DB::table('file')
|
||||
->where('public', 0)
|
||||
->where('created_id', $user_id);
|
||||
|
||||
if ($parent_id) {
|
||||
$model->where('parent_id', $parent_id);
|
||||
} else {
|
||||
$model->whereIn('id', $shares);
|
||||
}
|
||||
|
||||
$rows = $model->orderBy('folder', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
// 获取全部文件夹
|
||||
$parents = DB::table('file')
|
||||
->where('public', 0)
|
||||
->where('folder', 1)
|
||||
->where('created_id', $user_id)
|
||||
->get();
|
||||
|
||||
// 生成树形数组
|
||||
$parents = array_nest($parents);
|
||||
|
||||
$_shares = array_flip($shares);
|
||||
|
||||
$shared = [];
|
||||
|
||||
// 获取已经共享的文件夹和文件编号
|
||||
foreach ($parents as $parent) {
|
||||
if ($_shares[$parent['id']]) {
|
||||
$shared = array_merge($shared, $parent['child']);
|
||||
}
|
||||
}
|
||||
|
||||
$breadcrumb = [];
|
||||
|
||||
if ($parent_id) {
|
||||
// 点开了文件夹
|
||||
$paths = $parents[$parent_id]['parent'];
|
||||
// 获取文件夹所有父节编号
|
||||
foreach ($paths as $path) {
|
||||
// 有一种情况共享文件夹是子文件夹,必须排除没有共享的父节点
|
||||
if (in_array($path, $shared)) {
|
||||
$breadcrumb[] = ['name' => $parents[$path]['name'], 'id' => $path];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'breadcrumb' => $breadcrumb,
|
||||
'parent_id' => $parent_id,
|
||||
]);
|
||||
}
|
||||
|
||||
// 公共网盘
|
||||
public function commonAction()
|
||||
{
|
||||
$folder_id = Request::get('folder_id', 0);
|
||||
$files = DB::table('file')
|
||||
->where('parent_id', $folder_id)
|
||||
->where('folder', 0)
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
$folders = DB::table('file')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
$rows = [
|
||||
'name' => '公共网盘', 'type' => '',
|
||||
'name' => '公共网盘',
|
||||
'name' => '公共网盘',
|
||||
];
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
]);
|
||||
}
|
||||
|
||||
public function downAction()
|
||||
{
|
||||
$id = (int) Request::get('id', 0);
|
||||
$row = DB::table('file')->where('id', $id)->first();
|
||||
|
||||
if (empty($row)) {
|
||||
return $this->error('附件不存在。');
|
||||
}
|
||||
|
||||
$name = empty($row['path']) ? 'file/'.$row['name'] : $row['path'].'/'.$row['name'];
|
||||
|
||||
$downfile = upload_path($name);
|
||||
|
||||
if (is_file($downfile)) {
|
||||
//打开文件
|
||||
$filename = mb_convert_encoding($row['title'], "gbk", "UTF-8");
|
||||
$file = fopen($downfile, "r");
|
||||
DB::table('download')->where('id', $id)->increment('hits');
|
||||
//输入文件标签
|
||||
Header("Content-type: application/octet-stream");
|
||||
Header("Accept-Ranges: bytes");
|
||||
Header("Accept-Length: " . filesize($downfile));
|
||||
Header("Content-Disposition: attachment; filename=" . $filename);
|
||||
//输出文件内容
|
||||
echo fread($file, filesize($downfile));
|
||||
fclose($file);
|
||||
exit;
|
||||
} else {
|
||||
return $this->error('附件文件不存在。');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$id = (array)Request::get('id');
|
||||
$rows = DB::table('file')->whereIn('parent_id', $id)->get();
|
||||
if ($rows->count()) {
|
||||
return $this->error('文件夹不为空无法删除。');
|
||||
}
|
||||
|
||||
$rows = DB::table('file')->whereIn('id', $id)->get();
|
||||
foreach ($rows as $row) {
|
||||
$path = 'file/'.$row['path'];
|
||||
if (is_file(upload_path($path))) {
|
||||
unlink(upload_path($path));
|
||||
}
|
||||
DB::table('file')->where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
return $this->success('index', '删除成功。');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php namespace Gdoo\File\Controllers;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\File\Models\InspectReport;
|
||||
|
||||
class InspectReportController extends DefaultController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'file_inspect_report',
|
||||
'referer' => 1,
|
||||
'search' => [],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '下载',
|
||||
'action' => 'download',
|
||||
'display' => 1,
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
$item['size'] = human_filesize($item['size']);
|
||||
return $item;
|
||||
});
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = InspectReport::$tabs;
|
||||
$header['bys'] = InspectReport::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
$name = Request::get('name');
|
||||
$mime_type = $this->setting['upload_type'];
|
||||
$validator = Validator::make(
|
||||
['file' => $file, 'name' => $name],
|
||||
['file' => 'mimes:'.$mime_type, 'name' => 'required']
|
||||
);
|
||||
if ($validator->passes()) {
|
||||
$path = 'inspect_report/'.date('Y/m');
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
// 扩展名称
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
if ($uploadSuccess) {
|
||||
// 数据库写入
|
||||
$draft = new InspectReport;
|
||||
//$draft->name = mb_strtolower($file->getClientOriginalName());
|
||||
$draft->name = $name;
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->save();
|
||||
return $this->json('文件上传成功。', true);
|
||||
}
|
||||
} else {
|
||||
return $this->json($validator->errors()->first());
|
||||
}
|
||||
return $this->json('文件不能为空。');
|
||||
}
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
public function downloadAction()
|
||||
{
|
||||
$id = (int) Request::get('id', 0);
|
||||
$row = DB::table('file_inspect_report')->where('id', $id)->first();
|
||||
if (empty($row)) {
|
||||
return $this->error('附件不存在。');
|
||||
}
|
||||
$filename = upload_path($row['path']);
|
||||
if (is_file($filename)) {
|
||||
// 打开文件
|
||||
$name = mb_convert_encoding($row['name'], "gbk", "UTF-8");
|
||||
$file = fopen($filename, "r");
|
||||
DB::table('file_inspect_report')->where('id', $id)->increment('hits');
|
||||
// 输入文件标签
|
||||
Header("Content-type: application/octet-stream");
|
||||
Header("Accept-Ranges: bytes");
|
||||
Header("Accept-Length: " . filesize($filename));
|
||||
Header("Content-Disposition: attachment; filename=" . $name.'.'.$row['type']);
|
||||
// 输出文件内容
|
||||
echo fread($file, filesize($filename));
|
||||
fclose($file);
|
||||
exit;
|
||||
} else {
|
||||
return $this->error('附件文件不存在。');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = (array)Request::get('id');
|
||||
$rows = DB::table('file_inspect_report')->whereIn('id', $id)->get();
|
||||
if ($rows->isEmpty()) {
|
||||
return $this->json('附件不存在。');
|
||||
} else {
|
||||
foreach($rows as $row) {
|
||||
$path = upload_path($row['path']);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
DB::table('file_inspect_report')->where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
return $this->json('文件删除成功。', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php namespace Gdoo\File\Controllers;
|
||||
|
||||
use Request;
|
||||
use URL;
|
||||
|
||||
use Gdoo\Index\Controllers\Controller;
|
||||
|
||||
class WidgetController extends Controller
|
||||
{
|
||||
public $permission = ['index', 'download'];
|
||||
|
||||
public $rows = [/*[
|
||||
'title' => '盛华管理手机客户端',
|
||||
'date' => '2018-04-09',
|
||||
'android_url' => '/uploads/com.shenghua.oa/1.0.12.apk',
|
||||
'ios_url' => ''
|
||||
],[
|
||||
'title' => '盛华市场手机客户端',
|
||||
'date' => '2018-04-07',
|
||||
'android_url' => '/uploads/com.shenghua.customer/1.0.3.apk',
|
||||
'ios_url' => '/uploads/com.shenghua.customer/1.0.3.ipa'
|
||||
],*/[
|
||||
'title' => '身份验证器(GoogleAuthenticator)',
|
||||
'date' => '2015-06-17',
|
||||
'android_url' => '/uploads/android/authenticator2_21.apk',
|
||||
'ios_url' => ''
|
||||
],[
|
||||
'title' => '日历同步助手(Caldav)',
|
||||
'date' => '2017-06-29',
|
||||
'android_url' => '/uploads/android/calendar.caldav.sync.apk',
|
||||
'ios_url' => ''
|
||||
]];
|
||||
|
||||
public function downloadAction()
|
||||
{
|
||||
$key = Request::get('key');
|
||||
$row = $this->rows[$key];
|
||||
|
||||
$file = '';
|
||||
|
||||
if (get_device_type() == 'ios') {
|
||||
if ($row['ios_url']) {
|
||||
$file = url($row['ios_url']);
|
||||
}
|
||||
$img = '/assets/images/ios_download.png';
|
||||
} else {
|
||||
if ($row['android_url']) {
|
||||
$file = url($row['android_url']);
|
||||
}
|
||||
$img = '/assets/images/android_download.png';
|
||||
}
|
||||
|
||||
if (is_weixin()) {
|
||||
echo '<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title></title>
|
||||
<style>
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
background-color:#a2a2a2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<img src="'.$img.'" />
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
} else {
|
||||
if ($file) {
|
||||
echo "<form action='".$file."' id='go' method='GET'></form><script type='text/javascript'>document.getElementById('go').submit();</script>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (Request::isJson()) {
|
||||
foreach ($this->rows as $k => &$row) {
|
||||
$url = '';
|
||||
|
||||
if ($row['android_url']) {
|
||||
$url .= '<a class="option" href="'.url($row['android_url']).'"><i class="fa fa-fw fa-android"></i></a>';
|
||||
}
|
||||
|
||||
if ($row['ios_url']) {
|
||||
$url .= ' <a class="option" href="'.url($row['ios_url']).'"><i class="fa fa-fw fa-apple"></i></a>';
|
||||
} else {
|
||||
$url .= ' <span class="text-muted" href="javascript:;"><i class="fa fa-fw fa-apple"></i></span>';
|
||||
}
|
||||
|
||||
$qrcodeURL = url('index/api/qrcode', ['size' => 6, 'data' => url('file/widget/download', ['key' => $k])]);
|
||||
|
||||
$url .= ' <a class="option" href="javascript:;" onclick=\'$.messager.alert("'.$row['title'].'","<div align=\"center\"><img src=\"'.$qrcodeURL.'\"></div>");\'><i class="fa fa-fw fa-qrcode"></i></a>';
|
||||
|
||||
$row['option'] = $url;
|
||||
}
|
||||
|
||||
$json['total'] = sizeof($this->rows);
|
||||
$json['data'] = $this->rows;
|
||||
return response()->json($json);
|
||||
}
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\File\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Attachment extends BaseModel
|
||||
{
|
||||
public $table = 'attachment';
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\File\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Certificate extends BaseModel
|
||||
{
|
||||
public $table = 'file_certificate';
|
||||
|
||||
static public $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'user', 'url' => 'file/certificate/index', 'name' => '证照列表'],
|
||||
]
|
||||
];
|
||||
|
||||
static public $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\File\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class File extends BaseModel
|
||||
{
|
||||
public $table = 'file';
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\File\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class InspectReport extends BaseModel
|
||||
{
|
||||
public $table = 'file_inspect_report';
|
||||
|
||||
static public $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'user', 'url' => 'file/inspectReport/index', 'name' => '出厂检验列表'],
|
||||
]
|
||||
];
|
||||
|
||||
static public $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "文件管理",
|
||||
"version" => "1.0",
|
||||
"description" => "文件查看下载,供大家下载资料的通用功能。",
|
||||
"controllers" => [
|
||||
"certificate" => [
|
||||
"name" => "常规证照",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"download" => [
|
||||
"name" => "下载"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"inspectReport" => [
|
||||
"name" => "出厂检验报告",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"download" => [
|
||||
"name" => "下载"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,47 @@
|
||||
<style>
|
||||
.form-controller {
|
||||
padding: 0;
|
||||
}
|
||||
input[type=file] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<form class="form-horizontal form-controller" method="post" id="certificate_create" name="certificate_create">
|
||||
<div class="form-group">
|
||||
<div class="col-xs-2 control-label"><span class="red">*</span> 名称</div>
|
||||
<div class="col-xs-10 control-text">
|
||||
<input type="text" class="form-control input-sm" autocomplete="off" name="name" id="certificate_name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-2 control-label"><span class="red">*</span> 文件</div>
|
||||
<div class="col-xs-10 control-text">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" id="file_text" disabled="disabled">
|
||||
<input type="file" name="file" class="file" id="certificate_file" />
|
||||
<span class="input-group-btn">
|
||||
<a class="btn btn-sm btn-default" id="file_upload"><i class="fa fa-folder-open"></i>选择文件</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(function($) {
|
||||
$('#certificate_file').off('change').on('change', function() {
|
||||
var filename = getFileName(this.value);
|
||||
var name = filename.substring(0, filename.indexOf('.'));
|
||||
$('#file_text').val(filename);
|
||||
$('#certificate_name').val(name);
|
||||
});
|
||||
$('#file_upload').on('click', function() {
|
||||
$('#certificate_file').click();
|
||||
});
|
||||
});
|
||||
|
||||
function getFileName(path) {
|
||||
var paths = path.split("\\");
|
||||
return paths[paths.length-1];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,95 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['table']}}-grid" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
action.create = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var url = app.url('file/certificate/create');
|
||||
formDialog({
|
||||
title: '文件上传',
|
||||
url: url,
|
||||
id: 'certificate_create',
|
||||
dialogClass:'modal-md',
|
||||
onSubmit: function() {
|
||||
var me = this;
|
||||
var form = $('#certificate_create');
|
||||
var file = document.querySelector("#certificate_file").files[0];
|
||||
var name = form.find('#certificate_name').val();
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('name', name);
|
||||
|
||||
var loading = layer.msg('数据提交中...', {
|
||||
icon: 16, shade: 0.1, time: 1000 * 120
|
||||
});
|
||||
$.ajax(url, {
|
||||
method: "post",
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
complete: function() {
|
||||
layer.close(loading);
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status) {
|
||||
toastrSuccess(res.data);
|
||||
grid.remoteData();
|
||||
$(me).dialog('close');
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
action.download = function(data) {
|
||||
var url = app.url('file/certificate/download', {id: data.master_id});
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = search.advanced.query;
|
||||
grid.columnDefs = config.cols;
|
||||
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = grid;
|
||||
})(jQuery);
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">资料上传</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
@include('attachment/add')
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<form class="form-horizontal" method="post" action="{{url()}}" id="myfolder" name="myfolder">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" id="name" name="name" value="{{$row['name']}}">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" name="id" value="{{$row['id']}}" />
|
||||
<input type="hidden" name="parent_id" value="{{$row['parent_id']}}" />
|
||||
<input type="hidden" name="folder" value="{{$row['folder']}}" />
|
||||
</form>
|
||||
@@ -0,0 +1,31 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper">
|
||||
文件网盘
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="left">名称</th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="left">
|
||||
<a href="{{url($row['id'])}}"><i class="fa fa-folder-o"></i> {{$row['name']}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,150 @@
|
||||
<div class="hbox hbox-auto-xs hbox-auto-sm" ng-controller="MailCtrl">
|
||||
<div class="col w-md bg-light dk b-r bg-auto">
|
||||
|
||||
<div class="wrapper b-b bg">
|
||||
|
||||
<a class="btn btn-sm btn-info w-xs font-bold">文件夹列表</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrapper hidden-sm hidden-xs" id="email-menu">
|
||||
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
|
||||
@if($folders)
|
||||
@foreach($folders as $menuKey => $menuValue)
|
||||
<li @if(Request::action() == $menuValue['id']) class="active" @endif ><a class="text-base text-info" href="{{url($menuValue['id'])}}">{{$menuValue['name']}}</a></li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
|
||||
<!--
|
||||
<div class="wrapper">Labels</div>
|
||||
<ul class="nav nav-pills nav-stacked nav-sm">
|
||||
<li>
|
||||
<a><i class="fa fa-fw fa-circle text-info"></i>Angular</a>
|
||||
</li>
|
||||
<li>
|
||||
<a><i class="fa fa-fw fa-circle text-primary"></i>Bootstrap</a>
|
||||
</li>
|
||||
<li>
|
||||
<a><i class="fa fa-fw fa-circle text-success"></i>Work</a>
|
||||
</li>
|
||||
<li>
|
||||
<a><i class="fa fa-fw fa-circle text-muted"></i>Client</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="wrapper">
|
||||
<form name="label">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" placeholder="New label">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-sm btn-default" type="button">Add</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
<div>
|
||||
<!-- header -->
|
||||
<div class="wrapper bg-light lter b-b">
|
||||
|
||||
<div class="pull-right">
|
||||
<button type="button" data-toggle="dialog-form" data-title="新建文件夹" data-url="{{url('folder', ['folder'=>1,'parent_id'=>$parent_id])}}" data-id="myfolder" class="btn btn-default btn-sm"><i class="fa fa-folder-o"></i> 新建</button>
|
||||
<button type="button" data-toggle="dialog-form" data-title="上传文件" data-url="{{url('upload', ['parent_id' => $parent_id])}}" data-id="myupload" class="btn btn-info btn-sm"><i class="fa fa-file-o"></i> 上传文件</button>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<button type="button" class="btn btn-sm btn-default" data-toggle="dropdown">
|
||||
批量操作
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu text-xs">
|
||||
<li><a href="javascript:optionDelete('#myform','{{url('delete')}}');"><i class="fa fa-remove"></i> 删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- / header -->
|
||||
|
||||
<div class="panel">
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive ">
|
||||
<table class="table m-b-none table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input class="select-all" type="checkbox">
|
||||
</th>
|
||||
<th align="left">名称</th>
|
||||
<th align="center">类型</th>
|
||||
<th align="center">大小</th>
|
||||
<th align="center">时间</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input class="select-row" type="checkbox" name="id[]" value="{{$row['id']}}">
|
||||
</td>
|
||||
<td align="left">
|
||||
@if($row['folder'] == 0)
|
||||
<i class="fa fa-file-o"></i>
|
||||
{{$row['name']}}
|
||||
@else
|
||||
<a href="{{url('',['parent_id'=>$row['id']])}}">
|
||||
<i class="fa fa-folder-o"></i>
|
||||
{{$row['name']}}
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{$row['type']}}
|
||||
@else
|
||||
文件夹
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{human_filesize($row['size'])}}
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">@datetime($row['created_at'])</td>
|
||||
<td align='center'>
|
||||
|
||||
@if($row['folder'] == 0)
|
||||
<a class="option" href="{{url('show',['id'=>$row['id']])}}">打开</a>
|
||||
@else
|
||||
<a class="option" href="{{url('personal',['parent_id'=>$row['id']])}}">打开</a>
|
||||
@endif
|
||||
<a class="option" href="{{url('down',['id'=>$row['id']])}}">下载</a>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="重命名" data-url="{{url('folder', ['folder'=>$row['folder'],'id' => $row['id'], 'parent_id' => $parent_id])}}" data-id="myfolder">重命名</button>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="共享" data-url="{{url('sharing', ['id' => $row['id']])}}" data-id="myshare">共享</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<div class="panel1">
|
||||
|
||||
|
||||
<div class="wrapper1">
|
||||
|
||||
<div class="row1">
|
||||
|
||||
<div class="col-sm-2 m-b padder-n" style="padding-left:5px;">
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-heading b-b b-light">
|
||||
<div class="h5 m-t-xs m-b-xs"><i class="fa fa-cubes"></i> 文件夹列表</div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
@if($folders)
|
||||
@foreach($folders as $menuKey => $menuValue)
|
||||
<a class="list-group-item" href="{{url($menuValue['id'])}}">
|
||||
<!-- <span class="badge">{{$menuValue['version']}}</span> -->
|
||||
<span class="h5">{{$menuValue['name']}}</span>
|
||||
</a>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10 padder-r-n" style="padding-right:5px;">
|
||||
|
||||
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="pull-right">
|
||||
<button type="button" data-toggle="dialog-form" data-title="新建文件夹" data-url="{{url('folder', ['folder'=>1,'parent_id'=>$parent_id])}}" data-id="myfolder" class="btn btn-default btn-sm"><i class="fa fa-folder-o"></i> 新建</button>
|
||||
<button type="button" data-toggle="dialog-form" data-title="上传文件" data-url="{{url('upload', ['parent_id' => $parent_id])}}" data-id="myupload" class="btn btn-info btn-sm"><i class="fa fa-file-o"></i> 上传文件</button>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<button type="button" class="btn btn-sm btn-default" data-toggle="dropdown">
|
||||
批量操作
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu text-xs">
|
||||
<li><a href="javascript:optionDelete('#myform','{{url('delete')}}');"><i class="fa fa-remove"></i> 删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<ol class="breadcrumb bg-white m-b-xs lter b-t no-radius">
|
||||
<li><a href="{{url('file/file/index')}}">文件网盘</a></li>
|
||||
<li><a href="{{url('file/file/personal')}}">个人云盘</a></li>
|
||||
@foreach($breadcrumb as $path)
|
||||
<li @if($path['id'] == $parent_id) class="active" @endif><a href="{{url('', ['parent_id' => $path['id']])}}">{{$path['name']}}</a></li>
|
||||
@endforeach
|
||||
</ol>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input class="select-all" type="checkbox">
|
||||
</th>
|
||||
<th align="left">名称</th>
|
||||
<th align="center">类型</th>
|
||||
<th align="center">大小</th>
|
||||
<th align="center">时间</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input class="select-row" type="checkbox" name="id[]" value="{{$row['id']}}">
|
||||
</td>
|
||||
<td align="left">
|
||||
@if($row['folder'] == 0)
|
||||
<i class="fa fa-file-o"></i>
|
||||
{{$row['name']}}
|
||||
@else
|
||||
<a href="{{url('',['parent_id'=>$row['id']])}}">
|
||||
<i class="fa fa-folder-o"></i>
|
||||
{{$row['name']}}
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{$row['type']}}
|
||||
@else
|
||||
文件夹
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{human_filesize($row['size'])}}
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">@datetime($row['created_at'])</td>
|
||||
<td align='center'>
|
||||
|
||||
@if($row['folder'] == 0)
|
||||
<a class="option" href="{{url('show',['id'=>$row['id']])}}">打开</a>
|
||||
@else
|
||||
<a class="option" href="{{url('personal',['parent_id'=>$row['id']])}}">打开</a>
|
||||
@endif
|
||||
<a class="option" href="{{url('down',['id'=>$row['id']])}}">下载</a>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="重命名" data-url="{{url('folder', ['folder'=>$row['folder'],'id' => $row['id'], 'parent_id' => $parent_id])}}" data-id="myfolder">重命名</button>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="共享" data-url="{{url('sharing', ['id' => $row['id']])}}" data-id="myshare">共享</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<div class="panel">
|
||||
|
||||
<ol class="breadcrumb bg-white m-b-xs lter no-radius">
|
||||
<li><a href="{{url('file/file/index')}}">文件网盘</a></li>
|
||||
<li><a href="{{url('file/file/receive')}}">我收到的</a></li>
|
||||
</ol>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="left">姓名</th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="left">
|
||||
<a href="{{url('receivedata',['user_id'=>$row['id']])}}">
|
||||
<i class="fa fa-folder-o"></i>
|
||||
{{$row['name']}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,78 @@
|
||||
<div class="panel">
|
||||
|
||||
<ol class="breadcrumb bg-white m-b-xs lter no-radius">
|
||||
<li><a href="{{url('file/file/index')}}">文件网盘</a></li>
|
||||
<li><a href="{{url('file/file/receive')}}">我收到的</a></li>
|
||||
<li><a href="{{url('file/file/receivedata', ['user_id' => $user['id']])}}">{{$user['name']}}</a></li>
|
||||
@foreach($breadcrumb as $path)
|
||||
<li @if($path['id'] == $parent_id) class="active" @endif><a href="{{url('receivedata', ['parent_id' => $path['id'], 'user_id' => $user['id']])}}">{{$path['name']}}</a></li>
|
||||
@endforeach
|
||||
</ol>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input class="select-all" type="checkbox">
|
||||
</th>
|
||||
<th align="left">名称</th>
|
||||
<th align="center">类型</th>
|
||||
<th align="center">大小</th>
|
||||
<th align="center">时间</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input class="select-row" type="checkbox" name="id[]" value="{{$row['id']}}">
|
||||
</td>
|
||||
<td align="left">
|
||||
@if($row['folder'] == 0)
|
||||
<i class="fa fa-file-o"></i>
|
||||
{{$row['name']}}
|
||||
@else
|
||||
<a href="{{url('receivedata',['parent_id'=>$row['id'], 'user_id' => $user['id']])}}">
|
||||
<i class="fa fa-folder-o"></i>
|
||||
{{$row['name']}}
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{$row['type']}}
|
||||
@else
|
||||
文件夹
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{human_filesize($row['size'])}}
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">@datetime($row['created_at'])</td>
|
||||
<td align='center'>
|
||||
|
||||
@if($row['folder'] == 0)
|
||||
<a class="option" href="{{url('show',['id'=>$row['id']])}}">打开</a>
|
||||
@else
|
||||
<a class="option" href="{{url('receivedata',['parent_id'=>$row['id'], 'user_id' => $user['id']])}}">打开</a>
|
||||
@endif
|
||||
<a class="option" href="{{url('down',['id'=>$row['id']])}}">下载</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,93 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="input-group">
|
||||
<button type="button" class="btn btn-sm btn-default" data-toggle="dropdown">
|
||||
批量操作
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu text-xs">
|
||||
<li><a href="javascript:optionDelete('#myform','{{url('delete')}}');"><i class="fa fa-remove"></i> 删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<ol class="breadcrumb bg-white m-b-xs lter b-t no-radius">
|
||||
<li><a href="{{url('file/file/index')}}">文件网盘</a></li>
|
||||
<li><a href="{{url('file/file/share')}}">我共享的</a></li>
|
||||
@foreach($breadcrumb as $path)
|
||||
<li @if($path['id'] == $parent_id) class="active" @endif><a href="{{url('share', ['parent_id' => $path['id']])}}">{{$path['name']}}</a></li>
|
||||
@endforeach
|
||||
</ol>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive">
|
||||
<table class="table m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input class="select-all" type="checkbox">
|
||||
</th>
|
||||
<th align="left">名称</th>
|
||||
<th align="center">类型</th>
|
||||
<th align="center">大小</th>
|
||||
<th align="center">时间</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input class="select-row" type="checkbox" name="id[]" value="{{$row['id']}}">
|
||||
</td>
|
||||
<td align="left">
|
||||
@if($row['folder'] == 0)
|
||||
<i class="fa fa-file-o"></i>
|
||||
{{$row['name']}}
|
||||
@else
|
||||
<a href="{{url('share',['parent_id'=>$row['id']])}}">
|
||||
<i class="fa fa-folder-o"></i>
|
||||
{{$row['name']}}
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{$row['type']}}
|
||||
@else
|
||||
文件夹
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row['folder'] == 0)
|
||||
{{human_filesize($row['size'])}}
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">@datetime($row['created_at'])</td>
|
||||
<td align='center'>
|
||||
|
||||
@if($row['folder'] == 0)
|
||||
<a class="option" href="{{url('show',['id'=>$row['id']])}}">打开</a>
|
||||
@else
|
||||
<a class="option" href="{{url('share',['parent_id'=>$row['id']])}}">打开</a>
|
||||
@endif
|
||||
<a class="option" href="{{url('down',['id'=>$row['id']])}}">下载</a>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="重命名" data-url="{{url('folder', ['folder'=>$row['folder'],'id' => $row['id'], 'parent_id' => $parent_id])}}" data-id="myfolder">重命名</button>
|
||||
<button type="button" class="option" data-toggle="dialog-form" data-title="共享" data-url="{{url('sharing', ['id' => $row['id']])}}" data-id="myshare">共享</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<form class="form-horizontal" method="post" action="{{url()}}" id="myshare" name="myshare">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="left">
|
||||
{{App\Support\Dialog::search($row, 'id=receive_id&name=receive_name&multi=1')}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" name="id" value="{{$row['id']}}" />
|
||||
</form>
|
||||
@@ -0,0 +1,52 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td>
|
||||
<script type="text/javascript" src="{{$asset_url}}/libs/swfobject.min.js"></script>
|
||||
<script type="text/javascript" src="{{$asset_url}}/vendor/uploadify/jquery.uploadify.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function()
|
||||
{
|
||||
$("#uploadify").uploadify({
|
||||
formData: {
|
||||
PHPSESSID: '{{session()->getId()}}',
|
||||
parent_id: '{{$parent_id}}',
|
||||
},
|
||||
'swf' : '{{$asset_url}}/vendor/uploadify/uploadify.swf',
|
||||
'buttonClass' : 'btn btn-sm btn-info',
|
||||
'buttonText' : '<i class="fa fa-cloud-upload" aria-hidden="true"></i> 添加文件',
|
||||
'uploader' : '{{url("")}}',
|
||||
'queueID' : 'fileQueue',
|
||||
'multi' : true,
|
||||
'auto' : true,
|
||||
'width' : 90,
|
||||
'height' : 30,
|
||||
'itemTemplate' : '<div id="${fileID}" class="uploadify-queue-item">\
|
||||
<span class="file-name"><strong class="red" title="草稿附件">!</strong> <a href="javascript:attach.file(\'${fileID}\');">${fileName}</a></span>\
|
||||
<span class="file-size">(${fileSize})</span>\
|
||||
<span class="data"></span>\
|
||||
<span class="uploadify-progress"><span class="uploadify-progress-bar"></span></span>\
|
||||
<span class="insert"><a href="javascript:attach.insert(\'${fileID}\');">添加到正文</a></span>\
|
||||
<span class="cancel"><a href="javascript:attach.cancel(\'${fileID}\');">删除</a></span>\
|
||||
<input type="hidden" class="id" name="attachment[]" />\
|
||||
</div><div class="clear"></div>',
|
||||
'fileTypeExts' : "{{'*.'.str_replace(',',';*.',$setting['upload_type'])}}",
|
||||
'fileTypeDesc' : "只能上传({{'*.'.str_replace(',',';*.',$setting['upload_type'])}})文件",
|
||||
'fileSizeLimit': '{{$setting["upload_max"]*(1024*1024)}}',
|
||||
'removeCompleted': false,
|
||||
'onUploadSuccess':function(file, data, response)
|
||||
{
|
||||
$('#'+file.id).find(".id").val(data);
|
||||
$('#'+file.id).find(".uploadify-progress").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<input type="file" name="uploadify" id="uploadify">
|
||||
<div class="uploadify-info text-ellipsis"> 支持 {{strtoupper($setting['upload_type'])}}, 大小限制{{$setting['upload_max']}}MB</div>
|
||||
<div class="clear"></div>
|
||||
<div id="fileQueue"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
<style>
|
||||
.form-controller {
|
||||
padding: 0;
|
||||
}
|
||||
input[type=file] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<form class="form-horizontal form-controller" method="post" id="inspect_report_create" name="inspect_report_create">
|
||||
<div class="form-group">
|
||||
<div class="col-xs-2 control-label"><span class="red">*</span> 名称</div>
|
||||
<div class="col-xs-10 control-text">
|
||||
<input type="text" class="form-control input-sm" autocomplete="off" name="name" id="inspect_report_name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-2 control-label"><span class="red">*</span> 文件</div>
|
||||
<div class="col-xs-10 control-text">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" id="file_text" disabled="disabled">
|
||||
<input type="file" name="file" class="file" id="inspect_report_file" />
|
||||
<span class="input-group-btn">
|
||||
<a class="btn btn-sm btn-default" id="file_upload"><i class="fa fa-folder-open"></i>选择文件</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(function($) {
|
||||
$('#inspect_report_file').off('change').on('change', function() {
|
||||
var filename = getFileName(this.value);
|
||||
var name = filename.substring(0, filename.indexOf('.'));
|
||||
$('#file_text').val(filename);
|
||||
$('#inspect_report_name').val(name);
|
||||
});
|
||||
$('#file_upload').on('click', function() {
|
||||
$('#inspect_report_file').click();
|
||||
});
|
||||
});
|
||||
|
||||
function getFileName(path) {
|
||||
var paths = path.split("\\");
|
||||
return paths[paths.length-1];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,95 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['table']}}-grid" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
action.create = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var url = app.url('file/inspectReport/create');
|
||||
formDialog({
|
||||
title: '文件上传',
|
||||
url: url,
|
||||
id: 'inspect_report_create',
|
||||
dialogClass:'modal-md',
|
||||
onSubmit: function() {
|
||||
var me = this;
|
||||
var form = $('#inspect_report_create');
|
||||
var file = document.querySelector("#inspect_report_file").files[0];
|
||||
var name = form.find('#inspect_report_name').val();
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('name', name);
|
||||
|
||||
var loading = layer.msg('数据提交中...', {
|
||||
icon: 16, shade: 0.1, time: 1000 * 120
|
||||
});
|
||||
$.ajax(url, {
|
||||
method: "post",
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
complete: function() {
|
||||
layer.close(loading);
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status) {
|
||||
toastrSuccess(res.data);
|
||||
grid.remoteData();
|
||||
$(me).dialog('close');
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
action.download = function(data) {
|
||||
var url = app.url('file/inspectReport/download', {id: data.master_id});
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = search.advanced.query;
|
||||
grid.columnDefs = config.cols;
|
||||
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = grid;
|
||||
})(jQuery);
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,24 @@
|
||||
<table id="widget-file-file">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="title" data-align="left">标题</th>
|
||||
<th data-field="date" data-width="160" data-align="center">日期</th>
|
||||
<th data-field="option" data-width="200" data-align="center">下载</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
var $table = $('#widget-file-file');
|
||||
$table.bootstrapTable({
|
||||
sidePagination: 'server',
|
||||
showColumns: false,
|
||||
showHeader: false,
|
||||
height: 200,
|
||||
pagination: false,
|
||||
url: '{{url("file/widget/index")}}',
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
Reference in New Issue
Block a user