创建版本

This commit is contained in:
2021-02-22 12:17:00 +08:00
commit af555f49c3
2332 changed files with 369202 additions and 0 deletions
@@ -0,0 +1,201 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Form;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
class LogController extends DefaultController
{
public $permission = [];
/**
* 系统日志
*/
public function indexAction()
{
$header = [
'master_name' => '系统日志',
'simple_search_form' => 1,
'table' => 'system_log',
'master_table' => 'system_log',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'mail.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'type' => [
'field' => 'type',
'headerName' => '类型',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 100,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'user' => [
'field' => 'remark',
'headerName' => '备注',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 0,
],
'created_dt' => [
'field' => 'created_dt',
'headerName' => '操作时间',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'ip' => [
'field' => 'ip',
'headerName' => 'IP',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'browser' => [
'field' => 'browser',
'headerName' => '浏览器',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'device' => [
'field' => 'device',
'headerName' => '设备ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
/*
'error_count' => [
'field' => 'error_count',
'headerName' => '错误次数',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
*/
'level' => [
'field' => 'level',
'headerName' => '等级',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->orderBy('id', 'desc');
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
if ($row['status'] == 1) {
$row['status_name'] = '启用';
} else {
$row['status_name'] = '禁用';
}
return $row;
});
return $rows->toJson();
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
}
/**
* 删除
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
DB::table('system_log')->whereIn('id', $id)->delete();
return $this->json('操作完成。', true);
}
}
}
@@ -0,0 +1,257 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Form;
use Gdoo\Model\Grid;
use Gdoo\Index\Services\NotificationService;
use Gdoo\Index\Controllers\DefaultController;
class MailController extends DefaultController
{
public $permission = ['test'];
/**
* 邮件设置
*/
public function indexAction()
{
$header = [
'master_name' => '邮件',
'simple_search_form' => 1,
'table' => 'mail',
'master_table' => 'mail',
'create_btn' => 0,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'mail.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-',
'form_type' => 'text',
'width' => 0,
],
'user' => [
'field' => 'user',
'headerName' => '邮箱帐号',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'smtp' => [
'field' => 'smtp',
'headerName' => 'SMTP服务器',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'port' => [
'field' => 'port',
'headerName' => '服务器端口',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'status_name' => [
'field' => 'status_name',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'sort' => [
'field' => 'sort',
'headerName' => '排序',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 80,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
if ($row['status'] == 1) {
$row['status_name'] = '启用';
} else {
$row['status_name'] = '禁用';
}
return $row;
});
return $rows->toJson();
}
$header['buttons'] = [
//['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['left_buttons'] = [
['name' => '测试邮件', 'color' => 'default', 'icon' => 'fa-envelope-o', 'action' => 'test', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
}
// 新建邮箱帐号
public function createAction()
{
return $this->editAction();
}
// 编辑邮箱帐号
public function editAction()
{
$id = (int)Request::get('id');
$row = DB::table('mail')->where('id', $id)->first();
return $this->render([
'row' => $row,
], 'edit');
}
/**
* 保存
*/
public function storeAction()
{
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'smtp' => 'required',
'user' => 'required',
'password' => 'required',
'port' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->json(join('<br>', $v->errors()->all()));
}
if ($gets['id']) {
DB::table('mail')->where('id', $gets['id'])->update($gets);
} else {
DB::table('mail')->insert($gets);
}
return $this->json('恭喜你,操作成功。', true);
}
}
/**
* 删除
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
DB::table('mail')->whereIn('id', $id)->delete();
return $this->json('操作完成。', true);
}
}
/**
* 邮件测试
*/
public function testAction()
{
$mail_to = Request::get('mail_to');
if (Request::method() == 'POST') {
$send = NotificationService::mail('notification', [$mail_to], '测试邮件', '测试邮件内容');
if ($send) {
return $this->json('测试邮件已发送。', true);
} else {
return $this->json('发送失败,请检查邮件地址或SMTP配置。');
}
}
return $this->render([
'mail_to' => $mail_to
]);
}
}
@@ -0,0 +1,172 @@
<?php namespace Gdoo\System\Controllers;
use Session;
use Request;
use Validator;
use DB;
use Gdoo\System\Models\Media;
use Gdoo\Index\Controllers\DefaultController;
class MediaController extends DefaultController
{
public $permission = ['dialog', 'qrcode', 'create', 'delete', 'download', 'folder'];
/**
* 二维码上传
*/
public function qrcodeAction()
{
$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 function createAction()
{
$folderId = Request::get('folder_id');
$file = Request::file('Filedata');
$rules = [
'file' => 'mimes:'.$this->setting['upload_type'],
];
$v = Validator::make(['file' => $file], $rules);
if ($file->isValid() && $v->passes()) {
// 获取上传uri第一个目录
$path = 'media/'.date('Y/m');
$upload_path = upload_path().'/'.$path;
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 文件新名字
$filename = date('dhis_').str_random(4).'.'.$extension;
$filename = mb_strtolower($filename);
$fileTypes = ['image/png', 'image/jpg', 'image/jpeg'];
$mimeType = $file->getMimeType();
if ($file->move($upload_path, $filename)) {
$data = [
'name' => mb_strtolower($file->getClientOriginalName()),
'path' => $path.'/'.$filename,
'type' => $extension,
'folder_id' => $folderId,
'size' => $file->getClientSize(),
];
if (in_array($mimeType, $fileTypes)) {
thumb($upload_path.'/'.$filename, 420, 420);
$path = pathinfo($path.'/'.$filename);
$thumb = $path['dirname'].'/thumb-420-'.$path['basename'];
$data['thumb'] = $thumb;
}
$id = Media::insertGetId($data);
if ($id) {
$data['id'] = $id;
return $this->json($data, true);
} else {
return $this->json('文件上传失败');
}
}
}
return $this->json('文件上传失败');
}
/**
* 文件对话框
*/
public function dialogAction()
{
if (Request::method() == 'POST') {
$folder = Request::get('folder');
$folderId = Request::get('folder_id');
$userId = auth()->id();
$model = Media::where('created_id', $userId);
if ($folder == 1) {
$model->whereRaw('folder = 1');
} else {
$model->whereRaw('isnull(folder, 0) = 0');
if ($folderId) {
$model->where('folder_id', $folderId);
}
}
$rows = $model->orderBy('id', 'desc')->get()->toArray();
foreach($rows as &$row) {
if (in_array($row['type'], ['png', 'jpg', 'jpeg'])) {
$file = $row['path'];
$path = pathinfo($file);
$thumb = $path['dirname'].'/thumb-420-'.$path['basename'];
if (!is_file(upload_path().'/'.$thumb)) {
thumb(upload_path().'/'.$file, 420, 420);
}
$row['path'] = $file;
$row['thumb'] = $thumb;
}
}
return $this->json($rows, true);
}
return $this->render();
}
/**
* 新建文件夹
*/
public function folderAction()
{
if (Request::method() == 'POST') {
$gets = Request::all();
$gets['folder'] = 1;
Media::insertGetId($gets);
return $this->json('操作成功', true);
}
return $this->render();
}
/**
* 下载文件
*/
public function downloadAction()
{
$id = Request::get('id');
if ($id) {
$row = Media::where('id', $id)->first();
$path = upload_path().'/'.$row['path'];
return response()->download($path, $row['name']);
}
}
/**
* 删除文件
*/
public function deleteAction()
{
$id = (array)Request::get('id');
if (empty($id)) {
return $this->json('删除失败');
}
$rows = Media::whereIn('id', $id)->get();
foreach ($rows as $row) {
$file = upload_path().'/'.$row['path'];
if (is_file($file)) {
unlink($file);
}
}
Media::whereIn('id', $id)->delete();
return $this->json('删除成功', true);
}
}
@@ -0,0 +1,287 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\System\Models\Menu;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
class MenuController extends DefaultController
{
// 菜单列表
public function indexAction()
{
$header = [
'master_name' => '模型',
'simple_search_form' => 1,
'table' => 'menu',
'master_table' => 'menu',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'menu.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'text' => [
'field' => 'text',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 100,
],
'url' => [
'field' => 'url',
'headerName' => 'URL',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 0,
],
'access' => [
'field' => 'access',
'headerName' => '认证',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'sort' => [
'field' => 'sort',
'headerName' => '排序',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'status_name' => [
'field' => 'status_name',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'width' => 120,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 100,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = Menu::setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->orderBy('lft', 'asc');
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
$row['access'] = $row['access'] == 1 ? '是' : '否';
if ($row['status'] == 1) {
$row['status_name'] = '启用';
} else {
$row['status_name'] = '禁用';
}
return $row;
});
$items = $rows->items();
array_nest($items);
$rows->items($items);
return $rows;
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
/*
if (Request::method() == 'POST') {
$sorts = Request::get('sort');
foreach ($sorts as $id => $sort) {
DB::table('menu')->where('id', $id)->update(['sort' => $sort]);
}
tree_rebuild('menu');
return $this->success('index', '恭喜你,操作成功。');
}
$search = search_form([
'referer' => 1,
], []);
$rows = DB::table('menu')
->orderBy('lft', 'asc')
->get();
*/
/*
$rows = DB::table('dict')->get();
foreach ($rows as $key => $row) {
$values = json_decode($row['value'], true);
//$data['parent_id'] = $row['id'];
$id = DB::table('option')->insertGetId([
'parent_id' => 0,
'name' => $row['name'],
'value' => $row['key'],
]);
$data = [];
$data['parent_id'] = $id;
if($values) {
foreach ($values as $k => $v) {
$data['sort'] = $k;
$data['value'] = ''.$v['id'].'';
$data['name'] = ''.$v['name'].'';
DB::table('option')->insert($data);
}
}
}
print_r($rows);
exit;
*/
//$rows = array_nest($rows);
/*
return $this->display([
'rows' => $rows,
]);
*/
}
// 新建菜单
public function createAction()
{
$id = (int)Request::get('id');
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->back()->withErrors($v)->withInput();
}
if ($gets['id']) {
DB::table('menu')->where('id', $gets['id'])->update($gets);
} else {
DB::table('menu')->insert($gets);
}
tree_rebuild('menu');
return $this->json('恭喜你,操作成功。', true);
}
$row = DB::table('menu')->where('id', $id)->first();
$parents = DB::table('menu')->orderBy('lft', 'asc')->get();
$parents = array_nest($parents);
return $this->render([
'row' => $row,
'parents' => $parents,
], 'create');
}
public function editAction() {
return $this->createAction();
}
public function storeAction()
{
return $this->editAction();
}
// 删除菜单
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
$count = DB::table('menu')->whereIn('parent_id', $id)->count();
if ($count) {
return $this->json('存在子菜单无法删除。');
}
DB::table('menu')->whereIn('id', $id)->delete();
return $this->json('删除成功。', true);
}
}
}
@@ -0,0 +1,230 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\System\Models\Option;
use Gdoo\Index\Controllers\DefaultController;
class OptionController extends DefaultController
{
public $permission = ['category'];
// 枚举列表
public function indexAction()
{
$header = [
'master_name' => '枚举',
'simple_search_form' => 1,
'table' => 'option',
'master_table' => 'option',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
'parent_id' => 0,
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'option.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-',
'form_type' => 'text',
'width' => 0,
],
'value' => [
'field' => 'value',
'headerName' => '值',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'status_name' => [
'field' => 'status_name',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'sort' => [
'field' => 'sort',
'headerName' => '排序',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 80,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->where('option.parent_id', $query['parent_id']);
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
if ($row['status'] == 1) {
$row['status_name'] = '启用';
} else {
$row['status_name'] = '禁用';
}
return $row;
});
return $rows->toJson();
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
}
public function editAction()
{
return $this->createAction();
}
// 新建字典
public function createAction()
{
$id = (int)Request::get('id');
$row = DB::table('option')->where('id', $id)->first();
$parent_id = (int)Request::get('parent_id');
$parents = Option::where('parent_id', 0)->orderBy('sort', 'asc')->orderBy('id', 'asc')->get();
return $this->render([
'row' => $row,
'parents' => $parents,
'parent_id' => $parent_id,
], 'edit');
}
/**
* 保存
*/
public function storeAction()
{
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'value' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->back()->withErrors($v)->withInput();
}
if ($gets['id']) {
DB::table('option')->where('id', $gets['id'])->update($gets);
} else {
DB::table('option')->insert($gets);
}
return $this->json('恭喜你,操作成功。', true);
}
}
public function categoryAction()
{
if (Request::method() == 'POST') {
$rows = Option::where('parent_id', 0)->orderBy('sort', 'asc')->orderBy('id', 'asc')->get();
$rows->prepend(['name' => '全部类别', 'id' => 0, 'parent_id' => 0]);
return response()->json(['data' => $rows]);
}
}
// 删除字典
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
$count = DB::table('option')->whereIn('parent_id', $id)->count();
if ($count > 0) {
return $this->error('存在子选项无法删除。');
}
DB::table('option')->whereIn('id', $id)->delete();
return $this->back('删除成功。');
}
}
}
@@ -0,0 +1,151 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\Model\Form;
use Gdoo\System\Models\Region;
use Gdoo\Index\Controllers\DefaultController;
class RegionController extends DefaultController
{
public $permission = ['dialog', 'category'];
public function indexAction()
{
$header = Grid::header([
'code' => 'region',
'referer' => 1,
'search' => ['by' => '', 'parent_id' => 0],
'trash_btn' => 0,
]);
$cols = $header['cols'];
$cols['actions']['options'] = [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]];
$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->where('region.parent_id', $query['parent_id']);
$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);
return $items->toJson();
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['cols'] = $cols;
$header['tabs'] = Region::$tabs;
$header['bys'] = Region::$bys;
$header['js'] = Grid::js($header);
return $this->display([
'header' => $header,
]);
}
// 新建客户联系人
public function createAction()
{
$id = (int)Request::get('id');
$form = Form::make(['code' => 'region', 'id' => $id]);
return $this->render([
'form' => $form,
], 'create');
}
// 创建客户联系人
public function editAction()
{
return $this->createAction();
}
public function dialogAction()
{
$search = search_form([], [
['text','region.name','名称'],
['text','region.id','ID'],
]);
if (Request::method() == 'POST') {
$model = Region::orderBy('id', 'asc');
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$rows = $model->get(['*', 'name as text']);
$rows = array_nest($rows);
$json = [];
foreach($rows as $row) {
$row['text'] = $row['layer_space'].$row['name'];
$json[] = $row;
}
return response()->json(['data' => $json]);
}
return $this->render([
'search' => $search,
'query' => $search['query']
]);
}
public function categoryAction()
{
if (Request::method() == 'POST') {
$model = Region::orderBy('id', 'asc');
$rows = $model->get(['*', 'name as text']);
array_nest($rows);
return response()->json(['data' => $rows]);
}
}
// 删除
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
$id = array_filter((array)$id);
if (empty($id)) {
return $this->json('最少选择一行记录。');
}
$types = Region::whereIn('id', $id)->get();
foreach ($types as $type) {
// 删除数据
$type->delete();
}
return $this->json('恭喜你,操作成功。', url_referer('index'));
}
}
}
@@ -0,0 +1,272 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\System\Models\Setting;
use Gdoo\Index\Models\Notification;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
class SettingController extends DefaultController
{
/**
* 基本设置
*/
public function indexAction()
{
$header = [
'master_name' => '系统设置',
'simple_search_form' => 1,
'table' => 'setting',
'master_table' => 'setting',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '配置名称', 'field' => 'setting.name', 'value' => '', 'options' => []],
], 'model');
$query = $search['query'];
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'key' => [
'field' => 'key',
'headerName' => 'Key',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'value' => [
'field' => 'value',
'headerName' => '值',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 260,
],
'type' => [
'field' => 'type',
'headerName' => '类型',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'remark' => [
'field' => 'remark',
'headerName' => '备注',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 120,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 80,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
return $rows->toJson();
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
return $this->display();
}
// 新建邮箱帐号
public function createAction()
{
return $this->editAction();
}
// 编辑邮箱帐号
public function editAction()
{
$id = (int)Request::get('id');
$row = DB::table('setting')->where('id', $id)->first();
return $this->render([
'row' => $row,
], 'edit');
}
/**
* 上传设置
*/
public function uploadAction()
{
// 扫描字体目录
$paths = new \DirectoryIterator(public_path('assets/fonts'));
$fonts = [];
foreach ($paths as $file) {
if ($file->isFile()) {
$fonts[] = $file->getFilename();
}
}
return $this->display([
'fonts' => $fonts,
]);
}
/**
* 图片设置
*/
public function imageAction()
{
// 扫描字体目录
$paths = new \DirectoryIterator(public_path('assets/fonts'));
$fonts = [];
foreach ($paths as $file) {
if ($file->isFile()) {
$fonts[] = $file->getFilename();
}
}
return $this->display([
'fonts' => $fonts,
]);
}
/**
* 安全设置
*/
public function securityAction()
{
return $this->display();
}
/**
* 日期时间
*/
public function datetimeAction()
{
$lang = trans('setting');
return $this->display(array(
'lang' => $lang,
));
}
/**
* 保存
*/
public function storeAction()
{
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'key' => 'required',
'type' => 'required',
'value' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->json(join('<br>', $v->errors()->all()));
}
if ($gets['id']) {
DB::table('setting')->where('id', $gets['id'])->update($gets);
} else {
DB::table('setting')->insert($gets);
}
return $this->json('恭喜你,操作成功。', true);
}
}
/**
* 删除
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
DB::table('setting')->whereIn('id', $id)->delete();
return $this->json('删除成功。', true);
}
}
}
@@ -0,0 +1,243 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\Index\Services\NotificationService;
use Gdoo\Index\Controllers\DefaultController;
class SmsController extends DefaultController
{
public $permission = ['test'];
/**
* 短信设置
*/
public function indexAction()
{
$header = [
'master_name' => '短信',
'simple_search_form' => 1,
'table' => 'sms',
'master_table' => 'sms',
'create_btn' => 0,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'sms.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-',
'form_type' => 'text',
'width' => 120,
],
'apikey' => [
'field' => 'apikey',
'headerName' => 'apikey',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 0,
],
'driver' => [
'field' => 'driver',
'headerName' => '服务商',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'status_name' => [
'field' => 'status_name',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'sort' => [
'field' => 'sort',
'headerName' => '排序',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 120,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 80,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
if ($row['status'] == 1) {
$row['status_name'] = '启用';
} else {
$row['status_name'] = '禁用';
}
return $row;
});
return $rows->toJson();
}
$header['buttons'] = [
//['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['left_buttons'] = [
['name' => '测试短信', 'color' => 'default', 'icon' => 'fa-comment-o', 'action' => 'test', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
}
/**
* 短信保存
*/
public function storeAction()
{
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'apikey' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->json(join('<br>', $v->errors()->all()));
}
if ($gets['id']) {
DB::table('sms')->where('id', $gets['id'])->update($gets);
} else {
DB::table('sms')->insert($gets);
}
return $this->json('恭喜你,操作成功。', true);
}
}
// 新建短信帐号
public function createAction()
{
return $this->editAction();
}
// 编辑短信帐号
public function editAction()
{
$id = (int)Request::get('id');
$row = DB::table('sms')->where('id', $id)->first();
return $this->render([
'row' => $row,
], 'edit');
}
/**
* 删除
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
DB::table('sms')->whereIn('id', $id)->delete();
return $this->json('删除成功。', true);
}
}
/**
* 短信测试
*/
public function testAction()
{
$phone = Request::get('phone');
if (Request::method() == 'POST') {
$send = NotificationService::sms([$phone], '测试短信', '测试短信内容');
if ($send) {
return $this->json('测试短信已发送。', true);
} else {
return $this->json('发送失败,请检查短信配置。');
}
}
return $this->render([
'phone' => $phone
]);
}
}
@@ -0,0 +1,161 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
class SmsLogController extends DefaultController
{
public $permission = [];
/**
* 短信设置
*/
public function indexAction()
{
$header = [
'master_name' => '短信记录',
'simple_search_form' => 1,
'table' => 'sms_log',
'master_table' => 'sms_log',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'sms.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '服务商',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'content' => [
'field' => 'content',
'headerName' => '内容',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 120,
],
'data' => [
'field' => 'data',
'headerName' => '数据',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 0,
],
'phone' => [
'field' => 'phone',
'headerName' => '手机号',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'status_name' => [
'field' => 'status_name',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'width' => 80,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table($header['table'])->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->orderBy('id', 'desc');
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
if ($row['status'] == 1) {
$row['status_name'] = '成功';
} else {
$row['status_name'] = '失败';
}
return $row;
});
return $rows->toJson();
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
// 配置权限
return $this->display([
'header' => $header,
]);
}
/**
* 删除
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
DB::table('sms_log')->whereIn('id', $id)->delete();
return $this->json('删除成功。', true);
}
}
}
@@ -0,0 +1,302 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
use Gdoo\Model\Services\ModuleService;
use Gdoo\System\Models\Widget;
class WidgetController extends DefaultController
{
public $permission = ['refresh'];
/**
* 部件设置
*/
public function indexAction()
{
$header = [
'master_name' => '部件',
'simple_search_form' => 1,
'table' => 'widget',
'master_table' => 'widget',
'create_btn' => 1,
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'widget.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'sequence_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'code' => [
'field' => 'code',
'headerName' => '编码',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'url' => [
'field' => 'url',
'headerName' => 'URL',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 120,
],
'more_url' => [
'field' => 'more_url',
'headerName' => 'MoreURL',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 120,
],
'receive_name' => [
'field' => 'receive_name',
'headerName' => '授权范围',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'width' => 0,
],
'receive_name' => [
'field' => 'receive_name',
'headerName' => '授权范围',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'width' => 0,
],
'grid' => [
'field' => 'grid',
'headerName' => '位置',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'type' => [
'field' => 'type',
'headerName' => '类型',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'width' => 60,
],
'default' => [
'field' => 'default',
'headerName' => '全局',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'width' => 60,
],
'status' => [
'field' => 'status',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 60,
],
'sort' => [
'field' => 'sort',
'headerName' => '排序',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 60,
],
'updated_dt' => [
'field' => 'updated_dt',
'headerName' => '操作时间',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 100,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$query = $search['query'];
if (Request::method() == 'POST') {
$model = DB::table('widget')->setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->orderBy('sort', 'asc');
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
$row['type'] = $row['type'] == 1 ? '部件' : '信息';
$row['default'] = $row['default'] == 1 ? '是' : '否';
$row['status'] = $row['status'] == 1 ? '启用' : '禁用';
$row['grid'] = $row['grid'] == 8 ? '左' : '右';
$row['updated_dt'] = format_datetime($row['updated_at']);
return $row;
});
return $rows;
}
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['left_buttons'] = [
['name' => '更新', 'color' => 'default', 'icon' => 'fa-refresh', 'action' => 'refresh', 'display' => 1],
];
$header['search_form'] = $search;
$header['js'] = Grid::js($header);
return $this->display([
'header' => $header,
]);
}
// 新建部件
public function createAction()
{
$id = (int)Request::get('id');
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'url' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->json($v->errors()->first());
}
if ($gets['id']) {
DB::table('widget')->where('id', $gets['id'])->update($gets);
} else {
DB::table('widget')->insert($gets);
}
return $this->json('恭喜你,操作成功。', true);
}
$row = DB::table('widget')->where('id', $id)->first();
return $this->render([
'row' => $row
], 'create');
}
// 编辑部件
public function editAction()
{
return $this->createAction();
}
public function storeAction()
{
return $this->editAction();
}
/**
* 删除部件
*/
public function deleteAction()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
Widget::whereIn('id', $id)->delete();
return $this->json('恭喜你,操作成功。', true);
}
}
/**
* 更新部件列表
*/
public function refreshAction()
{
if (Request::method() == 'POST') {
$widgets = ModuleService::widgets();
foreach($widgets as $code => $widget) {
$model = Widget::firstOrNew(['code' => $code]);
$model->fill($widget);
$model->save();
}
return $this->json('部件刷新完成。', true);
}
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Media extends BaseModel
{
protected $table = 'media';
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Menu extends BaseModel
{
protected $table = 'menu';
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Option extends BaseModel
{
protected $table = 'option';
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Region extends BaseModel
{
protected $table = 'region';
public static $tabs = [
'name' => 'tab',
'items' => [
['value' => 'region', 'url' => 'system/region/index', 'name' => '城市档案'],
]
];
static public $bys = [
'name' => 'by',
'items' => [
['value' => '', 'name' => '全部'],
['value' => 'divider'],
['value' => 'day', 'name' => '今日创建'],
['value' => 'week', 'name' => '本周创建'],
['value' => 'month', 'name' => '本月创建'],
]
];
public function scopeDialog($q, $value)
{
return $q->whereIn('id', $value)->pluck('name', 'id');
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Setting extends BaseModel
{
protected $table = 'setting';
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class SystemLog extends BaseModel
{
protected $table = 'system_log';
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Widget extends BaseModel
{
protected $table = 'widget';
}
+160
View File
@@ -0,0 +1,160 @@
<?php namespace Gdoo\System\Services;
use DB;
class SmsService
{
public static $apikey = '';
public static $sign = '';
public static $driver = '';
public static function init()
{
$ch = curl_init();
/* 设置验证方式 */
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8'));
/* 设置返回结果为流 */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* 设置超时时间*/
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
/* 设置通信方式 */
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$sms = DB::table('sms')->where('status', 1)->first();
static::$apikey = $sms['apikey'];
static::$sign = $sms['name'];
static::$driver = $sms['driver'];
return $ch;
}
// 发送信息
public static function send($mobile, $text)
{
// 过滤
$text = static::replaceWords($text);
$ch = static::init();
if (empty(static::$apikey)) {
return ['code' => -1, 'msg' => '短信发送失败,请检查短信配置。'];
}
$data = array(
'apikey' => static::$apikey,
'text' => static::$sign.$text,
'mobile' => $mobile
);
if (static::$driver == 'gdoo') {
$api = 'http://crm.gdoooa.com/core/api/sms_send';
} else if (static::$driver == 'yunpian') {
$api = 'https://sms.yunpian.com/v2/sms/batch_send.json';
}
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$json = curl_exec($ch);
$res = json_decode($json, true);
return $res;
}
// 查询过滤词
public static function getBlackWord($text)
{
$ch = static::init();
curl_setopt($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/sms/get_black_word.json');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('text' => $text, 'apikey' => static::$apikey)));
$json = curl_exec($ch);
$res = json_decode($json, true);
return $res;
}
// 过滤短信关键词
public static function replaceWords($text)
{
// 替换括号
$search = ['【','】','[',']'];
$replace = ['(',')','(',')'];
/*
// 营运商已经关闭屏蔽词过滤
$blacks = file_get_contents(base_path('resources/black.txt'));
$words = explode("\n", $blacks);
foreach($words as $word) {
$word = trim($word);
if(strpos($text, $word) !== false) {
$len = mb_strlen($word);
$a = mb_substr($word, 0, 1, 'utf8');
$b = mb_substr($word, 1, $len, 'utf8');
$search[] = $word;
$replace[] = $a." ".$b; //\xe2\x80\x8b
}
}
*/
return str_replace($search, $replace, $text);
}
// 获取短信模板
public static function getTpl($id)
{
$ch = static::init();
curl_setopt($ch, CURLOPT_URL, 'http://crm.gdoooa.com/core/api/sms_tpl');
$query = [
'apikey' => static::$apikey,
'tpl_id' => $id
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
$json = curl_exec($ch);
$res = json_decode($json, true);
$res['tpl_content'] = str_replace(static::$sign, '', $res['tpl_content']);
return $res;
}
// 模板方式发送
public static function tplSend($mobile, $text)
{
$ch = static::init();
// $tpl = ('#code#').'='.urlencode('1234').'&'.urlencode('#company#').'='.urlencode('欢乐行');
$data = array(
'apikey' => static::$apikey,
'tpl_id' => '1',
'tpl_value' => $tpl,
'mobile' => $mobile
);
curl_setopt($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/sms/tpl_single_send.json');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$json = curl_exec($ch);
$res = json_decode($json, true);
return $res;
}
// 语音发送
public static function voiceSend($mobile, $text)
{
$ch = static::init();
curl_setopt($ch, CURLOPT_URL, 'http://voice.yunpian.com/v2/voice/send.json');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
return curl_exec($ch);
}
// 获取用户数据
public static function getUser()
{
$ch = static::init();
curl_setopt($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/user/get.json');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('apikey' => static::$apikey)));
$json = curl_exec($ch);
$res = json_decode($json, true);
return $res;
}
}
+170
View File
@@ -0,0 +1,170 @@
<?php
return [
"name" => "系统配置",
"version" => "1.0",
"description" => "系统模块",
'dialogs' => [
'region' => [
'name' => '行政区域',
'model' => 'Gdoo\System\Region::Dialog',
'url' => 'system/region/dialog',
],
],
"controllers" => [
"setting" => [
"name" => "基础设置",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"store" => [
"name" => "存储"
],
"delete" => [
"name" => "删除"
]
]
],
"mail" => [
"name" => "邮件管理",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"store" => [
"name" => "存储"
],
"delete" => [
"name" => "删除"
]
]
],
"region" => [
"name" => "城市档案",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"delete" => [
"name" => "删除"
]
]
],
"sms" => [
"name" => "短信管理",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"store" => [
"name" => "存储"
],
"delete" => [
"name" => "删除"
],
]
],
"smsLog" => [
"name" => "邮件记录",
"actions" => [
"index" => [
"name" => "列表"
],
"delete" => [
"name" => "删除"
]
]
],
"log" => [
"name" => "系统记录",
"actions" => [
"index" => [
"name" => "列表"
],
"delete" => [
"name" => "删除"
]
]
],
"menu" => [
"name" => "菜单管理",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"delete" => [
"name" => "删除"
]
]
],
"widget" => [
"name" => "部件管理",
"actions" => [
"index" => [
"name" => "列表"
],
/*
"create" => [
"name" => "新建"
],
*/
"edit" => [
"name" => "编辑"
],
"delete" => [
"name" => "删除"
]
]
],
"option" => [
"name" => "枚举管理",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"store" => [
"name" => "存储"
],
"delete" => [
"name" => "删除"
]
]
]
]
];
+59
View File
@@ -0,0 +1,59 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.show(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
+60
View File
@@ -0,0 +1,60 @@
<form method="post" class="form-horizontal" action="{{url('store')}}" id="mail" name="mail">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="10%">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">邮箱帐号</td>
<td align="left">
<input class="form-control input-sm" type="text" name="user" value="{{$row['user']}}">
</td>
</tr>
<tr>
<td align="right">邮箱密码</td>
<td align="left">
<input class="form-control input-sm" type="text" name="password" value="{{$row['password']}}">
</td>
</tr>
<tr>
<td align="right">SMTP服务器</td>
<td align="left">
<input class="form-control input-sm" type="text" name="smtp" value="{{$row['smtp']}}">
</td>
</tr>
<tr>
<td align="right">服务器端口</td>
<td align="left">
<input class="form-control input-sm" type="text" name="port" value="{{$row['port']}}">
</td>
</tr>
<tr>
<td align="right">连接方式</td>
<td align="left">
<select class="form-control input-sm" name="secure" id="secure">
<option value="" @if($row['secure'] == '') selected @endif>默认</option>
<option value="ssl" @if($row['secure'] == 'ssl') selected @endif>ssl</option>
</select>
</td>
</tr>
<tr>
<td align="right">状态</td>
<td align="left">
<select class="form-control input-sm" name="status" id="status">
<option value="1" @if($row['status'] == '1') selected @endif>启用</option>
<option value="0" @if($row['status'] == '0') selected @endif>停用</option>
</select>
</td>
</tr>
<tr>
<td align="right">排序</td>
<td align="left">
<input class="form-control input-sm" type="text" name="sort" value="{{$row['sort']}}">
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
@@ -0,0 +1,83 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
action.test = function() {
var me = this;
var grid = config.grid;
var rows = grid.api.getSelectedRows();
if (rows.length == 1) {
formDialog({
title: '测试邮件',
url: app.url('system/mail/test', {id: rows[0].id}),
storeUrl: app.url('system/mail/test'),
id: 'mail_test',
dialogClass:'modal-sm',
success: function(res) {
toastrSuccess(res.data);
$(this).dialog("close");
},
error: function(res) {
toastrError(res.data);
}
});
} else {
toastrError('只能选择一条数据。');
}
}
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
+10
View File
@@ -0,0 +1,10 @@
<form class="form-horizontal" method="post" action="{{url('mail_test')}}" id="mail_test" name="mail_test">
<table class="table table-form m-b-none">
<tr>
<td align="left">
<input class="form-control input-sm" placeholder="收信人邮箱地址" type="text" id="mail_to" name="mail_to" value="">
</td>
</tr>
</table>
</form>
@@ -0,0 +1,62 @@
<script id="uploader-item-tpl" type="text/html">
<div id="<%=fileId%>" class="uploadify-queue-item">
<span class="file-name"><span class="text-danger" title="草稿状态">!</span> <a href="javascript:uploader.file('<%=fileId%>');"><%=name%></a></span>
<span class="file-size">(<%=size%>)</span>
<span class="insert"><a class="option" href="javascript:uploader.insert('<%=fileId%>');">插入编辑器</a></span>
<span class="cancel"><a class="option" href="javascript:uploader.cancel('<%=fileId%>');">删除</a></span>
<input type="hidden" class="id" name="attachment[]" value="<%=id%>" />
</div>
<div class="clear"></div>
</script>
<div class="uploadify-queue">
<a class="btn btn-sm btn-info" href="javascript:viewBox('reader', '文件上传', '{{url('index/attachment/uploader', ['path' => Request::module()])}}');"><i class="fa fa-cloud-upload"></i> 文件上传</a>
<span class="uploader-size">&nbsp;文件大小限制 {{$setting['upload_max']}}MB</span>
<div class="clear"></div>
<div id="fileQueue" class="uploadify-queue">
@if($attach['main'])
@foreach($attach['main'] as $n => $file)
<div id="file_queue_{{$n}}" class="uploadify-queue-item">
<span class="file-name"><span class="icon icon-paperclip"></span> <a href="javascript:uploader.file('file_queue_{{$n}}');">{{$file['name']}}</a></span>
<span class="file-size">({{human_filesize($file['size'])}})</span>
<span class="insert"><a class="option" href="javascript:uploader.insert('file_queue_{{$n}}');">插入编辑器</a></span>
<span class="cancel"><a class="option" href="javascript:uploader.cancel('file_queue_{{$n}}');">删除</a></span>
<input type="hidden" class="id" name="attachment[]" value="{{$file['id']}}">
</div>
<div class="clear"></div>
@endforeach
@elseif($attachList['queue'])
@foreach($attachList['queue'] as $n => $v)
<div id="file_attach_{{$n}}" class="uploadify-queue-item">
<span class="file-name"><span class="icon icon-paperclip"></span> <a href="javascript:uploader.file('file_attach_{{$n}}');">{{$v['title']}}</a></span>
<span class="file-size"> ({{human_filesize($v['size'])}})</span>
<span class="insert"><a class="option" href="javascript:uploader.insert('file_attach_{{$n}}');">插入编辑器</a></span>
<span class="cancel"><a class="option" href="javascript:uploader.cancel('file_attach_{{$n}}');">删除</a></span>
<input type="hidden" class="id" name="attachment[]" value="{{$v['id']}}" />
</div>
<div class="clear"></div>
@endforeach
@endif
</div>
<div id="fileQueueDraft">
@if($attach['draft'])
@foreach($attach['draft'] as $n => $file)
<div id="queue_draft_{{$n}}" class="uploadify-queue-item">
<span class="file-name"><span class="text-danger" title="草稿附件">!</span> <a href="javascript:uploader.file('queue_draft_{{$n}}');">{{$file['name']}}</a></span>
<span class="file-size">({{human_filesize($file['size'])}})</span>
<span class="insert"><a class="option" href="javascript:uploader.insert('queue_draft_{{$n}}');">插入编辑器</a></span>
<span class="cancel"><a class="option" href="javascript:uploader.cancel('queue_draft_{{$n}}');">删除</a></span>
<input type="hidden" class="id" name="attachment[]" value="{{$file['id']}}">
</div>
<div class="clear"></div>
@endforeach
@endif
</div>
</div>
@@ -0,0 +1,354 @@
<style type="text/css">
#media-navigator {
height: 480px;
min-height: 480px;
background: #f4f5f9;
border-right: 1px solid #e7e7eb;
width: 140px;
float: left;
}
#media-navigator a, #media-navigator a:hover {
text-decoration: none;
}
#media-navigator ul {
list-style: none;
padding: 0;
}
#media-navigator ul li {
line-height: 38px;
}
#media-navigator ul li .node {
border-bottom: 1px solid #eee;
display: block;
padding: 0 10px;
}
#media-navigator ul li.active,
#media-navigator ul li:hover {
background-color: #fff;
}
#media-content {
height: 480px;
min-height: 480px;
margin-left: 140px;
overflow: hidden;
padding-right: 1px;
}
.media-tool {
padding: 10px;
border-bottom: 1px solid #e7e7eb;
}
.folder-tool {
vertical-align: initial;
display: none;
margin-right: 10px;
}
.folder-tool .fa {
color: #999;
}
#media-navigator ul li:hover .folder-tool {
display: block;
}
#media-navigator ul li .folder-tool a {
padding: 0 2px;
}
#media-navigator ul li .folder-tool a:hover .fa {
color: #0e90d2;
}
.files {
list-style: none;
margin: 0;
padding: 0;
padding-top: 10px;
overflow: auto;
height: 100%;
}
.files > li {
float: left;
width: 144px;
border: 1px solid #eee;
margin-bottom: 10px;
margin-left: 10px;
position: relative;
}
.files > li > .file-select {
position: absolute;
top: -4px;
left: -1px;
}
.file-icon.has-img {
padding: 0;
}
.file-icon {
text-align: center;
font-size: 65px;
color: #666;
display: block;
height: 100px;
}
.file-icon.has-img > img {
max-width: 100%;
height: auto;
max-height: 92px;
}
.file-info {
text-align: center;
padding: 10px;
background: #f4f4f4;
}
.file-name {
font-weight: bold;
color: #666;
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.file-size {
color: #999;
font-size: 12px;
display: block;
}
</style>
@verbatim
<div id="vue-app">
<div class="media-controller">
<div class="media-tool">
<div class="pull-right">
<button class="btn btn-success btn-sm" onclick="document.getElementById('upload').click();"><i class="fa fa-cloud-upload"></i> 上传文件</button>
<input type="file" id="upload" ref="upload" @change="onUpload" accept="image/*" multiple="multiple" style="display:none;">
<!--
<button class="btn btn-info btn-sm"><i class="fa fa-arrows"></i> 移动文件</button>
<button class="btn btn-danger btn-sm"><i class="fa fa-times"></i> 删除文件</button>
-->
</div>
<a @click="folder" class="btn btn-sm btn-default"><i class="fa fa-plus"></i> 添加文件夹</a>
<div class="clearfix"></div>
</div>
<div id="media-navigator">
<ul>
<li v-bind:class="{active:folderId == 0}">
<a @click="onFolder(0)" class="node">
<i class="fa fa-folder-o"></i> 全部
</a>
</li>
<li v-bind:class="{active:folderId == item.id}" v-for="(item, index) in folders" :key="item.id">
<span class="pull-right folder-tool">
<!--
<a class="hinted" title="修改"><i class="fa fa-pencil"></i></a>
-->
<a @click="onDelete(index, 1)" class="hinted" title="删除"><i class="fa fa-times"></i></a>
</span>
<a @click="onFolder(item.id)" class="node"><i class="fa fa-folder-o"></i> {{item.name}}</a>
</li>
</ul>
</div>
<div id="media-content">
<ul class="files">
<li v-for="(item, index) in files" :key="item.id">
<span class="file-select">
<label class="checkbox-inline i-checks">
<input type="checkbox" name="files" v-model="item.checked"><i></i>
</label>
</span>
<span class="file-icon has-img"><img :src="img(item.thumb)"></span>
<div class="file-info">
<a class="file-name" :title="item.name">
{{item.name}}
</a>
<span class="file-size">
{{filesize(item.size)}}
&nbsp;
<div class="btn-group btn-group-xs pull-right">
<button type="button" class="btn btn-default btn-xs" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a class="file-rename">改名 &amp; 移动</a></li>
<li><a @click="onDelete(index, 0)" class="file-delete">删除</a></li>
<li class="divider"></li>
<li><a :href="download(item.id)">下载</a></li>
</ul>
</div>
</span>
</div>
</li>
</ul>
</div>
</div>
</div>
@endverbatim
<script>
var vueApp = Vue.createApp({
data: function() {
return {
folderId: 0,
folders: [],
files: [],
}
},
created: function() {
let me = this;
me.getMedia(1, 0);
me.getMedia(0, 0);
},
methods: {
filesize: function(val) {
var size = '';
val = parseInt(val);
if (val < 0.1 * 1024) {
   // 如果小于0.1KB转化成B
size = val.toFixed(2) + ' B';
} else if(val < 0.1 * 1024 * 1024) {
// 如果小于0.1MB转化成KB
size = (val / 1024).toFixed(2) + ' KB';
} else if(val < 0.1 * 1024 * 1024 * 1024) {
// 如果小于0.1GB转化成MB
size = (val / (1024 * 1024)).toFixed(2) + ' MB';
} else {
// 其他转化成GB
size = (val / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
}
return size;
},
img: function(path) {
return app.url('uploads/' + path);
},
download: function(id) {
return app.url('system/media/download', {id: id});
},
folder: function() {
let me = this;
$.dialog({
title: '文件夹管理',
url: app.url('system/media/folder'),
dialogClass: 'modal-md',
buttons: [{
text: '提交',
'class': 'btn-success',
click: function() {
let modal = this;
let form = $('#myfolder').serialize();
axios.post(app.url('system/media/folder'), form)
.then(function(response) {
me.getMedia(1, 0);
$(modal).dialog('close');
}).catch(function(error) {
console.log(error);
});
}
}]
});
},
getMedia: function(folder, folderId) {
let me = this;
axios.post(app.url('system/media/dialog'), {
folder: folder,
folder_id: folderId
}).then(function(response) {
let res = response.data;
if (folder == 1) {
me.folders = res.data;
} else {
me.files = res.data;
}
}).catch(function(error) {
console.log(error);
});
},
onDelete: function(index, folder) {
let me = this;
let id = 0;
if (folder) {
id = me.folders[index].id;
} else {
id = me.files[index].id;
}
$.messager.confirm('操作警告', '确定要删除吗', function(btn) {
if (btn == true) {
axios.post(app.url('system/media/delete'), {
id: [id],
}).then(function(response) {
if (folder) {
me.folders.splice(index, 1);
} else {
me.files.splice(index, 1);
}
}).catch(function(error) {
console.log(error);
});
}
});
},
onFolder: function(id) {
let me = this;
me.folderId = id;
me.getMedia(0, id);
},
onUpload: function(e) {
let me = this;
let formData = new FormData();
formData.set('folder_id', me.folderId);
let files = me.$refs.upload.files;
for(var i = 0; i < files.length; i++) {
let file = files[i];
formData.set('Filedata', file);
axios.post(app.url('system/media/create'), formData, {
headers: {
'Content-Type': 'multipart/form-data'
},
}).then(function(response) {
let res = response.data;
me.files.unshift(res.data);
console.log(res.data);
})
.catch(function(error) {
console.log(error);
});
}
}
}
});
var vm = vueApp.mount('#vue-app');
function saveMedia(params) {
var files =[];
for (var i = 0; i < vm.files.length; i++) {
let file = vm.files[i];
if (file.checked) {
files.push(file);
}
}
if (files.length > 0) {
var media = $('#' + params['id'] + '-media');
media.empty();
if (params['multi'] == 0) {
let file = files[0];
var name = params['name'];
media.append('<div class="media-item"><input type="hidden" value="' + file.path + '" name="' + name + '" /><img class="img-responsive img-thumbnail" src="'+ app.url('uploads/' + file.path) +'" /><a class="close" title="删除这张图片" data-toggle="media-delete">×</a></div>');
} else {
var name = params['name'] + '[]';
for (var i = 0; i < files.length; i++) {
let file = files[i];
media.append('<div class="media-item"><input type="hidden" value="' + file.path + '" name="' + name + '" /><img class="img-responsive img-thumbnail" src="'+ app.url('uploads/' + file.path) +'" /><a class="close" title="删除这张图片" data-toggle="media-delete">×</a></div>');
}
}
}
}
</script>
@@ -0,0 +1,8 @@
<form class="form-horizontal form-controller" action="{{url()}}" method="post" id="myfolder" name="myfolder">
<div class="form-group no-border">
<label class="col-sm-2 control-label"><span class="red">*</span> 文件夹名称</label>
<div class="col-sm-10 control-text">
<input type="text" value="" required="required" class="form-control input-sm" autocomplete="off" name="name">
</div>
</div>
</form>
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{$setting['title']}}</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="{{$asset_url}}/dist/app.min.css" rel="stylesheet" type="text/css">
<script src="{{$asset_url}}/vendor/jquery.js"></script>
</head>
<style>
li { list-style: none; }
body {
margin: 0 auto;
text-align: center;
width: 80%;
}
.header {
text-align: center;
margin-top: 50px;
margin-bottom: 10px;
}
.logo img { border-radius: 500px; width:86px; height:86px; }
.input-group-addon {
background-color: #fff;
}
</style>
<body>
<div class="header">
<div class="logo">
<img class="circle" src="{{$asset_url}}/images/a1.jpg" />
<div>{{auth()->user()->name}}</div>
<div>欢迎使用{{$setting['title']}} 扫一扫</div>
<p class="message text-sm" style="color:red;"></p>
</div>
</div>
<form id="fileForm" class="form-horizontal">
<div class="form-group input-group">
<span class="input-group-addon">单据名称</span>
<input id="name" name="name" type="text" value="{{$model['name']}}" class="form-control input-sm" readonly="readonly" />
</div>
<div class="form-group input-group">
<span class="input-group-addon">文件名称</span>
<input type="text" id="filename" class="form-control input-sm" name="filename" />
</div>
<div class="form-group">
<a class="btn btn-info btn-lg btn-block" id="qrcode-btn"><i class="fa fa-qrcode"></i> 扫一扫</a>
<span style="display:none;">
<input type="file" name="file" id="fileToUpload" capture="camera" accept="image/*" onchange="fileSelected();">
</span>
</div>
<input type="hidden" name="key" value="{{$key}}" />
<input type="hidden" name="x-auth-token" value="{{$token}}" />
</form>
</body>
</html>
<script>
$(function() {
$('#qrcode-btn').on('click', function() {
$('.message').html('');
$('#fileToUpload').click();
});
});
var btn = '<i class="fa fa-qrcode"></i> 扫一扫';
function fileSelected() {
var formData = new FormData($('#fileForm')[0]);
$('.message').html('');
$('#fileToUpload').attr('disabled', 'disabled');
$.ajax({
url: '{{url("uploader")}}',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
xhr: function(){
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
$('#qrcode-btn').html('上传中...');
// xhr.upload.addEventListener("progress", onprogress, false);
return xhr;
}
},
success: function (returndata) {
$('#qrcode-btn').html(btn);
$('#fileToUpload').removeAttr('disabled');
$('#fileToUpload').val('');
$('.message').html('上传成功,请在提单界面等待图片出现。');
},
error: function (returndata) {
$('#qrcode-btn').html(btn);
$('#fileToUpload').removeAttr('disabled');
$('#fileToUpload').val('');
$('.message').html('上传失败。');
}
});
}
/*
function onprogress(evt) {
// $(".form-footer>a").html("上传中...");
}*/
</script>
+107
View File
@@ -0,0 +1,107 @@
<form method="post" id="menu" name="menu">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="100">上级</td>
<td align="left">
<select class="form-control input-sm" name="parent_id" id="parent_id">
<option value=""> - </option>
@foreach($parents as $parent)
<option value="{{$parent['id']}}" @if($row['parent_id'] == $parent['id']) selected @endif>{{$parent['layer_space']}}{{$parent['name']}}</option>
@endforeach
</select>
</td>
</tr>
<tr>
<td align="right">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" id="name" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">URL</td>
<td align="left">
<input class="form-control input-sm" type="text" id="url" name="url" value="{{$row['url']}}">
</td>
</tr>
<tr>
<td align="right">图标</td>
<td align="left">
<div class="input-group">
<span class="input-group-addon"></span>
<input data-placement="bottomLeft" type="text" autocomplete="off" class="form-control icp icp-auto input-sm" id="icon" name="icon" value="{{$row['icon']}}">
</div>
</td>
</tr>
<tr>
<td align="right">颜色</td>
<td align="left">
<div class="colorpicker-controller" title="选择颜色">
<div id="color-picker" class="colorpicker" style="background-color:{{$row['color']}};"></div>
</div>
<input type="hidden" id="color" name="color" value="{{$row['color']}}">
</td>
</tr>
<tr>
<td align="right">验证</td>
<td align="left">
<select class="form-control input-sm" name="access" id="access">
<option value="1" @if($row['access'] == '1') selected @endif></option>
<option value="0" @if($row['access'] == '0') selected @endif></option>
</select>
</td>
</tr>
<tr>
<td align="right">备注</td>
<td align="left">
<textarea class="form-control" name="description" id="description">{{$row['description']}}</textarea>
</td>
</tr>
<tr>
<td align="right">排序</td>
<td align="left">
<input class="form-control input-sm" type="text" id="sort" name="sort" value="{{$row['sort']}}">
</td>
</tr>
<tr>
<td align="right">状态</td>
<td align="left">
<select class="form-control input-sm" name="status" id="status">
<option value="1" @if($row['status'] == '1') selected @endif>启用</option>
<option value="0" @if($row['status'] == '0') selected @endif>禁用</option>
</select>
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
<script src="{{$asset_url}}/vendor/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js"></script>
<link href="{{$asset_url}}/vendor/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css" rel="stylesheet">
<script>
$(function() {
$('#icon').iconpicker();
$("#color-picker").colorpicker({
fillcolor: true,
target: "#color",
change: function(obj, color) {
$(obj).css({'background-color': color});
$('#color').val(color);
},
reset: function(obj, color) {
$(obj).css({'background-color': color});
$('#color').val(color);
}
});
});
</script>
@@ -0,0 +1,92 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
action.field = function(data) {
var me = this;
var grid = config.grid;
var url = app.url('model/field/index', {model_id: data.master_id});
var index = layer.open({
skin: 'layui-layer-frame',
scrollbar: false,
closeBtn: 2,
title: data.master_name + '[字段]',
type: 2,
move: false,
area: ['100%', '100%'],
content: url,
});
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
config.cols[0]['hide'] = true;
config.cols[1]['hide'] = true;
config.cols[2]['hide'] = true;
options.autoGroupColumnDef = {
headerName: '名称',
width: 120,
cellRendererParams: {
checkbox: true,
suppressCount: true,
}
};
options.treeData = true;
options.groupDefaultExpanded = -1;
options.getDataPath = function(data) {
return data.tree_path;
};
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
@@ -0,0 +1,35 @@
<form method="post" class="form-horizontal" action="{{url('edit')}}" id="option" name="option">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="100">上级</td>
<td align="left">
<select class="form-control input-sm" name="parent_id" id="parent_id">
<option value="0"></option>
@foreach($parents as $parent)
<option value="{{$parent['id']}}" @if($row['parent_id'] == $parent['id']) selected @endif>{{$parent['name']}}</option>
@endforeach
</select>
</td>
</tr>
<tr>
<td align="right">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" id="name" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right"></td>
<td align="left">
<input class="form-control input-sm" type="text" id="value" name="value" value="{{$row['value']}}">
</td>
</tr>
<tr>
<td align="right">排序</td>
<td align="left">
<input class="form-control input-sm" type="text" id="sort" name="sort" value="{{$row['sort']}}">
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
@@ -0,0 +1,129 @@
{{$header["js"]}}
<div class="panel no-border m-b-sm" id="{{$header['table']}}-controller">
@include('headers')
<div class="col-xs-4 col-sm-2">
<div class="list-jqgrid">
<div id="{{$header['table']}}-tree" style="width:100%;" class="tree-grid ag-theme-balham"></div>
</div>
</div>
<div class="col-xs-8 col-sm-10">
<div id="{{$header['table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
<div class="clearfix"></div>
</div>
<style>
.tree-grid.ag-theme-balham {
border-right: 1px solid #BDC3C7;
}
.tree-grid.ag-theme-balham .ag-ltr .ag-cell {
border-width: 0 0 0 0;
border-right-color: #d9dcde;
}
.tree-grid.ag-theme-balham .ag-header-cell,
.tree-grid.ag-theme-balham .ag-header-group-cell {
border-right-width: 0;
}
.ag-theme-balham {
border-left: 1px solid #BDC3C7;
border-right: 1px solid #BDC3C7;
}
.tree-box {
border: 1px solid #dee5e7;
overflow-y: auto;
}
.tree-box .ul {
margin-bottom: 0;
}
.col-xs-4 {
padding-right: 0;
padding-left: 5px;
}
.col-xs-8 {
padding-left: 5px;
padding-right: 5px;
}
@media screen and (min-width: 768px) {
.col-sm-2 {
padding-right: 0;
padding-left: 5px;
}
.col-sm-10 {
padding-left: 5px;
padding-right: 5px;
}
}
</style>
<script>
var table = '{{$header["table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
(function ($) {
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var height = getPanelHeight(98);
var treeOptions = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['table']}}-tree");
gridDiv.style.height = height;
treeOptions.columnDefs = [
{cellClass:'text-left', field: 'name', headerName: '枚举类别'},
];
treeOptions.onRowClicked = function (params) {
if (params.data.id >= 0) {
var query = search.simple.query;
query['parent_id'] = params.data.id;
query['page'] = 1;
config.grid.remoteData(query);
}
};
treeOptions.remoteDataUrl = "{{url('category')}}";
new agGrid.Grid(gridDiv, treeOptions);
// 读取数据
treeOptions.remoteData();
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
gridDiv.style.height = height;
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
@@ -0,0 +1,3 @@
<form class="form-horizontal form-controller" method="post" id="region" name="region">
{{$form['tpl']}}
</form>
@@ -0,0 +1,134 @@
<div class="wrapper-xs">
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline search-inline-form" method="get">
@include('searchForm6')
</form>
</div>
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
<script>
(function ($) {
var search = JSON.parse('{{json_encode($search)}}');
var params = search.query;
var option = gdoo.formKey(params);
var event = gdoo.event.get(option.key);
event.trigger('query', params);
var sid = params.prefix == 1 ? 'sid' : 'id';
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
var grid = new agGridOptions();
var selectedData = {};
var multiple = params.multi == 0 ? false : true;
grid.remoteDataUrl = '{{url()}}';
grid.remoteParams = params;
grid.suppressRowClickSelection = true;
grid.rowSelection = multiple ? 'multiple' : 'single';
grid.autoGroupColumnDef = {
headerName: '名称',
width: 420,
cellRendererParams: {
checkbox: true,
suppressCount: false,
}
};
grid.treeData = true;
grid.groupDefaultExpanded = 2;
grid.getDataPath = function(data) {
return data.text.split('/');
};
grid.columnDefs = [
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
];
grid.onRowClicked = function(row) {
var selected = row.node.isSelected();
if (selected === false) {
row.node.setSelected(true, true);
}
};
grid.onRowDoubleClicked = function (row) {
var ret = writeSelected();
if (ret == true) {
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
}
};
/**
* 初始化选择
*/
function initSelected() {
if (params.is_grid) {
} else {
var rows = {};
var id = $('#'+option.id).val();
if (id) {
var ids = id.split(',');
for (var i = 0; i < ids.length; i++) {
rows[ids[i]] = ids[i];
}
}
grid.api.forEachNode(function(node) {
var key = node.data[sid];
if (rows[key] != undefined) {
node.setSelected(true);
}
});
}
}
/**
* 写入选中
*/
function writeSelected() {
var rows = grid.api.getSelectedRows();
if (params.is_grid) {
var list = gdoo.forms[params.form_id];
list.api.dialogSelected(params);
} else {
var id = [];
var text = [];
$.each(rows, function(k, row) {
id.push(row[sid]);
text.push(row.name);
});
$('#'+option.id).val(id.join(','));
$('#'+option.id+'_text').val(text.join(','));
if (event.exist('onSelect')) {
return event.trigger('onSelect', multiple ? rows : rows[0]);
}
}
return true;
}
grid.writeSelected = writeSelected;
gdoo.dialogs[option.id] = grid;
new agGrid.Grid(gridDiv, grid);
// 读取数据
grid.remoteData();
// 数据载入成功
grid.remoteSuccessed = function() {
initSelected();
}
var data = search.forms;
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
data: data
});
search.find('#search-submit').on('click', function() {
var params = search.serializeArray();
$.map(params, function(row) {
data[row.name] = row.value;
});
grid.remoteData(data);
return false;
});
})(jQuery);
</script>
@@ -0,0 +1,148 @@
{{$header["js"]}}
<div class="panel no-border m-b-sm" id="{{$header['table']}}-controller">
@include('headers')
<div class="col-xs-4 col-sm-2">
<div class="list-jqgrid">
<div id="{{$header['table']}}-tree" style="width:100%;" class="tree-grid ag-theme-balham"></div>
</div>
</div>
<div class="col-xs-8 col-sm-10">
<div id="{{$header['table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
<div class="clearfix"></div>
</div>
<style>
.tree-grid.ag-theme-balham {
border-right: 1px solid #BDC3C7;
}
.tree-grid.ag-theme-balham .ag-ltr .ag-cell {
border-width: 0 0 0 0;
border-right-color: #d9dcde;
}
.tree-grid.ag-theme-balham .ag-header-cell,
.tree-grid.ag-theme-balham .ag-header-group-cell {
border-right-width: 0;
}
.ag-theme-balham {
border-left: 1px solid #BDC3C7;
border-right: 1px solid #BDC3C7;
}
.tree-box {
border: 1px solid #dee5e7;
overflow-y: auto;
}
.tree-box .ul {
margin-bottom: 0;
}
.col-xs-4 {
padding-right: 0;
padding-left: 5px;
}
.col-xs-8 {
padding-left: 5px;
padding-right: 5px;
}
@media screen and (min-width: 768px) {
.col-sm-2 {
padding-right: 0;
padding-left: 5px;
}
.col-sm-10 {
padding-left: 5px;
padding-right: 5px;
}
}
</style>
<script>
var table = '{{$header["table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
(function ($) {
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var height = getPanelHeight(163);
var treeOptions = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['table']}}-tree");
gridDiv.style.height = height;
treeOptions.autoGroupColumnDef = {
headerName: '行政区域',
width: 250,
sortable: false,
suppressMenu: true,
cellRendererParams: {
suppressCount: false,
}
};
treeOptions.treeData = true;
treeOptions.groupDefaultExpanded = -1;
treeOptions.getDataPath = function(data) {
return data.tree_path;
};
treeOptions.enableCellTextSelection = false;
treeOptions.treeData = true;
treeOptions.groupDefaultExpanded = 1;
treeOptions.onRowClicked = function (params) {
if (params.data.id > 0) {
var query = search.simple.query;
query['parent_id'] = params.data.id;
query['page'] = 1;
config.grid.remoteData(query);
}
};
treeOptions.remoteDataUrl = "{{url('category')}}";
treeOptions.columnDefs = [];
new agGrid.Grid(gridDiv, treeOptions);
// 读取数据
treeOptions.remoteData();
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
gridDiv.style.height = height;
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
@@ -0,0 +1,36 @@
<form method="post" class="form-horizontal" action="{{url('store')}}" id="setting" name="setting">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="10%">配置名称</td>
<td align="left">
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">Key</td>
<td align="left">
<input class="form-control input-sm" type="text" name="key" value="{{$row['key']}}">
</td>
</tr>
<tr>
<td align="right"></td>
<td align="left">
<textarea class="form-control input-sm" type="text" name="value">{{$row['value']}}</textarea>
</td>
</tr>
<tr>
<td align="right">类型</td>
<td align="left">
<input class="form-control input-sm" type="text" name="type" value="{{$row['type']}}">
</td>
</tr>
<tr>
<td align="right">备注</td>
<td align="left">
<input class="form-control input-sm" type="text" name="remark" value="{{$row['remark']}}">
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
@@ -0,0 +1,59 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
@@ -0,0 +1,59 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.show(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
+46
View File
@@ -0,0 +1,46 @@
<form method="post" class="form-horizontal" action="{{url('store')}}" id="sms" name="sms">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="10%">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">apikey</td>
<td align="left">
<input class="form-control input-sm" type="text" name="apikey" value="{{$row['apikey']}}">
</td>
</tr>
<tr>
<td align="right">服务商</td>
<td align="left">
<select class="form-control input-sm" name="driver" id="driver">
<option value="gdoo" @if($row['driver'] == 'gdoo') selected @endif>Gdoo短信</option>
<option value="alidayu" @if($row['driver'] == 'alidayu') selected @endif>阿里短信</option>
<option value="yunpian" @if($row['driver'] == 'yunpian') selected @endif>云片网</option>
</select>
</td>
</tr>
<tr>
<td align="right">状态</td>
<td align="left">
<select class="form-control input-sm" name="status" id="status">
<option value="1" @if($row['status'] == '1') selected @endif>启用</option>
<option value="0" @if($row['status'] == '0') selected @endif>停用</option>
</select>
</td>
</tr>
<tr>
<td align="right">排序</td>
<td align="left">
<input class="form-control input-sm" type="text" name="sort" value="{{$row['sort']}}">
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
+83
View File
@@ -0,0 +1,83 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
action.test = function() {
var me = this;
var grid = config.grid;
var rows = grid.api.getSelectedRows();
if (rows.length == 1) {
formDialog({
title: '测试短信',
url: app.url('system/sms/test', {id: rows[0].id}),
storeUrl: app.url('system/sms/test'),
id: 'sms_test',
dialogClass:'modal-sm',
success: function(res) {
toastrSuccess(res.data);
$(this).dialog("close");
},
error: function(res) {
toastrError(res.data);
}
});
} else {
toastrError('只能选择一条数据。');
}
}
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')
+14
View File
@@ -0,0 +1,14 @@
<form method="post" action="{{url('test')}}" id="sms_test" name="sms_test">
<table class="table table-form m-b-none">
<tr>
<td align="left">
<input class="form-control input-sm" placeholder="发送手机" name="data[sms_to]" type="text">
</td>
</tr>
<tr>
<td align="left">
<textarea class="form-control input-sm" placeholder="发送内容" name="data[sms_text]" rows="3"></textarea>
</td>
</tr>
</table>
</form>
@@ -0,0 +1,122 @@
<form method="post" id="widget" name="widget">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="10%">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">URL</td>
<td align="left">
<input class="form-control input-sm" type="text" readonly="readonly" name="url" value="{{$row['url']}}">
</td>
</tr>
<tr>
<td align="right">MoreURL</td>
<td align="left">
<input class="form-control input-sm" type="text" readonly="readonly" name="more_url" value="{{$row['more_url']}}">
</td>
</tr>
<tr>
<td align="right">权限</td>
<td align="left">
{{App\Support\Dialog::search($row, 'id=receive_id&name=receive_name&multi=1')}}
</td>
</tr>
<tr>
<td align="right">位置</td>
<td align="left">
<select name="grid" id="grid" class="form-control input-sm">
<option value="8" @if($row['grid'] == 8) selected="selected" @endif></option>
<option value="4" @if($row['grid'] == 4) selected="selected" @endif></option>
</select>
</td>
</tr>
<tr>
<td align="right">图标</td>
<td align="left">
<div class="input-group">
<span class="input-group-addon"></span>
<input data-placement="bottomLeft" type="text" autocomplete="off" class="form-control icp icp-auto input-sm" id="icon" name="icon" value="{{$row['icon']}}">
</div>
</td>
</tr>
<tr>
<td align="right">颜色</td>
<td align="left">
<div class="colorpicker-controller" title="选择颜色">
<div id="color-picker" class="colorpicker" style="background-color:{{$row['color']}};"></div>
</div>
<input type="hidden" id="color" name="color" value="{{$row['color']}}">
</td>
</tr>
<tr>
<td align="right">类型</td>
<td align="left">
<select class="form-control input-sm" disabled="disabled" name="type" id="type">
<option value="1" @if($row['type'] == 1) selected @endif>部件</option>
<option value="2" @if($row['type'] == 2) selected @endif>信息</option>
</select>
</td>
</tr>
<tr>
<td align="right">状态</td>
<td align="left">
<select class="form-control input-sm" name="status" id="status">
<option value="1" @if($row['status'] == 1) selected @endif>正常</option>
<option value="0" @if($row['status'] == 0) selected @endif>禁用</option>
</select>
</td>
</tr>
<tr>
<td align="right">全局</td>
<td align="left">
<select class="form-control input-sm" name="default" id="default">
<option value="1" @if($row['default'] == 1) selected @endif></option>
<option value="0" @if($row['default'] == 0) selected @endif></option>
</select>
</td>
</tr>
<tr>
<td align="right">排序</td>
<td align="left">
<input class="form-control input-sm" type="text" name="sort" value="{{$row['sort']}}">
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
<script src="{{$asset_url}}/vendor/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js"></script>
<link href="{{$asset_url}}/vendor/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css" rel="stylesheet">
<script>
$(function() {
$('#icon').iconpicker();
$("#color-picker").colorpicker({
fillcolor: true,
target: "#color",
change: function(obj, color) {
$(obj).css({'background-color': color});
$('#color').val(color);
},
reset: function(obj, color) {
$(obj).css({'background-color': color});
$('#color').val(color);
}
});
});
</script>
@@ -0,0 +1,76 @@
{{$header["js"]}}
<div class="panel no-border" id="{{$header['master_table']}}-controller">
@include('headers')
<div class='list-jqgrid'>
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
</div>
</div>
<script>
(function ($) {
var table = '{{$header["master_table"]}}';
var config = gdoo.grids[table];
var action = config.action;
var search = config.search;
action.dialogType = 'dialog';
// 自定义搜索方法
search.searchInit = function (e) {
var self = this;
}
action.refresh = function() {
var me = this;
var loading = layer.msg('部件更新中...', {
icon: 16, shade: 0.1, time: 1000 * 120
});
$.post(app.url('system/widget/refresh'), function(res) {
if (res.status) {
options.remoteData({page: 1});
toastrSuccess(res.data);
} else {
toastrError(res.data);
}
},'json').complete(function() {
layer.close(loading);
});
}
var options = new agGridOptions();
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
gridDiv.style.height = getPanelHeight(48);
options.remoteDataUrl = '{{url()}}';
options.remoteParams = search.advanced.query;
options.columnDefs = config.cols;
options.onRowDoubleClicked = function (params) {
if (params.node.rowPinned) {
return;
}
if (params.data == undefined) {
return;
}
if (params.data.master_id > 0) {
action.edit(params.data);
}
};
new agGrid.Grid(gridDiv, options);
// 读取数据
options.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 = options;
})(jQuery);
</script>
@include('footers')