Commit c6fae1f3 by 孙龙

up

parent a1b12a75
......@@ -13,14 +13,14 @@ DB_WEB_HOST=192.168.2.232
DB_WEB_DATABASE=liexin
DB_WEB_USERNAME=liexin
DB_WEB_PASSWORD=liexin#zsyM
DB_PORT=3306
DB_LABEL_HOST=192.168.2.232
DB_LABEL_DATABASE=lie_labels
DB_LABEL_USERNAME=lie_labels
DB_LABEL_PASSWORD=lie_labels#zsyM
DB_PORT=3306
DB_MICROSERVICE_HOST=192.168.2.232
DB_MICROSERVICE_DATABASE=lie_micro_service
DB_MICROSERVICE_USERNAME=micro_service
DB_MICROSERVICE_PASSWORD=lie_micro_service#zsyM
DB_MONGO_HOST=192.168.1.237
DB_MONGO_DATABASE=ichunt
......@@ -58,4 +58,4 @@ ADMIN=liuzhiyong@teshehui.com
LOGIN_DOMAIN='user.liexin.net'
ERP_DOMAIN=http://192.168.1.235:6886
ERP_DB_NAME=ICHUNT
\ No newline at end of file
ERP_DB_NAME=ICHUNT
<?php
namespace App\Exceptions;
class IcException extends \Exception{
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Model\MicroServiceInfoModel;
use App\Model\OfflinePrintModel;
use App\Model\TmplRelationsModel;
use Illuminate\Http\Request;
......@@ -25,7 +26,7 @@ class WebController extends Controller
$useremail= $request->user->email;
// 菜单
$menuconfig = DB::table('config')->where('config_title', '标签管理系统')->first();
$menuconfig = DB::table('config')->where('config_title', '微服务网关管理后台')->first();
$menus = [];
if ($menuconfig && !($menus = json_decode($menuconfig->config_data)))
$menus = [];
......@@ -72,127 +73,32 @@ class WebController extends Controller
}
// 模板列表
public function labelList($request, $info)
public function microServicesList($request, $info)
{
$info['title'] = '我的标签模板列表';
$info['title'] = '服务列表';
return view('web', $info);
}
// 模板列表
public function systemlabelList($request, $info)
{
$info['title'] = '系统内置标签模板列表';
$info['id']= "labelList";
$info["labelListSystem"] = 1;
return view('web', $info);
}
// 标签使用记录
public function record($request, $info)
// 模板列表
public function addMicroService($request, $info)
{
$info['title'] = '标签使用记录';
return view('web', $info);
}
/*
* 设计
*/
public function design($request,$info){
$info['title'] = '标签设计';
return view('web', $info);
}
/*
* 离线使用
*/
public function offline($request,$info){
$info['title'] = '离线使用';
return view('web', $info);
}
/*
* 标签预览
*/
public function showPage($request,$info){
$info['title'] = '预览';
$id = $request->input("tmpl_relation_id",0);
$html = (new \App\Services\LabelService)->getLabelHtml($id);
$info["html"] = $html;
return view('web', $info);
}
/*
* 标签预览
*/
public function showTemplate($request,$info){
$info['title'] = '预览';
$id = $request->input("t_id",0);
// $count = TemplateListModel::where("id",intval($id))->where("create_userid",$request->user->userId)->count("id");
// if($count <= 0){
// return back()->with('showTemplateerror', '没找到属于您的模板信息');
// }
$templateInfo = TemplateListModel::where("id",intval($id))->select("id","template_name","status")->first();
// if($templateInfo->status <= 0){
// return back()->with('showTemplateerror', '该模板已经被主人禁用了');
// }
// dump($templateInfo->template_extend);
$html = $templateInfo->template_extend;
$info["html"] = $html->html;
return view('web', $info);
}
$type = $request->input("type","add");
$id = $request->input("id",0);
if ($type == "add"){
$info['title'] = '创建HTTP服务';
}else{
$microServiceInfo = MicroServiceInfoModel::where(["id"=>$id])->first();
$info['title'] = '修改HTTP服务';
$info["microInfo"] = $microServiceInfo;
/*
* 打印标签
*/
public function prints($request,$info){
$tmpl_relationids = $request->input("tmpl_relationids",'');
$tmpl_relationid_arr = explode(",",$tmpl_relationids);
if(empty($tmpl_relationids)){
die("没有要打印的数据");
}
if(!empty($tmpl_relationid_arr)){
$tmpl_relationid_arr = array_unique($tmpl_relationid_arr);
$tmpl_relationid_arr = array_map("intval",$tmpl_relationid_arr);
$tmpl_relationid_arr = array_filter($tmpl_relationid_arr,function($val){
if ($val > 0) {
return true;
} else {
return false;
}
});
}
// dump($tmpl_relationid_arr);
$info['title'] = '打印';
$templateRelation = TmplRelationsModel::where("create_userid",$request->user->userId)->whereIn("id",$tmpl_relationid_arr)
->get();
if(!$templateRelation){
die("没有要打印的数据");
}
$html = [];
foreach($templateRelation as $item){
$createHtml = (new \App\Services\LabelService)->getLabelHtml($item->id);
if($createHtml){
array_push($html,$createHtml);
}
}
$info["html"] = $html;
return view('web.prints', $info);
$info["type"] = $type;
return view('web', $info);
}
public function offlinePrint($request,$info){
$path = storage_path(sprintf('offline_print/%s.txt',$request->user->userId));
$content = file_get_contents($path);
$info["html"] = json_decode($content,true);
// dump($info);
return view('web.prints', $info);
}
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class CmsModel extends Model
{
protected $table = 'user_info';
protected $primaryKey = 'userId';
public $timestamps = false;
// 获取用户名称
public function getUserName($userId)
{
$user = $this->where(['userId' => $userId])->select('name')->first();
return $user ? $user->name : '';
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
class CronLogModel extends Moloquent{
protected $connection = 'mongodb'; //库名
protected $collection = 'cron_log'; //文档名
protected $primaryKey = '_id'; //设置id
protected $guarded = ['_id']; //设置字段黑名单
public $timestamps = false;
// 获取任务执行日志
public function lists($request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['job_name'] = $request->input('job_name', '');
$map['plan_begin_time'] = $request->input('plan_begin_time', '') ? strtotime($request->input('plan_begin_time')) : '';
$map['plan_end_time'] = $request->input('plan_end_time', '') ? strtotime($request->input('plan_end_time')) + 86399 : '';
$map['schedule_begin_time'] = $request->input('schedule_begin_time', '') ? strtotime($request->input('schedule_begin_time')) : '';
$map['schedule_end_time'] = $request->input('schedule_end_time', '') ? strtotime($request->input('schedule_end_time')) + 86399 : '';
$map['exec_start_begin_time'] = $request->input('exec_start_begin_time', '') ? strtotime($request->input('exec_start_begin_time')) : '';
$map['exec_start_end_time'] = $request->input('exec_start_end_time', '') ? strtotime($request->input('exec_start_end_time')) + 86399 : '';
$map['exec_end_begin_time'] = $request->input('exec_end_begin_time', '') ? strtotime($request->input('exec_end_begin_time')) : '';
$map['exec_end_end_time'] = $request->input('exec_end_end_time', '') ? strtotime($request->input('exec_end_end_time')) + 86399 : '';
$list = $this->where('jobName', $map['job_name'])
->where(function($query) use($map) {
// 计划时间
if(!empty($map['plan_begin_time']) && !empty($map['plan_end_time'])) {
$query->whereBetween('planTime', [$map['plan_begin_time'], $map['plan_end_time']]);
} else if(!empty($map['plan_begin_time'])) {
$query->where('planTime', '>=', $map['plan_begin_time']);
} else if(!empty($map['plan_end_time'])) {
$query->where('planTime', '<=', $map['plan_end_time']);
}
// 调度时间
if(!empty($map['schedule_begin_time']) && !empty($map['schedule_end_time'])) {
$query->whereBetween('scheduleTime', [$map['schedule_begin_time'], $map['schedule_end_time']]);
} else if(!empty($map['schedule_begin_time'])) {
$query->where('scheduleTime', '>=', $map['schedule_begin_time']);
} else if(!empty($map['schedule_end_time'])) {
$query->where('scheduleTime', '<=', $map['schedule_end_time']);
}
// 执行时间
if(!empty($map['exec_start_begin_time']) && !empty($map['exec_start_end_time'])) {
$query->whereBetween('startTime', [$map['exec_start_begin_time'], $map['exec_start_end_time']]);
} else if(!empty($map['exec_start_begin_time'])) {
$query->where('startTime', '>=', $map['exec_start_begin_time']);
} else if(!empty($map['exec_start_end_time'])) {
$query->where('startTime', '<=', $map['exec_start_end_time']);
}
// 执行时间
if(!empty($map['exec_end_begin_time']) && !empty($map['exec_end_end_time'])) {
$query->whereBetween('endTime', [$map['exec_end_begin_time'], $map['exec_end_end_time']]);
} else if(!empty($map['exec_end_begin_time'])) {
$query->where('endTime', '>=', $map['exec_end_begin_time']);
} else if(!empty($map['exec_end_end_time'])) {
$query->where('endTime', '<=', $map['exec_end_end_time']);
}
})
->orderBy('endTime', 'DESC')
->paginate(intval($limit), ['*'], 'page', $page)
->toArray();
$data = $this->handleData($list['data']);
return ['code'=>0, 'msg'=>'获取成功', 'data'=>$data, 'count'=>$list['total']];
}
// 处理数据
public function handleData($data)
{
if (empty($data)) return $data;
$CmsModel = new CmsModel();
foreach ($data as $k=>&$v) {
$v['planTime'] = $v['planTime'] ? date('Y-m-d H:i:s', $v['planTime']) : '';
$v['scheduleTime'] = $v['scheduleTime'] ? date('Y-m-d H:i:s', $v['scheduleTime']) : '';
$v['startTime'] = $v['startTime'] ? date('Y-m-d H:i:s', $v['startTime']) : '';
$v['endTime'] = $v['endTime'] ? date('Y-m-d H:i:s', $v['endTime']) : '';
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
class JobsModel extends Moloquent{
protected $connection = 'mongodb'; //库名
protected $collection = 'cron_jobs'; //文档名
protected $primaryKey = '_id'; //设置id
protected $guarded = ['_id']; //设置字段黑名单
public $timestamps = false;
// 获取所有任务
public function lists($request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['job_name'] = $request->input('job_name', ''); // 任务名称
$map['user_group'] = $request->input('user_group', ''); // 所属分组
$map['status'] = $request->input('status', '');
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use($map) {
if ($map['job_name']) {
$query->where('job_name', 'like', '%'.$map['job_name'].'%');
}
if ($map['user_group']) {
$query->where('group', intval($map['user_group']));
}
if ($map['status']) {
$query->where('status', intval($map['status']));
}
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
} else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
} else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('create_time')
->paginate(intval($limit), ['*'], 'page', $page)
->toArray();
$data = $this->handleData($list['data']);
return ['code'=>0, 'msg'=>'获取成功', 'data'=>$data, 'count'=>$list['total']];
}
// 处理数据
public function handleData($data)
{
if (empty($data)) return $data;
$CmsModel = new CmsModel();
foreach ($data as $k=>&$v) {
$v['group_val'] = $v['group'] ? Config('config.user_group')[$v['group']] : '未知';
$v['job_type_val'] = $v['job_type'] ? Config('config.job_type')[$v['job_type']] : '未知';
$v['creator'] = $CmsModel->getUserName($v['creator']);
$v['modifier'] = $v['modifier'] ? $CmsModel->getUserName($v['modifier']) : '';
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
$v['update_time'] = $v['update_time'] ? date('Y-m-d H:i:s', $v['update_time']) : '';
}
return $data;
}
// 启用 / 禁用
public function action($request)
{
$id = $request->input('id', 0);
$status = $request->input('status', 1);
if ($status == -1) { // 禁用(删除etcd任务)
$data['job_name'] = $request->input('job_name');
$data['node'] = $request->input('node');
$go_url = Config('website.go_server').'job/delete';
} else {
$data['id'] = $id;
$data['job_name'] = $request->input('job_name');
$data['node'] = $request->input('node');
$data['group'] = $request->input('group');
$data['command'] = $request->input('command');
$data['cron_expr'] = $request->input('cron_expr');
$data['job_type'] = $request->input('job_type');
$data['concurrency_num'] = !empty($request->input('concurrency_num')) ? $request->input('concurrency_num') : 0;
$go_url = Config('website.go_server').'job/save';
}
try {
$res = curlApi($go_url, $data, 'POST');
$res = json_decode($res, true);
if ($res['errno'] != 0) return ['err_code'=>$res['errno'], 'err_msg'=>$res['msg']];
// 调整mongo状态
$update = $this->where('_id', $id)->update(['status' => $status, 'update_time'=>time()]);
if ($update === false) return ['err_code'=>1, 'err_msg'=>'操作失败'];
} catch (\Exception $e) {
return ['err_code'=>1, 'err_msg'=>'内部错误:'.$e->getMessage()];
}
return ['err_code'=>0, 'err_msg'=>'操作成功'];
}
// 新增/编辑
public function set($request)
{
$data['id'] = $request->input('job_id', '');
$data['job_name'] = $request->input('job_name');
$data['node'] = $request->input('job_node');
$data['group'] = $request->input('job_group');
$data['command'] = $request->input('command');
$data['cron_expr'] = $request->input('cron_expr');
$data['job_type'] = $request->input('job_type');
$data['concurrency_num'] = !empty($request->input('concurrency_num')) ? $request->input('concurrency_num') : 0;
if ($data['id']) {
$data['modifier'] = $request->user->userId;
} else {
$data['creator'] = $request->user->userId;
}
try {
$go_url = Config('website.go_server').'job/save';
$res = curlApi($go_url, $data, 'POST');
$res = json_decode($res, true);
if ($res['errno'] != 0) return ['err_code'=>$res['errno'], 'err_msg'=>$res['msg']];
} catch (\Exception $e) {
return ['err_code'=>1, 'err_msg'=>'内部错误:'.$e->getMessage()];
}
// 操作记录
// $ActionLogModel = new ActionLogModel();
// $ActionLogModel->addLog($id, $request->user->userId, $request->user->name, $event, 3);
return ['err_code'=>0, 'err_msg'=>'操作成功'];
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
class NodesModel extends Moloquent{
protected $connection = 'mongodb'; //库名
protected $collection = 'cron_nodes'; //文档名
protected $primaryKey = '_id'; //设置id
protected $guarded = ['_id']; //设置字段黑名单
public $timestamps = false;
// 获取所有节点
public function getlists($request)
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['node_ip'] = $request->input('node_ip', ''); // 节点IP
$map['status'] = $request->input('status', 0);
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use($map) {
if ($map['node_ip']) {
$query->where('node_ip', 'like', '%'.$map['node_ip'].'%');
}
if ($map['status']) {
$query->where('status', '=', intval($map['status']));
}
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
} else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
} else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('create_time', 'desc')
->orderBy('_id', 'desc')
->paginate(intval($limit), ['*'], 'page', $page)
->toArray();
$data = $this->handleData($list['data']);
return ['code'=>0, 'msg'=>'获取成功', 'data'=>$data, 'count'=>$list['total']];
}
// 处理数据
public function handleData($data)
{
if (empty($data)) return $data;
foreach ($data as $k=>&$v) {
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
$v['update_time'] = $v['update_time'] ? date('Y-m-d H:i:s', $v['update_time']) : '';
}
return $data;
}
// 获取节点,同时同步到mongo
public function getNodes()
{
$url = Config('website.go_server').'worker/list';
$res = json_decode(curlApi($url), true);
if (!$res || $res['errno'] != 0) return ['errcode' => 1, 'errmsg' => '节点获取失败'];
if (!$res['data']) return ['errcode' => 1, 'errmsg' => '未获取到节点信息'];
$exists_node = $this->lists('node_ip')->toArray(); // 已存在的节点
foreach ($res['data'] as $v) {
if (in_array($v, $exists_node)) { // 存在则更新
$this->where('node_ip', $v)->update(['update_time' => time()]);
} else { // 不存在则新增
$this->insert([
'node_ip' => $v,
'status' => 1,
'create_time' => time(),
'update_time' => time(),
]);
}
}
$diff = array_diff($exists_node, $res['data']); // 求差集,获取掉线节点
if (!$diff) return ['errcode' => 0, 'errmsg' => '获取节点成功,无掉线节点'];
foreach ($diff as $val) {
$this->where('node_ip', $val)->update(['status' => -1, 'update_time' => time()]);
}
return ['errcode' => 0, 'errmsg' => '获取节点成功'];
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class OfflinePrintModel extends Model{
protected $connection = 'label'; //库名
protected $table = 'offline_print';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class SaleOrderListsModel extends Model{
protected $connection = 'label'; //库名
protected $table = 'sale_order_lists';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = false;
protected $dateFormat = 'Y-m-d H:i:s';
public static $STATUS = [
-1=>"禁用",
1=>"可用",
];
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class TemplateExtendModel extends Model{
protected $connection = 'label'; //库名
protected $table = 'template_extend';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = false;
protected $dateFormat = 'Y-m-d H:i:s';
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class TemplateListModel extends Model{
protected $connection = 'label'; //库名
protected $table = 'template_list';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public static $STATUS = [
-1=>"禁用",
1=>"可用",
];
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function scopeTemplateName($query,$template_name=""){
if($template_name){
$query = $query->where('template_name',$template_name);
}
return $query;
}
public function scopeStatus($query,$status=""){
if($status == "all" ||$status == "" ){
return $query;
}else{
$query = $query->where('status',intval($status));
}
return $query;
}
public function scopeSearchTime($query,$begin_time='',$end_time=''){
$begin_time = $begin_time ? strtotime($begin_time." 00:00:00") : 0;
$end_time = $end_time ? strtotime($end_time." 23:59:59") : 0;
if($begin_time){
if($end_time){
$query = $query->where('create_time',">=",$begin_time)->where('create_time',"<=",$end_time);
}else{
$query = $query->where('create_time',">=",$begin_time);
}
}elseif($end_time){
$query = $query->where('create_time',"<=",$end_time);
}
return $query;
}
public function scopeCreateUserId($query,$create_userid=0,$role=null,$create_username='',$userType=0){
if($userType == 1){
return $query->where('create_userid',1000);
}
if($create_userid && $role != 1){
$query = $query->where('create_userid',$create_userid);
}
if($create_username && $role == 1){
$query = $query->where('create_username',"like","%".trim($create_username)."%");
}
return $query;
}
/**
* 获取关联到用户的手机
*/
public function template_extend()
{
return $this->hasOne(\App\Model\TemplateExtendModel::class,"template_id","id");
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class TmplRelationsModel extends Model{
protected $connection = 'label'; //库名
protected $table = 'tmpl_relations';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = false;
const CREATED_AT = 'create_time';
const UPDATED_AT = null;
protected $dateFormat = 'Y-m-d H:i:s';
public static $STATUS = [
-1=>"禁用",
1=>"可用",
];
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function template()
{
return $this->hasOne(\App\Model\TemplateListModel::class,"id","template_id");
}
public function saleOrder()
{
return $this->hasOne(\App\Model\SaleOrderListsModel::class,"id","type_id");
}
public function scopeCreateUserId($query,$create_userid=0,$role=null){
if($create_userid && $role != 1){
$query = $query->where('create_userid',$create_userid);
}
return $query;
}
public function scopeSaleOrderSn($query,$sale_order_sn='',$goods_type=''){
if($sale_order_sn || $goods_type){
$_query = new \App\Model\SaleOrderListsModel;
if($sale_order_sn){
$_query = $_query->where("sale_order_sn",$sale_order_sn);
}
if($goods_type){
$_query = $_query->where("goods_type",$goods_type);
}
$sale = $_query->pluck("id");
$query = $query->whereIn('type_id',$sale);
}
return $query;
}
public function scopeSearchTime($query,$begin_time='',$end_time=''){
$begin_time = $begin_time ? strtotime($begin_time." 00:00:00") : 0;
$end_time = $end_time ? strtotime($end_time." 23:59:59") : 0;
if($begin_time){
if($end_time){
$query = $query->where('create_time',">=",$begin_time)->where('create_time',"<=",$end_time);
}else{
$query = $query->where('create_time',">=",$begin_time);
}
}elseif($end_time){
$query = $query->where('create_time',"<=",$end_time);
}
return $query;
}
}
\ No newline at end of file
......@@ -71,12 +71,12 @@ return [
'strict' => false,
],
'label' => [
'microservice' => [
'driver' => 'mysql',
'host' => env('DB_LABEL_HOST', ''),
'database' => env('DB_LABEL_DATABASE', ''),
'username' => env('DB_LABEL_USERNAME', ''),
'password' => env('DB_LABEL_PASSWORD', ''),
'host' => env('DB_MICROSERVICE_HOST', ''),
'database' => env('DB_MICROSERVICE_DATABASE', ''),
'username' => env('DB_MICROSERVICE_USERNAME', ''),
'password' => env('DB_MICROSERVICE_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
......
......@@ -7,8 +7,8 @@ return [
// curl证书验证, 线下环境不用开启
'curl_verify' => true,
'web_name'=>'标签库系统告警[请及时修改]',
'web_name'=>'【本地】:微服务网关后台告警:',
// webhook的值
'webhook' => 'https://oapi.dingtalk.com/robot/send?access_token=3966b80b7e56e8ffdff5ed2aefa1ea465c0f944a0db6ec5519eeef8721d1eb43',
'webhook' => 'https://oapi.dingtalk.com/robot/send?access_token=561c9ea2085ad3f9953559b6f5e8a6096092f39844b090f45a34c5856a7be6b3',
];
\ No newline at end of file
......@@ -12,14 +12,13 @@ return [
'domain' => 'liexin.net',
'risk_url' => 'http://label.liexin.net',
'risk_url' => 'http://micro.liexin.net/',
// API项目
'api_domain' => 'http://api.liexin.com/',
// 获取用户权限接口
'perm_api' => 'http://perm.liexin.net/api/perms/',
// 获取用户许可权限接口
'check_access_api' => 'http://perm.liexin.net/api/perms/access',
// go 服务
'go_server' => 'http://127.0.0.1:8070/',
];
layui.use(['form', 'table', 'laydate'], function(){
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
table.render({
elem: '#list'
,url: '/ajax/labelList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,where: {
userType: $('input[name=labelListSystem]').val(),
}
,cols: [[ //表头
{title: 'ID',field:"id",fixed: 'left', width: 80}
,{field: 'template_name', title: '模板名称(可点击修改)',edit: 'text',width: 300}
,{field: 'status', title: '状态',templet:"#status",width: 80}
,{field: 'create_username', title: '创建人',width: 100}
,{field: 'create_time', title: '创建时间', sort: true,width: 200}
,{field: 'update_time', title: '更新时间', sort: true,width: 200}
,{ title: '操作', fixed: 'right', toolbar: '#action',}
]]
,limit: 10
,limits: [10, 20, 50,]
});
form.on('submit(load)', function(data) {
//console.log(data)
//执行重载
table.reload('list', {
page: {
curr: 1
},
url: '/ajax/labelList' //数据接口
,where: data.field
});
return false;
});
var enable_tool = function (title,content,url,datax){
layer.open({
title: title,
content: content,
btn: ['确认', '取消'],
yes: function(index) {
$.ajax({
url : url,
type: 'post',
data: datax,
success: function(resp) {
if (resp.err_code == 0) {
layer.msg(resp.err_msg);
// renderTable(); // 重新加载table
$('.search').trigger("click"); // 触发搜索按钮
if(typeof resp.data.redictUrl != "undefined"){
window.location.href=resp.data.redictUrl;
}
return false;
}
layer.alert(resp.err_msg);
},
error: function(err) {
console.log(err)
}
})
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
//监听工具条
table.on('tool(list)', function(obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的 DOM 对象(如果有的话)
if (layEvent == "enable"){
title = '启用模板';
content = '确定启用该模板?';
url = '/ajax/template_status';
datax = {id:data.id,status:data.status}
enable_tool(title,content,url,datax);
}else if (layEvent == "forbid"){
title = '禁用模板';
content = '确定禁用该模板?';
url = '/ajax/template_status';
datax = {id:data.id,status:data.status}
enable_tool(title,content,url,datax);
}else if(layEvent == "copy"){
title = '复制模板';
content = '确定要复制该模板?';
url = '/ajax/copy_template';
datax = {t_id:data.id}
enable_tool(title,content,url,datax);
}else if(layEvent == "push"){
title = '推送模板信息到erp';
content = '确定推送?';
url = '/ajax/push_template_erp';
datax = {t_id:data.id}
enable_tool(title,content,url,datax);
}
})
//监听单元格编辑
table.on('edit(list)', function(obj){
var value = obj.value //得到修改后的值
,data = obj.data //得到所在行所有键值
,field = obj.field; //得到字段
title = '修改模板名称';
content = '确定修改模板名称?';
url = '/ajax/edit_template_info';
console.log(obj.data)
enable_tool(title,content,url,obj.data)
});
});
\ No newline at end of file
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标签库管理后台 | 首页</title>
<title>微服务网关管理后台 | 首页</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
@include('index.css')
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标签库管理后台 | {{$title or ''}}</title>
<title>微服务网关管理后台 | {{$title or ''}}</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
@include('table.css')
......
<style>
.cron_job_log label {
width: 130px;
}
.cron_job_name label {
width: 95px;
font-weight: 600;
}
.cron_job_name span {
line-height: 38px;
}
</style>
<form class="layui-form layui-box cron_job_log" method="post">
<input type="hidden" name="job_name" value="{{ $job_name }}">
<div class="layui-form-item cron_job_name">
<div class="layui-inline">
<label class="layui-form-label">任务名称:</label>
<span class="layui-text">{{ $job_name }}</span>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">计划时间</label>
<div class="layui-input-inline">
<input type="text" name="plan_begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="plan_begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="plan_end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="plan_end_time" readonly>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">调度时间</label>
<div class="layui-input-inline">
<input type="text" name="schedule_begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="schedule_begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="schedule_end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="schedule_end_time" readonly>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">执行开始时间</label>
<div class="layui-input-inline">
<input type="text" name="exec_start_begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="exec_start_begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="exec_start_end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="exec_start_end_time" readonly>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">执行结束时间</label>
<div class="layui-input-inline">
<input type="text" name="exec_end_begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="exec_end_begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="exec_end_end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="exec_end_end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn search" data-type="search">搜索</button>
</div>
</div>
</form>
<table id="cron_log" lay-filter="cron_log"></table>
@if (session('showTemplateerror'))
<div class="alert alert-success">
{{ session('showTemplateerror') }}
</div>
@endif
@if(!isset($labelListSystem))
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">模板名称</label>
<div class="layui-input-inline">
<input type="text" name="template_name" value="" autocomplete="off" placeholder="请填写模板名称" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建人</label>
<div class="layui-input-inline">
<input type="text" name="create_username" value="" autocomplete="off" placeholder="请填写创建人" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
<select name="status" lay-verify="" lay-search>
<option value=""></option>
@foreach (\App\Model\TemplateListModel::$STATUS as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button style="float:left;" lay-submit lay-filter="load" class="layui-btn search" data-type="search">搜索</button>
</div>
</div>
</form>
@endif
<input type="hidden" name="labelListSystem" value="{{ isset($labelListSystem)?$labelListSystem:0 }}" />
<table id="list" lay-filter="list"></table>
<script type="text/html" id="action">
<a class="btn btn-xs btn-outline btn-success" href="/web/showTemplate?t_id=@{{ d.id }}" target="_blank" lay-event="show">预览</a>
@{{# if (d.status > 0) { }}
<a title="复制一份该模板" class="btn btn-xs btn-outline btn-info" lay-event="copy">复制</a>
@{{# } }}
@if(!isset($labelListSystem))
<a class="btn btn-xs btn-outline btn-info" href="/web/offline?t_id=@{{ d.id }}">离线使用</a>
<a class="btn btn-xs btn-outline btn-success" href="/web/design?t_id=@{{ d.id }}" target="_blank">编辑</a>
@{{# if (d.status == -1) { }}
<a class="btn btn-xs btn-outline layui-btn-primary" lay-event="enable">启用</a>
@{{# }else{ }}
<a class="btn btn-xs btn-outline btn-info" lay-event="forbid">禁用</a>
@{{# } }}
@{{# if (d.is_push == 0) { }}
<a title="推送模板信息到erp" style="color: #ffffff" class="btn btn-xs btn-outline layui-btn-warm" lay-event="push">推送</a>
@{{# } }}
@endif
</script>
<script type="text/html" id="status">
@{{# if (d.status == -1) { }}
<div style="color:#ccc;">禁用</div>
@{{# } else { }}
<div style="color:#5FB878;">可用</div>
@{{# } }}
</script>
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">节点IP</label>
<div class="layui-input-inline">
<input type="text" name="node_ip" value="" autocomplete="off" placeholder="请填写节点IP" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">节点状态</label>
<div class="layui-input-inline">
<select name="status" lay-verify="" lay-search>
<option value=""></option>
@foreach (Config('config.node_status') as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn search" data-type="search">搜索</button>
<a class="layui-btn layui-btn-warm update_node">更新节点</a>
</div>
</div>
</form>
<table id="node" lay-filter="node"></table>
<script type="text/html" id="status">
@{{# if (d.status == -1) { }}
<div style="color:#ccc;">掉线</div>
@{{# } else { }}
<div style="color:#5FB878;">正常</div>
@{{# } }}
</script>
@include('web.offline_design')
<div class=" site-demo-button" style="margin-top: 30px;">
<legend>离线使用</legend>
<form class="layui-form" action="">
<div>
<button type="button" class="layui-btn" id="offline_upload"><i class="layui-icon"></i>上传文件</button>
<a type="button" class="layui-btn layui-btn-normal" href="/excel/标签离线导入.xlsx">下载模板</a>
</div>
</form>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">去打印</button>
</div>
</script>
</div>
<table id="demo" lay-filter="demo"></table>
<link href="/css/style.css" rel="stylesheet">
<style>
body{background:#fff;margin:0px;}
.print{background:#fff;padding-left:8px;}
.edit-con{box-sizing:border-box;top:6px;}
.layui-btn{
display: inline-block;
height: 38px;
line-height: 38px;
padding: 0 18px;
background-color: #009688;
color: #fff;
white-space: nowrap;
text-align: center;
font-size: 14px;
border: none;
border-radius: 2px;
cursor: pointer;
}
</style>
@foreach($html as $item)
<div class="print">
{!! $item !!}
</div>
</div>
@endforeach
<script src="../../../../js/jquery-2.2.1.js"></script>
<script type="text/javascript">
$(function(){
$(".print").width($(".edit-con").width());
if($(".edit-con").height()==280){
$(".print").css({"height":"303px"})
}
$(".huabuitem[type='5'],.huabuitem[type='6'],.huabuitem[type='7']").each(function(){
var urlo_=$(this).css("backgroundImage").replace('url(','').replace(')','');
$(this).css({"background":""})
$(this).html("<img src='"+urlo_.substring(1,urlo_.length-1)+"' />");
if($(this).attr("name")=="yiweimait"){
var max_width=$(this).width();
var width_=$(this).find("img").width();
if(width_>max_width){
width_=max_width
}
$(this).find("img").css({height:"100%",width:width_});
}else{
$(this).find("img").css({width:"100%",height:"100%"})
}
})
setTimeout(function(){
window.print();
}, 100);
})
</script>
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">销售单号</label>
<div class="layui-input-inline">
<input type="text" name="sale_order_sn" value="" autocomplete="off" placeholder="请填写订单号" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">型号</label>
<div class="layui-input-inline">
<input type="text" name="goods_type" value="" autocomplete="off" placeholder="请填写型号" class="layui-input">
</div>
</div>
{{--<div class="layui-inline">--}}
{{--<label class="layui-form-label">状态</label>--}}
{{--<div class="layui-input-inline">--}}
{{--<select name="status" lay-verify="" lay-search>--}}
{{--<option value=""></option>--}}
{{--@foreach (\App\Model\TemplateListModel::$STATUS as $k=>$v)--}}
{{--<option value="{{$k}}">{{$v}}</option>--}}
{{--@endforeach--}}
{{--</select>--}}
{{--</div>--}}
{{--</div>--}}
<div class="layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button style="float:left;" lay-submit lay-filter="load" class="layui-btn search" data-type="search">搜索</button>
</div>
</div>
</form>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">去打印</button>
</div>
</script>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="action">
<a class="btn btn-xs btn-outline btn-info" href="/web/showPage?tmpl_relation_id=@{{ d.id }}" target="_blank" lay-event="offline">去预览</a>
<a class="btn btn-xs btn-outline btn-success" href="/web/showPage?tmpl_relation_id=@{{ d.id }}" target="_blank">去下载</a>
{{--@{{# if (d.status == -1) { }}--}}
{{--<a class="btn btn-xs btn-outline layui-btn-primary" lay-event="enable">启用</a>--}}
{{--@{{# }else{ }}--}}
{{--<a class="btn btn-xs btn-outline btn-info" lay-event="forbid">禁用</a>--}}
{{--@{{# } }}--}}
</script>
<script type="text/html" id="status">
@{{# if (d.status == -1) { }}
<div style="color:#ccc;">禁用</div>
@{{# } else { }}
<div style="color:#5FB878;">可用</div>
@{{# } }}
</script>
{!! $html !!}
<br/>
<div style="border-top:1px solid #ccc;margin-top:20px;margin-bottom:20px;"></div>
<a class="downpng layui-btn" target="_blank" href="" download="downImg">下载</a>
<script src="https://cdn.bootcdn.net/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.js"></script>
<script>
var canvas2 = document.createElement("canvas");
var _canvas = document.querySelector('.edit-con');
var w = parseInt(window.getComputedStyle(_canvas).width);
var h = parseInt(window.getComputedStyle(_canvas).height);
canvas2.width = w+Number($(".edit-con").css("borderWidth").split("px")[0])*2;
canvas2.height = h+Number($(".edit-con").css("borderWidth").split("px")[0])*2;
var context = canvas2.getContext("2d");
context.translate(-$(".edit-con").offset().left,-$(".edit-con").offset().top);
html2canvas(document.querySelector('.edit-con'), { canvas: canvas2 }).then(function(canvas) {
document.querySelector(".downpng").setAttribute('href', canvas.toDataURL());
});
</script>
{!! $html !!}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment