重构系统附件字段逻辑
修改各模块附件功能
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
|
||||
<div class="wrapper-sm">
|
||||
@include('attachment/view')
|
||||
@include('attachment/show')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -285,12 +285,9 @@ class EventController extends DefaultController
|
||||
$repeats['repeat_date'] = '';
|
||||
$repeats['repeat_year'] = 'bydate';
|
||||
|
||||
$attachment['model'] = 'calendar_attachment';
|
||||
$attachment['path'] = 'calendar';
|
||||
$attachment['draft'] = AttachmentService::draft(Auth::id());
|
||||
|
||||
$attachment = AttachmentService::edit('', 'calendar_object', 'attachment', 'calendar');
|
||||
return $this->render(array(
|
||||
'attachList' => $attachment,
|
||||
'attachment' => $attachment,
|
||||
'options' => $options,
|
||||
'repeats' => $repeats,
|
||||
));
|
||||
@@ -594,14 +591,10 @@ class EventController extends DefaultController
|
||||
$repeats['repeat_year'] = 'bydate';
|
||||
}
|
||||
|
||||
$attachment['model'] = 'calendar_attachment';
|
||||
$attachment['path'] = 'calendar';
|
||||
$attachment['draft'] = AttachmentService::draft(Auth::id());
|
||||
$attachment['queue'] = AttachmentService::get($event['attachment']);
|
||||
|
||||
$attachment = AttachmentService::edit($event['attachment'], 'calendar_object', 'attachment', 'calendar');
|
||||
$share = ShareService::getItem('event', $gets['id']);
|
||||
return $this->render(array(
|
||||
'attachList' => $attachment,
|
||||
'attachment' => $attachment,
|
||||
'repeats' => $repeats,
|
||||
'options' => $options,
|
||||
'share' => $share,
|
||||
@@ -673,7 +666,7 @@ class EventController extends DefaultController
|
||||
|
||||
$attach['model'] = 'calendar_attachment';
|
||||
$attach['path'] = 'calendar';
|
||||
$attach['main'] = AttachmentService::get($event['attachment']);
|
||||
$attach['rows'] = AttachmentService::get($event['attachment']);
|
||||
|
||||
$calendar = CalendarService::getCalendar($event['calendarid'], false);
|
||||
$share = ShareService::getItem('event', $id);
|
||||
@@ -692,6 +685,7 @@ class EventController extends DefaultController
|
||||
if ($id > 0) {
|
||||
CalendarService::remove($id);
|
||||
ShareService::removeItem('event', $id);
|
||||
|
||||
return $this->json('删除成功。', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<tr>
|
||||
<td align="right">附件列表</td>
|
||||
<td align="left">
|
||||
@include('attachment/add')
|
||||
@include('attachment/create')
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ use Gdoo\Chat\Models\Message;
|
||||
use Gdoo\Chat\Services\ChatService;
|
||||
|
||||
use Gdoo\Index\Controllers\Controller;
|
||||
use Str;
|
||||
|
||||
class ChatController extends Controller
|
||||
{
|
||||
@@ -76,10 +77,10 @@ class ChatController extends Controller
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
|
||||
// 文件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
$size = $file->getClientSize();
|
||||
$size = $file->getSize();
|
||||
$name = mb_strtolower($file->getClientOriginalName());
|
||||
$mime = $file->getMimeType();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class AttachmentController extends DefaultController
|
||||
// 扩展名称
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
@@ -58,7 +58,7 @@ class AttachmentController extends DefaultController
|
||||
$draft->name = mb_strtolower($file->getClientOriginalName());
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->size = $file->getSize();
|
||||
$draft->save();
|
||||
return $draft->id;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ class InspectReportController extends DefaultController
|
||||
// 附件新名字
|
||||
$filename = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
$filesize = $file->getSize();
|
||||
$uploadSuccess = $file->move($upload_path, $filename);
|
||||
if ($uploadSuccess) {
|
||||
// 数据库写入
|
||||
@@ -92,7 +93,7 @@ class InspectReportController extends DefaultController
|
||||
$draft->name = $name;
|
||||
$draft->path = $path.'/'.$filename;
|
||||
$draft->type = $extension;
|
||||
$draft->size = $file->getClientSize();
|
||||
$draft->size = $filesize;
|
||||
$draft->save();
|
||||
return $this->json('文件上传成功。', true);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,22 @@ use URL;
|
||||
|
||||
class AttachmentController extends DefaultController
|
||||
{
|
||||
public $permission = ['list','view','preview','create','delete','download','show', 'uploader', 'draft', 'qrcode'];
|
||||
public $permission = [
|
||||
'list',
|
||||
'preview',
|
||||
'create',
|
||||
'upload',
|
||||
'delete',
|
||||
'download',
|
||||
'show',
|
||||
'draft',
|
||||
'qrcode'
|
||||
];
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public function uploader()
|
||||
public function upload()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
@@ -34,7 +44,8 @@ class AttachmentController extends DefaultController
|
||||
}
|
||||
|
||||
// 获取上传uri第一个目录
|
||||
$key = Request::get('key', 'default');
|
||||
$table = Request::get('table');
|
||||
$field = Request::get('field');
|
||||
$node = Request::get('path', 'default');
|
||||
$path = $node.date('/Ym/');
|
||||
|
||||
@@ -43,15 +54,16 @@ class AttachmentController extends DefaultController
|
||||
// 文件新名字
|
||||
$filename = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
$filesize = $file->getSize();
|
||||
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
$data = [
|
||||
'name' => mb_strtolower($file->getClientOriginalName()),
|
||||
'node' => $node,
|
||||
'table' => $table,
|
||||
'field' => $field,
|
||||
'path' => $path.$filename,
|
||||
'type' => $extension,
|
||||
'key' => $key,
|
||||
'size' => $file->getClientSize(),
|
||||
'size' => $filesize,
|
||||
];
|
||||
$insertId = DB::table('attachment')->insertGetId($data);
|
||||
$data['id'] = $insertId;
|
||||
@@ -61,68 +73,12 @@ class AttachmentController extends DefaultController
|
||||
}
|
||||
}
|
||||
$query = Request::all();
|
||||
$SERVER_URL = url("index/attachment/uploader", $query);
|
||||
$SERVER_URL = url("index/attachment/upload", $query);
|
||||
return $this->render([
|
||||
'SERVER_URL' => $SERVER_URL,
|
||||
'key' => $query['key'],
|
||||
'key' => $query['table'].'_'.$query['field'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建文件
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
$file = Request::file('Filedata');
|
||||
|
||||
$rules = [
|
||||
'file' => 'mimes:'.$this->setting['upload_type'],
|
||||
];
|
||||
$v = Validator::make(['file' => $file], $rules);
|
||||
|
||||
if ($file->isValid() && $v->passes()) {
|
||||
// 获取上传uri第一个目录
|
||||
$path = Request::get('path', 'main').date('/Y/m/');
|
||||
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
|
||||
// 文件后缀名
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
|
||||
// 文件新名字
|
||||
$filename = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
return DB::table('attachment')->insertGetId([
|
||||
'name' => mb_strtolower($file->getClientOriginalName()),
|
||||
'path' => $path.$filename,
|
||||
'type' => $extension,
|
||||
'size' => $file->getClientSize(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 二维码上传
|
||||
*/
|
||||
public function qrcode()
|
||||
{
|
||||
$key = Request::get('key');
|
||||
$path = Request::get('path');
|
||||
list($table, $field) = explode('.', $key);
|
||||
$model = DB::table('model')->where('table', $table)->first();
|
||||
$token = Request::get('x-auth-token');
|
||||
return $this->render([
|
||||
'model' => $model,
|
||||
'token' => $token,
|
||||
'key' => $key,
|
||||
], 'attachment.qrcode');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use Request;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Str;
|
||||
|
||||
class AttachmentService
|
||||
{
|
||||
@@ -26,15 +27,16 @@ class AttachmentService
|
||||
}
|
||||
|
||||
// 文件新名字
|
||||
$name = date('dhis_').str_random(4).'.'.$extension;
|
||||
$name = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$name = mb_strtolower($name);
|
||||
$size = $file->getSize();
|
||||
|
||||
if ($file->move($upload_path, $name)) {
|
||||
$res[] = DB::table('attachment')->insertGetId([
|
||||
'name' => $name,
|
||||
'path' => $path.'/'.$name,
|
||||
'type' => $extension,
|
||||
'size' => $file->getClientSize(),
|
||||
'size' => $size,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
@@ -55,7 +57,7 @@ class AttachmentService
|
||||
$res = [];
|
||||
|
||||
foreach ($images as $image) {
|
||||
$name = date('dhis_').str_random(4).'.'.$extension;
|
||||
$name = date('dhis_').Str::random(4).'.'.$extension;
|
||||
$name = mb_strtolower($name);
|
||||
|
||||
$image = base64_decode(str_replace(' ', '+', $image));
|
||||
@@ -81,8 +83,7 @@ class AttachmentService
|
||||
if (is_array($ids)) {
|
||||
return $ids;
|
||||
}
|
||||
$ids = array_filter(explode("\n", $ids));
|
||||
|
||||
$ids = array_filter(explode(",", $ids));
|
||||
return (array)$ids;
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ class AttachmentService
|
||||
*/
|
||||
public static function get($ids)
|
||||
{
|
||||
$ids = self::getIds($ids);
|
||||
$ids = static::getIds($ids);
|
||||
return DB::table('attachment')
|
||||
->whereIn('id', $ids)
|
||||
->where('status', 1)->get();
|
||||
@@ -100,10 +101,13 @@ class AttachmentService
|
||||
/**
|
||||
* 获取当前ID附件和草稿
|
||||
*/
|
||||
public static function edit($ids, $key)
|
||||
public static function edit($ids, $table, $field, $path = 'default')
|
||||
{
|
||||
$res['rows'] = self::get($ids);
|
||||
$res['draft'] = self::draft($key);
|
||||
$res['path'] = $path;
|
||||
$res['table'] = $table;
|
||||
$res['field'] = $field;
|
||||
$res['rows'] = static::get($ids);
|
||||
$res['draft'] = static::draft($table, $field);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -112,7 +116,7 @@ class AttachmentService
|
||||
*/
|
||||
public static function show($ids)
|
||||
{
|
||||
$res['rows'] = self::get($ids);
|
||||
$res['rows'] = static::get($ids);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -121,7 +125,7 @@ class AttachmentService
|
||||
*/
|
||||
public static function publish($ids)
|
||||
{
|
||||
$ids = self::getIds($ids);
|
||||
$ids = static::getIds($ids);
|
||||
$rows = DB::table('attachment')
|
||||
->whereIn('id', $ids)
|
||||
->where('status', 0)
|
||||
@@ -137,9 +141,9 @@ class AttachmentService
|
||||
/**
|
||||
* 发布附件,改成状态为可用
|
||||
*/
|
||||
public static function store($key)
|
||||
public static function store($table, $field)
|
||||
{
|
||||
$rows = self::draft($key);
|
||||
$rows = static::draft($table, $field);
|
||||
foreach ($rows as $row) {
|
||||
DB::table('attachment')->where('id', $row['id'])->update([
|
||||
'status' => 1,
|
||||
@@ -151,14 +155,15 @@ class AttachmentService
|
||||
/**
|
||||
* 获取草稿文件
|
||||
*/
|
||||
public static function draft($key, $user_id = 0)
|
||||
public static function draft($table, $field, $user_id = 0)
|
||||
{
|
||||
if ($user_id == 0) {
|
||||
$user_id = auth()->id();
|
||||
}
|
||||
return DB::table('attachment')
|
||||
->where('created_id', $user_id)
|
||||
->where('key', $key)
|
||||
->where('table', $table)
|
||||
->where('field', $field)
|
||||
->where('status', '0')
|
||||
->get();
|
||||
}
|
||||
|
||||
+7
-10
@@ -469,10 +469,6 @@ class Form
|
||||
|
||||
$attribute = [];
|
||||
|
||||
if ($action == 'show') {
|
||||
$field['is_show'] = true;
|
||||
}
|
||||
|
||||
$permission_table = $permission[$flow['table']];
|
||||
$p = $permission_table[$field['field']];
|
||||
$field['is_print'] = $action == 'print';
|
||||
@@ -481,12 +477,13 @@ class Form
|
||||
$field['is_auto'] = $p['m'] == 1 ? 1 : 0;
|
||||
$field['is_hide'] = $p['s'] == 1 ? 1 : $field['is_hide'];
|
||||
|
||||
$validate = (array) $p['v'];
|
||||
|
||||
if ($action == 'print') {
|
||||
$field['is_show'] = true;
|
||||
if ($action == 'show' || $action == 'print') {
|
||||
$field['is_show'] = 1;
|
||||
$field['is_write'] = 0;
|
||||
}
|
||||
|
||||
$validate = (array) $p['v'];
|
||||
|
||||
if ($action == 'print') {
|
||||
} else {
|
||||
$required = '';
|
||||
@@ -2000,7 +1997,7 @@ class Form
|
||||
|
||||
// 权限可写
|
||||
if ($permission['w'] == 1) {
|
||||
|
||||
|
||||
// 自定义过滤器
|
||||
$_field_data = Hook::fire($table.'.onFieldFilter', ['table' => $table, 'master' => $master, 'field' => $field, 'values' => $values]);
|
||||
extract($_field_data);
|
||||
@@ -2033,7 +2030,7 @@ class Form
|
||||
case 'files':
|
||||
$value = (array)$value;
|
||||
$dataFiles = array_merge($dataFiles, $value);
|
||||
$value = join("\n", $value);
|
||||
$value = join(",", $value);
|
||||
break;
|
||||
case 'images':
|
||||
$value = join("\n", (array)$value);
|
||||
|
||||
@@ -1343,6 +1343,38 @@ class FieldService
|
||||
return join(' ', $str);
|
||||
}
|
||||
|
||||
public static function content_location($field, $content = '', $row)
|
||||
{
|
||||
$field = static::content_field($field);
|
||||
$setting = $field['setting'];
|
||||
|
||||
$attribute = $field['attribute'];
|
||||
$id = $attribute['id'];
|
||||
$name = $attribute['name'];
|
||||
|
||||
$attribute['readonly'] = 'readonly';
|
||||
|
||||
if ($field['is_show']) {
|
||||
return '
|
||||
<div id="'.$id.'-media" class="media-controller">
|
||||
<i class="icon icon-map-marker text-info text-sm"></i><a href="javascript:;" data-location="'.$row['location'].'" data-longitude="'.$row['longitude'].'" data-latitude="'.$row['latitude'].'" data-toggle="map-show">'.$content.'</a>
|
||||
</div>';
|
||||
} else {
|
||||
$str = '
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<a href="javascript:;" data-location="'.$row['location'].'" data-name="'.$name.'" data-id="'.$id.'" data-longitude="'.$row['longitude'].'" data-latitude="'.$row['latitude'].'" data-toggle="map-select" class="btn btn-sm btn-info"><i class="fa fa-map"></i> 选择位置</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="'.$id.'-media" class="media-controller media-input">
|
||||
<input type="text" class="form-control input-sm" autocomplete="off" id="'.$id.'" value="' .$content. '" name="' .$name. '">
|
||||
<input type="hidden" id="'.$id.'_longitude" value="'.$row['longitude'].'" name="' .$field['table']. '[longitude]" />
|
||||
<input type="hidden" id="'.$id.'_latitude" value="'.$row['latitude'].'" name="' .$field['table']. '[latitude]" />
|
||||
</div>';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function content_image($field, $content = '')
|
||||
{
|
||||
$field = static::content_field($field);
|
||||
@@ -1453,38 +1485,6 @@ class FieldService
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function content_location($field, $content = '', $row)
|
||||
{
|
||||
$field = static::content_field($field);
|
||||
$setting = $field['setting'];
|
||||
|
||||
$attribute = $field['attribute'];
|
||||
$id = $attribute['id'];
|
||||
$name = $attribute['name'];
|
||||
|
||||
$attribute['readonly'] = 'readonly';
|
||||
|
||||
if ($field['is_show']) {
|
||||
return '
|
||||
<div id="'.$id.'-media" class="media-controller">
|
||||
<i class="icon icon-map-marker text-info text-sm"></i><a href="javascript:;" data-location="'.$row['location'].'" data-longitude="'.$row['longitude'].'" data-latitude="'.$row['latitude'].'" data-toggle="map-show">'.$content.'</a>
|
||||
</div>';
|
||||
} else {
|
||||
$str = '
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<a href="javascript:;" data-location="'.$row['location'].'" data-name="'.$name.'" data-id="'.$id.'" data-longitude="'.$row['longitude'].'" data-latitude="'.$row['latitude'].'" data-toggle="map-select" class="btn btn-sm btn-info"><i class="fa fa-map"></i> 选择位置</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="'.$id.'-media" class="media-controller media-input">
|
||||
<input type="text" class="form-control input-sm" autocomplete="off" id="'.$id.'" value="' .$content. '" name="' .$name. '">
|
||||
<input type="hidden" id="'.$id.'_longitude" value="'.$row['longitude'].'" name="' .$field['table']. '[longitude]" />
|
||||
<input type="hidden" id="'.$id.'_latitude" value="'.$row['latitude'].'" name="' .$field['table']. '[latitude]" />
|
||||
</div>';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function content_file($name, $content = '', $field = '')
|
||||
{
|
||||
// 配置
|
||||
@@ -1502,140 +1502,100 @@ class FieldService
|
||||
{
|
||||
$field = static::content_field($field);
|
||||
$setting = $field['setting'];
|
||||
|
||||
$attribute = $field['attribute'];
|
||||
$name = $attribute['name'];
|
||||
$key = $attribute['key'];
|
||||
$input_id = $attribute['id'];
|
||||
|
||||
$config = Setting::where('type', 'system')->pluck('value', 'key');
|
||||
|
||||
$input_id = $attribute['id'];
|
||||
$attachment = AttachmentService::edit($content, $field['table'], $field['field']);
|
||||
|
||||
$attachment = AttachmentService::edit($content, $key);
|
||||
$str = '<div id="file_'.$input_id.'" class="uploadify-queue">';
|
||||
|
||||
if ($field['is_read'] || $field['is_show']) {
|
||||
$str = '<div id="fileQueue_'.$input_id.'" class="uploadify-queue">';
|
||||
if ($field['is_write']) {
|
||||
$str .= '<a class="btn btn-sm btn-info hinted" title="文件大小限制: '.$config['upload_max'].'MB" href="javascript:viewBox(\'attachment\', \'上传\', \''.url('index/attachment/upload', ['path' => Request::module(), 'table' => $field['table'], 'field' => $field['field']]).'\');"><i class="fa fa-cloud-upload"></i> 文件上传</a>';
|
||||
$str .= '<div class="clear"></div>';
|
||||
}
|
||||
|
||||
if (count((array)$attachment['rows'])) {
|
||||
foreach ($attachment['rows'] as $file) {
|
||||
$str .= '<div id="file_queue_'.$file['id'].'" class="uploadify-queue-item">
|
||||
<span class="file-name"><i class="icon icon-paperclip"></i> <a class="option" title="下载" download="'.$file['name'].'" href="'.URL::to('uploads').'/'.$file['path'].'">'.$file['name'].'</a></span>
|
||||
<input type="hidden" class="'.$input_id.' id" value="'.$file['id'].'">';
|
||||
|
||||
if (in_array($file['type'], ['pdf'])) {
|
||||
$str .= '<a href="'.URL::to('uploads').'/'.$file['path'].'" class="btn btn-xs btn-default" target="_blank">[预览]</a>';
|
||||
} elseif (in_array($file['type'], ['jpg','png','gif','bmp'])) {
|
||||
// $str .= '<a data-toggle="dialog-image2" src="'.URL::to('uploads').'/'.$file['path'].'" data-original="'.URL::to('uploads').'/'.$file['path'].'" data-title="附件预览" class="option">[预览]</a>';
|
||||
$str .= '<img data-original="'.URL::to('uploads').'/'.$file['path'].'" /><a data-toggle="image-show" data-title="附件预览" class="option">[预览]</a>';
|
||||
}
|
||||
$str .= '<span class="file-size">('.human_filesize($file['size']).')</span> <span class="file-created_by"> '.$file['created_by'].' </span>';
|
||||
$str .= '</div><div class="clear"></div>';
|
||||
if (count((array)$attachment['rows'])) {
|
||||
foreach ($attachment['rows'] as $file) {
|
||||
$str .= '<div id="file_queue_'.$file['id'].'" class="uploadify-queue-item">
|
||||
<span class="file-name"><i class="icon icon-paperclip"></i> <a class="option" title="下载" download="'.$file['name'].'" href="'.URL::to('uploads').'/'.$file['path'].'">'.$file['name'].'</a></span>
|
||||
<input type="hidden" class="'.$input_id.' id" name="'. $name . '[]" value="'.$file['id'].'">';
|
||||
|
||||
// pdf
|
||||
if (in_array($file['type'], ['pdf'])) {
|
||||
$str .= '<a href="'.URL::to('uploads').'/'.$file['path'].'" class="btn btn-xs btn-default" target="_blank">[预览]</a>';
|
||||
}
|
||||
|
||||
// 图片
|
||||
if (in_array($file['type'], ['jpg','png','gif','bmp'])) {
|
||||
$str .= '<img data-original="'.URL::to('uploads').'/'.$file['path'].'" /><a data-toggle="image-show" class="option">[预览]</a>';
|
||||
}
|
||||
|
||||
// 删除
|
||||
if ($field['is_write']) {
|
||||
$str .= '<span class="cancel"><a class="option gray hinted" title="删除文件" href="javascript:uploader.cancel(\'file_queue_'.$file['id'].'\');"><i class="fa fa-times-circle"></i></a></span>';
|
||||
}
|
||||
|
||||
$str .= '<span class="file-size">('.human_filesize($file['size']).')</span> <span class="file-created_by"> '.$file['created_by'].' </span>';
|
||||
$str .= '</div><div class="clear"></div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
||||
$str .= '<script type="text/javascript">
|
||||
(function($) {
|
||||
var galley_id = "fileQueue_'.$input_id.'";
|
||||
var galley = document.getElementById(galley_id);
|
||||
var viewer = new Viewer(galley, {
|
||||
navbar: false,
|
||||
url: "data-original",
|
||||
});
|
||||
$("#" + galley_id).on("click", \'[data-toggle="image-show"]\', function() {
|
||||
$(this).prev().click();
|
||||
});
|
||||
})(jQuery);
|
||||
</script>';
|
||||
|
||||
return $str;
|
||||
} else {
|
||||
//$qrcode = url('index/attachment/qrcode', ['path' => Request::module(), 'key' => $key, 'x-auth-token' => create_token(auth()->id(), 7)]);
|
||||
$str = '<script id="uploader-item-tpl" type="text/html">
|
||||
}
|
||||
|
||||
if ($field['is_write']) {
|
||||
$str .= '<script id="upload-item-tpl" type="text/html">
|
||||
<div id="file_draft_<%=id%>" class="uploadify-queue-item">
|
||||
<span class="file-name"><span class="text-danger hinted" title="草稿状态">!</span> <a class="option" href="javascript:uploader.file(\'file_draft_<%=id%>\', \''.URL::to('uploads').'/<%=path%>\');"><%=name%></a></span>
|
||||
<span class="file-size">(<%=size%>)</span>
|
||||
|
||||
<img data-original="'.URL::to('uploads').'/<%=path%>" /><a data-toggle="image-show" data-title="附件预览" class="option">[预览]</a>
|
||||
|
||||
<span class="cancel"><a class="option gray hinted" title="删除文件" href="javascript:uploader.cancel(\'file_draft_<%=id%>\');"><i class="fa fa-times-circle"></i></a></span>
|
||||
<input type="hidden" class="'.$input_id.' id" name="'. $name . '[]" value="<%=id%>" />
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</script>
|
||||
<div class="uploadify-queue">';
|
||||
/*
|
||||
<script src="'.URL::to('/assets').'/vendor/jquery.qrcode.min.js"></script>
|
||||
<style>
|
||||
.layui-layer-tips .layui-layer-content {
|
||||
background-color: #eee;
|
||||
padding: 8px;
|
||||
}
|
||||
.layui-layer-tips i.layui-layer-TipsL, .layui-layer-tips i.layui-layer-TipsR {
|
||||
border-bottom-color: #eee;
|
||||
}
|
||||
</style>
|
||||
*/
|
||||
$str .= '<a class="btn btn-sm btn-info hinted" title="文件大小限制: '.$config['upload_max'].'MB" href="javascript:viewBox(\'attachment\', \'上传\', \''.url('index/attachment/uploader', ['path' => Request::module(), 'key' => $key]).'\');"><i class="fa fa-cloud-upload"></i> 文件上传</a>';
|
||||
/*
|
||||
<a class="btn btn-sm btn-info" id="qrcode_'.$input_id.'_btn" href="javascript:;"><i class="fa fa-qrcode"></i> 扫码上传</a>
|
||||
<div id="qrcode_'.$input_id.'" style="display:none;"></div>
|
||||
*/
|
||||
$str .= '<div class="clear"></div>
|
||||
<div id="fileQueue_'.$input_id.'" class="uploadify-queue">';
|
||||
|
||||
if (count((array)$attachment['rows'])) {
|
||||
foreach ($attachment['rows'] as $file) {
|
||||
$str .= '<div id="file_queue_'.$file['id'].'" class="uploadify-queue-item">
|
||||
<span class="file-name"><span class="icon icon-paperclip"></span> <a class="option" href="javascript:uploader.file(\'file_queue_'.$file['id'].'\', \''.URL::to('uploads').'/'.$file['path'].'\');">'.$file['name'].'</a></span>
|
||||
<span class="file-size">('.human_filesize($file['size']).')</span>
|
||||
<span class="cancel"><a class="option gray hinted" title="删除文件" href="javascript:uploader.cancel(\'file_queue_'.$file['id'].'\');"><i class="fa fa-times-circle"></i></a></span>
|
||||
<input type="hidden" class="'.$input_id.' id" name="'. $name . '[]" value="'.$file['id'].'">
|
||||
</div>
|
||||
<div class="clear"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$str .= '</div><div id="fileDraft_'.$input_id.'">';
|
||||
</script>';
|
||||
|
||||
$str .= '<div id="fileDraft_'.$input_id.'">';
|
||||
if (count($attachment['draft'])) {
|
||||
foreach ($attachment['draft'] as $file) {
|
||||
$str .= '<div id="queue_draft_'.$file['id'].'" class="uploadify-queue-item">
|
||||
<span class="file-name"><span class="text-danger hinted" title="草稿附件">!</span> <a class="option" href="javascript:uploader.file(\'queue_draft_'.$file['id'].'\', \''.URL::to('uploads').'/'.$file['path'].'\');">'.$file['name'].'</a></span>
|
||||
<span class="file-size">('.human_filesize($file['size']).')</span>
|
||||
<span class="cancel"><a class="option gray hinted" title="删除文件" href="javascript:uploader.cancel(\'queue_draft_'.$file['id'].'\');"><i class="fa fa-times-circle"></i></a></span>
|
||||
<span class="file-size">('.human_filesize($file['size']).')</span>';
|
||||
|
||||
// pdf
|
||||
if (in_array($file['type'], ['pdf'])) {
|
||||
$str .= '<a href="'.URL::to('uploads').'/'.$file['path'].'" class="btn btn-xs btn-default" target="_blank">[预览]</a>';
|
||||
}
|
||||
|
||||
// 图片
|
||||
if (in_array($file['type'], ['jpg','png','gif','bmp'])) {
|
||||
$str .= '<img data-original="'.URL::to('uploads').'/'.$file['path'].'" /><a data-toggle="image-show" class="option">[预览]</a>';
|
||||
}
|
||||
|
||||
$str .= '<span class="cancel"><a class="option gray hinted" title="删除文件" href="javascript:uploader.cancel(\'queue_draft_'.$file['id'].'\');"><i class="fa fa-times-circle"></i></a></span>
|
||||
<input type="hidden" class="'.$input_id.' id" name="'. $name . '[]" value="'.$file['id'].'">
|
||||
</div>
|
||||
<div class="clear"></div>';
|
||||
}
|
||||
}
|
||||
$str .= '</div></div>';
|
||||
|
||||
/*
|
||||
$str .= '<script type="text/javascript">
|
||||
(function($) {
|
||||
$("#qrcode_'.$input_id.'").qrcode({
|
||||
render: "canvas",
|
||||
text: "'.$qrcode.'",
|
||||
width: 150,
|
||||
height: 150
|
||||
});
|
||||
var qr = $("#qrcode_'.$input_id.'").find("canvas")[0];
|
||||
var qrimg = "<img src="+ qr.toDataURL() +" />";
|
||||
var qrcode_index = 0;
|
||||
var timer_'.$input_id.' = null;
|
||||
$("#qrcode_'.$input_id.'_btn").on("mouseenter", function() {
|
||||
qrcode_index = layer.tips(qrimg, "#qrcode_'.$input_id.'_btn", {
|
||||
time: 0,
|
||||
});
|
||||
// 激活扫码上传功能
|
||||
if(timer_'.$input_id.' == null) {
|
||||
timer_'.$input_id.' = setInterval(\'FindFile("'.$input_id.'", "'.$key.'")\', 3000);
|
||||
}
|
||||
}).on("mouseleave", function() {
|
||||
layer.close(qrcode_index);
|
||||
});
|
||||
})(jQuery);
|
||||
</script>';
|
||||
*/
|
||||
return $str;
|
||||
$str .= '</div>';
|
||||
}
|
||||
|
||||
$str .= '</div><script type="text/javascript">
|
||||
(function($) {
|
||||
var galley_id = "file_'.$input_id.'";
|
||||
var galley = document.getElementById(galley_id);
|
||||
var viewer = new Viewer(galley, {
|
||||
navbar: false,
|
||||
url: "data-original",
|
||||
});
|
||||
$("#" + galley_id).on("click", \'[data-toggle="image-show"]\', function() {
|
||||
$(this).prev().click();
|
||||
});
|
||||
})(jQuery);
|
||||
</script>';
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use Gdoo\Project\Models\Task;
|
||||
use Gdoo\Project\Models\Log;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Gdoo\Index\Services\AttachmentService;
|
||||
|
||||
class CommentController extends DefaultController
|
||||
{
|
||||
@@ -43,7 +44,9 @@ class CommentController extends DefaultController
|
||||
|
||||
$task_id = $request->input('task_id');
|
||||
|
||||
$attachment = AttachmentService::edit('', 'project_task_log', 'attachment', 'project');
|
||||
return $this->render([
|
||||
'attachment' => $attachment,
|
||||
'task_id' => $task_id,
|
||||
]);
|
||||
}
|
||||
@@ -68,7 +71,9 @@ class CommentController extends DefaultController
|
||||
$id = $request->input('id');
|
||||
$log = Log::find($id);
|
||||
|
||||
$attachment = AttachmentService::edit($log['attachment'], 'project_task_log', 'attachment', 'project');
|
||||
return $this->render([
|
||||
'attachment' => $attachment,
|
||||
'log' => $log,
|
||||
]);
|
||||
}
|
||||
@@ -84,8 +89,13 @@ class CommentController extends DefaultController
|
||||
return $this->json('请先选择数据。');
|
||||
}
|
||||
|
||||
$rows = Log::whereIn('id', $id)->get();
|
||||
Log::whereIn('id', $id)->delete();
|
||||
|
||||
foreach($rows as $row) {
|
||||
AttachmentService::remove($row['attachment']);
|
||||
}
|
||||
|
||||
return $this->json('恭喜你,删除评论成功。', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ class ProjectController extends DefaultController
|
||||
public function index()
|
||||
{
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
'referer' => 1,
|
||||
'status' => 0
|
||||
'status' => 1
|
||||
], [
|
||||
['text', 'project.title', '名称'],
|
||||
['text', 'project.user_id', '拥有者'],
|
||||
@@ -62,25 +63,14 @@ class ProjectController extends DefaultController
|
||||
|
||||
$rows = $model->paginate()->appends($query);
|
||||
|
||||
$tabs = [
|
||||
'name' => 'status',
|
||||
'items' => Project::$tabs
|
||||
];
|
||||
|
||||
return $this->display([
|
||||
'auth_id' => $auth_id,
|
||||
'rows' => $rows,
|
||||
'search' => $search,
|
||||
'tabs' => $tabs,
|
||||
'query' => $query,
|
||||
'search' => $search
|
||||
]);
|
||||
}
|
||||
|
||||
// 项目详情
|
||||
public function show(Request $request)
|
||||
{
|
||||
return $this->display([]);
|
||||
}
|
||||
|
||||
// 添加项目
|
||||
public function add(Request $request)
|
||||
{
|
||||
|
||||
@@ -27,14 +27,29 @@ class TaskController extends DefaultController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
'project_id' => '',
|
||||
'tpl' => 'gantt',
|
||||
'referer' => '',
|
||||
'tpl' => 'index',
|
||||
], [
|
||||
['text','project_task.name','任务名称'],
|
||||
['text','project_task.user_id','执行者'],
|
||||
]);
|
||||
['form_type' => 'text', 'name' => '任务名称', 'field' => 'project_task.name', 'value' => '', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '执行者', 'field' => 'project_task.user_id', 'value' => '', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$header = [
|
||||
'master_name' => '项目任务',
|
||||
'simple_search_form' => 1,
|
||||
'table' => 'project_task',
|
||||
'master_table' => 'project_task',
|
||||
];
|
||||
|
||||
/*
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
*/
|
||||
|
||||
$header['search_form'] = $search;
|
||||
$query = $search['query'];
|
||||
|
||||
if ($request->ajax() && $request->wantsJson()) {
|
||||
@@ -62,38 +77,14 @@ class TaskController extends DefaultController
|
||||
'add_task' => $project['user_id'] == $user_id,
|
||||
];
|
||||
|
||||
// 返回页面
|
||||
$referer = session()->get('referer_'.$request->module().'_project_index');
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
'project' => $project,
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
'referer' => $referer,
|
||||
'permission' => $permission,
|
||||
|
||||
], 'index/'.$query['tpl']);
|
||||
}
|
||||
|
||||
// 显示任务
|
||||
public function show(Request $request)
|
||||
{
|
||||
$search = search_form([
|
||||
'project_id' => ''
|
||||
], [
|
||||
['text','project.title','任务名称'],
|
||||
['text','project.created_at','执行者'],
|
||||
]);
|
||||
|
||||
$project_id = $request->input('project_id');
|
||||
$project = Project::find($project_id);
|
||||
|
||||
return $this->render([
|
||||
'project' => $project,
|
||||
'search' => $search,
|
||||
]);
|
||||
}
|
||||
|
||||
// 移动任务
|
||||
public function drag(Request $request)
|
||||
{
|
||||
@@ -180,8 +171,11 @@ class TaskController extends DefaultController
|
||||
->get();
|
||||
|
||||
$tpl = $type == 'item' ? 'item/add' : 'add';
|
||||
|
||||
$attachment = AttachmentService::edit('', 'project_task', 'attachment', 'project');
|
||||
return $this->render([
|
||||
'items' => $items,
|
||||
'attachment' => $attachment,
|
||||
'project_id' => $project_id,
|
||||
'parent_id' => $parent_id,
|
||||
'type' => $type,
|
||||
@@ -300,12 +294,15 @@ class TaskController extends DefaultController
|
||||
];
|
||||
}
|
||||
$tpl = $type == 'item' ? 'item/edit' : 'edit';
|
||||
|
||||
$attachment = AttachmentService::edit($task['attachment'], 'project_task', 'attachment', 'project');
|
||||
return $this->render([
|
||||
'task' => $task,
|
||||
'logs' => $logs,
|
||||
'items' => $items,
|
||||
'tasks' => $tasks,
|
||||
'type' => $type,
|
||||
'attachment' => $attachment,
|
||||
'permission' => $permission,
|
||||
], $tpl);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<form method="post" action="{{url()}}" id="comment-form" name="comment-form">
|
||||
<div class="panel m-b-none">
|
||||
|
||||
<table class="table table-form m-b-none">
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<textarea class="form-control" type="text" name="content" id="content"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="left">
|
||||
{{attachment_uploader('comment_attachment', $comment['attachment'], 'project_task_log')}}
|
||||
@include('attachment/create')
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task_id" value="{{$task_id}}">
|
||||
|
||||
</form>
|
||||
@@ -4,26 +4,19 @@
|
||||
|
||||
<form method="post" action="{{url()}}" id="comment-form" name="comment-form">
|
||||
<div class="panel m-b-none">
|
||||
|
||||
<table class="table table-form m-b-none">
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<textarea class="form-control" type="text" name="content" id="content"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="left">
|
||||
{{attachment_uploader('comment_attachment', $comment['attachment'], 'project_task_log')}}
|
||||
@include('attachment/create')
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="{{$comment->id}}">
|
||||
|
||||
</form>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
<div class="wrapper-xs">
|
||||
@include('project/query')
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
@if($row->tasks->count())
|
||||
<span class="text-base badge bg-danger">{{$row->tasks->count()}}</span>
|
||||
@endif
|
||||
<a class="m-t-sm" href="{{url('task/index', ['project_id' => $row->id])}}">
|
||||
<a class="m-t-sm" data-toggle="tab-frame-url" data-name="项目任务详情" data-id="project_task_index" data-url="project/task/index?project_id={{$row->id}}" href="javascript:;">
|
||||
{{$row->name}}
|
||||
</a>
|
||||
</h4>
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
{{$rows->links()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
</style>
|
||||
|
||||
<form method="post" action="{{url()}}" id="task-form" name="task-form">
|
||||
|
||||
<input type="hidden" name="type" value="{{$type}}">
|
||||
|
||||
@if($type == 'subtask')
|
||||
<input type="hidden" name="parent_id" value="{{$parent_id}}">
|
||||
@endif
|
||||
@@ -72,7 +72,7 @@
|
||||
<tr>
|
||||
<td align="right">附件</td>
|
||||
<td align="left">
|
||||
{{attachment_uploader('attachment', '', 'project_task')}}
|
||||
@include('attachment/create')
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<style>
|
||||
.modal-body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wrapper-sm {
|
||||
background-color: #f0f3f4;
|
||||
}
|
||||
.modal-body {
|
||||
overflow: hidden;
|
||||
}
|
||||
.wrapper-sm {
|
||||
background-color: #f0f3f4;
|
||||
}
|
||||
</style>
|
||||
<div class="wrapper-sm">
|
||||
|
||||
@@ -126,9 +125,9 @@
|
||||
<td align="right">附件</td>
|
||||
<td align="left">
|
||||
@if($permission['attachment'])
|
||||
{{attachment_uploader('attachment', $task['attachment'], 'project_task')}}
|
||||
@include('attachment/create')
|
||||
@else
|
||||
{{attachment_show('attachment', $task['attachment'], 'project_task')}}
|
||||
@include('attachment/show')
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@@ -179,10 +178,8 @@
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="task-log" id="task-log-{{$task->id}}">
|
||||
|
||||
<div class="panel b-a m-b-none">
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
<script src="{{$asset_url}}/vendor/dhtmlxgantt/locale_cn.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="{{$asset_url}}/vendor/dhtmlxgantt/dhtmlxgantt.css" type="text/css">
|
||||
<style type="text/css">
|
||||
/* 新样式 */
|
||||
html, body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.gantt_side_content.gantt_right {
|
||||
padding-left: 10px;
|
||||
}
|
||||
@@ -18,7 +16,7 @@ html, body {
|
||||
}
|
||||
|
||||
.gantt_container {
|
||||
border: 1px solid #eee;
|
||||
border: 1px solid #fff;
|
||||
border-top: 1px solid #cecece;
|
||||
}
|
||||
|
||||
@@ -106,52 +104,8 @@ html, body {
|
||||
|
||||
</style>
|
||||
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm b-b">
|
||||
<span class="text-md">{{$project['name']}}</span> <span class="text-muted">{{$project['description']}}</span>
|
||||
</div>
|
||||
|
||||
<div class="wrapper-xs" id="gantt-wrapper">
|
||||
|
||||
<form id="search-task-form" class="form-inline" name="mytasksearch" method="get">
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'index'])}}" class="btn btn-sm btn-default @if($query['tpl'] == 'index') active @endif">列表</a>
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'gantt'])}}" class="btn btn-sm btn-default @if($query['tpl'] == 'gantt') active @endif">甘特图</a>
|
||||
<!--
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'board'])}}" class="btn btn-sm btn-default @if($query['tpl'] == 'board') active @endif">看板</a>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{url($referer)}}" class="btn btn-sm btn-default"><i class="fa fa-reply"></i> 返回</a>
|
||||
|
||||
@if(isset($access['add']))
|
||||
|
||||
@if($permission['add_item'])
|
||||
<a href="javascript:addItem();" title="添加列表" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加列表</a>
|
||||
@endif
|
||||
|
||||
@if($permission['add_task'])
|
||||
<a href="javascript:addTask();" title="添加任务" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加任务</a>
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@include('searchForm')
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#search-task-form').searchForm({
|
||||
data: {{json_encode($search['forms'])}},
|
||||
init:function(e) {
|
||||
var self = this;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('task/index/header')
|
||||
<div id="gantt-view"></div>
|
||||
</div>
|
||||
|
||||
@@ -163,7 +117,6 @@ var params = {project_id:project_id};
|
||||
gantt.config.columns = [
|
||||
{name:"name", label:"任务列表", tree:true, width:'*', resize: true}
|
||||
];
|
||||
|
||||
gantt.config.scale_unit = 'month';
|
||||
gantt.config.date_scale = '%Y - %m';
|
||||
gantt.config.scale_height = 50;
|
||||
@@ -284,7 +237,7 @@ gantt._do_autosize = function() {
|
||||
// 设置高度
|
||||
var height = $('#gantt-wrapper').outerHeight();
|
||||
var iframeHeight = $(window).height();
|
||||
$('#gantt-view').height(iframeHeight - height - 68 + 'px');
|
||||
$('#gantt-view').height(iframeHeight - height - 102 + 'px');
|
||||
|
||||
var resize = this._get_resize_options();
|
||||
var boxSizes = this._get_box_styles();
|
||||
@@ -308,15 +261,6 @@ gantt._do_autosize = function() {
|
||||
gantt.init("gantt-view");
|
||||
gantt.load(app.url('project/task/index', params));
|
||||
|
||||
$('#search-submit').on('click', function() {
|
||||
var query = $('#search-task-form').serializeArray();
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
dataReload();
|
||||
return false;
|
||||
});
|
||||
|
||||
function dataReload() {
|
||||
gantt.clearAll();
|
||||
gantt.load(app.url('project/task/index', params));
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<div class="wrapper-sm b-b">
|
||||
<span class="text-md">{{$project['name']}}</span> <span class="text-muted">{{$project['description']}}</span>
|
||||
</div>
|
||||
|
||||
<div id="index-wrapper">
|
||||
<form id="{{$header['master_table']}}-search-form" class="form-inline" name="mytasksearch" method="get">
|
||||
|
||||
<div class="pull-right wrapper-xs">
|
||||
<div class="btn-group">
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'index'])}}" class="btn btn-sm btn-default @if($header['search_form']['query']['tpl'] == 'index') active @endif">列表</a>
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'gantt'])}}" class="btn btn-sm btn-default @if($header['search_form']['query']['tpl'] == 'gantt') active @endif">甘特图</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('left_buttons')
|
||||
@if(isset($access['add']))
|
||||
@if($permission['add_item'])
|
||||
<a href="javascript:addItem();" title="添加列表" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加列表</a>
|
||||
@endif
|
||||
|
||||
@if($permission['add_task'])
|
||||
<a href="javascript:addTask();" title="添加任务" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加任务</a>
|
||||
@endif
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
@include('headers')
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<style type="text/css">
|
||||
.ag-theme-balham .ag-root {
|
||||
border-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,40 +1,8 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm b-b">
|
||||
<span class="text-md">{{$project['name']}}</span> <span class="text-muted">{{$project['description']}}</span>
|
||||
</div>
|
||||
|
||||
<div class="wrapper-xs" id="index-wrapper">
|
||||
<form id="search-task-form" class="form-inline" name="mytasksearch" method="get">
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'index'])}}" class="btn btn-sm btn-default @if($query['tpl'] == 'index') active @endif">列表</a>
|
||||
<a href="{{url('index', ['project_id' => $project['id'], 'tpl' => 'gantt'])}}" class="btn btn-sm btn-default @if($query['tpl'] == 'gantt') active @endif">甘特图</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{url($referer)}}" class="btn btn-sm btn-default"><i class="fa fa-reply"></i> 返回</a>
|
||||
|
||||
@if(isset($access['add']))
|
||||
|
||||
@if($permission['add_item'])
|
||||
<a href="javascript:addItem();" title="添加列表" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加列表</a>
|
||||
@endif
|
||||
|
||||
@if($permission['add_task'])
|
||||
<a href="javascript:addTask();" title="添加任务" class="hinted btn btn-sm btn-info"><i class="icon icon-plus"></i> 添加任务</a>
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@include('searchForm')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="panel" id="{{$header['master_table']}}-controller">
|
||||
@include('task/index/header')
|
||||
<div class="gdoo-list-grid">
|
||||
<div id="jqgrid-table" class="ag-theme-balham" style="width:100%;"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -43,25 +11,6 @@ var project_id = "{{(int)$project['id']}}";
|
||||
var params = {project_id:project_id};
|
||||
var auth_id = '{{auth()->id()}}';
|
||||
|
||||
function progressRenderer(params) {
|
||||
var data = params.data;
|
||||
if (data.type == 'task' || data.type == 'subtask') {
|
||||
if (params.value == 1) {
|
||||
return '<div class="label label-success">已完成</div>';
|
||||
} else {
|
||||
return '<div class="label label-' + (auth_id == data.user_id ? 'danger' : 'info') + '">进行中</div>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function durationRenderer(params) {
|
||||
if (params.value) {
|
||||
return '<span class="hinted" title="任务持续' + params.value + '">' + params.value + '</span>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
(function($) {
|
||||
grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
@@ -90,6 +39,25 @@ function durationRenderer(params) {
|
||||
return data.tree_path;
|
||||
};
|
||||
|
||||
function progressRenderer(params) {
|
||||
var data = params.data;
|
||||
if (data.type == 'task' || data.type == 'subtask') {
|
||||
if (params.value == 1) {
|
||||
return '<div class="label label-success">已完成</div>';
|
||||
} else {
|
||||
return '<div class="label label-' + (auth_id == data.user_id ? 'danger' : 'info') + '">进行中</div>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function durationRenderer(params) {
|
||||
if (params.value) {
|
||||
return '<span class="hinted" title="任务持续' + params.value + '">' + params.value + '</span>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
grid.columnDefs.push(
|
||||
{cellClass:'text-center', sortable: false, field: 'user_name', headerName: '执行者', width: 140},
|
||||
{cellClass:'text-center', sortable: false, field: 'users', headerName: '参与者', minWidth: 200},
|
||||
@@ -115,24 +83,11 @@ function durationRenderer(params) {
|
||||
};
|
||||
|
||||
var gridDiv = document.querySelector("#jqgrid-table");
|
||||
gridDiv.style.height = getPanelHeight(12);
|
||||
gridDiv.style.height = getPanelHeight(11);
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
grid.remoteData();
|
||||
|
||||
var search = $('#search-task-form').searchForm({
|
||||
data: JSON.parse('{{json_encode($search["forms"])}}'),
|
||||
init:function(e) {
|
||||
var self = this;
|
||||
}
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var query = search.serializeArray();
|
||||
params.page = 1;
|
||||
grid.remoteData(params);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
function dataReload() {
|
||||
@@ -141,7 +96,6 @@ function dataReload() {
|
||||
}
|
||||
|
||||
function getTask(id) {
|
||||
console.log(grid.api.getRowNode(id));
|
||||
return grid.api.getRowNode(id);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,59 @@
|
||||
<script>
|
||||
(function($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var search = JSON.parse('{{json_encode($header["search_form"])}}');
|
||||
search.advanced = {};
|
||||
search.simple = {};
|
||||
search.advanced.el = $('#' + table + '-search-form-advanced').searchForm({
|
||||
data: search.forms,
|
||||
advanced: true
|
||||
});
|
||||
search.simple.el = $('#' + table + '-search-form').searchForm({
|
||||
data: search.forms
|
||||
});
|
||||
search.simple.el.find('#search-submit').on('click', function() {
|
||||
var query = search.simple.el.serializeArray();
|
||||
search.queryType = 'simple';
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
dataReload();
|
||||
return false;
|
||||
});
|
||||
|
||||
// 过滤数据
|
||||
var panel = $('#' + table + '-controller');
|
||||
panel.on('click', '[data-toggle="' + table + '"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'filter') {
|
||||
$(search.advanced.el).dialog({
|
||||
title: '高级搜索',
|
||||
modalClass: 'no-padder',
|
||||
buttons: [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text: "确定",
|
||||
'class': "btn-info",
|
||||
click: function() {
|
||||
var query = search.advanced.el.serializeArray();
|
||||
search.queryType = 'advanced';
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
dataReload();
|
||||
$(this).dialog("close");
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
function formsBox(title, url, id, success, remove, error)
|
||||
{
|
||||
var options = {
|
||||
@@ -11,7 +66,7 @@ function formsBox(title, url, id, success, remove, error)
|
||||
|
||||
if (typeof success === 'function') {
|
||||
options.buttons.push({
|
||||
text: '<i class="fa fa-check"></i> 提交',
|
||||
text: '<i class="fa fa-check"></i> 保存',
|
||||
class: 'btn-info',
|
||||
click: function() {
|
||||
var me = this;
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" id="mytaskform" name="mytaskform">
|
||||
<div class="panel m-b-none">
|
||||
|
||||
<table class="table table-form m-b-none">
|
||||
|
||||
<tr>
|
||||
<td align="right" width="15%">名称</td>
|
||||
<td align="left">
|
||||
<input type="text" name="name" id="name" value="{{$task['name']}}" class="form-control input-sm">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">列表</td>
|
||||
<td align="left">
|
||||
<select class="form-control input-inline input-sm" id="item_id" name="item_id">
|
||||
<option value="1">测试日程1_</option>
|
||||
<option value="2">abc123</option>
|
||||
<option value="408">一般事件</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">执行者</td>
|
||||
<td align="left">
|
||||
{{App\Support\Dialog::user('user','user_id', $task['user_id'], 0, 0)}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">参与者</td>
|
||||
<td align="left">
|
||||
{{App\Support\Dialog::user('user', 'users', $task['users'], 1, 0)}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">时间</td>
|
||||
<td align="left">
|
||||
<input type="text" name="start_at" autocomplete="off" data-toggle="datetime" value="@datetime($task->start_at,time())" id="start_at" class="form-control input-sm input-inline">
|
||||
-
|
||||
<input type="text" name="end_at" autocomplete="off" data-toggle="datetime" value="@datetime($task->end_at)" id="end_at" class="form-control input-sm input-inline">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">备注</td>
|
||||
<td>
|
||||
<textarea class="form-control" type="text" name="purchase_plan[remark]" id="remark" placeholder="暂无备注"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">附件</td>
|
||||
<td align="left">
|
||||
{{attachment_uploader('attachment', $task['attachment'])}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">子任务</td>
|
||||
<td>
|
||||
<a href="#" class="option"><i class="fa fa-fw fa-plus"></i>添加子任务</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">评论</td>
|
||||
<td>
|
||||
<a href="#" class="option"><i class="fa fa-fw fa-plus"></i>添加评论</a>
|
||||
<!--
|
||||
<textarea class="form-control" rows="2" type="text" name="comment" id="comment" placeholder="内容"></textarea>
|
||||
{{attachment_uploader('comment_attachment', '', false)}}
|
||||
<a href="#" class="btn btn-sm btn-success"> 提交</a>
|
||||
-->
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">活动</td>
|
||||
<td>
|
||||
<div class="project-task-log">
|
||||
@if($logs)
|
||||
@foreach($logs as $log)
|
||||
<p><span class="time">@datetime($log->created_at)</span>{{$log->description}}</p>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="{{$task->id}}">
|
||||
<input type="hidden" name="project_id" value="{{$project_id}}">
|
||||
|
||||
</form>
|
||||
@@ -297,7 +297,7 @@ class MaterialController extends DefaultController
|
||||
if ($image->move($upload_path, $filename)) {
|
||||
|
||||
// 修改图片大小
|
||||
imageResize($upload_path.'/'.$filename, 1024, 1024);
|
||||
image_resize($upload_path.'/'.$filename, 1024, 1024);
|
||||
|
||||
$rows[] = DB::table('promotion_material_file')->insertGetId([
|
||||
'material_id' => $material_id,
|
||||
|
||||
@@ -12,23 +12,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class MediaController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog', 'qrcode', 'create', 'delete', 'download', 'folder'];
|
||||
|
||||
/**
|
||||
* 二维码上传
|
||||
*/
|
||||
public function qrcode()
|
||||
{
|
||||
$key = Request::get('key');
|
||||
list($table, $field) = explode('.', $key);
|
||||
$model = DB::table('model')->where('table', $table)->first();
|
||||
$token = Request::get('x-auth-token');
|
||||
return $this->render([
|
||||
'model' => $model,
|
||||
'token' => $token,
|
||||
'key' => $key,
|
||||
], 'qrcode');
|
||||
}
|
||||
public $permission = ['dialog', 'create', 'delete', 'download', 'folder'];
|
||||
|
||||
public function create()
|
||||
{
|
||||
@@ -53,6 +37,7 @@ class MediaController extends DefaultController
|
||||
|
||||
$fileTypes = ['image/png', 'image/jpg', 'image/jpeg'];
|
||||
$mimeType = $file->getMimeType();
|
||||
$filesize = $file->getSize();
|
||||
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
$data = [
|
||||
@@ -60,13 +45,12 @@ class MediaController extends DefaultController
|
||||
'path' => $path.'/'.$filename,
|
||||
'type' => $extension,
|
||||
'folder_id' => $folderId,
|
||||
'size' => $file->getClientSize(),
|
||||
'size' => $filesize,
|
||||
];
|
||||
|
||||
if (in_array($mimeType, $fileTypes)) {
|
||||
thumb($upload_path.'/'.$filename, 420, 420);
|
||||
$path = pathinfo($path.'/'.$filename);
|
||||
$thumb = $path['dirname'].'/thumb-420-'.$path['basename'];
|
||||
$thumb = $path['dirname'].'/'.thumb($upload_path.'/'.$filename, 750);
|
||||
$data['thumb'] = $thumb;
|
||||
}
|
||||
|
||||
@@ -85,7 +69,7 @@ class MediaController extends DefaultController
|
||||
public function dialog()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$folder = Request::get('folder');
|
||||
$folder = Request::get('folder');
|
||||
$folderId = Request::get('folder_id');
|
||||
$userId = auth()->id();
|
||||
|
||||
@@ -103,9 +87,9 @@ class MediaController extends DefaultController
|
||||
if (in_array($row['type'], ['png', 'jpg', 'jpeg'])) {
|
||||
$file = $row['path'];
|
||||
$path = pathinfo($file);
|
||||
$thumb = $path['dirname'].'/thumb-420-'.$path['basename'];
|
||||
$thumb = $path['dirname'].'/t750_'.$path['basename'];
|
||||
if (!is_file(upload_path().'/'.$thumb)) {
|
||||
thumb(upload_path().'/'.$file, 420, 420);
|
||||
thumb(upload_path().'/'.$file, 750);
|
||||
}
|
||||
$row['path'] = $file;
|
||||
$row['thumb'] = $thumb;
|
||||
|
||||
@@ -10,6 +10,8 @@ use App\Illuminate\Database\MySqlConnection;
|
||||
use App\Illuminate\Database\SqlsrvConnection;
|
||||
use Illuminate\Database\Events\StatementPrepared;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
|
||||
use Event;
|
||||
use PDO;
|
||||
|
||||
@@ -47,6 +49,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Paginator::defaultView('vendor/pagination/gdoo');
|
||||
Event::listen(StatementPrepared::class, function ($event) {
|
||||
$event->statement->setFetchMode(\PDO::FETCH_ASSOC);
|
||||
});
|
||||
|
||||
@@ -135,7 +135,7 @@ class Image
|
||||
{
|
||||
// 原文件不存在
|
||||
if (!is_file($file)) {
|
||||
throw new Exception('原文件不存在。');
|
||||
throw new \Exception('原文件不存在。');
|
||||
}
|
||||
$temp = getimagesize($file);
|
||||
$this->srcw = $srcw = $temp[0];
|
||||
|
||||
+58
-241
@@ -488,256 +488,73 @@ function authorise($action = null, $asset_name = null)
|
||||
return Gdoo\User\Services\UserService::authorise($action, $asset_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件上传
|
||||
*/
|
||||
function attachment_uploader($field, $ids, $key, $draft = true)
|
||||
{
|
||||
$attachments = Gdoo\Index\Services\AttachmentService::edit($ids, $key . '.' . $field);
|
||||
if ($draft == false) {
|
||||
unset($attachments['draft']);
|
||||
}
|
||||
return view('attachment/create2', [
|
||||
'field' => $field,
|
||||
'key' => $key,
|
||||
'attachments' => $attachments,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件显示
|
||||
*/
|
||||
function attachment_show($field, $ids = '')
|
||||
{
|
||||
$attachments = Gdoo\Index\Services\AttachmentService::show($ids);
|
||||
return view('attachment/show2', [
|
||||
'attachments' => $attachments,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件编辑
|
||||
*/
|
||||
function attachment_edit($table, $id, $path = '')
|
||||
{
|
||||
$attach['model'] = $table;
|
||||
$attach['path'] = $path;
|
||||
$attach['draft'] = DB::table($table)->where('created_id', Auth::id())->where('status', 0)->get();
|
||||
|
||||
$id = array_filter(explode(',', $id));
|
||||
if ($id) {
|
||||
$queue = DB::table($table)->whereIn('id', $id)->where('status', 1)->get();
|
||||
}
|
||||
$attach['queue'] = array_by($queue);
|
||||
return $attach;
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件编辑
|
||||
*/
|
||||
function attachment_view($table, $id)
|
||||
{
|
||||
$attach['model'] = $table;
|
||||
$id = array_filter(explode(',', $id));
|
||||
if ($id) {
|
||||
$queue = DB::table($table)->whereIn('id', $id)->where('status', 1)->get();
|
||||
}
|
||||
$attach['view'] = array_by($queue);
|
||||
|
||||
return $attach;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询附件
|
||||
*/
|
||||
function attachment_get($table, $id)
|
||||
{
|
||||
$id = array_filter(explode(',', $id));
|
||||
if ($id) {
|
||||
return DB::table($table)->whereIn('id', $id)->get();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件删除
|
||||
*/
|
||||
function attachment_delete($table, $id)
|
||||
{
|
||||
if ($id) {
|
||||
$rows = DB::table($table)->whereIn('id', $id)->get();
|
||||
foreach ($rows as $row) {
|
||||
// 文件路径
|
||||
$name = $row['path'] == '' ? $row['name'] : $row['path'];
|
||||
$file = upload_path() . '/' . $name;
|
||||
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
// 旧版文件删除
|
||||
$old = upload_path() . '/' . $row['path'] . '/' . $row['name'];
|
||||
if (is_file($old)) {
|
||||
unlink($old);
|
||||
}
|
||||
|
||||
DB::table($table)->where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将草稿附件存储为可用
|
||||
*/
|
||||
function attachment_store($table, $id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ($id as $_id) {
|
||||
DB::table($table)->where('id', $_id)->update([
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
return join(',', array_filter($id));
|
||||
}
|
||||
|
||||
// 多图片base64上传保存
|
||||
function attachment_base64($table, $images, $path = 'default', $extension = 'jpg')
|
||||
{
|
||||
$path = $path . '/' . date('Y/m');
|
||||
$directory = upload_path() . '/' . $path;
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
@mkdir($directory, 0777, true);
|
||||
}
|
||||
|
||||
$res = [];
|
||||
|
||||
foreach ($images as $image) {
|
||||
$name = date('dhis_') . str_random(4) . '.' . $extension;
|
||||
$name = mb_strtolower($name);
|
||||
|
||||
$image = base64_decode(str_replace(' ', '+', $image));
|
||||
$size = file_put_contents($directory . '/' . $name, $image);
|
||||
if ($size) {
|
||||
$res[] = DB::table($table)->insertGetId([
|
||||
'path' => $path,
|
||||
'name' => $name,
|
||||
'title' => $name,
|
||||
'type' => $extension,
|
||||
'status' => 1,
|
||||
'size' => $size,
|
||||
'created_id' => Auth::id(),
|
||||
'created_at' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
return join(',', array_filter($res));
|
||||
}
|
||||
|
||||
// 多图片上传保存
|
||||
function attachment_images($table, $name, $path = 'default')
|
||||
{
|
||||
$images = Request::file($name);
|
||||
|
||||
$path = $path . '/' . date('Y/m');
|
||||
$upload_path = upload_path() . '/' . $path;
|
||||
|
||||
$res = [];
|
||||
|
||||
foreach ($images as $image) {
|
||||
if ($image->isValid()) {
|
||||
// 文件后缀名
|
||||
$extension = $image->getClientOriginalExtension();
|
||||
|
||||
// 兼容do开发的客户端上传
|
||||
if ($extension == 'do') {
|
||||
$clientName = $image->getClientOriginalName();
|
||||
$extension = pathinfo(substr($clientName, 0, -3), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
// 文件新名字
|
||||
$filename = date('dhis_') . str_random(4) . '.' . $extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
if ($image->move($upload_path, $filename)) {
|
||||
$res[] = DB::table($table)->insertGetId([
|
||||
'path' => $path,
|
||||
'name' => $filename,
|
||||
'title' => $filename,
|
||||
'type' => $extension,
|
||||
'status' => 1,
|
||||
'size' => $image->getClientSize(),
|
||||
'created_id' => Auth::id(),
|
||||
'created_at' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return join(',', array_filter($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 单图片上传,并删除旧图片
|
||||
*/
|
||||
function image_create($path, $name = 'image', $oldfile = '')
|
||||
{
|
||||
if (Request::hasFile($name)) {
|
||||
$file = Request::file($name);
|
||||
|
||||
// 文件后缀名
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
|
||||
// 文件新名字
|
||||
$filename = date('dhis_') . str_random(4) . '.' . $extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
|
||||
$path = $path . '/' . date('Y/m');
|
||||
|
||||
$upload_path = upload_path() . '/' . $path;
|
||||
|
||||
if ($file->move($upload_path, $filename)) {
|
||||
// 上传成功删除旧文件
|
||||
if ($oldfile) {
|
||||
image_delete($oldfile);
|
||||
}
|
||||
return $path . '/' . $filename;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个图片
|
||||
*/
|
||||
function image_delete($file)
|
||||
{
|
||||
$file = upload_path() . '/' . $file;
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成缩略图
|
||||
*/
|
||||
function thumb($file, $width, $hight)
|
||||
function image_thumb($file, $width = 750)
|
||||
{
|
||||
$info = pathinfo($file);
|
||||
$thumb = $info['dirname'] . '/thumb-' . $width . '-' . $info['basename'];
|
||||
$thumb = $info['dirname'] . '/t' . $width . '_' . $info['basename'];
|
||||
if (is_file($thumb)) {
|
||||
return 'thumb-' . $width . '-' . $info['basename'];
|
||||
return 't' . $width . '_' . $info['basename'];
|
||||
}
|
||||
|
||||
$img = new App\Support\Image();
|
||||
if (is_file($file)) {
|
||||
$img->crop($file, $width, $hight, 3, true);
|
||||
$img->save($thumb);
|
||||
$temp = getimagesize($file);
|
||||
$srcw = $temp[0];
|
||||
$srch = $temp[1];
|
||||
$type = $temp[2];
|
||||
|
||||
if ($srcw > $width) {
|
||||
// 1=gif 2=jpg 3=png
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$image = imagecreatefromgif($file);
|
||||
break;
|
||||
case 2:
|
||||
$image = imagecreatefromjpeg($file);
|
||||
break;
|
||||
case 3:
|
||||
$image = imagecreatefrompng($file);
|
||||
break;
|
||||
}
|
||||
|
||||
if (function_exists('imageantialias')) {
|
||||
imageantialias($image, true);
|
||||
}
|
||||
|
||||
// 计算绽放比例
|
||||
$rate = $width / $srcw;
|
||||
// 计算出缩放后的高度
|
||||
$height = floor($srch * $rate);
|
||||
// 创建一个缩放的画布
|
||||
$dest = imagecreatetruecolor($width, $height);
|
||||
|
||||
// 处理png透明
|
||||
imagealphablending($dest, false);
|
||||
imagesavealpha($dest, true);
|
||||
|
||||
// 缩放
|
||||
imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcw, $srch);
|
||||
|
||||
switch ($type) {
|
||||
case 1:
|
||||
imagegif($dest, $thumb);
|
||||
break;
|
||||
case 2:
|
||||
imagejpeg($dest, $thumb, 75);
|
||||
break;
|
||||
case 3:
|
||||
imagepng($dest, $thumb);
|
||||
break;
|
||||
}
|
||||
if ($image) {
|
||||
imagedestroy($image);
|
||||
}
|
||||
return 't' . $width . '_' . $info['basename'];
|
||||
}
|
||||
return $info['basename'];
|
||||
}
|
||||
return 'thumb-' . $width . '-' . $info['basename'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -746,7 +563,7 @@ function thumb($file, $width, $hight)
|
||||
* $dst_w:目标输出的宽
|
||||
* $dst_h:目标输出的高
|
||||
*/
|
||||
function imageResize($src_file, $dst_w, $dst_h)
|
||||
function image_resize($src_file, $dst_w, $dst_h)
|
||||
{
|
||||
# 获取图片信息
|
||||
$imarr = getimagesize($src_file);
|
||||
|
||||
Reference in New Issue
Block a user