Commit 29756f12 by 孙龙

init

parent 1f46a6ed
......@@ -15,6 +15,13 @@ 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_MONGO_HOST=192.168.1.237
DB_MONGO_DATABASE=ichunt
DB_MONGO_USERNAME=ichunt
......
......@@ -5,9 +5,9 @@ use App\Exceptions\IcException;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use App\Model\JobsModel;
use App\Model\NodesModel;
use App\Model\CronLogModel;
use App\Model\TemplateListModel;
use App\Model\SaleOrderListsModel;
use App\Model\TmplRelationsModel;
Class AjaxController extends Controller
{
......@@ -17,46 +17,92 @@ Class AjaxController extends Controller
return $this->$id($request);
}
// 任务列表
public function taskList($request)
// 模板列表
public function labelList($request)
{
$JobsModel = new JobsModel();
return $JobsModel->lists($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",'');
$admin_id = $request->user->userId;
$perm = new PermController;
// 用户角色
$role = $perm->getUserRole($request);
$query = TemplateListModel::select('*')->CreateUserId($admin_id,$role,$create_username)->TemplateName($template_name)
->Status($status)
->SearchTime($begin_time,$end_time)
->OrderBy("id","desc");
$query = $query->paginate($limit,[],'page',$page);
$list = $query->toArray();
// dump($list);
return ['code'=>0, 'count'=>$list['total'],'data'=>$list["data"]];
}
// 项目配置-操作:启用、禁用
public function taskAction($request)
// 标签使用记录
public function record($request)
{
$JobsModel = new JobsModel();
return $JobsModel->action($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",'');
// 项目配置-新增/编辑
public function setTask($request)
{
$JobsModel = new JobsModel();
return $JobsModel->set($request);
}
// 任务列表
public function nodeList($request)
{
$NodesModel = new NodesModel();
return $NodesModel->getlists($request);
$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]["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 updateNodes($request)
{
$NodesModel = new NodesModel();
return $NodesModel->getNodes();
/*
* 模板列表修改状态
*/
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($id);
if($tmpl){
$tmpl->status = ($tmpl->status == -1) ? 1 :-1;
$tmpl->save();
return $this->ajaxReturn(0,"修改成功");
}else{
return $this->ajaxReturn(-1,"没找到与自己对应的模板");
}
}
// 执行日志
public function cronLogList($request)
{
$CronLogModel = new CronLogModel();
return $CronLogModel->lists($request);
protected function ajaxReturn($code,$msg="",$data=[]){
return [
"err_code"=>$code,
"err_msg"=>$msg,
"data"=>$data,
];
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use App\Model\JobsModel;
use App\Model\TemplateListModel;
use App\Model\NodesModel;
class WebController extends Controller
......@@ -20,7 +20,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 = [];
......@@ -66,36 +66,20 @@ class WebController extends Controller
return $this->$id($request, $info);
}
// 任务列表
public function taskList($request, $info)
// 模板列表
public function labelList($request, $info)
{
$info['title'] = '任务列表';
$NodesModel = new NodesModel();
$info['nodes'] = $NodesModel->where('status', 1)->select('node_ip')->get()->toArray();
$info['title'] = '标签模板列表';
return view('web', $info);
}
// 节点列表
public function nodeList($request, $info)
// 标签使用记录
public function record($request, $info)
{
$info['title'] = '节点列表';
$info['title'] = '标签使用记录';
return view('web', $info);
}
// 执行日志
public function cronLog($request, $info)
{
$info['title'] = '执行日志列表';
$info['paths'] = [["title" => '任务列表', "href" => '/web/taskList'], ["title" => '执行日志', "href" => '#']];
$info['job_name'] = $request->input('job_name', '');
if (!$info['job_name']) return redirect('/web/taskList');
return view('web', $info);
}
}
......@@ -209,9 +209,10 @@
{
$actives = [];
CheckActive($menus, $actives, $uri);
$ret = '';
foreach ($actives as $k => $v) {
if ($k == count($actives) - 1) {
if ($k != 0 && $k == count($actives) - 1) {
$ret .= '<li class="active"><a>' . $menus[$actives[0]]->childs[$actives[1]]->title . '</a></li>';
} else {
$ret .= '<li><a href="#">' . $menus[$actives[0]]->title . '</a></li>';
......
......@@ -40,46 +40,7 @@ Route::group(['middleware' => 'web'], function () {
Route::get('/exportg/score_list', 'ExportController@scoreList');
});
// 不需要登陆态
Route::group(['middleware' => 'api'], function () {
Route::get('/api/sendmsg', 'MessageController@sendMsg');
});
Route::group(['prefix' => 'console'], function () {
//取出我们需要的所有定时任务的列表
Route::get('/', function () {
$list = Artisan::all();/*将所有的定时任务取出来,如果没有可能是需要装一下_ide_helper.php拓展包*/
$tmpArr = [];
foreach ($list as $key => $val) {
$isMatched = preg_match('/(user|Fund|command|market|emp):\w+/', $key, $matches);/*将我们需要的定时任务取出来*/
if (!$isMatched) {
continue;
}
//将定时任务名称与描述关联成数组
$tmpArr[$key] = $val->getDescription();
}
dd($tmpArr);//显示定时任务的列表
});
//运行我们的要运行的定时任务命令
Route::get('/{name}/{param?}', function ($name = null, $param = null) {
$list = Artisan::all();
//判断输入的命令是否在命令列表中
if (!array_key_exists($name, $list)) {
dd('没有此命令');
}
//定时任务执行的时长设置,要不浏览器中容易超时
set_time_limit(300);
//执行定时任务
$str = "cd " . base_path() . " && php artisan $name $param";
exec($str, $output, $return_var);
dd($output);
dd(implode("\r\n", $output));
});
});
<?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 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=''){
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;
}
}
\ 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
......@@ -22,4 +22,17 @@
-1 => '掉线',
],
"template_fields"=>[
1=>[
"sale_order_sn",
"goods_type",
"goods_brand",
"goods_number",
"sku_code",
"customer_code",
"customer_type",
"customer_com",
],
],
];
......@@ -71,6 +71,19 @@ return [
'strict' => false,
],
'label' => [
'driver' => 'mysql',
'host' => env('DB_LABEL_HOST', ''),
'database' => env('DB_LABEL_DATABASE', ''),
'username' => env('DB_LABEL_USERNAME', ''),
'password' => env('DB_LABEL_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'web' => [
'driver' => 'mysql',
'host' => env('DB_WEB_HOST', ''),
......
......@@ -3,11 +3,7 @@
return [
'sys_roles' => [ // 系统角色
'管理员' => 1,
'后台开发组' => 2,
'运维组' => 3,
'金蝶组' => 4,
'测试组' => 5,
'普通用户' => 6,
'普通用户' => 4,
],
];
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: {
model_id: $('input[name=model_id]').val()
}
,cols: [[ //表头
{title: 'ID',field:"id", type: 'numbers',fixed: 'left', width: 80}
,{field: 'template_name', title: '模板名称'}
,{field: 'status', title: '状态',templet:"#status"}
,{field: 'create_username', title: '创建人'}
,{field: 'create_time', title: '创建时间', sort: true}
,{field: 'update_time', title: '更新时间', sort: true}
,{ 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,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"); // 触发搜索按钮
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,url,datax);
}else if (layEvent == "forbid"){
title = '禁用模板';
content = '确定禁用该模板?';
url = '/ajax/template_status';
datax = {id:data.id,status:data.status}
enable_tool(title,url,datax);
}
})
});
\ No newline at end of file
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/record' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,where: {
model_id: $('input[name=model_id]').val()
}
,cols: [[ //表头
{title: '序号',field:"id", type: 'numbers',fixed: 'left', width: 80}
,{field: 'template_name', title: '模板名称'}
,{field: 'sale_order_sn', title: '销售单号'}
,{field: 'goods_type', title: '型号'}
,{field: 'print_nums', title: '打印次数', sort: true}
,{field: '', title: '销售员', sort: true}
,{field: 'create_time', title: '使用时间', sort: true}
,{field: 'print_time', title: '打印时间', sort: true}
,{ title: '操作',width: 250, 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/record' //数据接口
,where: data.field
});
return false;
});
var enable_tool = function (title,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"); // 触发搜索按钮
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,url,datax);
}else if (layEvent == "forbid"){
title = '禁用模板';
content = '确定禁用该模板?';
url = '/ajax/template_status';
datax = {id:data.id,status:data.status}
enable_tool(title,url,datax);
}
})
});
\ No newline at end of file
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' //指定元素
});
var renderTable = function () {
table.render({
id: 'list'
,elem: '#task'
,url: '/ajax/taskList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 80}
,{field: '_id', title: '任务ID', width: 220}
,{field: 'etcd_key', title: 'ETCD Key', width: 300}
,{field: 'job_name', title: '任务名称', width: 200}
,{field: 'node', title: '所属节点', width: 200}
,{field: 'group_val', title: '所属分组', width: 100}
,{field: 'command', title: 'shell命令', width: 300}
,{field: 'cron_expr', title: 'cron表达式', width: 150}
,{field: 'concurrency_num', title: '并发数', width: 100}
,{field: 'job_type_val', title: '任务类型', width: 100}
,{field: 'status', title: '状态', templet:'#status', width: 100}
,{field: 'creator', title: '创建人', width: 100}
,{field: 'modifier', title: '修改人', width: 100}
,{field: 'create_time', title: '创建时间', sort: true, width: 160}
,{field: 'update_time', title: '更新时间', sort: true, width: 160}
,{title: '操作', align:'center', fixed: 'right', toolbar: '#action', width: 200}
]]
,limit: 10
,limits: [10, 20, 50,]
});
}
renderTable(); // 加载表格
form.on('submit(load)', function(data) {
//执行重载
table.reload('list', {
page: {
curr: 1
}
,where: data.field
});
return false;
});
// tool操作
table.on('tool(task)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的DOM对象
var title = '';
var content = '';
var url = '';
var datax = [];
if(layEvent === 'enable'){ // 启用
title = '启用该任务';
content = '确定启用该任务?';
url = '/ajax/taskAction';
datax = {id: data._id, status: 1, job_name: data.job_name, node: data.node, group: data.group, command: data.command, cron_expr: data.cron_expr, job_type: data.job_type, concurrency_num: data.concurrency_num};
} else if(layEvent === 'forbid'){ // 禁用
title = '禁用该任务';
content = '确定禁用该任务?';
url = '/ajax/taskAction';
datax = {id: data._id, status: -1, job_name: data.job_name, node: data.node};
} else if (layEvent == 'edit') {
$('.job_id').val(data._id);
$('.job_name').val(data.job_name).addClass('layui-disabled'); // 编辑时禁止修改任务名
$('.job_node').val(data.node);
$('.job_group').val(data.group);
$('.command').val(data.command);
$('.cron_expr').val(data.cron_expr);
$('.job_type').val(data.job_type).attr('disabled', true);
$('.concurrency_num').val(data.concurrency_num);
form.render('select');
taskSet('编辑任务');
return false;
}
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"); // 触发搜索按钮
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);
}
})
});
// 新增任务
$('.add').click(function() {
$('.job_id').val('');
$('.job_name').val('').removeClass('layui-disabled');
$('.job_node').val('');
$('.job_group').val('');
$('.command').val('');
$('.cron_expr').val('');
$('.job_type').val('').attr('disabled', false);
$('.concurrency_num').val('');
form.render('select');
taskSet('新增任务');
})
/**
* 新增、编辑任务
* @param {[type]} title [标题]
*/
function taskSet(title) {
layer.open({
type: 1,
area: ['600px'],
title: title,
content: $('#task-set'),
btn: ['确认', '取消'],
yes: function(index) {
var job_id = $('.job_id').val();
var job_name = $('.job_name').val();
var job_node = $('.job_node').val();
var job_group = $('.job_group').val();
var command = $('.command').val();
var cron_expr = $('.cron_expr').val();
var job_type = $('.job_type').val();
var concurrency_num = $('.concurrency_num').val();
var reg = /\d/;
if (!job_name) {
layer.msg('请输入任务名称');
return false;
}
if (!job_node) {
layer.msg('请输入所属节点');
return false;
}
if (!job_group) {
layer.msg('请选择所属分组');
return false;
}
if (!command) {
layer.msg('请输入shell命令');
return false;
}
if (!cron_expr) {
layer.msg('请输入cron表达式');
return false;
}
if (!job_type) {
layer.msg('请选择任务类型');
return false;
}
if (concurrency_num && !reg.test(concurrency_num)) {
layer.msg('格式错误,请填写数值');
return false;
}
// var datax = $('.task-set-form').serialize();
var datax = {
job_id: job_id,
job_name: job_name,
job_node: job_node,
job_group: job_group,
command: command,
cron_expr: cron_expr,
job_type: job_type,
concurrency_num: concurrency_num,
};
$.ajax({
url : '/ajax/setTask',
type: 'post',
data: datax,
success: function(resp) {
if (resp.err_code == 0) {
layer.msg(resp.err_msg);
// renderTable(); // 重新加载table
$('.search').trigger("click"); // 触发搜索按钮
return false;
}
layer.alert(resp.err_msg);
},
error: function(err) {
console.log(err)
}
})
layer.close(index);
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
});
\ 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')
......
<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>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="action">
<a class="btn btn-xs btn-outline btn-info" lay-event="offline">离线使用</a>
<a class="btn btn-xs btn-outline btn-success" lay-event="show">预览</a>
<a class="btn btn-xs btn-outline btn-success" href="/web/editLabel?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>
@{{# } }}
</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">订单号</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>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="action">
<a class="btn btn-xs btn-outline btn-info" lay-event="offline">离线使用</a>
<a class="btn btn-xs btn-outline btn-success" lay-event="show">预览</a>
<a class="btn btn-xs btn-outline btn-success" href="/web/editLabel?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>
@{{# } }}
</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">任务名称</label>
<div class="layui-input-inline">
<input type="text" name="job_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">
<select name="user_group" lay-verify="" lay-search>
<option value=""></option>
@foreach (Config('config.user_group') 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">
<select name="status" lay-verify="" lay-search>
<option value=""></option>
@foreach (Config('config.job_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 type="button" class="layui-btn layui-btn-normal add">新增任务</button>
<button lay-submit lay-filter="load" class="layui-btn search" data-type="search">搜索</button>
</div>
</div>
</form>
<table id="task" lay-filter="task"></table>
<script type="text/html" id="status">
@{{# if (d.status == -1) { }}
<div style="color:#ccc;">禁用</div>
@{{# } else { }}
<div style="color:#5FB878;">启用</div>
@{{# } }}
</script>
<script type="text/html" id="action">
@{{# if (d.status == -1) { }}
<a class="btn btn-xs btn-outline btn-info" lay-event="enable">启用</a>
@{{# } else { }}
<a class="btn btn-xs btn-outline btn-success" lay-event="edit">编辑</a>
@{{# if (d.job_type == 1) { }}
<a class="btn btn-xs btn-outline btn-warning" lay-event="forbid">禁用</a>
@{{# } else { }}
<!-- <a class="btn btn-xs btn-outline btn-danger" lay-event="kill">强杀</a> -->
@{{# } }}
<a class="btn btn-xs btn-outline btn-primary" href="/web/cronLog?job_name=@{{ d.job_name }}" target="_blank">执行日志</a>
@{{# } }}
</script>
<style>
#task-set {
display: none;
}
.layui-layer-page .layui-layer-content {
overflow: visible;
}
.task-set-form {
padding: 20px;
}
.task-set-form .layui-form-item .layui-input-inline {
width: 380px;
}
.x-sign {
color: red;
}
</style>
<!-- 新增或编辑弹窗 -->
<div id="task-set">
<form class="layui-form layui-box task-set-form">
<input type="hidden" class="job_id" name="job_id" value="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>任务名称</label>
<div class="layui-input-inline">
<input class="layui-input job_name" type="text" name="job_name" value="" autocomplete="off" placeholder="请输入任务名称">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>所属节点</label>
<div class="layui-input-inline">
<select class="job_node" name="job_node" lay-filter="job_node" lay-search>
<option value=""></option>
@if ($nodes)
@foreach ($nodes as $v)
<option value="{{$v['node_ip']}}">{{$v['node_ip']}}</option>
@endforeach
@endif
</select>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>所属分组</label>
<div class="layui-input-inline">
<select class="job_group" name="job_group" lay-filter="job_group" lay-search>
<option value=""></option>
@foreach (Config('config.user_group') as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>shell命令</label>
<div class="layui-input-inline">
<textarea class="layui-textarea command" name="command" placeholder="请输入shell命令"></textarea>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>cron表达式</label>
<div class="layui-input-inline">
<input class="layui-input cron_expr" type="text" name="cron_expr" value="" autocomplete="off" placeholder="请输入cron表达式,格式为秒、分、时、日、月、周、年">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><i class="x-sign"> * </i>任务类型</label>
<div class="layui-input-inline">
<select class="job_type" name="job_type" lay-filter="job_type" lay-search>
<option value=""></option>
@foreach (Config('config.job_type') as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">并发数</label>
<div class="layui-input-inline">
<input class="layui-input concurrency_num" type="text" name="concurrency_num" value="" autocomplete="off" placeholder="请输入并发数">
</div>
</div>
</div>
</form>
</div>
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