创建版本

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,172 @@
<?php namespace Gdoo\Index\Controllers;
use DB;
use URL;
use Request;
use App\Support\Pinyin;
use Gdoo\User\Models\User;
use Gdoo\Index\Models\Notification;
class ApiController extends Controller
{
/**
* jq导出xls
*/
public function jqexportAction()
{
$gets = Request::all();
$data = urldecode($gets['data']);
$rows = json_decode($data, true);
return writeExcel($rows['thead'], $rows['tbody'], 'jqexport');
}
/**
* 初始化JS输出
*/
public function commonAction()
{
$settings['public_url'] = URL::to('/');
$settings['upload_file_type'] = $this->setting['upload_type'];
$settings['upload_max_size'] = $this->setting['upload_max'];
$settings['openSource'] = $this->openSource;
header('Content-type: text/javascript');
echo 'var settings = '. json_encode($settings, JSON_UNESCAPED_UNICODE);
exit;
}
/**
* 任务调用
*/
public function taskAction()
{
$rows = DB::table('cron')->where('status', 1)->get();
if ($rows) {
foreach ($rows as $row) {
$cron = \Cron\CronExpression::factory($row['expression']);
// 由于定时任务无法定义秒这里特殊处理一下
if (strtotime($row['next_run']) <= time()) {
// 这里执行代码
// 记录下次执行和本次执行结果
$next = $cron->getNextRunDate()->format('Y-m-d H:i:00');
$data = [
'next_run' => $next,
'last_run' => '执行成功。'
];
DB::table('cron')->where('id', $row['id'])->update($data);
}
}
}
}
/**
* 获取单据编号
*/
public function billSeqNoAction()
{
$bill_id = Request::get('bill_id');
$date = Request::get('date');
$bill = DB::table('model_bill')->where('id', $bill_id)->first();
$model = DB::table('model')->where('id', $bill['model_id'])->first();
$make_sn = make_sn([
'table' => $model['table'],
'date' => $date,
'bill_id' => $bill['id'],
'prefix' => $bill['sn_prefix'],
'rule' => $bill['sn_rule'],
'length' => $bill['sn_length'],
]);
return $this->json($make_sn['new_value'], true);
}
/**
* 汉字转拼音
*/
public function pinyinAction()
{
$word = Request::get('name');
$type = Request::get('type');
if (empty($word)) {
return '';
}
if ($type == 'first') {
return str_replace('/', '', Pinyin::output(str_replace(' ', '', $word)));
} else {
return str_replace('/', '', Pinyin::getstr(str_replace(' ', '', $word)));
}
}
/**
* 显示位置信息
*/
public function locationAction()
{
$gets = Request::all();
return $this->render(array(
'gets' => $gets
));
}
/**
* 系统字典
*/
public function dictAction()
{
$key = Request::get('key');
$rows = option($key);
return response()->json($rows)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
/**
* 系统选项
*/
public function optionAction()
{
$key = Request::get('key');
$rows = option($key);
return response()->json($rows)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
/**
* 不支持浏览器提示
*/
public function unsupportedBrowserAction()
{
return $this->render();
}
/*
* 显示用户列表
*/
public function dialogAction()
{
$gets = Request::all();
return $this->render([
'gets' => $gets
]);
}
/*
* 调用省市县显示
*/
public function regionAction()
{
$parent_id = Request::get('parent_id', 0);
$layer = Request::get('layer', 1);
$names = [1=>'省' ,2=>'市', 3=>'县'];
$title[] = ['id' => '' ,'name' => $names[$layer]];
$rows = DB::table('region')
->where('parent_id', (int)$parent_id)
->where('layer', $layer)
->get()->toArray();
$rows = array_merge($title, $rows);
return response()->json($rows);
}
}
@@ -0,0 +1,222 @@
<?php namespace Gdoo\Index\Controllers;
use Session;
use Request;
use Validator;
use DB;
use Gdoo\Index\Services\AttachmentService;
use URL;
class AttachmentController extends DefaultController
{
public $permission = ['list','view','preview','create','delete','download','show', 'uploader', 'draft', 'qrcode'];
/**
* 上传文件
*/
public function uploaderAction()
{
if (Request::method() == 'POST') {
$file = Request::file('file');
/*
$rules = [
'file' => 'mimes:'.$this->setting['upload_type'],
];
$v = Validator::make(['file' => $file], $rules);
*/
$upload_type = explode(',', $this->setting['upload_type']);
if ($file->isValid()) {
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 判断文件类型
if (!in_array($extension, $upload_type)) {
return;
}
// 获取上传uri第一个目录
$key = Request::get('key', 'default');
$node = Request::get('path', 'default');
$path = $node.date('/Ym/');
$upload_path = upload_path().'/'.$path;
// 文件新名字
$filename = date('dhis_').str_random(4).'.'.$extension;
$filename = mb_strtolower($filename);
if ($file->move($upload_path, $filename)) {
$data = [
'name' => mb_strtolower($file->getClientOriginalName()),
'node' => $node,
'path' => $path.$filename,
'type' => $extension,
'key' => $key,
'size' => $file->getClientSize(),
];
$insertId = DB::table('attachment')->insertGetId($data);
$data['id'] = $insertId;
$data['success'] = true;
return json_encode($data);
}
}
}
$query = Request::all();
$SERVER_URL = url("index/attachment/uploader", $query);
return $this->render([
'SERVER_URL' => $SERVER_URL,
'key' => $query['key'],
]);
}
/**
* 新建文件
*/
public function createAction()
{
set_time_limit(0);
$file = Request::file('Filedata');
$rules = [
'file' => 'mimes:'.$this->setting['upload_type'],
];
$v = Validator::make(['file' => $file], $rules);
if ($file->isValid() && $v->passes()) {
// 获取上传uri第一个目录
$path = Request::get('path', 'main').date('/Y/m/');
$upload_path = upload_path().'/'.$path;
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 文件新名字
$filename = date('dhis_').str_random(4).'.'.$extension;
$filename = mb_strtolower($filename);
if ($file->move($upload_path, $filename)) {
return DB::table('attachment')->insertGetId([
'name' => mb_strtolower($file->getClientOriginalName()),
'path' => $path.$filename,
'type' => $extension,
'size' => $file->getClientSize(),
]);
}
}
return 0;
}
/**
* 二维码上传
*/
public function qrcodeAction()
{
$key = Request::get('key');
$path = Request::get('path');
list($table, $field) = explode('.', $key);
$model = DB::table('model')->where('table', $table)->first();
$token = Request::get('x-auth-token');
return $this->render([
'model' => $model,
'token' => $token,
'key' => $key,
], 'attachment.qrcode');
}
/**
* 获取文件列表
*/
public function listAction()
{
$id = Request::get('id');
$rows = AttachmentService::get($id);
return response()->json($rows);
}
/**
* 获取草稿列表
*/
public function draftAction()
{
$key = Request::get('key');
$rows = AttachmentService::draft($key);
return response()->json($rows);
}
/**
* 预览文件
*/
public function showAction()
{
$id = Request::get('id');
$rows = AttachmentService::get($id);
if (empty($rows)) {
return $this->error('文件不存在。');
}
$image = upload_path($rows[0]['path']);
if (is_file($image)) {
Header('Content-type:image/'.$rows[0]['type']);
return file_get_contents($image);
} else {
return $this->error('文件不存在。');
}
}
/**
* 预览文件
*/
public function previewAction()
{
$id = Request::get('id');
$file = AttachmentService::get($id)[0];
$url = '';
$stream = URL::to('uploads').'/'.$file['path'];
if (in_array($file['type'], array('jpg', 'gif', 'png'))) {
$view = 'image';
$url = "javascript:imageBox('{$file['name']}','{$file['name']}','{$file['name']}');";
} else {
return $this->back()->with('error', '此格式不支持预览。');
}
return $this->display([
'url' => $url,
'stream' => $stream,
], 'attachment.view');
}
/**
* 下载文件
*/
public function downloadAction()
{
$id = Request::get('id');
if ($id) {
$row = DB::table('attachment')->where('id', $id)->first();
$path = upload_path().'/'.$row['path'];
return response()->download($path, $row['name']);
}
}
public function deleteAction()
{
$gets = Request::all();
if ($gets['id']) {
AttachmentService::remove($gets['id']);
return 1;
}
return 0;
}
}
@@ -0,0 +1,71 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\User\Models\UserAsset;
use Gdoo\Index\Models\Menu;
use View;
use Validator;
use DB;
use Request;
use App\Support\AES;
use App\Support\Hook;
use Gdoo\Model\Models\Bill;
use Gdoo\Model\Models\Model;
class AuditController extends DefaultController
{
public function __construct()
{
parent::__construct();
}
/**
* 审核
*/
public function auditAction()
{
if (Request::method() == 'POST') {
$key = Request::get('key');
$keys = AES::decrypt($key, config('app.key'));
list($bill_id, $data_id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$model = Model::find($bill->model_id);
DB::beginTransaction();
try {
Hook::fire($model->table.'.onBeforeAudit', ['table' => $model->table, 'id' => $data_id]);
DB::table($model->table)->where('id', $data_id)->update(['status' => 1]);
DB::commit();
return $this->json($bill->name.'审核成功', true);
} catch(\Exception $e) {
DB::rollBack();
return $this->json($e->getMessage());
}
}
}
/**
* 弃审
*/
public function abortAction()
{
if (Request::method() == 'POST') {
$key = Request::get('key');
$keys = AES::decrypt($key, config('app.key'));
list($bill_id, $data_id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$model = Model::find($bill->model_id);
DB::beginTransaction();
try {
Hook::fire($model->table.'.onBeforeAbort', ['table' => $model->table, 'id' => $data_id]);
DB::table($model->table)->where('id', $data_id)->update(['status' => 0]);
DB::commit();
return $this->json($bill->name.'弃审成功', true);
} catch(\Exception $e) {
DB::rollBack();
return $this->json($e->getMessage());
}
}
}
}
+181
View File
@@ -0,0 +1,181 @@
<?php namespace Gdoo\Index\Controllers;
use Session;
use View;
use URL;
use Request;
use Gdoo\Index\Services\RetService;
use Gdoo\System\Models\Setting;
use App\Http\Controllers\Controller as BaseController;
class Controller extends BaseController
{
/**
* @var 程序版本
*/
public $version = '<a target="_blank" href="http://www.gdoo.net">Gdoo</a> 2.2.1';
/**
* @var 资源版本
*/
public $resVersion = '20210221';
/**
* @var 开发商名称
*/
public $powered = 'Gdoo';
/**
* @var 是否开源版
*/
public $openSource = false;
/**
* @var 配置参数
*/
public $setting = [];
/**
* @var 跳过acl检查的方法
*/
public $permission = [];
/**
* @var 当前控制下的方法权限
*/
public $access = [];
/**
* @var layout 布局视图模板
*/
protected $layout = 'layouts.default';
/**
* @var 数据库类型
*/
public $dbType = 'sqlsrv';
/**
* 初始化ret数据
*/
public $ret = null;
/**
* @var 执行初始化工作
*/
public function __construct()
{
// 不丢失表单返回数据
header('Cache-control:private, must-revalidate');
// 获取配置数据
$this->setting = Setting::where('type', 'system')->pluck('value', 'key');
$this->setting['powered'] = $this->powered;
$this->dbType = env('DB_CONNECTION');
$this->ret = RetService::make();
View::share([
'title' => 'GdooOA',
'setting' => $this->setting,
'public_url' => URL::to('/'),
'upload_url' => URL::to('/uploads'),
'static_url' => URL::to('/static'),
'asset_url' => URL::to('/assets'),
'version' => $this->version,
'openSource' => $this->openSource,
'resVersion' => $this->resVersion,
]);
}
/**
* Ajax调用返回
*
* 返回json数据, 供前台ajax调用
* @param array $data 返回数组,支持数组
* @param boolean $status 执行状态, 1为true, 0为false
* @param string $type 返回信息类型, 默认为primary
* @return string
*/
public function json($data, $status = false)
{
return response_json($data, $status);
}
/**
* 返回页面
*/
public function back($message = null, $type = 'message')
{
$args = func_num_args();
if ($args == 0) {
return redirect()->back();
}
return redirect()->back()->with($type, $message);
}
// 操作错误返回
public function error($error = null, $type = 'error')
{
$args = func_num_args();
if ($args == 0) {
return redirect()->back();
}
return redirect()->back()->with($type, $error);
}
// 操作成功跳转
public function success($path, $params = [], $message = null, $referer = 1)
{
$args = func_num_args();
if ($args > 2) {
return $this->to($path, $params, $referer)->with('message', $message);
} else {
return $this->to($path, [], $referer)->with('message', $params);
}
}
/**
* 刷新页面附带 referer
*/
public function to($path = null, $params = [], $referer = 1)
{
return redirect(url_referer($path, $params, $referer));
}
/**
* 模板文件名
*/
public function viewFile($file)
{
if ($file === null) {
$file = Request::controller().'.'.Request::action();
} else {
if (substr_count($file, '.') === 0) {
$file = Request::controller().'.'.$file;
}
}
return $file;
}
/**
* 直接渲染模板不包含layout视图
*/
public function render($params = [], $file = null)
{
return view($this->viewFile($file), $params);
}
/**
* 渲染模板嵌套到layout视图
*/
public function display($params = [], $file = null, $layout = '')
{
$layout = $layout == '' ? $this->layout : $layout;
$layout = view($layout, $params);
return $layout->nest('content', $this->viewFile($file), $params);
}
}
@@ -0,0 +1,326 @@
<?php namespace Gdoo\Index\Controllers;
use Request;
use DB;
use Gdoo\System\Models\Menu;
use Gdoo\System\Models\Widget;
use Gdoo\User\Models\UserWidget;
class DashboardController extends DefaultController
{
public $permission = ['index', 'config', 'quickMenu', 'settingWidget', 'settingInfo'];
public function indexAction()
{
$auth = auth()->user();
$widgets = DB::table('widget')
->where('type', 1)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get();
$user_widgets = UserWidget::where('user_id', $auth['id'])
->where('type', 1)
->orderBy('sort', 'asc')
->get()->keyBy('node_id');
$widgets->transform(function ($row) use($user_widgets) {
$user_widget = $user_widgets[$row['id']];
if (not_empty($user_widget)) {
$row['id'] = $user_widget['id'];
$row['status'] = $user_widget['status'];
$row['grid'] = $user_widget['grid'];
$row['sort'] = $user_widget['sort'];
if ($user_widget['name']) {
$row['name'] = $user_widget['name'];
}
if ($user_widget['color']) {
$row['color'] = $user_widget['color'];
}
if ($user_widget['icon']) {
$row['icon'] = $user_widget['icon'];
}
$row['params'] = json_decode($user_widget['params'], true);
return $row;
}
});
$widgets = $widgets->sortBy('sort');
$infos = DB::table('widget')
->where('type', 2)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get();
$user_infos = UserWidget::where('user_id', $auth['id'])
->where('type', 2)
->orderBy('sort', 'asc')
->get()->keyBy('node_id');
$infos->transform(function ($row) use($user_infos) {
$user_info = $user_infos[$row['id']];
if (not_empty($user_info)) {
$row['id'] = $user_info['id'];
$row['status'] = $user_info['status'];
$row['sort'] = $user_info['sort'];
if ($user_info['name']) {
$row['name'] = $user_info['name'];
}
if ($user_info['color']) {
$row['color'] = $user_info['color'];
}
if ($user_info['icon']) {
$row['icon'] = $user_info['icon'];
}
$row['params'] = json_decode($user_info['params'], true);
return $row;
}
});
$infos = $infos->sortBy('sort');
$quicks = Menu::leftJoin('user_widget', 'user_widget.node_id', '=', 'menu.id')
->where('user_widget.user_id', $auth['id'])
->where('user_widget.type', 3)
->orderBy('user_widget.sort', 'asc')
->get(['menu.*','user_widget.name','user_widget.color','user_widget.icon']);
$quicks->transform(function ($row) {
$count = substr_count($row['url'], '/');
if ($count == 0) {
$row['url'] = $row['url'].'/index/index';
} else if($count == 1) {
$row['url'] = $row['url'].'/index';
}
$row['key'] = str_replace(['/', '?', '='], ['_', '_', '_'], $row['url']);
return $row;
});
$grids = ['8', '4'];
return $this->display([
'widgets' => $widgets,
'infos' => $infos,
'grids' => $grids,
'quicks' => $quicks,
]);
}
// 仪表板设置
public function configAction()
{
$auth = auth()->user();
if (Request::method() == 'POST') {
$gets = Request::all();
$widgets = $gets['widget'];
$sort = 1;
foreach($widgets as $widget) {
$widget['sort'] = $sort;
$sort ++;
$model = UserWidget::firstOrNew(['type' => 1, 'node_id' => $widget['id'], 'user_id' => $auth['id']]);
$model->fill($widget);
$model->save();
}
$infos = $gets['info'];
$sort = 1;
foreach($infos as $info) {
$info['sort'] = $sort;
if ($info['permission'] && $info['date']) {
$info['params'] = json_encode(['permission' => $info['permission'], 'date' => $info['date']], JSON_UNESCAPED_UNICODE);
}
$sort ++;
$model = UserWidget::firstOrNew(['type' => 2, 'node_id' => $info['id'], 'user_id' => $auth['id']]);
$model->fill($info);
$model->save();
}
$menus = $gets['menu'];
$sort = 1;
$nodeIds = UserWidget::where('type', 3)->where('user_id', $auth['id'])->pluck('id', 'node_id')->toArray();
foreach($menus as $menu) {
unset($nodeIds[$menu['node_id']]);
$menu['sort'] = $sort;
$sort ++;
$model = UserWidget::firstOrNew(['type' => 3, 'node_id' => $menu['node_id'], 'user_id' => $auth['id']]);
$model->fill($menu);
$model->save();
}
// 删除旧菜单
UserWidget::whereIn('id', array_values($nodeIds))->delete();
return $this->json('仪表盘设置成功', true);
}
$widgets = DB::table('widget')
->where('type', 1)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'status']);
$user_widgets = UserWidget::where('user_id', $auth['id'])
->where('type', 1)
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'node_id', 'status'])->keyBy('node_id');
$widgets->transform(function ($row) use($user_widgets) {
$user_widget = $user_widgets[$row['id']];
if (not_empty($user_widget)) {
$row['sort'] = $user_widget['sort'];
$row['status'] = $user_widget['status'];
$row['node_id'] = $user_widget['node_id'];
$row['widget_id'] = $user_widget['id'];
$row['grid'] = $user_widget['grid'];
if ($user_widget['name']) {
$row['name'] = $user_widget['name'];
}
if ($user_widget['color']) {
$row['color'] = $user_widget['color'];
}
if ($user_widget['icon']) {
$row['icon'] = $user_widget['icon'];
}
}
return $row;
});
$widgets = $widgets->sortBy('sort');
$infos = DB::table('widget')
->where('type', 2)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'status']);
$user_infos = UserWidget::where('user_id', $auth['id'])
->where('type', 2)
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'node_id', 'status', 'params'])->keyBy('node_id');
$infos->transform(function ($row) use($user_infos) {
$user_info = $user_infos[$row['id']];
if (not_empty($user_info)) {
$row['sort'] = $user_info['sort'];
$row['status'] = $user_info['status'];
$row['node_id'] = $user_info['node_id'];
$row['info_id'] = $user_info['id'];
if ($user_info['name']) {
$row['name'] = $user_info['name'];
}
if ($user_info['color']) {
$row['color'] = $user_info['color'];
}
if ($user_info['icon']) {
$row['icon'] = $user_info['icon'];
}
$row['params'] = json_decode($user_info['params'], true);
}
return $row;
});
$infos = $infos->sortBy('sort');
$menus = UserWidget::where('user_id', $auth['id'])
->where('type', 3)
->orderBy('sort', 'asc')
->get();
$grids = ['8', '4'];
$json = [
'widgets' => $widgets,
'infos' => $infos,
'menus' => $menus,
];
$json = json_encode($json, JSON_UNESCAPED_UNICODE);
return $this->render([
'json' => $json,
'widgets' => $widgets,
'infos' => $infos,
'grids' => $grids,
'menus' => $menus,
]);
}
// 添加快捷菜单
public function quickMenuAction()
{
$menus = DB::table('menu')->orderBy('lft', 'asc')->get();
$menus = array_nest($menus);
return $this->render([
'menus' => $menus,
]);
}
// 设置单个组件
public function settingInfoAction()
{
// 定义权限
$permissions = [
'me' => "本人",
'me2' => "本人和下属",
'department' => "本部门",
'department2' => "本部门和下属部门",
'team' => "本销售组",
'team2' => "本销售组和下属销售组",
'all' => "所有人",
];
$dates = [
'day' => '今天',
'day2' => '昨天',
'week' => '本周',
'week2' => '上周',
'month' => '本月',
'month2' => '上月',
'season' => '本季度',
'season2' => '上季度',
'year' => '本年',
'year2' => '去年',
];
$info_id = Request::input('info_id');
$row = UserWidget::where('id', $info_id)->first();
$widget = Widget::where('id', $row['node_id'])->first();
if (empty($row['date'])) {
$row['date'] = 'month';
}
if (empty($row['permission'])) {
$row['permission'] = 'department';
}
$row['widget_name'] = $widget['name'];
return $this->render([
'permissions' => $permissions,
'dates' => $dates,
'row' => $row,
]);
}
// 设置单个组件
public function settingWidgetAction()
{
$widget_id = Request::input('widget_id');
$row = UserWidget::where('id', $widget_id)->first();
$widget = Widget::where('id', $row['node_id'])->first();
if (empty($row['date'])) {
$row['date'] = 'month';
}
if (empty($row['permission'])) {
$row['permission'] = 'department';
}
$row['widget_name'] = $widget['name'];
return $this->render([
'row' => $row,
]);
}
}
@@ -0,0 +1,128 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\User\Services\UserAssetService;
use Gdoo\Index\Models\Menu;
use View;
use DB;
use Validator;
use Request;
use App\Support\AES;
use Gdoo\Model\Models\Bill;
use Gdoo\Model\Form;
use Gdoo\Model\Services\ModelService;
use Gdoo\Index\Services\MenuService;
class DefaultController extends Controller
{
protected $user = [];
public function __construct()
{
$this->permission[] = 'store';
parent::__construct();
UserAssetService::setPermissions($this->permission);
// 登录认证和RBAC检查
$this->middleware('auth');
// 获取登录认证数据
$this->middleware(function ($request, $next) {
$this->user = $request->user();
$this->access = UserAssetService::getNowRoleAssets();
$menus = MenuService::getItems();
View::share([
'menus' => $menus,
'access' => $this->access,
]);
return $next($request);
});
}
/**
* 保存表单
*/
public function storeAction()
{
$gets = Request::all();
$master = $gets['master'];
$keys = AES::decrypt($master['key'], config('app.key'));
list($bill_id, $id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$models = ModelService::getModels($bill->model_id);
$model = $models[0];
if (Request::method() == 'POST') {
// 检查表单
$valid = Form::flowRules($models, $gets);
if ($valid['rules']) {
$v = Validator::make($gets, $valid['rules'], $valid['messages'], $valid['attributes']);
if ($v->fails()) {
$errors = $v->errors()->all();
return $this->json(join('<br>', $errors));
}
}
// 保存数据
$id = Form::store($bill, $models, $gets, $id, 'store');
// 保存草稿跳转到编辑界面
$url = url($master['uri'].'/show', ['id' => $id, 'client' => $master['client']]);
return $this->json($bill['name'].'保存成功', $url);
}
}
/**
* 关闭行数据
*/
public function closeRowAction()
{
$gets = Request::all();
if (Request::method() == 'POST') {
$id = $gets['id'];
if (strpos($id, 'draft_') === 0) {
return $this->json('关闭行数据成功', true);
}
$row = DB::table($gets['table'])->where('id', $id)->first();
if ($row['use_close'] == 1) {
$use_close = 0;
} else {
$use_close = 1;
}
DB::table($gets['table'])->where('id', $id)->update(['use_close' => $use_close]);
return $this->json('关闭行数据成功', true);
}
}
/**
* 关闭所有行数据
*/
public function closeAllRowAction()
{
$gets = Request::all();
if (Request::method() == 'POST') {
$ids = [];
foreach($gets['ids'] as $id) {
if (strpos($id, 'draft_') === 0) {
continue;
}
$ids[] = $id;
}
$rows = DB::table($gets['table'])->whereIn('id', $ids)->get();
if ($rows[0]['use_close'] == 1) {
$use_close = 0;
} else {
$use_close = 1;
}
DB::table($gets['table'])->whereIn('id', $ids)->update(['use_close' => $use_close]);
return $this->json('关闭所有行数据成功', true);
}
}
}
@@ -0,0 +1,520 @@
<?php namespace Gdoo\Index\Controllers;
use DB;
use URL;
use Request;
use App\Support\Pinyin;
use Gdoo\User\Models\User;
use Gdoo\Index\Models\Notification;
class DemoController extends Controller
{
#[Attribute(Attribute::TARGET_FUNCTION)]
public function vouchAction()
{
return $this->display();
}
public function helloAction()
{
//\App\Jobs\SendEmail::dispatch('abc', ['fvzone@qq.com'], '您的验证码是0123', 'fsdafsd哈哈哈');
//\App\Jobs\SendSms::dispatch(['15182223008'], '您的验证码是01234');
$menus = DB::table('menu')->get();
foreach($menus as $menu) {
$url = str_replace('.', '/', $menu['url']);
DB::table('menu')->where('id', $menu['id'])->update([
'url' => $url,
]);
}
//\App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
exit;
/*
$dbParams = array(
'dbname' => 'gdoooa_demo',
'user' => 'root',
'password' => 'root',
'host' => 'localhost:3307',
'driver' => 'pdo_mysql',
'charset' => 'utf8mb4',
'default_table_options' => [
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_unicode_ci',
]
);
$paths = array(base_path(). "/abc");
$isDevMode = false;
$config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$metadata = $em->getClassMetadata('App\\Share');
//$cmf = $em->getMetadataFactory();
//$class = $cmf->getMetadataFor('Share');
print_r($metadata);
*/
$abc['indexes'] = [
'idx_object_id' => [
'columns' => ['source_id'],
],
];
$abc['columns'] = [
'id' => [
'name' => '',
'type' => '',
'default' => '',
'notnull' => '',
'length' => '',
'unsigned' => '',
'autoincrement' => '',
'comment' => '',
], 'name' => [
'name' => '',
'type' => '',
'default' => '',
'notnull' => '',
'length' => '',
'unsigned' => '',
'autoincrement' => '',
'comment' => '',
]];
file_put_contents(base_path().'/abc.json', json_encode($abc, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
/*
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
$sm = $conn->getSchemaManager();
$columns = $sm->listTableColumns('role');
foreach ($columns as $column) {
$column->
echo $column->getName() . ': ' . $column->getType() . "\n";
}
print_r($columns);
*/
exit;
$abc = \Gdoo\Produce\Services\ProduceService::getPlanDetail('2020-08-01', '2020-08-04', 0, 0, 0);
// $abc = \Gdoo\Stock\Service\StockService::reportOrderStockInOut(139, 0, '', '', '2020-08-01', '2020-09-21', 1, 1, 0);
print_r($abc);
exit;
/*
$rows = DB::table('model_permission')->get();
foreach($rows as $row) {
$data = json_decode($row['data'], true);
print_r($data);
foreach($data as $k => $rr) {
// _product
print_r($k);
echo "\n";
}
}
exit;
*/
/*
$users = DB::table('user')
->where('group_id', 2)
->get(['id','status', 'name', 'username']);
foreach($users as $user) {
DB::table('customer')->where('user_id', $user['id'])->update([
'status' => $user['status'],
'name' => $user['name'],
'code' => $user['username'],
]);
}
echo 'demo';
exit;
*/
$gets['stock_allocation']['out_warehouse_id'] = 111;
if($gets['stock_allocation']['out_warehouse_id'] <> 140 and $gets['stock_allocation']['out_warehouse_id'] <> 139 and $gets['stock_allocation']['out_warehouse_id'] <> 20005 and $gets['stock_allocation']['out_warehouse_id'] <> 20048) {
echo '1111111111111';
}
if($gets['stock_allocation']['out_warehouse_id'] == 140 or $gets['stock_allocation']['out_warehouse_id'] == 139 or $gets['stock_allocation']['out_warehouse_id'] == 20005 or $gets['stock_allocation']['out_warehouse_id'] == 20048) {
echo '22222222222222';
exit;
}
exit;
/*
$customers = DB::table('tbb_customer')
->get(['tbb_customer.*']);
$users = [];
foreach($customers as $customer) {
$users[] = [
'id' => $customer['CustID'],
'code' => $customer['cCusCode'],
'name' => $customer['cCusName'],
'tel' => $customer['cCusPhone'],
'fax' => $customer['cCusFax'],
'address' => $customer['cCusAddress'],
'head_phone' => $customer['cCusLPersonPhone'],
'head_name' => $customer['cCusLPerson'],
'email' => $customer['cCusEmail'],
// 直营 3
'type_id' => (int)($customer['bZykh2'] == 1 ? 3 : 1),
// 是否调拨
'is_allocate' => (int)$customer['bZykh'],
// 一般纳税人
'general_taxpayer' => (int)$customer['Sfybnsr'],
'status' => (int)$customer['Status'],
'warehouse_address' => $customer['CustWhAddress'],
'warehouse_tel' => $customer['TelPhone'],
'warehouse_contact' => $customer['CustWhPerson'],
'warehouse_phone' => $customer['CustWhPhone'],
'warehouse_size' => $customer['CustWhSqure'],
];
}
*/
/*
$pwd = bcrypt('123456');
foreach($users as $user) {
DB::table('user')->insert([
'id' => $user['id'],
'username' => $user['code'],
'name' => $user['name'],
'email' => $user['email'],
'phone' => $user['head_phone'],
'status' => $user['status'],
'group_id' => 2,
'role_id' => 2,
'password' => $pwd,
]);
DB::table('customer')->insert($user);
}
exit;
$ufcustomer = DB::table('ufcustomer')->get()->toArray();
$ccodes = [];
foreach($ufcustomer as $_ufcustomer) {
$ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
}
foreach($ccodes as $cid => $_codes) {
foreach($_codes as $i => $_code) {
}
}
*/
//100189
$ufcustomer = DB::table('ufcustomer')->get()->toArray();
$ccodes = [];
foreach($ufcustomer as $_ufcustomer) {
$ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
}
$users = DB::table('user')->where('group_id', 2)->get()->keyBy('username')->toArray();
foreach($ccodes as $cid => $_codes) {
foreach($_codes as $i => $_code) {
}
}
/*
set_time_limit(0);
$rows = file_get_contents(public_path('r.json'));
$rows = json_decode($rows, true);
foreach($rows as $row) {
$id1 = DB::table('region')->insertGetId(['name' => $row['name'], 'code' => $row['code'], 'layer' => 1]);
foreach($row['cityList'] as $city) {
$id2 = DB::table('region')->insertGetId(['layer' => 2, 'parent_id' => $id1, 'name' => $city['name'], 'code' => $city['code']]);
foreach($city['areaList'] as $area) {
DB::table('region')->insertGetId(['layer' => 3, 'parent_id' => $id2, 'name' => $area['name'], 'code' => $area['code']]);
}
}
}
echo 111;
*/
exit;
/*
\App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
exit;
DB::enableQueryLog();
$user = DB::table('user as u')->orderBy('id', 'desc')->orderBy('username', 'asc')->first();
print_r(DB::getQueryLog());
*/
/*
$units = option('product.unit')->pluck('id', 'name');
$rows = DB::table('product')->get();
foreach($rows as $row) {
$unit = strtolower($row['unit']);
if (isset($units[$unit])) {
$row['unit_id'] = $units[$unit];
DB::table('product')->where('id', $row['id'])->update($row);
} else {
echo $unit."\n";
}
}
*/
exit;
/*
$t1 = microtime(true);
$stocks = DB::table('stock_yonyou_data')
->groupBy('code')
->selectRaw('sum(quantity_set - quantity_get) as quantity,code')
->pluck('quantity', 'code');
$abc = 0;
foreach ($stocks as $stock) {
$abc += $stock;
}
echo $abc."<br>";
$t2 = microtime(true);
echo '耗时'.($t2 - $t1).'秒';
``
exit;
*/
//$abc = \Yunpian::send('15182223008', '您的验证码是5967');
//print_r($abc);
//exit;
/*
$agentid = 1000035;
$url = 'http://www.shenghuafood.com/article/article/view?id=1336&agentid='.$agentid;
//$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww42727b1e44abc7fa&redirect_uri='.$u.'&response_type=code&scope=snsapi_privateinfo&agentid='.$agentid.'&state='.$agentid.'#wechat_redirect';
$msg = array(
'touser' => 'qy01bbfb5d6f30ae009bc0e5b8fb',
'toparty' => '',
'msgtype' => 'news',
'agentid' => $agentid,
'news' => array(
"articles"=> array(
0 => array(
"title" => "有新的公告提醒",
"description" => "[公告】关于西安大军区的调整公告",
"url" => $url,
"picurl" => ""
))
)
'text' => array(
"content"=>"各部门及同事:\n".
"为更好的服务好再来大厦,满足大厦入驻员工的班车需求,现对部分班车路线及时刻做相应调整,自2016年9月20日零时生效。详情点击\n<a href=\"http://banche.hoolilai.com\">http://banche.hoolilai.com</a>"
)
);
$api = new \App\Wechat\Work\App($agentid);
var_dump($api->sendMsgToUser($msg));
*/
$xml = simplexml_load_file('tpl.xml');
/*
$attributes = $xml->record->attributes();
foreach ($attributes as $k => $v) {
print_r($k.'---'.$v);
}
*/
$form = $xml->xpath("record[@type='form']/form")[0];
foreach ($form as $key => $node) {
if ($key == 'group') {
$fields = [];
foreach ($node as $k => $field) {
if ($k == 'field') {
$attr = $field->attributes();
$col = $attr['col'] - 2;
$abc[] = '<label class="col-sm-2 control-label" for=""><span class="red">*</span> 供应商</label>';
$abc[] = '<div class="col-sm-'.$col.' control-text"><input type="text" value="180407-185" required="required" class="form-control input-sm" id="supplier_price_sn" name="supplier_price[sn]" readonly="readonly"></div>';
}
//print_r($k);
}
print_r($abc);
}
}
//$abc = Yunpian::send('15182223008', '您的验证码是5967');
//print_r($abc);
//$ab = new Hawind\Core();
// 开启 log
//DB::connection()->enableQueryLog();
//$abc = User::whereIn('user.id', [1,2,3,4])->select(['user.*','user.name as role_name'])->paginate();
// 获取已执行的查询数组
//$abc = DB::getQueryLog();
//$ab->test($abc);
//print_r($abc);
//print_r($cron->isDue());
//$cron = Cron\CronExpression::factory('0 0 0 ? 1/2 FRI#2 *');
//if ($cron->isDue()) {
// The promotion should be enabled!
//}
/*
$datas = DB::table('stock')
->where('date', '0000-00-00')
->get();
foreach ($datas as $key => $data) {
$data['date'] = date('Y-m-d', $data['add_time']);
DB::table('stock')->where('id', $data['id'])->update($data);
}
*/
/*
$logs = DB::table('model_step_log')
->where('table', 'promotion')
->where('step_status', 'next')
->where('created_id', '278')
->get();
foreach ($logs as $log) {
$data['data_30'] = date('Y-m-d', $log['created_at']);
DB::table('promotion')->where('id', $log['table_id'])->update($data);
}
*/
//$sms = new iscms\Alisms\SendsmsPusher();
//$t = "项目流程提醒! 主题:关于违反销售管理制度之扣分——龚涛天 -【销售行为】处罚等待确认!";
//$words = Yunpian::replaceWords($t);
//$t = str_replace($words[0], $words[1], $t);
//$b = mb_str_split('销售');
//print_r(var_dump($words));
//$abc = Yunpian::getBlackWord($words);
//$abc = Yunpian::getTpl('1701454');
// $abc = Yunpian::getUser();
//print_r($abc['balance'] / 0.05);
//print_r($words);
exit;
/*
$departments = DB::table('department')->pluck('name', 'id');
$roles = DB::table('role')->pluck('name', 'id');
$users = DB::table('user')->pluck('name', 'id');
$shares = DB::table('article')->get();
foreach ($shares as $share) {
$id = $name = [];
$share_user = explode(',', $share['user_id']);
foreach ($share_user as $user) {
if($users[$user]) {
$id[] = 'u'.$user;
$name[] = $users[$user];
}
}
$share_role = explode(',', $share['role_id']);
foreach ($share_role as $role) {
if($roles[$role]) {
$id[] = 'r'.$role;
$name[] = $roles[$role];
}
}
$share_department = explode(',', $share['department_id']);
foreach ($share_department as $department) {
if($departments[$department]) {
$id[] = 'd'.$department;
$name[] = $departments[$department];
}
}
DB::table('article')->where('id', $share['id'])->update([
'receive_id' => join(',', $id),
'receive_name' => join(',', $name)
]);
}
*/
/*
$users = User::get();
foreach ($users as $user) {
if($user->password_text == '' && mb_strlen($user->password) == 32) {
$user->password = \Hash::make($user->username);
$user->password_text = $user->username;
$user->save();
}
}
*/
/*
$p2 = DB::connection('sqlite')
->table('city')
->where('parent_id', 2621)
->get();
print_r($p2);
exit;
*/
// app()->configure('pcas');
// $abc = config('pcas');
// print_r(json_encode($abc, JSON_UNESCAPED_UNICODE));
/*
$users = DB::table('user')->get();
foreach ($users as $user) {
$data['warehouse_tel'] = $user['warehouse_tel'];
$data['warehouse_contact'] = $user['warehouse_contact'];
$data['warehouse_phone'] = $user['warehouse_phone'];
$data['warehouse_address'] = $user['warehouse_address'];
$data['invoice_type'] = $user['invoice'];
DB::table('customer')->where('user_id', $user['id'])->update($data);
}
*/
// print_r(123);
// exit;
// return $this->render([]);
}
}
@@ -0,0 +1,81 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\Index\Services\InfoService;
use Request;
use Gdoo\Model\Services\ModuleService;
class IndexController extends DefaultController
{
/**
* 设置可直接访问的方法
*/
public $permission = [
'info',
'badge',
'badges',
'help',
'index',
'unsupportedBrowser',
'support',
];
public function indexAction()
{
$user = auth()->user();
return $this->render([
'user' => $user,
]);
}
public function infoAction()
{
return InfoService::getInfo("abv");
}
// 首页登录指南页面
public function helpAction()
{
return $this->render();
}
// 技术支持
public function supportAction()
{
return $this->render();
}
/*
* 通用对话框
*/
public function dialogAction()
{
$gets = Request::all();
return $this->render([
'gets' => $gets
]);
}
// 获取单个待办数量
public function badgeAction()
{
$key = Request::input('key');
if ($key) {
$badge = ModuleService::badges($key);
if ($badge) {
return response()->json($badge());
}
}
return response()->json(['total' => 0, 'data' => []]);
}
// 获取全部待办数量
public function badgesAction()
{
$badges = ModuleService::badges();
$json = [];
foreach($badges as $key => $badge) {
$json[$key] = $badge();
}
return response()->json($json);
}
}
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
<?php namespace Gdoo\Index\Models;
use DB;
use Auth;
class Attachment extends BaseModel
{
protected $table = 'attachment';
}
+194
View File
@@ -0,0 +1,194 @@
<?php namespace Gdoo\Index\Models;
use DB;
use Illuminate\Database\Eloquent\Model as Eloquent;
use App\Illuminate\Database\Query\Builder as QueryBuilder;
class BaseModel extends Eloquent
{
public $timestamps = false;
/**
* 设置不允许批量赋值的字段
*/
protected $guarded = ['id'];
/**
* 获取连接的新查询生成器实例
*
* @return \App\Database\Query\Builder
*/
protected function newBaseQueryBuilder()
{
$connection = $this->getConnection();
return new QueryBuilder(
$connection,
$connection->getQueryGrammar(),
$connection->getPostProcessor()
);
}
/**
* 重写日期格式
*/
public function getDateFormat()
{
return 'U';
}
public function getDates()
{
return [];
}
public function scopeWithAt($query, $relation, array $columns)
{
return $query->with([$relation => function ($query) use ($columns) {
$query->select(array_merge(['id'], $columns));
}]);
}
/**
* 查询 Dialog 字段显示的值,其他模型可复写此方法
*/
public function scopeDialog($query, $value)
{
return $query->whereIn('id', $value)->get();
}
/**
* 取得所有层级
*
* @var string $columns 选择字段
*/
public function scopeTree($query, $select = ['node.*'])
{
$rows = $this->from(DB::raw($this->from.' as node, '.$this->from.' as parent'))
->select($select)
->selectRaw('(COUNT(parent.id)-1) level')
->whereRaw('node.lft BETWEEN parent.lft AND parent.rgt')
->groupBy('node.id')
->orderBy('node.lft', 'asc');
$result = array();
if (is_array($rows)) {
foreach ($rows as $row) {
$row['layer'] = str_repeat('|&ndash;', $row['level']);
$result[$row['id']] = $row;
}
}
return $result;
}
/**
* 取得指定层级集
*
* @var int $id 条件编号
* $type int 0.包含自己的所有子类, 1.包含自己所有父类
*/
public function scopeTreeById($query, $id, $type = 0)
{
$table = $this->table;
$rows = $this->from(DB::raw($table.' as node, '.$table.' as parent'))
->whereRaw($type == 0 ? 'node.lft BETWEEN parent.lft AND parent.rgt' : 'parent.rgt BETWEEN node.lft AND node.rgt')
->where('parent.id', $id)
->groupBy('node.id')
->orderBy('node.lft', 'asc')
->select(['node.*'])
->get();
return $rows;
}
public function scopeToTree($query, $text = 'name', $selected = 0, $state = 'closed')
{
if ($selected > 0) {
$selected = $query->treeSinglePath($selected);
}
$nodes = $query->get()->toArray();
// 格式化的树
$tree = [];
//临时扁平数据
$map = [];
foreach ($nodes as $node) {
$node['text'] = $node[$text];
$node['state'] = ($state == 'closed' && empty($selected[$node['id']])) ? 'closed' : 'open';
$map[$node['id']] = $node;
}
unset($selected);
foreach ($nodes as $node) {
if (isset($map[$node['parent_id']])) {
$map[$node['parent_id']]['children'][] = &$map[$node['id']];
} else {
$tree[] = &$map[$node['id']];
}
}
unset($map, $nodes);
return $tree;
}
/**
* 将所有子节点的ID压入根节点
*/
public function scopeToChild($query, array $select = array('*'))
{
$items = $query->get($select)->keyBy('id')->toArray();
$id = 0;
foreach ($items as &$item) {
$path = explode(',', $item['path']);
$item['parent'] = $path;
}
return $items;
}
/**
* 返回当前节点的完整路径
*/
public function scopeTreeSinglePath($query, $id)
{
$table = $this->table;
$rows = $this->from(DB::raw($table.' as node, '.$table.' as parent'))
->whereRaw('node.lft BETWEEN parent.lft AND parent.rgt')
->where('node.id', $id)
->orderBy('node.lft', 'asc')
->select(['parent.*'])
->get()->keyBy('id');
return $rows;
}
/**
* 重建树形结构的左右值
*
* @var $parent_id 构建的开始id
*/
public function scopeTreeRebuild($query, $parent_id = 0, $left = 0, $layer = 0)
{
// 左值 +1 是右值
$right = $left + 1;
// 获得这个节点的所有子节点
$rows = $this->where('parent_id', $parent_id)
->orderBy('sort', 'asc')
->get(['id', 'parent_id', 'lft', 'rgt']);
if ($rows->count()) {
foreach ($rows as $row) {
// 这个节点的子$right是当前的右值,这是由treeRebuild函数递增
$right = $this->TreeRebuild($row->id, $right, $layer + 1);
}
}
// 更新左右值
$this->where('id', $parent_id)->orderBy('sort', 'asc')
->update(['lft'=>$left, 'rgt'=>$right, 'layer' => $layer]);
// 返回此节点的右值+1
return $right + 1;
}
}
+6
View File
@@ -0,0 +1,6 @@
<?php namespace Gdoo\Index\Models;
class Region extends BaseModel
{
protected $table = 'region';
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\Index\Models;
use Gdoo\Index\Models\BaseModel;
class Share extends BaseModel
{
public $table = 'share';
}
@@ -0,0 +1,183 @@
<?php namespace Gdoo\Index\Services;
use Request;
use DB;
use Auth;
class AttachmentService
{
public static function files($name, $path = 'default')
{
$files = Request::file($name);
$path = $path.'/'.date('Ym');
$upload_path = upload_path().'/'.$path;
$res = [];
foreach ($files as $file) {
if ($file->isValid()) {
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 兼容do客户端上传
if ($extension == 'do') {
$clientName = $file->getClientOriginalName();
$extension = pathinfo(substr($clientName, 0, -3), PATHINFO_EXTENSION);
}
// 文件新名字
$name = date('dhis_').str_random(4).'.'.$extension;
$name = mb_strtolower($name);
if ($file->move($upload_path, $name)) {
$res[] = DB::table('attachment')->insertGetId([
'name' => $name,
'path' => $path.'/'.$name,
'type' => $extension,
'size' => $file->getClientSize(),
'status' => 1,
]);
}
}
}
return join(',', array_filter($res));
}
public static function base64($images, $path = 'default', $extension = 'jpg')
{
$path = $path.date('/Ym');
$directory = upload_path().'/'.$path;
if (!is_dir($directory)) {
@mkdir($directory, 0777, true);
}
$res = [];
foreach ($images as $image) {
$name = date('dhis_').str_random(4).'.'.$extension;
$name = mb_strtolower($name);
$image = base64_decode(str_replace(' ', '+', $image));
$size = file_put_contents($directory.'/'.$name, $image);
if ($size) {
$res[] = DB::table('attachment')->insertGetId([
'name' => $name,
'path' => $path.'/'.$name,
'type' => $extension,
'size' => $size,
'status' => 1,
]);
}
}
return join(',', array_filter($res));
}
/**
* 将ids字符串转换为数组
*/
public static function getIds($ids)
{
if (is_array($ids)) {
return $ids;
}
$ids = array_filter(explode("\n", $ids));
return (array)$ids;
}
/**
* 获取指定编号附件列表
*/
public static function get($ids)
{
$ids = self::getIds($ids);
return DB::table('attachment')
->whereIn('id', $ids)
->where('status', 1)->get();
}
/**
* 获取当前ID附件和草稿
*/
public static function edit($ids, $key)
{
$res['rows'] = self::get($ids);
$res['draft'] = self::draft($key);
return $res;
}
/**
* 获取当前ID附件
*/
public static function show($ids)
{
$res['rows'] = self::get($ids);
return $res;
}
/**
* 发布附件,改成状态为可用
*/
public static function publish($ids)
{
$ids = self::getIds($ids);
$rows = DB::table('attachment')
->whereIn('id', $ids)
->where('status', 0)
->get();
foreach ($rows as $row) {
DB::table('attachment')->where('id', $row['id'])->update([
'status' => 1,
]);
}
return true;
}
/**
* 发布附件,改成状态为可用
*/
public static function store($key)
{
$rows = self::draft($key);
foreach ($rows as $row) {
DB::table('attachment')->where('id', $row['id'])->update([
'status' => 1,
]);
}
return true;
}
/**
* 获取草稿文件
*/
public static function draft($key, $user_id = 0)
{
if ($user_id == 0) {
$user_id = auth()->id();
}
return DB::table('attachment')
->where('created_id', $user_id)
->where('key', $key)
->where('status', '0')
->get();
}
/**
* 删除附件和文件
*/
public static function remove($ids)
{
$ids = self::getIds($ids);
$rows = DB::table('attachment')->whereIn('id', $ids)->get();
foreach ($rows as $row) {
// 删除文件
$file = upload_path().'/'.$row['path'];
if (is_file($file)) {
unlink($file);
}
DB::table('attachment')->where('id', $row['id'])->delete();
}
return 1;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php namespace Gdoo\Index\Services;
use DB;
class BadgeService
{
/**
* 获取待办事项
*/
public static function getModelTodo($table)
{
$master = DB::table('model')->where('table', $table)->first();
$rows = DB::table('model_run_log')
->leftJoin('model_run', 'model_run.id', '=', 'model_run_log.run_id')
->leftJoin($table, $table.'.id', '=', 'model_run.data_id')
->leftJoin('user as run_log_user', 'run_log_user.id', '=', 'model_run_log.user_id')
->where('model_run_log.updated_id', 0)
->where('model_run_log.user_id', auth()->id())
->where('model_run_log.bill_id', $master['id'])
->where($table.'.id', '>', 0)
->get(['model_run_log.*']);
$ret['total'] = sizeof($rows);
$ret['data'] = $rows;
return $ret;
}
}
+149
View File
@@ -0,0 +1,149 @@
<?php namespace Gdoo\Index\Services;
use DB;
use Auth;
use Gdoo\System\Models\Widget;
use Gdoo\User\Models\UserWidget;
use Request;
class InfoService
{
/**
* 获取季度日期
*/
public static function getSeason($interval = 0) {
$season = ceil(date('n') / 3) + $interval;
$a = date('Y-m-d', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));
$b = date('Y-m-d', mktime(23, 59, 59, $season * 3, date('t', mktime(0, 0, 0, $season * 3, 1, date("Y"))), date('Y')));
return [$a, $b];
}
public static function getInfo($table)
{
$auth = auth()->user();
$gets = Request::all();
$dates = [
'day' => '昨天',
'day2' => '前天',
'week' => '上周',
'week2' => '前周',
'month' => '上月',
'month2' => '前月',
'quarter' => '上季度',
'quarter2' => '前季度',
'year' => '去年',
'year2' => '前年',
];
$user_info = UserWidget::where('user_id', $auth['id'])
->where('id', $gets['id'])->first();
$info = Widget::where('id', $user_info['node_id'])
->first();
if (not_empty($user_info)) {
$info['id'] = $user_info['id'];
if ($user_info['name']) {
$info['name'] = $user_info['name'];
}
if ($user_info['color']) {
$info['color'] = $user_info['color'];
}
if ($user_info['icon']) {
$info['icon'] = $user_info['icon'];
}
$info['params'] = json_decode($user_info['params'], true);
}
$params = $info['params'];
$permission = empty($params['permission']) ? 'department' : $params['permission'];
$date = empty($params['date']) ? 'month' : $params['date'];
switch ($date) {
case 'day':
case 'day2':
// 天
$day = date('Y-m-d');
$day2 = strtotime('-1 day '.$day);
$day3 = strtotime('-2 day '.$day);
break;
case 'week':
case 'week2':
// 周
$week[] = date('Y-m-d', strtotime('this week'));
$week[] = date('Y-m-d', strtotime('this week +6 day'));
$week2[] = date('Y-m-d', strtotime('next week'));
$week2[] = date('Y-m-d', strtotime('next week +6 day'));
$week3[] = date('Y-m-d', strtotime('monday -2 week'));
$week3[] = date('Y-m-d', strtotime('sunday -1 week'));
break;
case 'month':
case 'month2':
// 月
$month = date('Y-m');
$month2 = date('Y-m', strtotime("-1 month"));
$month3 = date('Y-m', strtotime("-2 month"));
break;
case 'season':
case 'season2':
// 季度
$season = static::getSeason();
$season2 = static::getSeason(-1);
$season3 = static::getSeason(-2);
break;
case 'year':
case 'year2':
// 年
$year = date('Y');
$year2 = $year - 1;
$year3 = $year - 2;
break;
}
$sql = $sql2 = '';
switch ($date) {
case 'day':
$sql = sql_year_month_day($table.'created_at','ts')."='$day'";
$sql2 = sql_year_month_day($table.'created_at','ts')."='$day2'";
break;
case 'day2':
$sql = sql_year_month_day($table.'.created_at','ts')."='$day2'";
$sql2 = sql_year_month_day($table.'.created_at','ts')."='$day3'";
break;
case 'week':
$sql = sql_year_month_day($table.'.created_at','ts')." between '$week[0]' and '$week[1]'";
$sql2 = sql_year_month_day($table.'.created_at','ts')." between '$week2[0]' and '$week2[1]'";
break;
case 'week2':
$sql = sql_year_month_day($table.'.created_at','ts')." between '$week2[0]' and '$week2[1]'";
$sql2 = sql_year_month_day($table.'.created_at','ts')." between '$week3[0]' and '$week3[1]'";
break;
case 'month':
$sql = sql_year_month($table.'.created_at','ts')."='$month'";
$sql2 = sql_year_month($table.'.created_at','ts')."='$month2'";
break;
case 'month2':
$sql = sql_year_month($table.'.created_at','ts')."='$month2'";
$sql2 = sql_year_month($table.'.created_at','ts')."='$month3'";
break;
case 'season':
$sql = sql_year_month_day($table.'.created_at','ts')." between '$season[0]' and '$season[1]'";
$sql2 = sql_year_month_day($table.'.created_at','ts')." between '$season2[0]' and '$season2[1]'";
break;
case 'season2':
$sql = sql_year_month_day($table.'.created_at','ts')." between '$season2[0]' and '$season2[1]'";
$sql2 = sql_year_month_day($table.'.created_at','ts')." between '$season3[0]' and '$season3[1]'";
break;
case 'year':
$sql = sql_year($table.'.created_at','ts')."='$year'";
$sql2 = sql_year($table.'.created_at','ts')."='$year2'";
break;
case 'year2':
$sql = sql_year($table.'.created_at','ts')."='$year2'";
$sql2 = sql_year($table.'.created_at','ts')."='$year3'";
break;
}
return ['info' => $info, 'dates' => $dates, 'sql' => $sql, 'sql2' => $sql2, 'gets' => $gets, 'params' => $params, 'auth' => $auth];
}
}
+70
View File
@@ -0,0 +1,70 @@
<?php namespace Gdoo\Index\Services;
use Auth;
use DB;
use Gdoo\User\Services\UserAssetService;
class MenuService
{
/**
* 取得菜单列表
*/
public static function getItems()
{
static $data = [];
if ($data) {
return $data;
}
$assets = UserAssetService::getRoleAuthorise(Auth::user()->role_id);
$menus = DB::table('menu')->where('status', 1)->orderBy('lft', 'asc')->get();
$menus = array_tree($menus);
$positions = [];
foreach ($menus as $menuId => &$menu) {
if ($menu['children']) {
// 二级菜单
foreach ($menu['children'] as $groupId => &$group) {
$group['url'] = str_replace('.', '/', $group['url']);
if (substr_count($group['url'], '/') < 2) {
$group['url'] = '';
}
if ($group['url']) {
$group['url'] = str_replace('.', '/', $group['url']);
$group['key'] = str_replace('/', '_', $group['url']);
if ($group['access'] == 0 || isset($assets[$group['url']])) {
$menu['selected'] = 1;
$group['selected'] = 1;
}
}
if ($group['children']) {
// 三级菜单
foreach ($group['children'] as $actionId => &$action) {
$action['url'] = str_replace('.', '/', $action['url']);
$action['key'] = str_replace('/', '_', $action['url']);
$positions[$action['url']] = $menuId.','.$groupId.','.$actionId;
if ($action['access'] == 0 || isset($assets[$action['url']])) {
if (empty($group['url'])) {
$group['url'] = $action['url'];
$group['key'] = $action['key'];
}
$menu['selected'] = 1;
$group['selected'] = 1;
$action['selected'] = 1;
}
}
}
}
}
}
$data['children'] = $menus;
return $data;
}
}
@@ -0,0 +1,155 @@
<?php namespace Gdoo\Index\Services;
use Log;
use DB;
use Mail;
use Gdoo\System\Models\Setting;
use Gdoo\Wechat\Services\WechatService;
use Gdoo\System\Services\SmsService;
class NotificationService
{
/**
* 微信公众号模板消息
*/
public static function wechatTemplate($users, $content)
{
if (env('WECHAT_MESSAGE_PUSH_STATUS') === false) {
return false;
}
if (empty($users) || empty($content)) {
return false;
}
try {
$tousers = DB::table('wechat_user')->whereIn('user_id', $users)->pluck('openid');
if ($tousers) {
$app = WechatService::getApp();
foreach ($tousers as $touser) {
$content['touser'] = $touser;
$app->template_message->send($content);
}
}
return true;
} catch(\Exception $e) {
system_log('notification.wechat', '微信消息', $e->getMessage(), 'error');
return false;
}
}
/**
* 站内通知
*/
public static function site($users, $subject, $content, $url)
{
if (empty($subject) || empty($content) || empty($users)) {
return false;
}
try {
foreach ($users as $user_id) {
DB::table('user_message')->insert([
'content' => $subject.$content,
'url' => $url,
'read_id' => $user_id,
'created_id' => auth()->id(),
]);
}
return true;
} catch(\Exception $e) {
system_log('notification.site', '站内消息', $e->getMessage(), 'error');
return false;
}
}
/**
* 添加新通知
*/
public static function sms($users, $subject, $content = '')
{
if (empty($subject) || empty($users)) {
return false;
}
try {
// 短信群发一次最大条数
$users = array_chunk($users, 500);
foreach ($users as $user) {
$user = join(',', $user);
if ($user) {
// 记录发送结果
$res = SmsService::send($user, $subject.$content);
if ($res['code'] <> 0) {
abort_error($res['msg']);
}
foreach ($res['data'] as $row) {
$data = json_encode([
'msg' => $row['msg'],
'code' => $row['code'],
'count' => $row['count'],
], JSON_UNESCAPED_UNICODE);
$log = [
'content' => $subject.$content,
'data' => $data,
'phone' => $row['mobile'],
'status' => $row['code'] == 0 ? 1 : 0,
];
DB::table('sms_log')->insert($log);
}
}
}
return true;
} catch(\Exception $e) {
system_log('notification.sms', '短信消息', $e->getMessage(), 'error');
return false;
}
}
/**
* 邮件通知
*/
public static function mail($view, $users, $subject, $content)
{
if ($subject == '' || $content == '' || empty($users)) {
return false;
}
$setting = Setting::where('type', 'system')->pluck('value', 'key');
$mail = DB::table('mail')->where('status', 1)->orderBy('sort', 'asc')->first();
$config = config('mail');
config([
'mail' => array_merge($config, [
'host' => $mail['smtp'],
'port' => $mail['port'],
'encryption' => $mail['secure'],
'username' => $mail['user'],
'password' => $mail['password'],
'from' => [
'address' => $mail['user'],
'name' => $mail['name'],
],
])
]);
$data['subject'] = $subject;
$data['content'] = $content;
try {
return Mail::send('emails.'.$view, $data, function ($message) use ($setting, $users, $subject) {
foreach ($users as $user) {
$message->to($user);
}
$message->subject($setting['title']);
});
} catch(\Exception $e) {
system_log('notification.mail', '邮件消息', $e->getMessage(), 'error');
return false;
}
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php namespace Gdoo\Index\Services;
class RetService
{
public $data = null;
public static function make($data = null)
{
$me = new static();
$me->data = collect();
$me->set($data);
return $me;
}
public function set($key, $value = null)
{
if (empty($key)) {
return;
}
if (empty($value)) {
$this->data = $this->data->merge($key);
} else {
$this->data[$key] = $value;
}
}
public function error($msg)
{
$this->data['msg'] = $msg;
$this->data['success'] = false;
return json_encode($this->data, JSON_UNESCAPED_UNICODE);
}
public function success($msg)
{
$this->data['msg'] = $msg;
$this->data['success'] = true;
return json_encode($this->data, JSON_UNESCAPED_UNICODE);
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php namespace Gdoo\Index\Services;
use Gdoo\Index\Models\Share;
use Gdoo\User\Models\User;
class ShareService
{
/**
* 获取分享数据
*/
public static function getItemsSourceBy(array $source_type, $user_id)
{
$user = User::find($user_id);
return Share::leftJoin('user', 'share.created_id', '=', 'user.id')
->permission('share.receive_id', $user)
->whereIn('share.source_type', $source_type)
->get(['share.*', 'user.name', 'user.username']);
}
/**
* 获取分享数据
*/
public static function getItemsCreatedBy(array $source_type, $user_id)
{
return Share::where('created_id', $user_id)
->whereIn('source_type', $source_type)
->get();
}
/**
* 添加分享数据
*/
public static function getItemsSourceId($source_type, $source_id)
{
return Share::where('source_id', $source_id)
->where('source_type', $source_type)
->get();
}
/**
* 添加分享数据
*/
public static function getItem($source_type, $source_id)
{
return Share::where('source_id', $source_id)
->where('source_type', $source_type)
->first();
}
/**
* 删除一条分享数据
*/
public static function removeItem($source_type, $source_id)
{
return Share::where('source_id', $source_id)
->where('source_type', $source_type)
->delete();
}
/**
* 添加分享数据
*/
public static function addItem($data)
{
if ($data['receive_id'] == '') {
return;
}
if (empty($data['source_id']) || empty($data['source_type'])) {
return;
}
Share::insert($data);
}
/**
* 编辑分享数据
*/
public static function editItem($source_type, $source_id, $data)
{
if ($data['receive_id'] == '') {
// 共享对象为空删除共享记录
static::removeItem($source_type, $source_id);
return;
}
if (empty($source_id) || empty($source_type)) {
return;
}
return Share::where('source_id', $source_id)
->where('source_type', $source_type)
->update($data);
}
}
+42
View File
@@ -0,0 +1,42 @@
<style>
.close-header { margin: 0 15px 0; }
</style>
<button type="button" data-dismiss="dialog" class="close close-header">&times;</button>
<ul class="nav nav-tabs padder m-t" id="api-dialog">
<li class="active"><a href="#modal-department" data-toggle="tab">部门</a></li>
<li><a href="#modal-role" data-toggle="tab">角色</a></li>
<li><a href="#modal-user" data-toggle="tab">用户</a></li>
<li><a href="#modal-customer" data-toggle="tab">客户</a></li>
</ul>
<div id="tab-content"></div>
<script>
(function($) {
var params = {{json_encode($gets)}};
var routes = {
'#modal-user': 'user/user/dialog',
'#modal-role': 'user/role/dialog',
'#modal-department': 'user/department/dialog',
'#modal-customer': 'customer/customer/dialog',
'#modal-customer-contact': 'customer/contact/dialog',
'#modal-supplier': 'supplier/supplier/dialog',
'#modal-supplier-contact': 'supplier/contact/dialog'
};
function loadData(target) {
params['prefix'] = 1;
$.get(app.url(routes[target], params), function(html) {
$('#tab-content').html(html);
});
}
loadData('#modal-department');
$('#api-dialog a[data-toggle=tab]').click(function() {
var target = $(this).attr('href');
loadData(target);
});
})(jQuery);
</script>
@@ -0,0 +1,15 @@
<script type="text/javascript">
$(document).ready(function() {
// 百度地图API功能
var map = new BMap.Map("mapinfo");
var point = new BMap.Point({{$gets['lng']}},{{$gets['lat']}});
map.centerAndZoom(point, 15);
// 创建标注
var marker = new BMap.Marker(point);
// 将标注添加到地图中
map.addOverlay(marker);
// 鼠标滑轮缩放
map.enableScrollWheelZoom();
});
</script>
<div id="mapinfo" style="height:430px;">地图加载中...</div>
+17
View File
@@ -0,0 +1,17 @@
<form class="form-horizontal" method="post" action="{{url()}}" id="user-sms" name="user-sms">
<table class="table table-form m-b-none">
<tbody>
<tr>
<td width="10%" align="right">接收者</td>
<td>{{$user['name']}}</td>
</tr>
<tr>
<td align="right">内容</td>
<td colspan="3">
<textarea rows="2" class="form-control" id="content" name="content"></textarea>
<input type="hidden" name="user_id" value="{{$user['id']}}">
</td>
</tr>
</tbody>
</table>
</form>
@@ -0,0 +1,34 @@
Gdoo
<html lang="en">
<head>
<meta charset="UTF-8">
<title>浏览器升级提示</title>
<style>
body { color:#333; margin-top:100px; text-align:center; font-family:'Microsoft Yahei'; }
a { color:#563d7c; font-weight:bold; }
a:hover { color:#cdbfe3; }
li { color:#666; list-style:none; padding:5px 0; }
</style>
</head>
<body>
<h2>很遗憾,Gdoo OA 不支持 IE 8 以下的浏览器</h2>
<h3>为了更好地使用本系统,你可以选择</h3>
<ul>
<li>
<a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">升级浏览器</a>
</li>
<li>
安装强大、好用的标准浏览器
<div>
<a href="http://www.google.com/chrome/">Chrome</a>
<a href="http://www.mozilla.org/zh-CN/firefox/new/">Firefox</a>
<a href="http://www.opera.com/zh-cn">Opera</a>
<a href="http://www.apple.com/safari/">Safari</a>
</div>
</li>
<li>
<a href="http://www.google.com/chromeframe/thankyou.html?extra=betachannel&hl=zh-CN&prefersystemlevel=true&statcb">如果您还是习惯使用当前的浏览器,请安装 Chrome 框架</a>
</li>
</ul>
</body>
</html>
@@ -0,0 +1,352 @@
<style type="text/css">
.dashboard-edit { background-color: #f0f3f4; }
.panel-shadow {
box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.03);
border: solid 1px rgba(0, 0, 0, 0.08);
border-radius: 4px !important;
}
.edit-droppable div {
border: 1px dashed #23b7e5;
background: #dcf2f8;
text-align: center;
color: #ccc;
padding-bottom: 10px;
margin-bottom: 10px;
border-radius: 4px;
}
.widget-edit { display: flex; flex-direction: row; align-items:stretch; }
.widget-edit .col-xs-12 {
min-height: 100px;
}
.widget-edit-item .panel-heading {
padding-left: 5px;
padding-right: 5px;
cursor:move;
}
.widget-edit-item > div {
padding-left: 5px;
padding-right: 5px;
}
.todo-edit .panel { display: flex; padding-bottom: 10px; text-align: center; }
.todo-edit-l-t { cursor:move; color: #fff; margin-top:12px; margin-left: 10px; border-radius: 50%; width: 50px; height:50px; line-height:58px; vertical-align: middle; }
.todo-edit-c-t { flex:1; margin-left: 12px; text-align: left; }
.todo-edit-c-t .todo-name { margin-top:13px; color: #666; }
.todo-edit-c-t .todo-item { font-size: 24px; color: #666; }
.todo-edit-r-t { text-align: left; margin-right: 10px; margin-top:5px; }
.widget-option {
padding-top:10px;
text-align: right;
padding-right: 8px;
}
.widget-option .fa {
font-size: 14px;
color: #999;
}
.widget-option:hover .fa {
color: #0e90d2;
}
.quick-edit {
margin-bottom: 10px;
padding: 3px;
padding-top: 10px;
}
.quick-edit-text {
float: left;
margin-right: 10px;
padding: 5px;
}
.quick-edit-text .title {
width: 48px;
text-overflow: hidden;
text-align: center;
padding-top: 5px;
color: #333;
}
.quick-edit-item {
position: relative;
cursor:move;
}
.quick-edit-item .quick-remove {
line-height: 0;
display: none;
}
.quick-edit-item:hover .quick-remove {
display: block;
position: absolute;
top: -8px;
right: -8px;
background-color: #fff;
height: 20px;
line-height: 20px;
width: 20px;
z-index: 1;
border-radius: 50%;
box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.10);
}
.quick-edit-item:hover .quick-remove .fa {
font-size: 12px;
color: #999;
}
.quick-edit-item:hover .quick-remove:hover .fa {
color: #f00;
}
.quick-edit-add {
background-color:#fff;
line-height: 52px;
}
.quick-edit-add .fa {
color:#999;
}
.quick-edit-add:hover .fa {
color:#2490f8;
}
</style>
@verbatim
<div id="dashboard-config">
<div class="dashboard-edit">
<form method="post" id="widget-edit" name="widget_edit">
<div class="quick-edit">
<div class="row row-sm">
<draggable
v-model="menus"
item-key="id"
group="menus"
@start="drag=true"
@end="drag=false">
<template #item="{element, index}">
<div class="quick-edit-text">
<div class="quick-icon quick-edit-item" :style="'background-color:' + element.color">
<a class="quick-remove" @click="quickRemove(index);">
<i class="fa fa-times"></i>
</a>
<i :class="'fa fa-3x ' + element.icon"></i>
</div>
<div class="title">{{element.name}}</div>
</div>
</template>
</draggable>
<div class="quick-edit-text">
<a href="javascript:;" @click="quickAdd">
<div class="quick-icon quick-edit-add">
<i class="fa fa-3x fa-plus"></i>
</div>
<div class="title">添加快捷</div>
</a>
</div>
</div>
</div>
<draggable
class="row row-sm todo-edit"
v-model="infos"
handle=".todo-edit-l-t"
item-key="id"
group="infos"
@start="dragging=true"
@end="dragging=false">
<template #item="{element, index}">
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-3">
<div class="panel panel-shadow">
<div class="todo-edit-l-t" :style="'background-color:' + element.color">
<i :class="'fa fa-2x ' + element.icon"></i>
</div>
<div class="todo-edit-c-t">
<div class="todo-name">{{element.name}}</div>
<span class="todo-node">
<div class="text-info todo-item">0</div>
</span>
</div>
<div class="todo-edit-r-t">
<label title="显示/隐藏" class="i-switch bg-success m-t-xs">
<input type="checkbox" v-model="element.status" :true-value="1" :false-value="0"><i></i>
</label>
<div class="widget-option">
<a @click="infoOption(index, element)" title="配置">
<i class="fa fa-gear"></i>
</a>
</div>
</div>
</div>
</div>
</template>
</draggable>
<div class="row row-sm widget-edit">
<draggable
class="col-xs-12 col-sm-8"
v-model="leftWidgets"
handle=".panel-heading"
item-key="id"
group='widgets'
@start="dragging=true"
@end="dragging=false">
<template #item="{element, index}">
<div class="widget-edit-item" :id="'widget_item_' + element.id">
<div class="panel panel-shadow">
<div class="panel-heading text-base">
<div class="pull-right">
<label title="显示/隐藏" class="i-switch bg-primary m-t-xs">
<input type="checkbox" v-model="element.status" :true-value="1" :false-value="0"><i></i>
</label>
<div class="widget-option">
<a @click="widgetOption(index, element)" title="配置">
<i class="fa fa-gear"></i>
</a>
</div>
</div>
{{element.name}}
</div>
<div class="panel-body wrapper-sm"></div>
</div>
</div>
</template>
</draggable>
<draggable
class="col-xs-12 col-sm-4"
v-model="rightWidgets"
handle=".panel-heading"
item-key="id"
group='widgets'
@start="dragging=true"
@end="dragging=false">
<template #item="{element, index}">
<div class="widget-edit-item" :id="'widget_item_' + element.id">
<div class="panel panel-shadow">
<div class="panel-heading text-base">
<div class="pull-right">
<label title="显示/隐藏" class="i-switch bg-primary m-t-xs">
<input type="checkbox" v-model="element.status" :true-value="1" :false-value="0"><i></i>
</label>
<div class="widget-option">
<a @click="widgetOption(index, element)" title="配置">
<i class="fa fa-gear"></i>
</a>
</div>
</div>
{{element.name}}
</div>
<div class="panel-body wrapper-sm"></div>
</div>
</div>
</template>
</draggable>
</div>
</div>
</div>
@endverbatim
<script>
var configData = {{$json}};
var settingWidget = Vue.createApp({
components: {
draggable: GdooVueComponents.draggable,
},
data() {
return {
infos: configData.infos,
widgets: configData.widgets,
menus: configData.menus,
leftWidgets: [],
rightWidgets: [],
dragging: false
}
},
methods: {
quickRemove(index) {
this.menus.splice(index, 1);
},
quickAdd() {
var me = this;
formDialog({
title: '添加菜单',
url: app.url('index/dashboard/quickMenu'),
id: 'quick-menu',
dialogClass:'modal-sm',
onSubmit: function() {
var items = $('#quick-menu').serializeArray();
var row = {};
$.each(items, function(index, item) {
row[item.name] = item.value;
});
me.menus.push(row);
$(this).dialog("close");
}
});
},
infoOption(index, item) {
var me = this;
formDialog({
title: '配置',
url: app.url('index/dashboard/settingInfo', {info_id:item.info_id}),
id: 'setting-info',
dialogClass:'modal-sm',
onSubmit: function() {
var info = $('#setting-info').serializeArray();
$.each(info, function(k, v) {
item[v.name] = v.value;
});
me.infos[index] = item;
$(this).dialog("close");
}
});
},
widgetOption(index, item) {
var me = this;
formDialog({
title: '配置',
url: app.url('index/dashboard/settingWidget', {widget_id:item.widget_id}),
id: 'setting-widget',
dialogClass:'modal-sm',
onSubmit: function() {
var widget = $('#setting-widget').serializeArray();
$.each(widget, function(k, v) {
item[v.name] = v.value;
});
if (item.grid == 8) {
me.leftWidgets[index] = item;
} else {
me.rightWidgets[index] = item;
}
$(this).dialog("close");
}
});
},
save() {
var me = this;
var res = {
menu: me.menus,
info: me.infos,
widget: [],
};
me.leftWidgets.forEach(function(item) {
item.grid = 8;
res.widget.push(item);
});
me.rightWidgets.forEach(function(item) {
item.grid = 4;
res.widget.push(item);
});
return res;
}
},
created () {
this.leftWidgets = this.widgets.filter(function(item) {
return item.grid == 8;
});
this.rightWidgets = this.widgets.filter(function(item) {
return item.grid == 4;
});
}
}).mount('#dashboard-config');
</script>
<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">
@@ -0,0 +1,425 @@
<style type="text/css">
html {
overflow: hidden;
}
a { outline: none; }
.dashboard-widget {
overflow: hidden;
overflow-y: auto;
height: calc(100vh - 32px);
padding-top: 10px;
}
.dashboard-config {
text-align: center;
position: fixed;
right: 22px;
top: 0;
background-color: rgba(255, 255, 255, 0.8);
height: 26px;
line-height: 25px;
width: 26px;
z-index: 1;
border-radius: 0 0 4px 4px;
border: solid 1px rgba(255, 255, 255, 0.2);
box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.10);
}
.dashboard-config .fa {
color: #999;
}
.dashboard-config:hover {
border: solid 1px rgba(255, 255, 255, 0.1);
}
.dashboard-config:hover .fa {
color: #2490f8;
}
.panel-heading {
padding: 5px 10px;
}
.content-body { margin: 0; }
.content-body .panel:last-child {
margin-bottom: 10px;
}
.frame-green .dashboard-title {
color: #fff;
}
.frame-primary .dashboard-title {
color: #58666e;
}
.frame-blue .dashboard-title {
color: #fff;
}
.frame-blue2 .dashboard-title {
color: #1890ff;
}
.frame-blue .quick-text .title,
.frame-purple .quick-text .title,
.frame-green .quick-text .title,
.frame-lilac .quick-text .title,
.frame-wood .quick-text .title {
color: #fff;
}
.panel-shadow {
box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.03);
border: solid 1px rgba(0, 0, 0, 0.08);
border-radius: 4px !important;
}
.frame-blue .panel-shadow,
.frame-purple .panel-shadow,
.frame-green .panel-shadow,
.frame-lilac .panel-shadow,
.frame-wood .panel-shadow {
border: solid 0;
}
.row-sm { margin-left: 5px; margin-right: 5px; }
.row-sm > div { padding-left: 5px; padding-right: 5px; }
.row-sm > div > .panel {
text-align: center;
}
.row-info .panel { display: flex; padding-bottom: 10px; position: relative; text-align: center; border-radius: 4px !important; }
.info-skin1 .info-l { color: #fff; margin-top:16px; margin-left: 15px; border-radius: 50%; width: 50px; height:50px; line-height:58px; vertical-align: middle; }
.info-skin1 .info-c { flex:1; margin-left: 15px; text-align: left; }
.info-skin1 .info-c .info-name { margin-top:18px; font-size: 14px; color: #666; }
.info-skin1 .info-c .info-item { font-size: 24px; color: #333; }
.info-skin1 .info-r { margin-left: auto; margin-top:18px; width: 70px; line-height:22px; }
.info-skin1 .info-r .rate { color: #2bbf24; }
.info-skin1 .info-r .red { color:#f00; }
.info-skin1 .info-r::before { position:absolute;top:22px;content:"";width:1px;height:40px;background-color:#e6e6e6;display:block; }
.info-items { height: 94px; }
.app-title {
padding: 15px;
}
.app-title a {
color: #999;
line-height: 22px;
}
.app-title a:hover {
color: #0e90d2;
}
@media (min-width: 768px) {
.widget-item {
min-height: 200px;
}
.todo-text { margin-left: 60px; }
}
.row-widget .panel-heading {
padding: 10px;
color: #2490f8;
font-size: 14px;
text-align: left;
}
.row-widget .widget-item {
text-align: left;
}
.row-widget .widget-item .red {
font-size: 15px;
font-weight: bold;
color: #333;
}
.row-widget .widget-droppable div {
border-radius: 4px;
}
.ag-theme-balham .ag-header {
border-bottom: 1px solid #dee5e7;
}
.ag-theme-balham .ag-header-cell::after, .ag-theme-balham .ag-header-group-cell::after {
border-right: 0 !important;
}
.dashboard-footer {
background: #fff;
position: fixed;
bottom: 0;
right: 0;
left: 0;
box-shadow: 20px 0px 8px 0 rgba(29,35,41,.05);
border-top: 1px solid #e8e8e8;
}
.dashboard-footer .box {
padding: 6px;
padding-bottom: 8px;
text-align: right;
color: #999;
}
.dashboard-footer .box a {
color: #999;
font-weight: bold;
background: -webkit-linear-gradient(-70deg, #db469f, #2188ff);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
.dashboard-footer .box a:hover {
color: #0e90d2;
}
.row-quick {
margin-bottom: 10px;
padding: 10px;
}
.quick-text {
float: left;
margin-right: 10px;
}
.quick-text .title {
text-align: center;
padding-top: 5px;
color: #333;
}
.quick-icon .quick-num {
font-family: Arial;
position: absolute;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
font-size: 12px;
color: #fff;
right: -5px;
top: -5px;
background: #f00;
border-radius: 100%;
border: solid 1px #f05050;
display: none;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12);
}
.quick-icon {
width: 48px;
height: 48px;
text-align: center;
line-height: 50px;
border-radius: 5px;
border: solid 1px rgba(255,255,255,0.1);
box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.15);
position: relative;
}
.quick-icon .fa {
font-size: 20px;
color: #fff;
}
.dropdown-toggle {
border: solid 1px rgba(0, 0, 0, 0.1);
}
</style>
<div class="dashboard-widget">
<div class="pull-right hidden-xs">
<a class="dashboard-config" data-toggle="dashboard-config" title="仪表盘设置">
<i class="fa fa-gear"></i>
</a>
</div>
<div class="row-quick">
<div class="row row-sm">
@forelse($quicks as $quick)
<div class="quick-text">
<a href="javascript:;" data-toggle="addtab" data-url="{{$quick['url']}}" data-id="{{$quick['key']}}" data-name="{{$quick['name']}}">
<div class="quick-icon quick-item" style="background-color:{{$quick['color']}}" data-url="{{$quick['url']}}" data-key="{{$quick['key']}}">
<i class="fa fa-3x {{$quick['icon']}}"></i>
<span class="quick-num">0</span>
</div>
<div class="title">{{$quick['name']}}</div>
</a>
</div>
@empty
<div class="quick-text">
<a href="javascript:;" data-toggle="dashboard-config">
<div class="quick-icon" style="background-color:#13D06C;">
<i class="fa fa-3x fa-plus"></i>
</div>
<div class="title">添加快捷</div>
</a>
</div>
@endforelse
</div>
</div>
<div class="row row-sm row-info">
@foreach($infos as $info)
@if($info['status'])
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
<div class="info-items" data-id="{{$info['id']}}" data-url="{{$info['url']}}" data-more_url="{{$info['more_url']}}"></div>
</div>
@endif
@endforeach
</div>
<div class="row row-sm row-widget">
@foreach($grids as $grid)
<div class="col-xs-12 col-sm-{{$grid}}">
@foreach($widgets as $widget)
@if($widget['status'])
@if($widget['grid'] == $grid)
<div class="panel panel-shadow">
<div class="panel-heading text-base b-b">
<div class="pull-right"></div>
<a data-toggle='widget-refresh' data-url="{{$widget['url']}}" data-key="{{str_replace(['/', '?', '='], ['_', '_', '_'], $widget['url'])}}" data-id="{{$widget['id']}}">{{$widget['name']}}</a>
</div>
<div class="widget-item" id="widget_item_{{$widget['id']}}" data-id="{{$widget['id']}}" data-url="{{$widget['url']}}">
</div>
</div>
@endif
@endif
@endforeach
</div>
@endforeach
</div>
</div>
<div class="dashboard-footer">
<div class="box">
{{$version}} {{$openSource ? '开源版' : '企业版'}}
</div>
</div>
<style>
.ag-theme-balham .ag-root {
border: 0;
}
.ag-theme-balham .ag-status-bar {
border: 0;
}
.ag-theme-balham .ag-header {
background-color: #fff;
}
.ag-theme-balham .ag-header-cell, .ag-theme-balham .ag-header-group-cell {
border-right: transparent;
}
.ag-theme-balham .ag-ltr .ag-cell {
border-width: 0 0 0 0;
border-right-color: #d9dcde;
}
.ag-theme-balham .ag-header-cell::after, .ag-theme-balham .ag-header-group-cell::after {
border-right: 1px solid rgba(189, 195, 199, 0.5);
}
</style>
<script>
(function($) {
var $document = $(document);
var myProcess = null;
function widgetRefresh() {
if (myProcess) {
var items = $('.widget-item');
items.each(function(index, item) {
var data = $(item).data();
if (data.key) {
gdoo.widgets[data.key].remoteData({page: 1});
console.log('refresh item:' + data.key);
}
});
}
myProcess = setTimeout(function() {
widgetRefresh();
}, 1000 * 60 * 5);
}
widgetRefresh();
$document.on('click', '[data-toggle="addtab"]', function(event) {
event.preventDefault();
// 触屏设备不触发事件
var mq = top.checkMQ();
if ($(this).parent().find('ul').length) {
if(mq == 'mobile' || mq == 'tablet') {
return false;
}
}
// 无ID不触发事件
var data = $(this).data();
if(data.id == undefined) {
return false;
}
top.addTab(data.url, data.id, data.name);
});
$('[data-toggle="dashboard-config"]').on('click', function() {
formDialog({
title: '仪表盘设置',
url: app.url('index/dashboard/config'),
id: 'widget-edit',
dialogClass:'modal-lg',
onSubmit: function() {
var me = this;
var data = settingWidget.save();
$.post(app.url('index/dashboard/config'), data, function(res) {
if (res.status) {
location.reload();
toastrSuccess(res.data);
$(me).dialog("close");
} else {
toastrError(res.data);
}
});
}
});
});
$('[data-toggle="widget-refresh"]').on('click', function() {
var data = $(this).data();
if (data.key) {
gdoo.widgets[data.key].remoteData({page: 1});
}
});
function widgetInit() {
var items = $('.widget-item');
items.each(function(index, item) {
var data = $(item).data();
if (data == undefined) {
return false;
}
if (data.url) {
$(item).load(app.url(data.url, {id: data.id}));
}
});
var items = $('.info-items');
items.each(function(index, item) {
var me = $(item);
var data = me.data();
if (data.url) {
$(item).load(app.url(data.url, {id: data.id}));
}
});
var items = $('.quick-item');
items.each(function(index, item) {
var me = $(item);
var data = me.data();
$.get(app.url('index/index/badge', {key: data.key}), function(res) {
if(res.total > 0) {
me.find('.quick-num').show().text(res.total);
}
});
});
}
widgetInit();
})(jQuery);
</script>
@@ -0,0 +1,501 @@
<style type="text/css">
html {
overflow: hidden;
}
a { outline: none; }
.dashboard-widget-header {
margin-top: 49px;
height: calc(100vh - 80px);
overflow: hidden;
overflow-y: auto;
}
.dashboard-title {
padding: 10px;
position: absolute;
top: 0;
width: 100vw;
border-bottom: solid 1px rgba(0, 0, 0, 0.05);
}
.dashboard-title .btn {
border: solid 1px rgba(0, 0, 0, 0.15);
background-color: #fff;
}
.dashboard-config {
text-align: center;
height: 26px;
line-height: 26px;
width: 26px;
display: block;
border-radius: 4px;
background-color: #fff;
border: solid 1px rgba(0, 0, 0, 0.1);
}
.dashboard-config .fa {
color: #999;
}
.dashboard-config:hover {
border: solid 1px rgba(0, 0, 0, 0.2);
}
.dashboard-config:hover .fa {
color: #2490f8;
}
.panel-heading {
padding: 5px 10px;
}
.content-body { margin: 0; }
.content-body .panel:last-child {
margin-bottom: 10px;
}
.frame-green .dashboard-title {
color: #fff;
}
.frame-primary .dashboard-title {
color: #58666e;
}
.frame-blue .dashboard-title {
color: #fff;
}
.frame-blue2 .dashboard-title {
color: #1890ff;
}
.frame-blue .quick-text .title,
.frame-purple .quick-text .title,
.frame-green .quick-text .title,
.frame-lilac .quick-text .title,
.frame-wood .quick-text .title {
color: #fff;
}
.frame-blue .dashboard-title .btn,
.frame-purple .dashboard-title .btn,
.frame-green .dashboard-title .btn,
.frame-lilac .dashboard-title .btn,
.frame-wood .dashboard-title .btn {
border: solid 1px rgba(0, 0, 0, 0.15);
background-color: rgba(0, 0, 0, 0.15);
color: #fff;
}
.panel-shadow {
box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.03);
border: solid 1px rgba(0, 0, 0, 0.08);
border-radius: 4px !important;
}
.frame-blue .panel-shadow,
.frame-purple .panel-shadow,
.frame-green .panel-shadow,
.frame-lilac .panel-shadow,
.frame-wood .panel-shadow {
border: solid 0;
}
.row-sm { margin-left: 5px; margin-right: 5px; }
.row-sm > div { padding-left: 5px; padding-right: 5px; }
.row-sm > div > .panel {
text-align: center;
}
.row-info .panel { display: flex; padding-bottom: 10px; position: relative; text-align: center; border-radius: 4px !important; }
.row-info .widget-droppable div { border-radius: 4px; }
.info-l { color: #fff; margin-top:16px; margin-left: 15px; border-radius: 50%; width: 50px; height:50px; line-height:58px; vertical-align: middle; }
.info-c { flex:1; margin-left: 15px; text-align: left; }
.info-c .info-name { margin-top:18px; font-size: 14px; color: #666; }
.info-c .info-item { font-size: 24px; color: #333; }
.info-r { margin-left: auto; margin-top:18px; width: 70px; line-height:22px; }
.info-r .rate { color: #2bbf24; }
.info-r::before { position:absolute;top:22px;content:"";width:1px;height:40px;background-color:#e6e6e6;display:block; }
.app-title {
padding: 15px;
}
.app-title a {
color: #999;
line-height: 22px;
}
.app-title a:hover {
color: #0e90d2;
}
@media (min-width: 768px) {
.widget-item {
min-height: 200px;
}
.todo-text { margin-left: 60px; }
}
.widget-droppable div {
border: 1px dashed #23b7e5;
background: #dcf2f8;
text-align: center;
color: #ccc;
padding-bottom: 10px;
}
.row-widget .panel-heading {
padding: 10px;
color: #2490f8;
font-size: 14px;
text-align: left;
}
.row-widget .widget-item {
text-align: left;
}
.row-widget .widget-item .red {
font-size: 15px;
font-weight: bold;
color: #333;
}
.row-widget .widget-droppable div {
border-radius: 4px;
}
.ag-theme-balham .ag-header {
border-bottom: 1px solid #dee5e7;
}
.ag-theme-balham .ag-header-cell::after, .ag-theme-balham .ag-header-group-cell::after {
border-right: 0 !important;
}
.dashboard-footer {
background: #fff;
position: fixed;
bottom: 0;
right: 0;
left: 0;
box-shadow: 20px 0px 8px 0 rgba(29,35,41,.05);
border-top: 1px solid #e8e8e8;
}
.dashboard-footer .box {
padding: 6px;
padding-bottom: 8px;
text-align: right;
color: #999;
}
.dashboard-footer .box a {
color: #999;
font-weight: bold;
background: -webkit-linear-gradient(-70deg, #db469f, #2188ff);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
.dashboard-footer .box a:hover {
color: #0e90d2;
}
.row-quick {
margin-bottom: 10px;
padding: 10px;
}
.quick-text {
float: left;
margin-right: 10px;
}
.quick-text .title {
text-align: center;
padding-top: 5px;
color: #333;
}
.quick-icon .quick-num {
font-family: Arial;
position: absolute;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
font-size: 12px;
color: #fff;
right: -5px;
top: -5px;
background: #f00;
border-radius: 100%;
border: solid 1px #f05050;
display: none;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12);
}
.quick-icon {
width: 48px;
height: 48px;
text-align: center;
line-height: 50px;
border-radius: 5px;
border: solid 1px rgba(255,255,255,0.1);
box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.15);
position: relative;
}
.quick-icon .fa {
font-size: 20px;
color: #fff;
}
</style>
<div class="dashboard-widget">
<div class="dashboard-title">
<div class="pull-right">
<a class="dashboard-config" data-toggle="dashboard-config" title="仪表盘设置">
<i class="fa fa-gear"></i>
</a>
</div>
<div class="font-thin">
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-filter"></span> 本部门下属部门
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">本人</a></li>
<li><a href="#">本人和下属</a></li>
<li><a href="#">本部门</a></li>
<li class="active"><a href="#">本部门下属部门</a></li>
<li class="divider"></li>
<li class=""><a href="#">自定义</a></li>
</ul>
</div>
<div class="btn-group m-l-xs" role="group">
<button type="button" class="btn btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-filter"></span> 本月
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">今天</a></li>
<li><a href="#">昨天</a></li>
<li><a href="#">本周</a></li>
<li><a href="#">上周</a></li>
<li class="active"><a href="#">本月</a></li>
<li><a href="#">上月</a></li>
<li><a href="#">本季度</a></li>
<li><a href="#">上季度</a></li>
<li><a href="#">本年</a></li>
<li><a href="#">去年</a></li>
<li class="divider"></li>
<li class=""><a href="#">自定义</a></li>
</ul>
</div>
</div>
</div>
<div class="dashboard-widget-header">
<div class="row-quick m-t-sm">
<div class="row row-sm">
@forelse($quicks as $quick)
<div class="quick-text">
<a href="javascript:;" data-toggle="addtab" data-url="{{$quick['url']}}" data-id="{{$quick['key']}}" data-name="{{$quick['name']}}">
<div class="quick-icon quick-item" style="background-color:{{$quick['color']}}" data-url="{{$quick['url']}}" data-key="{{$quick['key']}}">
<i class="fa fa-3x {{$quick['icon']}}"></i>
<span class="quick-num">0</span>
</div>
<div class="title">{{$quick['name']}}</div>
</a>
</div>
@empty
<div class="quick-text">
<a href="javascript:;" data-toggle="dashboard-config">
<div class="quick-icon" style="background-color:#13D06C;">
<i class="fa fa-3x fa-plus"></i>
</div>
<div class="title">添加快捷</div>
</a>
</div>
@endforelse
</div>
</div>
<div class="row row-sm row-info">
@foreach($infos as $info)
@if($info['status'])
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
<div class="panel panel-shadow">
<div class="info-l hidden-xs bg-{{$info['color']}}">
<i class="fa fa-2x {{$info['icon']}}"></i>
</div>
<div class="info-c">
<div class="info-name">{{$info['name']}}</div>
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
<div class="text-info info-item" data-url="{{$info['url']}}" data-more_url="{{$info['more_url']}}"></div>
</a>
</div>
<div class="info-r">
<div>较上月</div>
<div class="rate">50%</div>
</div>
</div>
</div>
@endif
@endforeach
</div>
<div class="row row-sm row-widget">
@foreach($grids as $grid)
<div class="col-xs-12 col-sm-{{$grid}}">
@foreach($widgets as $widget)
@if($widget['status'])
@if($widget['grid'] == $grid)
<div class="panel panel-shadow">
<div class="panel-heading text-base b-b">
<div class="pull-right"></div>
<a data-toggle='widget-refresh' data-url="{{$widget['url']}}" data-key="{{str_replace(['/', '?', '='], ['_', '_', '_'], $widget['url'])}}" data-id="{{$widget['id']}}">{{$widget['name']}}</a>
</div>
<div class="widget-item" id="widget_item_{{$widget['id']}}" data-url="{{$widget['url']}}">
</div>
</div>
@endif
@endif
@endforeach
</div>
@endforeach
</div>
</div>
</div>
<div class="dashboard-footer">
<div class="box">
{{$version}} {{$openSource ? '开源版' : '企业版'}}
</div>
</div>
<style>
.ag-theme-balham .ag-root {
border: 0;
}
.ag-theme-balham .ag-status-bar {
border: 0;
}
.ag-theme-balham .ag-header {
background-color: #fff;
}
.ag-theme-balham .ag-header-cell, .ag-theme-balham .ag-header-group-cell {
border-right: transparent;
}
.ag-theme-balham .ag-ltr .ag-cell {
border-width: 0 0 0 0;
border-right-color: #d9dcde;
}
.ag-theme-balham .ag-header-cell::after, .ag-theme-balham .ag-header-group-cell::after {
border-right: 1px solid rgba(189, 195, 199, 0.5);
}
</style>
<script>
(function($) {
var $document = $(document);
var myProcess = null;
function widgetRefresh() {
if (myProcess) {
var items = $('.widget-item');
items.each(function(index, item) {
var data = $(item).data();
if (data.key) {
gdoo.widgets[data.key].remoteData({page: 1});
console.log('refresh item:' + data.key);
}
});
}
myProcess = setTimeout(function() {
widgetRefresh();
}, 1000 * 60 * 5);
}
widgetRefresh();
$document.on('click', '[data-toggle="addtab"]', function(event) {
event.preventDefault();
// 触屏设备不触发事件
var mq = top.checkMQ();
if ($(this).parent().find('ul').length) {
if(mq == 'mobile' || mq == 'tablet') {
return false;
}
}
// 无ID不触发事件
var data = $(this).data();
if(data.id == undefined) {
return false;
}
top.addTab(data.url, data.id, data.name);
});
$('[data-toggle="dashboard-config"]').on('click', function() {
formDialog({
title: '仪表盘设置',
url: app.url('index/dashboard/config'),
id: 'widget-edit',
dialogClass:'modal-lg',
success: function(res) {
location.reload();
toastrSuccess(res.data);
$(this).dialog("close");
},
error: function(res) {
toastrError(res.data);
}
});
});
$('[data-toggle="widget-refresh"]').on('click', function() {
var data = $(this).data();
if (data.key) {
gdoo.widgets[data.key].remoteData({page: 1});
}
});
function widgetInit() {
var items = $('.widget-item');
items.each(function(index, item) {
var data = $(item).data();
if (data == undefined) {
return false;
}
if (data.url) {
$(item).load(app.url(data.url, {id: data.id}));
}
});
var items = $('.info-item');
items.each(function(index, item) {
var me = $(item);
var data = me.data();
$.get(app.url('index/index/info', {type: data.url}), function(res) {
if(res > 0) {
me.removeClass('text-info').addClass('text-danger');
} else {
me.removeClass('text-danger').addClass('text-info');
}
me.text(res);
});
});
var items = $('.quick-item');
items.each(function(index, item) {
var me = $(item);
var data = me.data();
$.get(app.url('index/index/badge', {key: data.key}), function(res) {
if(res.total > 0) {
me.find('.quick-num').show().text(res.total);
}
});
});
}
widgetInit();
})(jQuery);
</script>
@@ -0,0 +1,72 @@
<form method="post" id="quick-menu" name="quick_menu">
<table class="table table-form m-b-none">
<tr>
<td align="right">菜单</td>
<td>
<select class="form-control input-sm" name="node_id" id="node_id">
<option value=""> - </option>
@foreach($menus as $menu)
<option value="{{$menu['id']}}" data-menu_id="{{$menu['id']}}" data-name="{{$menu['name']}}" data-color="{{$menu['color']}}" data-icon="{{$menu['icon']}}" data-url="{{$menu['url']}}">{{$menu['layer_space']}}{{$menu['name']}}</option>
@endforeach
</select>
</td>
</tr>
<tr>
<td align="right">显示名称</td>
<td align="left">
<input type="text" autocomplete="off" class="form-control input-sm" id="name" name="name">
</td>
</tr>
<tr>
<td align="right">图标</td>
<td align="left">
<div class="input-group">
<span class="input-group-addon" id="icon-picker"></span>
<input data-placement="bottomLeft" type="text" autocomplete="off" class="form-control icp icp-auto input-sm" id="icon" name="icon">
</div>
</td>
</tr>
<tr>
<td align="right">颜色</td>
<td align="left">
<div class="colorpicker-controller" title="选择颜色">
<div id="color-picker" class="colorpicker"></div>
</div>
<input type="hidden" id="color" name="color">
</td>
</tr>
<tr>
<td align="right">URL</td>
<td align="left">
<input type="text" readonly="readonly" class="form-control input-sm" id="url" name="url">
</td>
</tr>
</table>
</form>
<script>
$(function() {
$('#node_id').on('change', function() {
var data = $(this).find("option:selected").data();
$('#color-picker').css({'background-color': data.color});
$('#color').val(data.color);
$('#icon-picker').html('<i class="fa ' + data.icon + '"></i>');
$('#icon').val(data.icon);
$('#url').val(data.url);
$('#name').val(data.name);
});
$('#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,71 @@
<form method="post" id="setting-info" name="setting_info">
<table class="table table-form m-b-none">
<tr>
<td align="right">名称</td>
<td align="left">
<input type="text" autocomplete="off" class="form-control input-sm" readonly="readonly" value="{{$row['widget_name']}}">
</td>
</tr>
<tr>
<td align="right">显示名称</td>
<td align="left">
<input type="text" autocomplete="off" class="form-control input-sm" id="name" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">权限</td>
<td>
<select class="form-control input-sm" name="permission" id="permission">
@foreach($permissions as $key => $permission)
<option value="{{$key}}" @if($row['permission'] == $key) selected="selected" @endif>{{$permission}}</option>
@endforeach
</select>
</td>
</tr>
<tr>
<td align="right">日期</td>
<td>
<select class="form-control input-sm" name="date" id="date">
@foreach($dates as $key => $date)
<option value="{{$key}}" @if($row['date'] == $key) selected="selected" @endif>{{$date}}</option>
@endforeach
</select>
</td>
</tr>
<tr>
<td align="right">图标</td>
<td align="left">
<div class="input-group">
<span class="input-group-addon" id="icon-picker"></span>
<input data-placement="bottomLeft" type="text" autocomplete="off" value="{{$row['icon']}}" class="form-control icp icp-auto input-sm" id="icon" name="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>
</table>
</form>
<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,53 @@
<form method="post" id="setting-widget" name="setting_widget">
<table class="table table-form m-b-none">
<tr>
<td align="right">名称</td>
<td align="left">
<input type="text" autocomplete="off" class="form-control input-sm" readonly="readonly" value="{{$row['widget_name']}}">
</td>
</tr>
<tr>
<td align="right">显示名称</td>
<td align="left">
<input type="text" autocomplete="off" class="form-control input-sm" id="name" name="name" value="{{$row['name']}}">
</td>
</tr>
<!--
<tr>
<td align="right">图标</td>
<td align="left">
<div class="input-group">
<span class="input-group-addon" id="icon-picker"></span>
<input data-placement="bottomLeft" type="text" autocomplete="off" class="form-control icp icp-auto input-sm" id="icon" name="icon">
</div>
</td>
</tr>
-->
<tr>
<td align="right">背景颜色</td>
<td align="left">
<div class="colorpicker-controller" title="选择颜色">
<div id="color-picker" class="colorpicker"></div>
</div>
<input type="hidden" id="color" name="color">
</td>
</tr>
</table>
</form>
<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>
+228
View File
@@ -0,0 +1,228 @@
<style>
body {
text-align:center;
}
.abc {
display: inline-block;
text-align:left;
}
.table-c {
border-right: 1px solid black;
border-bottom: 1px solid black;
background-color: white;
}
.td { padding-left: 5px; }
.maxth {
width: 18%;
}
.maxtd {
padding-left: 5px;
}
.middletd {
/*
width: 13.5%;
*/
padding-left: 5px;
}
.mintd {
}
.mintd-blue {
border-right: 1px solid blue;
}
.mintd-red {
border-right: 1px solid red;
}
.mintd-m {
width: 3px;
}
.mintd, .mintd-blue, .mintd-red {
width: 2.5%;
text-align: center;
}
.td, .maxth, .maxtd, .middleth, .middletd, .mintd, .mintd-blue, .mintd-red, .mintd-m {
border-left: 1px solid black;
border-top: 1px solid black;
}
.input {
border-left: 0px;
border-top: 0px;
border-right: 0px;
border-bottom: 1px;
width: 100%;
height: 100%;
}
</style>
<?php
$m = mb_str_split("千百十万千百十元角分 千百十万千百十元角分");
$jfze = 0;
$dfze = 0;
?>
<script>
window.onresize = function () {
resize();
}
$(document).ready(function () {
resize();
})
function resize() {
var table = document.getElementById("maintable");
table.style.width = window.innerWidth * 0.45+"px";
table.style.height = window.innerWidth * 0.35 / 2.8 + "px";
}
</script>
<body>
<div class="abc">
<table>
<tr>
<td colspan="3" style="text-align:center;"><h2>记账凭证</h2></td>
</tr>
<tr>
<td></td>
<td style="text-align:center;">凭证日期:2020-10-10</td>
<td style="text-align:right;"><b>@Model[0].Pzlb 字: @Model[0].Pzxh 号</b></td>
</tr>
<tr>
<td colspan="3">
<table class="table-c" id="maintable">
<tr>
<td rowspan="2" class="maxth" style="text-align:center;"><h4><b>摘 要</b></h4></td>
<td colspan="2" class="td" style="text-align:center;height:30px;"><b>科 目</b></td>
<td colspan="10" class="td" style="text-align:center;"><b>借 方 金 额</b></td>
<td class="mintd-m"></td>
<td colspan="10" class="td" style="text-align:center;"><b>贷 方 金 额</b></td>
</tr>
<tr>
<td class="middleth" style="text-align:center;height:30px;"><b>科 目 代 码</b></td>
<td class="maxth" style="text-align:center;"><b>会 计 科 目</b></td>
@for ($j = 1; $j <= 21; $j++)
@if ($j == 2 || $j == 5 || $j == 13 || $j == 16)
<td class="mintd-blue"><?php echo $m[$j - 1]; ?></td>
@elseif ($j == 8 || $j == 19)
<td class="mintd-red"><?php echo $m[$j - 1]; ?></td>
@elseif ($j == 11)
<td class="mintd-m"></td>
@else
<td class="mintd"><?php echo $m[$j - 1]; ?></td>
@endif
@endfor
</tr>
@for ($i = 0; $i < 3; $i++)
<?php $jfze += 0; ?>
<?php $dfze += 0; ?>
<tr>
<td class="maxtd">@Model[i].Zy</td>
<td class="middletd">@Model[i].Kjkmdm</td>
<td class="maxtd">@Model[i].Kjkmmc</td>
<!--
@VouRow(Model[i].Jfje, Model[i].Dfje)
-->
@for ($j = 1; $j <= 21; $j++)
@if ($j == 2 || $j == 5 || $j == 13 || $j == 16)
<td class="mintd-blue"><?php echo 0; ?></td>
@elseif ($j == 8 || $j == 19)
<td class="mintd-red"><?php echo 0; ?></td>
@elseif ($j == 11)
<td class="mintd-m"></td>
@else
<td class="mintd"><?php echo 2; ?></td>
@endif
@endfor
</tr>
@endfor
<tr>
<td colspan="3" class="td" style="text-align:left"><b>合计:</b>@NumtoChinese(jfze)</td>
<!--
@VouRow(jfze, dfze)
-->
@for ($j = 1; $j <= 21; $j++)
@if ($j == 2 || $j == 5 || $j == 13 || $j == 16)
<td class="mintd-blue"><?php echo 11; ?></td>
@elseif ($j == 8 || $j == 19)
<td class="mintd-red"><?php echo 22; ?></td>
@elseif ($j == 11)
<td class="mintd-m"></td>
@else
<td class="mintd"><?php echo 33; ?></td>
@endif
@endfor
</tr>
</table>
</td>
</tr>
<tr>
<td>经办人:张三</td>
<td>记账人:李四</td>
<td>审核人:王五</td>
</tr>
</table>
</div>
</body>
<!--
@helper VouRow(string m)
{
for (int j = 1; j <= 21; j++)
{
if (j == 2 || j == 5 || j == 13 || j == 16)
{
<td class="mintd-blue">@m[j - 1]</td>
}
else if (j == 8 || j == 19)
{
<td class="mintd-red">@m[j - 1]</td>
}
else if (j == 11)
{
<td class="mintd-m"></td>
}
else
{
<td class="mintd">@m[j - 1]</td>
}
}
}
@helper VouRow(decimal k, decimal d)
{
string m = (k == 0 ? "".PadLeft(10) : k.ToString().Replace(".", "").PadLeft(10)) + " " + (d == 0 ? "".PadLeft(10) : d.ToString().Replace(".", "").PadLeft(10));
@VouRow(m)
}
@helper NumtoChinese(decimal s)
{
s = Math.Round(s, 2);//四舍五入到两位小数,即分
string[] n = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
//数字转大写
string[] d = { "", "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿" };
//不同位置的数字要加单位
List<string> needReplace = new List<string> { "零拾", "零佰", "零仟", "零万", "零亿", "亿万", "零元", "零零", "零角", "零分" };
List<string> afterReplace = new List<string> { "零", "零", "零", "万", "亿", "亿", "元", "零", "", "" };//特殊情况用replace剔除
string b = "人民币";//开头
string e = s % 1 == 0 ? "整" : "";//金额是整数要加一个“整”结尾
string re = "";
Int64 a = (Int64)(s * 100);
int k = 1;
while (a != 0)
{//初步转换为大写+单位
re = n[a % 10] + d[k] + re;
a = a / 10;
k = k < 11 ? k + 1 : 4;
}
string need = needReplace.Where(tb => re.Contains(tb)).FirstOrDefault<string>();
while (need != null)
{
int i = needReplace.IndexOf(need);
re = re.Replace(needReplace[i], afterReplace[i]);
need = needReplace.Where(tb => re.Contains(tb)).FirstOrDefault<string>();
}//循环排除特殊情况
re = re == "" ? "" : b + re + e;
<span>@re</span>;
}
-->
+189
View File
@@ -0,0 +1,189 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{$setting['title']}} - Powered By {{$setting['powered']}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=yes" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="{{$asset_url}}/dist/index.min.css?v={{$resVersion}}" type="text/css" />
<script src="{{$public_url}}/common?v={{$resVersion}}"></script>
<script src="{{$asset_url}}/dist/index.min.js?v={{$resVersion}}"></script>
<script src="{{$asset_url}}/vendor/layer/layer.js"></script>
<script src="{{$asset_url}}/dist/bundle.min.js"></script>
<style type="text/css">
@foreach($menus['children'] as $menu_id => $menu)
.side-nav a.a{{$menu_id}} {box-shadow: inset 3px 0 0 {{$menu['color']}};}
.side-nav a.a{{$menu_id}} .icon,.side-nav .hover a.a{{$menu_id}} { background-color: {{$menu['color']}}; }
.side-nav a.a{{$menu_id}} .icon .fa { color: #fff; }
.side-nav .hover a.a{{$menu_id}} .icon { background-color: #fff; }
.side-nav .hover a.a{{$menu_id}} .icon .fa { color: {{$menu['color']}}; }
@endforeach
</style>
</head>
<body class="theme-{{auth()->user()->theme ?: 'lilac'}}">
<header class="header navbar">
<div class="navbar-header" id="navbar-left">
<a href="javascript:;" title="折叠菜单" data-toggle="side-folded" class="folded">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-right text-active"></i>
</a>
<a class="btn btn-link visible-xs" data-toggle="dropdown" data-target=".nav-user">
<i class="icon icon-cog"></i>
</a>
<a href="{{url('/')}}" class="navbar-brand">
<img src="{{$asset_url}}/images/logo.svg" width="18" />
<!--
<i class="fa text-lg fa-buysellads"></i>
-->
<span class="navbar-brand-title">
{{$setting['title']}}
</span>
</a>
<a class="btn btn-link visible-xs nav-trigger" data-target="#nav">
<span></span>
</a>
</div>
<ul class="nav navbar-nav tabs-list hidden-xs" id="tabs-list">
<li role='presentation'>
<a href="#tab_dashboard" aria-controls="0" data-toggle="tab" role="tab">
<i class="fa fa-square-o"></i>
<span>首页</span>
</a>
</li>
</ul>
<div id="notificationApp"><notification/></div>
</header>
<div class="nav-scroll">
<div class="side-nav" id="tabs-left">
@if(Auth::user()->avatar_show == 1)
<div class="side-nav-avatar">
<span class="thumb-md avatar">
<a href="javascript:;" data-toggle="addtab" data-url="user/profile/index" data-id="user_profile_index" data-name="个人资料">
<img src="{{avatar(Auth::user()->avatar)}}" class="img-circle">
<i class="on md b-white bottom"></i>
</a>
</span>
<span class="text-avatar text-muted text-xs block m-t-xs">
<?php echo Auth::user()->name; ?>
</span>
</div>
@endif
<ul>
@foreach($menus['children'] as $menu_id => $menu)
@if($menu['selected'])
<li class="has-children">
<a href="javascript:;" class="a{{$menu_id}}" title="{{$menu['name']}}">
<span class="pull-right">
<i class="fa fa-fw fa-angle-right text"></i>
<i class="fa fa-fw fa-angle-down text-active"></i>
</span>
<span class="icon">
<span class="pulse-box">
<span id="badge_menu_{{$menu['id']}}" class="pulse" style="display:none;"></span>
</span>
<i class="fa {{$menu['icon']}}"></i>
</span>
<span class="title">{{$menu['name']}}</span>
</a>
<ul>
@foreach($menu['children'] as $groupId => $group)
@if($group['selected'])
<li class="has-children">
<a class="notify-box" href="javascript:;" data-toggle="addtab" data-url="{{$group['url']}}" data-id="{{$group['key']}}" data-name="{{$group['name']}}">
@if(count((array)$group['children']))
<span class="pull-right">
<i class="fa fa-fw fa-angle-right text"></i>
<i class="fa fa-fw fa-angle-down text-active"></i>
</span>
<b id="badge_group_{{$group['id']}}" class="pulse pulse-right" style="display:none;"></b>
@else
<b data-menu_id="{{$menu['id']}}" id="badge_{{$group['key']}}" class="badge bg-danger pull-right" style="display:none;"></b>
@endif
{{$group['name']}}
</a>
@if(count((array)$group['children']))
<ul>
@foreach($group['children'] as $action)
@if($action['selected'])
<li class="@if($action['active']) active @endif">
<a href="javascript:;" data-toggle="addtab" data-url="{{$action['url']}}" data-id="{{$action['key']}}" data-name="{{$action['name']}}">
@if($group['url'])
<b data-menu_id="{{$menu['id']}}" data-group_id="{{$group['id']}}" id="badge_{{$action['key']}}" class="badge bg-danger pull-right" style="display:none;"></b>
@endif
{{$action['name']}}
</a>
</li>
@endif
@endforeach
</ul>
@endif
</li>
@endif
@endforeach
</ul>
</li>
@endif
@endforeach
</ul>
<ul class="profile">
<li class="label">个人</li>
<li>
<a href="javascript:;" data-toggle="addtab" data-url="user/message/index" data-id="user_message_index" data-name="通知提醒"
title="通知提醒">
<i class="fa fa-bell"></i>
<span class="title">通知提醒</span>
<!--
<span class="count badge pull-right bg-danger">3</span>
-->
</a>
</li>
</ul>
</div>
</div>
<div class="main-content">
<div class="tab-content" id="tabs-content">
<div role="tabpanel" class="tab-pane active" id="tab_dashboard">
<iframe src="{{url('index/dashboard/index')}}" id="tab_iframe_dashboard" frameBorder=0 scrolling=auto width="100%" height="100%"></iframe>
</div>
</div>
</div>
<script>
const vueApp = Vue.createApp({
components: {
notification: GdooVueComponents.notification,
}
});
vueApp.config.globalProperties.url = app.url;
vueApp.mount('#notificationApp');
</script>
</body>
</html>
@@ -0,0 +1,36 @@
<div class="table-responsive">
<table class="table m-b-none">
<tr>
<td width="25%" align="right" style="border-top:0;">
软件版本
</td>
<td align="left" style="border-top:0;">
{{$version}} {{$openSource ? '开源版' : '企业版'}}
</td>
</tr>
<tr>
<td align="right">
资源版本
</td>
<td align="left">
{{$resVersion}}
</td>
</tr>
<tr>
<td align="right">
开发商
</td>
<td align="left">
眉山市爱客网络科技有限公司
</td>
</tr>
<tr>
<td align="right">
支持方式
</td>
<td align="left">
15182223008(电话/微信)
</td>
</tr>
</table>
</div>