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,15 +2,16 @@
namespace App\Http\Controllers;
use App\Exceptions\IcException;
use App\Exceptions\MicroException;
use App\Model\OfflinePrintModel;
use App\Model\ServiceLoadBalanceModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Log;
use App\Model\TemplateListModel;
use App\Model\SaleOrderListsModel;
use App\Model\TmplRelationsModel;
use App\Model\TemplateExtendModel;
use App\Model\MicroServiceInfoModel;
use App\Model\ServiceAccessControlModel;
use App\Model\ServiceHttpRuleModel;
Class AjaxController extends Controller
{
......@@ -21,123 +22,6 @@ Class AjaxController extends Controller
return $this->$id($request);
}
// 模板列表
public function labelList($request)
{
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$template_name = $request->input("template_name",'');
$create_username = $request->input("create_username",'');
$status = $request->input("status",'all');
$begin_time = $request->input("begin_time",'');
$end_time = $request->input("end_time",'');
$userType = $request->input("userType",0);//1只显示系统模板
$admin_id = $request->user->userId;
$perm = new PermController;
// 用户角色
$role = $perm->getUserRole($request);
$query = TemplateListModel::select('*')->CreateUserId($admin_id,$role,$create_username,$userType)->TemplateName($template_name)
->Status($status)
->SearchTime($begin_time,$end_time)
->OrderBy("status","desc")
->OrderBy("id","desc");
$query = $query->paginate($limit,[],'page',$page);
$list = $query->toArray();
return ['code'=>0, 'count'=>$list['total'],'data'=>$list["data"]];
}
// 标签使用记录
public function record($request)
{
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$sale_order_sn = $request->input("sale_order_sn",'');
$goods_type = $request->input("goods_type",'');
$status = $request->input("status",'all');
$begin_time = $request->input("begin_time",'');
$end_time = $request->input("end_time",'');
$perm = new PermController;
// 用户角色
$role = $perm->getUserRole($request);
$admin_id = $request->user->userId;
$query = TmplRelationsModel::select('*')->with("saleOrder")->CreateUserId($admin_id,$role)
->SaleOrderSn($sale_order_sn,$goods_type)->SearchTime($begin_time,$end_time)
->OrderBy("id","desc");
// dump($query->toSql());
$list = $query->paginate($limit,[],'page',$page);
// dump($list);
$arr = [];
foreach($list as $k=>$item){
$arr[$k]["id"] = $item->id;
$arr[$k]["template_name"] = $item->template ? $item->template->template_name : '';
$arr[$k]["sale_order_sn"] = $item->saleOrder ? $item->saleOrder->sale_order_sn : '';
$arr[$k]["goods_type"] = $item->saleOrder ? $item->saleOrder->goods_type : '';
$arr[$k]["createUser"] = $item->saleOrder ? $item->saleOrder->createUser : '';
$arr[$k]["print_nums"] = $item->print_nums;
$arr[$k]["create_time"] = date("Y-m-d h:i:s",$item->create_time);
$arr[$k]["print_time"] = date("Y-m-d h:i:s",$item->print_time);
}
return ['code'=>0, 'count'=>collect($list)->get("total"),'data'=>$arr];
}
/*
* 模板列表修改状态
*/
public function template_status($request){
$id = $request->input("id",0);
$status = $request->input("status",0);
$perm = new PermController;
// 用户角色
$role = $perm->getUserRole($request);
$tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id));
if($tmpl){
$tmpl->status = ($tmpl->status == -1) ? 1 :-1;
$tmpl->save();
//此处推送到erp
$this->pushTemplateErp(intval($id));
return $this->ajaxReturn(0,"修改成功");
}else{
return $this->ajaxReturn(-1,"没找到与自己对应的模板");
}
}
/*
* 模板列表修改名称
*/
public function edit_template_info($request){
$id = $request->input("id",0);
$template_name = $request->input("template_name",'');
if(!$template_name){
return $this->ajaxReturn(-1,"模板名称必填");
}
$tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id));
if(!$tmpl){
return $this->ajaxReturn(-1,"您只能修改自己创建的模板哦!");
}
$count = TemplateListModel::where(["create_userid"=>$request->user->userId,"template_name"=>$template_name])->count();
if($count > 0){
return $this->ajaxReturn(-1,"已经存在该名称的模板了!");
}
$tmpl->template_name = $template_name;
$bk = $tmpl->save();
if($bk === false){
return $this->ajaxReturn(-1,"修改模板失败!");
}
//此处推送到erp
$this->pushTemplateErp(intval($id));
return $this->ajaxReturn(0,"修改成功");
}
protected function ajaxReturn($code,$msg="",$data=[]){
return [
"err_code"=>$code,
......@@ -147,298 +31,183 @@ Class AjaxController extends Controller
}
/*
* 推送模板消息到erp
*/
protected function pushTemplateErp($t_id=0){
// return true;
try{
$template = TemplateListModel::find($t_id);
//登录
$soap = new \SoapClient(env("ERP_DOMAIN").'/ormrpc/services/EASLogin?wsdl');
$res = $soap->login( 'TC', 'unicom', 'eas', env('ERP_DB_NAME'), 'L2', 1, 'BaseDB');
//接口
$this->erp = new \SoapClient(ENV("ERP_DOMAIN").'/ormrpc/services/WSIchuntjKFacade?wsdl');
$res = $this->erp->createIssueLabel(json_encode([
"templateId"=>$template->id,
"templateNmae"=>$template->template_name,
"createUser"=>$template->create_username,
"status"=>intval($template->status),
]));
$template->is_push = 0;
$arr = [];
if($res){
$res = \GuzzleHttp\json_decode($res,true);
Log::info(print_r($res,true));
if(isset($res["0000"])){
$template->is_push = 1;
$arr = ['err_code'=>0,'err_msg'=>"模板推送成功"];
}elseif(isset($res["4444"])){
$arr = ['err_code'=>-1,'err_msg'=>sprintf("模板推送erp失败 %s",$res["4444"])];
}
}else{
$arr = ['err_code'=>-1,'err_msg'=>sprintf("模板信息推送到erp失败")];
}
$template->save();
return $arr;
}catch(\Exception $e){
$template->is_push = 0;//0未推送至erp 1已推送
$template->save();
Log::info(sprintf("模板:%s 信息推送到erp失败:%s",$t_id,$e->getMessage()));
return ['err_code'=>-1,'err_msg'=>sprintf("模板信息推送到erp异常,原因:%s",$e->getMessage())];
}
}
public function ajaxMicroServicesList(Request $request){
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$query = MicroServiceInfoModel::select('*')->where(["is_delete"=>0])
->OrderBy("id","asc");
$query = $query->paginate($limit,[],'page',$page);
$list = $query->toArray();
return ['code'=>0, 'count'=>$list['total'],'data'=>$list["data"]];
}
/*
* 添加模板
*/
public function add_template($request){
$template_name = $request->input("designName",'');
$html = $request->input("htmlp",'');
$lableBg = $request->input("lableBg",'');
$lableBorder = $request->input("lableBorder",'');
$lableSize = $request->input("lableSize",'');
if(!$template_name){
return $this->ajaxReturn(-1,"请填写模板名称!");
}
if(!$html){
return $this->ajaxReturn(-1,"模板标签是空!");
}
public function delMicroService(Request $request){
$id = $request->input("id",0);
$bk = MicroServiceInfoModel::where(["id"=>$id])->update([
"is_delete"=>1
]);
$attribute["lableBg"] = $lableBg;
$attribute["lableBorder"] = $lableBorder;
$attribute["lableSize"] = $lableSize;
$data['template_name'] = $template_name;
$data['html'] = $html;
$data['attribute'] = $attribute;
$id = $request->input("t_id",0);
if(intval($id) > 0){
//----------------------------修改模板------------------------------------------------------------------
$count = TemplateListModel::where("id",intval($id))->where("create_userid",$request->user->userId)->count("id");
if($count <= 0){
return $this->ajaxReturn(-1,"没找到属于您的模板信息");
}
$templateInfo = TemplateListModel::where("id",intval($id))->select("id","template_name","status")->first();
if($templateInfo->status <= 0){
return $this->ajaxReturn(-1,"该模板已经被主人禁用了");
}
if($template_name != $templateInfo->template_name){
$count = TemplateListModel::where("create_userid",$request->user->userId)->where("template_name",$template_name)->count("id");
if($count > 0){
return $this->ajaxReturn(-1,"模板名称已经存在,请修改模板名称再提交!");
}
}
$data['t_id'] = intval($id);
try{
DB::Connection("label")->transaction(function () use($data,$request) {
//创建模板
$templateList = TemplateListModel::where(["id"=>$data['t_id']])->update([
"template_name"=>trim($data['template_name']),
"update_time"=>time(),
]);
if($templateList === false){
throw new \Exception("修改模板名称失败",-1);
}
//创建模板扩展信息 属性
$templateExtend = TemplateExtendModel::where(["template_id"=>$data['t_id']])->update([
"html"=>$data['html'],
"attribute"=>json_encode($data['attribute']),
]);
if($templateExtend === false){
throw new \Exception("修改模板属性失败",-1);
}
//此处推送到erp
$this->pushTemplateErp($data['t_id']);
});
return $this->ajaxReturn(0,"修改模板成功");
}catch(\Exception $e){
return $this->ajaxReturn(-1,$e->getMessage());
}
exit;
if ($bk > 0){
return $this->ajaxReturn(0,"删除成功");
}else{
return $this->ajaxReturn(-1,"删除失败");
}
// --------------------------新增模板------------------------------------------------------------
}
//新增模板
$count = TemplateListModel::where("template_name",trim($data['template_name']))
->where(function($q) use($request){
$q->where(["create_userid"=>$request->user->userId])->orWhere(["create_userid"=>1000]);
})->count("id");
if($count){
return $this->ajaxReturn(-1,"模板名称已经存在,请修改模板名称再提交!");
}
protected function _addMicroService($request){
try{
DB::Connection("label")->transaction(function () use($data,$request) {
//创建模板
$templateList = TemplateListModel::create([
"template_name"=>trim($data['template_name']),
"create_userid"=>$request->user->userId,
"create_username"=>$request->user->name,
DB::transaction(function () use($request) {
$service_name = $request->input("service_name","");
$service_desc = $request->input("service_desc","");
$direct_forward_url = $request->input("direct_forward_url","");
$rule_type = $request->input("rule_type",0);
$load_type = $request->input("load_type",0);
$need_direct_forward = $request->input("need_direct_forward",0);
$round_type = $request->input("round_type",2);
$rule = $request->input("rule","");
$url_rewrite = $request->input("url_rewrite","");
$url_rewrite = $this->trimStr($url_rewrite);
$header_transfor = $request->input("header_transfor","");
$header_transfor = $this->trimStr($header_transfor);
$clientip_flow_limit = $request->input("clientip_flow_limit","");
$service_flow_limit = $request->input("service_flow_limit","");
$microServiceInfo = MicroServiceInfoModel::create([
"load_type"=>$load_type,
"service_name"=>trim($service_name),
"service_desc"=>$service_desc,
"create_time"=>time(),
"update_time"=>time(),
]);
if(!$templateList){
throw new \Exception("添加模板失败",-1);
$service_id = $microServiceInfo->id;
if ($service_id <= 0){
throw new MicroException("新增失败");
}
//创建模板扩展信息 属性
$templateExtend = TemplateExtendModel::create([
"template_id"=>$templateList->id,
"html"=>$data['html'],
"attribute"=>json_encode($data['attribute']),
$bk = ServiceAccessControlModel::create([
"service_id"=>$service_id,
"clientip_flow_limit"=>intval($clientip_flow_limit),
"service_flow_limit"=>intval($service_flow_limit),
]);
if(!$templateExtend){
throw new \Exception("添加模板失败",-1);
if (!$bk){
throw new MicroException("新增失败");
}
//此处推送到erp
$this->pushTemplateErp($templateList->id);
});
return $this->ajaxReturn(0,"添加模板成功");
}catch(\Exception $e){
return $this->ajaxReturn(-1,$e->getMessage());
}
$bk = ServiceHttpRuleModel::create([
"service_id"=>$service_id,
"rule_type"=>$rule_type,
"rule"=>trim($rule),
"url_rewrite"=>$url_rewrite,
"direct_forward_url"=>$direct_forward_url,
"need_direct_forward"=>$need_direct_forward,
"header_transfor"=>$header_transfor,
]);
if (!$bk){
throw new MicroException("新增失败");
}
}
$bk = ServiceLoadBalanceModel::create([
"service_id"=>$service_id,
"round_type"=>$round_type,
]);
if (!$bk){
throw new MicroException("新增失败");
}
/*
* 推送模板信息到erp
*/
public function push_template_erp($request){
$id = $request->input("t_id",0);
$template = TemplateListModel::where(["create_userid"=>$request->user->userId])->find($id);
if(!$template){
return $this->ajaxReturn(-1,"没找到属于您的模板相关信息");
}
//此处推送到erp
$res = $this->pushTemplateErp($template->id);
if(!empty($res) && $res['err_code'] < 0){
return $this->ajaxReturn(-1,$res['err_msg']);
}
$template->is_push = 1;
if($template->save() === false){
return $this->ajaxReturn(-1,推送失败);
});
}catch(MicroException $e){
return $this->ajaxReturn(-1,"新增失败");
}
return $this->ajaxReturn(0,"推送模板成功");
return $this->ajaxReturn(0,"新增成功");
}
protected function trimStr($string){
$string = trim($string);
$string = trim($string,PHP_EOL);
$string = trim($string,",");
$string = trim($string,",");
$string = trim($string,PHP_EOL);
$string = trim($string);
$string = trim($string,",");
$string = trim($string,",");
$string = trim($string,PHP_EOL);
$string = trim($string);
return $string;
}
/*
* 复制模板
*/
public function copy_template($request){
$id = $request->input("t_id",0);
$copyTemplate = TemplateListModel::find($id);
if(!$copyTemplate){
return $this->ajaxReturn(-1,"没找到该模板相关信息");
}
public function _editMicroService($request){
try{
DB::Connection("label")->transaction(function () use($copyTemplate,$request) {
$templateList = TemplateListModel::create([
"template_name"=>$copyTemplate->template_name."_copy"."_".date("Ymdhis"),
"create_userid"=>$request->user->userId,
"create_username"=>$request->user->name,
"create_time"=>time(),
DB::transaction(function () use($request) {
$service_id = $request->input("id","");
$service_name = $request->input("service_name","");
$service_desc = $request->input("service_desc","");
$direct_forward_url = $request->input("direct_forward_url","");
$need_direct_forward = $request->input("need_direct_forward",0);
$rule_type = $request->input("rule_type",0);
$load_type = $request->input("load_type",0);
$round_type = $request->input("round_type",2);
$rule = $request->input("rule","");
$url_rewrite = $request->input("url_rewrite","");
$url_rewrite = $this->trimStr($url_rewrite);
$header_transfor = $request->input("header_transfor","");
$header_transfor = $this->trimStr($header_transfor);
$clientip_flow_limit = $request->input("clientip_flow_limit","");
$service_flow_limit = $request->input("service_flow_limit","");
MicroServiceInfoModel::where(["id"=>$service_id])->update([
"load_type"=>$load_type,
"service_name"=>$service_name,
"service_desc"=>$service_desc,
"update_time"=>time(),
]);
if(!$templateList){
throw new \Exception("复制模板失败",-1);
}
//创建模板扩展信息 属性
$templateExtend = TemplateExtendModel::create([
"template_id"=>$templateList->id,
"html"=>$copyTemplate->template_extend->html,
"attribute"=>$copyTemplate->template_extend->attribute,
]);
if(!$templateExtend){
throw new \Exception("复制模板失败",-1);
}
//此处推送到erp
$this->pushTemplateErp($templateList->id);
});
$data = [];
if($copyTemplate->create_userid == "1000"){
$data = ["redictUrl"=>"/web/labelList"];
}
return $this->ajaxReturn(0,"复制模板成功",$data);
}catch(\Exception $e){
return $this->ajaxReturn(-1,$e->getMessage());
}
}
ServiceAccessControlModel::where(["service_id"=>$service_id])->update([
"service_id"=>$service_id,
"clientip_flow_limit"=>intval($clientip_flow_limit),
"service_flow_limit"=>intval($service_flow_limit),
]);
/*
* 判断是否是管理员
*/
protected function isAdmin($request){
$role_id = (new \App\Http\Controllers\PermController)->getUserRole($request);
return in_array($role_id,[1]) ? true : false;
}
/**
* 编辑模板 获取模板详情
*/
public function getTemplateDetail($request){
$id = $request->input("t_id",0);
$isAdmin = $this->isAdmin($request);
if(!$isAdmin){
$count = TemplateListModel::where("id",intval($id))->where("create_userid",$request->user->userId)->count("id");
if($count <= 0){
return $this->ajaxReturn(-1,"没找到属于您的模板信息");
}
}
ServiceHttpRuleModel::where(["service_id"=>$service_id])->update([
"service_id"=>$service_id,
"rule_type"=>$rule_type,
"rule"=>$rule,
"url_rewrite"=>$url_rewrite,
"direct_forward_url"=>$direct_forward_url,
"need_direct_forward"=>$need_direct_forward,
"header_transfor"=>$header_transfor,
]);
$templateInfo = TemplateListModel::where("id",intval($id))->select("id","template_name","status")->first();
if($templateInfo->status <= 0){
return $this->ajaxReturn(-1,"该模板已经被主人禁用了");
}
$templateInfo->template_extend = isset($templateInfo->template_extend) ? $templateInfo->template_extend : null;
return $this->ajaxReturn(0,"ok",$templateInfo);
}
ServiceLoadBalanceModel::where(["service_id"=>$service_id])->update([
"round_type"=>$round_type
]);
public function offline_upload($request){
$uploadService = new \App\Services\UploadService();
$offlineLabelService = new \App\Services\OfflineLabelService();
$resData = $uploadService->upload($request);
if($resData === false || empty($resData->data)){
return $this->ajaxReturn(-1,"文件上传失败,请检查文件格式或者联系管理员");
});
}catch(MicroException $e){
return $this->ajaxReturn(-1,"修改失败");
}
$data = $offlineLabelService->getOfflineUploadData($resData->data);
return $this->ajaxReturn(0,"ok",$data);
return $this->ajaxReturn(0,"修改成功");
}
/*
* 离线导入打印标签
*/
public function offlinePrint($request){
$html = $request->input("html",'');
$datas = $request->input("datas",'');
$returnHtml = [];
foreach($datas as $k=>$item){
$createHtml = (new \App\Services\LabelService)->getLabelOfflineHtml($html,$item);
if($createHtml){
array_push($returnHtml,$createHtml->outertext);
}
}
$str = \GuzzleHttp\json_encode($returnHtml);
$path = storage_path(sprintf('offline_print/%s.txt',$request->user->userId));
$bk = file_put_contents($path,$str);
if($bk === false){
return $this->ajaxReturn(-1,"打印失败");
public function addMicroService(Request $request){
$id = $request->input("id","");
$type = $request->input("type","");
if ($id > 0 && $type == "edit"){
return $this->_editMicroService($request);
}else{
return $this->_addMicroService($request);
}
return $this->ajaxReturn(0,"ok");
}
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class PermController extends Controller
{
// 检查用户是否具有系统访问权限
public function checkAccess($request)
{
$user_id = $request->user->userId;
$role = $this->getUserRole($request);
if ($role == 1) return true; // 超级管理员或系统管理员直接进入
$userPerms = $this->getUserAllPerms($user_id, $role);
if (!$userPerms) return false;
if (in_array('apply_access', $userPerms)) return true; // 访问权限ID是否存在
return false;
}
// 获取系统信息
public function getBusinessInfo()
{
// 根据域名查询系统业务ID
$business = DB::table('t_business_config')->where('url', Config('website.risk_url'))->first();
return !empty($business) ? $business : false;
}
// 获取用户角色
public function getUserRole(Request $request)
{
$uid = $request->user->userId;
$email = $request->user->email;
if ($email == 'admin@ichunt.com') {
return 1;
}
$business = $this->getBusinessInfo();
if ($business) {
$bid = $business->bid;
// 权限系统配置的管理帐号
$adminAccount = json_decode($business->admin, true);
if (in_array($email, $adminAccount)) {
return 1;
}
// 根据用户ID和业务ID查看角色
$userPerm = DB::table('t_user_perm')->where(['userId' => $uid, 'bid' => $bid])->first();
if (empty($userPerm)) {
return 0;
} else {
if ($userPerm->roles == 'null') return 0;
$role = json_decode($userPerm->roles, true);
foreach ($role as $v) {
$department = DB::table('t_role_perm')->where(['roleId' => $v, 'bid' => $bid])->first();
return in_array($department->name,array_keys(Config('roles.sys_roles'))) ? array_get(Config('roles.sys_roles'),$department->name) : 0;
}
}
}
return 0;
}
// 获取所有角色用户集合
public function getRoleUsers($roleName)
{
// 根据域名查询系统业务ID
$business = $this->getBusinessInfo();
$userId = [];
$roleUsers = [];
if ($business) {
$bid = $business->bid;
$role = DB::table('t_role_perm')->where(['bid' => $bid, 'name' => $roleName])->first();
$roleId = $role->roleId;
$user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` REGEXP $roleId");
if ($user) {
foreach ($user as $v) {
$userId[] = $v->userId;
$id = $v->userId ? $v->userId : 0;
if(!$id) continue;
$userId[] = $id;
$userInfo = DB::table('user_info')->where('userId', $id)->select('userId', 'name', 'status')->first();
// 判断用户是否已离职 4为离职状态
if ($userInfo->status != 4) {
$roleUsers[] = $userInfo;
}
}
}
}
return $roleUsers;
}
// 获取权限菜单
public function getPermMenu($menus, $user_id)
{
$userPerms = $this->getUserAllPerms($user_id);
if ($userPerms) {
return $this->handleMenus($menus, $userPerms);
}
return false;
}
// 获取用户所有权限
public function getUserAllPerms($user_id, $role=0)
{
// 根据域名查询系统业务ID
$business = $this->getBusinessInfo();
if ($business) {
if ($role != 1) {
$bid = $business->bid;
$url = Config('website.perm_api').$user_id.'/'.$bid;
$userPerms = json_decode(curlApi($url), true);
if ($userPerms && $userPerms['retcode'] == 0) {
return $userPerms['data']['perms'];
}
} else { // 获取管理员所有权限
return $this->getAllPerms(json_decode($business->configs, true));
}
}
return false;
}
// 获取系统配置权限
public function getAllPerms($configs)
{
$perms = [];
foreach ($configs as $k => $v) {
$perm_a = [];
$perm_b = [];
if (isset($v['childs']) && count($v['childs']) > 0) {
$perm_b = $this->getAllPerms($v['childs']);
} else {
$perm_a[] = $v['permId'];
}
$perms = array_merge($perms, array_merge($perm_a, $perm_b));
}
return $perms;
}
// 处理菜单
public function handleMenus($menus, $perms)
{
foreach ($menus as $k => $v) {
if (strlen($v->href) > 2) {
if (preg_match('/\/web\//', $v->href)) {
$permId = str_replace('/web/','',$v->href);
} else {
$permId = str_replace('/', '', $v->href);
}
// 查看菜单权限
$permId = $permId . '_check';
if (!in_array($permId, $perms)) {
unset($menus[$k]);
}
}
if (count($v->childs) > 0) {
$menus[$k]->childs = array_values($this->handleMenus($v->childs, $perms));
if (empty($menus[$k]->childs)) {
unset($menus[$k]);
}
}
}
return array_values($menus);
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class PermController extends Controller
{
// 检查用户是否具有系统访问权限
public function checkAccess($request)
{
$user_id = $request->user->userId;
$role = $this->getUserRole($request);
if ($role == 1) return true; // 超级管理员或系统管理员直接进入
$userPerms = $this->getUserAllPerms($user_id, $role);
if (!$userPerms) return false;
if (in_array('apply_access', $userPerms)) return true; // 访问权限ID是否存在
return false;
}
// 获取系统信息
public function getBusinessInfo()
{
// 根据域名查询系统业务ID
$business = DB::table('t_business_config')->where('url', Config('website.risk_url'))->first();
return !empty($business) ? $business : false;
}
// 获取用户角色
public function getUserRole(Request $request)
{
$uid = $request->user->userId;
$email = $request->user->email;
if ($email == 'admin@ichunt.com') {
return 1;
}
$business = $this->getBusinessInfo();
if ($business) {
$bid = $business->bid;
// 权限系统配置的管理帐号
$adminAccount = json_decode($business->admin, true);
if (in_array($email, $adminAccount)) {
return 1;
}
// 根据用户ID和业务ID查看角色
$userPerm = DB::table('t_user_perm')->where(['userId' => $uid, 'bid' => $bid])->first();
if (empty($userPerm)) {
return 0;
} else {
if ($userPerm->roles == 'null') return 0;
$role = json_decode($userPerm->roles, true);
foreach ($role as $v) {
$department = DB::table('t_role_perm')->where(['roleId' => $v, 'bid' => $bid])->first();
return in_array($department->name,array_keys(Config('roles.sys_roles'))) ? array_get(Config('roles.sys_roles'),$department->name) : 0;
}
}
}
return 0;
}
// 获取所有角色用户集合
public function getRoleUsers($roleName)
{
// 根据域名查询系统业务ID
$business = $this->getBusinessInfo();
$userId = [];
$roleUsers = [];
if ($business) {
$bid = $business->bid;
$role = DB::table('t_role_perm')->where(['bid' => $bid, 'name' => $roleName])->first();
$roleId = $role->roleId;
$user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` REGEXP $roleId");
if ($user) {
foreach ($user as $v) {
$userId[] = $v->userId;
$id = $v->userId ? $v->userId : 0;
if(!$id) continue;
$userId[] = $id;
$userInfo = DB::table('user_info')->where('userId', $id)->select('userId', 'name', 'status')->first();
// 判断用户是否已离职 4为离职状态
if ($userInfo->status != 4) {
$roleUsers[] = $userInfo;
}
}
}
}
return $roleUsers;
}
// 获取权限菜单
public function getPermMenu($menus, $user_id)
{
$userPerms = $this->getUserAllPerms($user_id);
if ($userPerms) {
return $this->handleMenus($menus, $userPerms);
}
return false;
}
// 获取用户所有权限
public function getUserAllPerms($user_id, $role=0)
{
// 根据域名查询系统业务ID
$business = $this->getBusinessInfo();
if ($business) {
if ($role != 1) {
$bid = $business->bid;
$url = Config('website.perm_api').$user_id.'/'.$bid;
$userPerms = json_decode(curlApi($url), true);
if ($userPerms && $userPerms['retcode'] == 0) {
return $userPerms['data']['perms'];
}
} else { // 获取管理员所有权限
return $this->getAllPerms(json_decode($business->configs, true));
}
}
return false;
}
// 获取系统配置权限
public function getAllPerms($configs)
{
$perms = [];
foreach ($configs as $k => $v) {
$perm_a = [];
$perm_b = [];
if (isset($v['childs']) && count($v['childs']) > 0) {
$perm_b = $this->getAllPerms($v['childs']);
} else {
$perm_a[] = $v['permId'];
}
$perms = array_merge($perms, array_merge($perm_a, $perm_b));
}
return $perms;
}
// 处理菜单
public function handleMenus($menus, $perms)
{
foreach ($menus as $k => $v) {
if (strlen($v->href) > 2) {
if (preg_match('/\/web\//', $v->href)) {
$permId = str_replace('/web/','',$v->href);
} else {
$permId = str_replace('/', '', $v->href);
}
// 查看菜单权限
$permId = $permId . '_check';
if (!in_array($permId, $perms)) {
unset($menus[$k]);
}
}
if (count($v->childs) > 0) {
$menus[$k]->childs = array_values($this->handleMenus($v->childs, $perms));
if (empty($menus[$k]->childs)) {
unset($menus[$k]);
}
}
}
return array_values($menus);
}
}
\ 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>
<input type="hidden" id="templateid" value='{{Request::input("t_id")}}'/>
<div class="tag-content">
<div class="tag-tools">
<div class="tips">请拖动此处标签制作工具到下方编辑区域编辑!</div>
<div class="items yuan" name="round"><div class="round zctem" type="1" w="45" h="45" name="round" xtys="#333"></div><span>圆形</span></div>
<div class="items fang" name="rectangle"><div class="rectangle zctem" type="2" w="70" h="45" name="rectangle" xtys="#333"></div><span>矩形</span></div>
<div class="items text" name="textarea"><textarea class="textarea zctem" zhg="26" zh="14" wenben="测试文本" zt="Microsoft YaHei" type="3" w="200" h="26" ztys="#000000" name="textarea" placeholder="请输入文案">测试文本</textarea>A<span>文本</span></div>
<div class="items line" name="lineit"><div class="lineit zctem" type="4" w="70" h="1" name="lineit" xtys="#333"></div><span>线</span></div>
<div class="items erweima" name="erweimait" style="background: url(http://img.ichunt.com/images/cms/201905/05/0998e54c5120aec61e6868943a67916e.png) no-repeat;background-size: 100% 100%;"><div class="zctem erweimait" type="5" w="45" h="45" name="erweimait"style="background: url(http://img.ichunt.com/images/cms/201905/05/0998e54c5120aec61e6868943a67916e.png) no-repeat;background-size: 100% 100%;"></div><span>二维码</span></div>
<div class="items yiweima" name="yiweimait" style="background: url(http://sz.ichunt.com/v3/dist/res/home/images/about/yiweima.png) no-repeat;background-size: 100% 100%;"><div class="zctem yiweimait" type="5" w="87" h="35" name="yiweimait" style="background: url(http://sz.ichunt.com/v3/dist/res/home/images/about/yiweima.png) no-repeat;background-size: 100% 100%;"></div><span>一维码</span></div>
<div class="items tupian" name="imageit" style="background: url(http://sz.ichunt.com/v3/dist/res/home/images/about/charutupian.png) no-repeat;background-size: 100% 100%;"> <div class="zctem imageit" type="6" w="60" h="45" name="imageit" style="background: url(http://sz.ichunt.com/v3/dist/res/home/images/about/charutupian.png) no-repeat;background-size: 100% 100%;"></div><span>插入图片</span></div>
<div class="items logo1" name="logo1it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"><div class="zctem logo1it logobase64" type="7" w="91" h="45" name="logo1it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"></div><span>logo1</span></div>
<div class="items logo2" name="logo2it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"><div class="zctem logo2it logobase64" type="7" w="64" h="25" name="logo2it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"></div><span>logo1</span></div>
<div class="items logo3" name="logo3it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"><div class="zctem logo3it logobase64" type="7" w="88" h="34" name="logo3it" style="background: url(http://img.ichunt.com/images/ichunt/label/new_logo.png) no-repeat;background-size: 100% 100%;"></div><span>logo1</span></div>
</div>
<div class="tag-edit clr">
<h3>标签编辑区域</h3>
<div class="edit-seclect clr">
<div class="seclect-group fl">
<span>标签大小:</span>
<select class="tag-size">
<option value="440*280">90*60</option>
</select>
</div>
<div class="seclect-group fl">
<span>标签底色:</span>
<input type="text" class="tag-bgm" value="#ffffff"/>
</div>
<div class="seclect-group fl">
<span>边框:</span>
<select class="tag-border">
<option value=""></option>
<option value="1px solid #333">边框一</option>
<option value="2px solid #333">边框二</option>
</select>
</div>
<div class="seclect-group fl">
<span>辅助线:</span>
<select class="tag-fz">
<option value=""></option>
<option value="1"></option>
</select>
</div>
<div class="seclect-group fl">
<span>模板名称:</span>
<input type="text" placeholder="输入模板名称" style="width:120px;" class="designName"/>
</div>
</div>
<div class="fztip">格子区域为画图区域,每个辅助格子20px*20px,从左上角开始,横向为X轴,纵向为Y轴,标尺每个刻度10px</div>
<div class="fztip" ><b style="color:red;">双击删除</b> 编辑区域内标签工具,鼠标停留在画图区域,可按住<b style="color:red;">键盘上下左右键移动当前标签工具</b></div>
<div class="fztip" ><span style="color:red;">颜色选择器,复制此处颜色可用 </span><input type="text" id="colorpicker" /></div>
<div class="edit-box fl">
<div class="edit-con init-border" ></div>
</div>
<div class="edit-value fr" >
<div class="tools tool1" >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">线色浓度</span><input type="number" class="xsnd fl" placeholder="输入数值"/>
<span class="fl">线样式</span>
<select class="xys">
<option value="solid">实线</option>
<option value="dashed">虚线</option>
</select>
</div>
<div class="group-value clr">
<span class="fl">填充颜色</span><input type="text" class="tcys fl" />
<span class="fl">线条颜色</span><input type="text" class="xtys fl" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
</div>
<div class="tools tool2" >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">线色浓度</span><input type="number" class="xsnd fl" placeholder="输入数值"/>
<span class="fl">线样式</span>
<select class="xys">
<option value="solid">实线</option>
<option value="dashed">虚线</option>
</select>
</div>
<div class="group-value clr">
<span class="fl">填充颜色</span><input type="text" class="tcys fl" />
<span class="fl">线条颜色</span><input type="text" class="xtys fl" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
</div>
<div class="tools tool3" >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">文本类容</span><input type="text" class="wenben fl" style="width:350px;margin-top: 10px;"/>
</div>
<div class="group-value clr">
<span class="fl">字体</span>
<select class="zt fl">
<option value="Microsoft YaHei">微软雅黑</option>
<option value="SimSun">宋体</option>
<option value="KaiTi">楷体</option>
<option value="LiSu">隶书</option>
</select>
<span class="fl">字号</span>
<select class="zh fl">
<option value="12">12</option>
<option value="14">14</option>
<option value="18">18</option>
<option value="20">20</option>
<option value="22">22</option>
<option value="24">24</option>
</select>
</div>
<div class="group-value clr">
<span class="fl">字色浓度</span>
<select class="zsnd fl">
<option value="100">1</option>
<option value="200">2</option>
<option value="300">3</option>
<option value="400">4</option>
<option value="500">5</option>
<option value="600">6</option>
<option value="700">7</option>
<option value="800">8</option>
<option value="900">9</option>
</select>
<span class="fl">字间距</span><input type="number" class="zjj fl" placeholder="输入数值"/>
</div>
<div class="group-value clr">
<span class="fl">字体颜色</span><input type="text" class="ztys fl" placeholder=""/>
<span class="fl">字行高</span><input type="number" class="zhg fl" placeholder="输入数值"/>
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
<div class="group-value clr">
<div class="sjglgroup clr">
<span class="fl">数据关联</span>
<div class="sjglbox fl">
<select class="sjgl sjgl1 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
</div>
</div>
<div class="tools tool4" >
<div class="group-value clr">
<span class="fl">方向</span>
<select class="fx fl">
<option value="">横向</option>
<option value="1">纵向</option>
</select>
</div>
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">长度W</span><input type="number" class="kdw fl" />
<span class="fl">线色浓度</span><input type="number" class="xsnd fl" placeholder="输入数值"/>
</div>
<div class="group-value clr">
<span class="fl">线样式</span>
<select class="xys fl">
<option value="solid">实线</option>
<option value="dashed">虚线</option>
</select>
<span class="fl">线条颜色</span><input type="text" class="xtys fl" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
</div>
<div class="tools tool5" >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
<div class="group-value clr">
<div class="sjglgroup clr">
<span class="fl">数据关联</span>
<div class="sjglbox fl">
<select class="sjgl sjgl1 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl2 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl3 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl4 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
</div>
</div>
<div class="tools tool6 " >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">上传图片</span>
<input type="file" class="imagesurl fl" style="border:0px;padding:0px;width:200px;" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
</div>
<div class="tools tool7 " >
<div class="group-value clr">
<span class="fl">坐标X</span><input type="number" class="zbx fl" />
<span class="fl">坐标Y</span><input type="number" class="zby fl" />
</div>
<div class="group-value clr">
<span class="fl">宽度W</span><input type="number" class="kdw fl" />
<span class="fl">高度H</span><input type="number" class="gdh fl" />
</div>
<div class="group-value clr">
<span class="fl">图层层级</span><input type="number" class="tccj fl" placeholder="输入数值,越大越高"/>
</div>
</div>
</div>
</div>
<br/><br/>
<button class="submitx layui-btn">提交</button>
</div>
<script src="../../../js/colorselect.js"></script>
@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>
<input type="hidden" id="templateid" value='{{Request::input("t_id")}}'/>
<div class="tag-content">
<div class="tag-edit clr">
<div class="fztip" style="color:red;">点击下面的一维码、二维码、文案等可以选择或者修改关联数据!!</div></br>
<div class="editgo fl">
</div>
<div class="edit-value fr" style="position: initial;margin-top:0px;">
<div class="tools tool3" >
<div class="group-value clr">
<div class="sjglgroup clr">
<span class="fl">数据关联</span>
<div class="sjglbox fl">
<select class="sjgl sjgl1 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
</div>
</div>
<div class="tools tool5" >
<div class="group-value clr">
<div class="sjglgroup clr">
<span class="fl">数据关联</span>
<div class="sjglbox fl">
<select class="sjgl sjgl1 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl2 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl3 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
<div class="sjglgroup clr">
<span class="fl">
<select style="width:60px;" class="sjgl">
<option value="/">/</option>
<option value="\">\</option>
<option value="-">-</option>
<option value="+">+</option>
<option value="%">%</option>
<option value="&amp;">&amp;</option>
<option value="*">*</option>
<option value="#">#</option>
<option value=";"></option>
<option value=":"></option>
</select>
</span>
<div class="sjglbox fl">
<select class="sjgl sjgl4 fl">
<option value="">自定义</option>
<option value="sku_code">SKU编码</option>
<option value="goods_type">型号名称</option>
<option value="goods_brand">型号品牌</option>
<option value="goods_number">型号数量</option>
<option value="sale_order_sn">销售单号</option>
<option value="customer_code">客户编码</option>
<option value="customer_type">客户型号</option>
<option value="customer_com">客户公司</option>
</select>
<input type="text" class="sjgl zdynr" placeholder="输入自定义内容" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var offine={
init:function(){
offine.getInfo();
offine.handle();
},
itemedit:function(){
var ele=$(".huabuitem.act");
$(".tools.act").removeClass("act");
$(".tool"+ele.attr("type")).addClass("act");
for(var i=0;i<$(".tools.act .sjglgroup").length;i++){
var current_=(i+1);
if(typeof(ele.attr("sjgl"+current_))=="undefined"){
$(".tools.act .sjgl").val("");
$(".tools.act .sjgl").next().val("").show();
$(".tools.act .sjgl").parents(".sjglgroup").find("span").find("select").val("/");
break;
}
if(ele.attr("sjgl"+current_)){
if(ele.attr("sjgl"+current_).indexOf("||zdyxkpoiop")!=-1){
//非自定义
if(current_==1){
$(".tools.act .sjgl"+current_).val(ele.attr("sjgl"+current_).split("||zdyxkpoiop")[0]);
}else{
$(".tools.act .sjgl"+current_).val(ele.attr("sjgl"+current_).slice(1).split("||zdyxkpoiop")[0]);
$(".tools.act .sjgl"+current_).parents(".sjglgroup").find("span").find("select").val(ele.attr("sjgl"+current_)[0])
}
$(".tools.act .sjgl"+current_).next().val("").hide();
}else{
//自定义
$(".tools.act .sjgl"+current_).val("");
if(current_==1){
$(".tools.act .sjgl"+current_).next().val(ele.attr("sjgl"+current_));
}else{
$(".tools.act .sjgl"+current_).next().val(ele.attr("sjgl"+current_).slice(1));
$(".tools.act .sjgl"+current_).parents(".sjglgroup").find("span").find("select").val(ele.attr("sjgl"+current_)[0])
}
$(".tools.act .sjgl"+current_).next().show();
}
}else{
$(".tools.act .sjgl"+current_).val("");
$(".tools.act .sjgl"+current_).next().val("").show();
$(".tools.act .sjgl"+current_).parents(".sjglgroup").find("span").find("select").val("/")
}
}
},
getInfo:function(){
$.ajax({
url : '/ajax/getTemplateDetail?t_id='+$("#templateid").val(),
type: 'get',
success: function(resp) {
if (resp.err_code == 0) {
$(".editgo").html(resp.data.template_extend.html);
$("textarea").attr("readonly",true);
}else{
layer.msg(resp.err_msg,{time:2000});
}
},
error: function(err) {
console.log(err)
}
})
},
handle:function(){
//监听画布已有工具
$(document).on("click",".huabuitem[type='5'],.huabuitem[type='3']",function(e){
var self=$(this);
if(!$(this).hasClass("act")){
$(".huabuitem").removeClass("act");
self.addClass("act");
}
offine.itemedit();
})
//监听属性赋值
$(document).on("input propertychange",".tools.act select,.tools.act input",function(){
var ele=$(".huabuitem.act");
var name_=$(this).attr("class").split(" ")[0];
var self=$(this);
var val_=self.val();
switch(name_) {
case "sjgl":
//ele.attr("sjgl1",val_);
var parent_=self.parents(".group-value");
var datatypes="";
for(var i=0;i<parent_.find(".sjglgroup").length;i++){
var elp=parent_.find(".sjgl"+(i+1));
var qz_="";
if(i>0){
qz_=elp.parents(".sjglgroup").find("span select").val();
}
if(elp.val()){
ele.attr("sjgl"+(i+1),qz_+elp.val()+"||zdyxkpoiop");
datatypes+=qz_+"<<<"+elp.val()+">>>";
}else{
var nextval_=elp.next().val();
if(nextval_){
ele.attr("sjgl"+(i+1),qz_+nextval_);
datatypes+=qz_+nextval_;
}else{
ele.attr("sjgl"+(i+1),elp.next().val());
}
}
ele.attr("datatypes",datatypes)
}
break;
default:
break;
}
});
//数据关联联动
$(".sjglbox select").bind('input propertychange', function() {
var val_=$(this).val();
if(!val_){
$(this).next().show()
}else{
$(this).next().hide()
}
})
}
}
$(function(){
offine.init()
})
</script>
<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