Commit 26db6e8a by 李洋

消息模板分类

parent 9438ddbd
......@@ -13,6 +13,7 @@ use App\Http\Requests;
use DB;
use RedisDB;
use Config;
use \Exception;
class MessageApiController extends Controller
{
......@@ -60,9 +61,9 @@ class MessageApiController extends Controller
// if (empty($data['tpl_key'])) {
// $this->Export(11003, '请输入模板描述');
// }
if (empty($data['cls_id'])){
$this->Export(11024, '请输入模板分类');
}
// if (empty($data['cls_id'])){
// $this->Export(11024, '请输入模板分类');
// }
if (empty($data['sub_cls_id'])){
$this->Export(11025, '请输入模板二级分类');
}
......@@ -96,7 +97,7 @@ class MessageApiController extends Controller
$tpl_model['creater'] = $data['creater'];
$tpl_model['obj_user'] = $data['obj_user'];
$tpl_model['msg_type'] = $data['msg_type'];
$tpl_model['sub_cls_id'] = $data['sub_cls_id'];
$tpl_model['cls_id'] = $data['sub_cls_id'];
if (empty($tpl_model['tpl_id'])) {
$tpl_model['create_time'] = time();
......@@ -367,8 +368,8 @@ class MessageApiController extends Controller
*/
private function getSubTplCls($request){
$data = $request->input();
$sub_tpl_info = DB::connection('message')->table('lie_msg_tpl_sub_classify')->select('sub_cls_id','sub_cls_name')
->where('cls_id',$data['sel_msg_tpl_cls'])->get();
$sub_tpl_info = DB::connection('message')->table('lie_msg_classify')->select('cls_id','name')
->where('parent_id',$data['sel_edit_cls'])->where('parent_id','!=',0)->get();
$this->Export(0, 'success',objectToArray($sub_tpl_info));
}
......@@ -381,78 +382,152 @@ class MessageApiController extends Controller
}
}
//编辑分类
//新增/编辑分类
private function editClassify($request){
$in_data = $request->input('field');
//验证数据合理性
$this->verifyClassifyData($in_data);
//去字符串空格
if (!empty($in_data)){
foreach ($in_data as &$d){
$d = trim($d);
}
unset($d);
}
//验证数据合理性 并去除字符串中的空格
$in_data = $this->verifyClassifyData($in_data);
//数据库操作
$db = DB::connection('message');
if (1 == $in_data['edit_type']){
if (!empty($in_data['add_classify'])){
$res = $db->table('lie_msg_tpl_classify')->insertGetId(['cls_name'=>$in_data['add_classify']]);
if (!$res){
$this->Export(11100, '新增分类失败');
$classify_model = $this->constructClassifyModel($db, [], $in_data);
$this->insertClassify($db, $classify_model);
}else{
$this->updateClassify($db, $in_data);
}
$this->Export(0, '操作成功');
}
if (!empty($in_data['add_sub_classify']) && !empty($in_data['sel_add_classify'])){
$res = $db->table('lie_msg_tpl_sub_classify')->insertGetId([
'cls_id'=>$in_data['sel_add_classify'],
'sub_cls_name'=>$in_data['add_sub_classify']
]);
if (!$res){
$this->Export(11101, '新增子分类失败');
//获取父级iD路径
private function getParentIdPath($db, $parent_id) {
if ($parent_id==0) {
return strval(1);
}
$parent_id_path = $db->table('lie_msg_classify')->select('id_path')->where('cls_id',$parent_id)->first();
if (!$parent_id_path) {
$this->Export(111, '未查找到根分类!');
}
}else{
if (!empty($in_data['sel_edit_classify_1st']) && !empty($in_data['edit_classify'])){
$res = $db->table('lie_msg_tpl_classify')->where('cls_id',$in_data['sel_edit_classify_1st'])->update(['cls_name'=>$in_data['edit_classify']]);
if (!$res && 0!==$res){
$this->Export(11102, '更新分类失败');
return $parent_id_path->id_path;
}
//添加分类
private function insertClassify($db, $classify_model) {
if ($classify_model['depth']==1) {
$root_id = $db->table('lie_msg_classify')->insertGetId($classify_model);
if (!$root_id) {
$this->Export(111, '创建根分类失败!');
}
$this->Export(0, '创建根分类成功');
} else {
//获取父级id路径
$parent_id_path = $this->getParentIdPath($db, $classify_model['parent_id']);
$db->beginTransaction();
try {//添加一级/二级分类
$new_cls_id = $db->table('lie_msg_classify')->insertGetId($classify_model);
if (!$new_cls_id) {
$this->Export(111, '创建分类失败!');
}else {//补充id路径
$id_path = $parent_id_path.','.strval($new_cls_id);
$res = $db->table('lie_msg_classify')->where('cls_id',$new_cls_id)->update(['id_path'=>$id_path]);
if (!$res) {
$this->Export(111, '更新分类id路径失败!');
}
if (!empty($in_data['sel_edit_classify_2nd']) && !empty($in_data['sel_edit_sub_classify']) && !empty($in_data['edit_sub_classify'])){
$res = $db->table('lie_msg_tpl_sub_classify')
->where('sub_cls_id',$in_data['sel_edit_sub_classify'])
->where('cls_id',$in_data['sel_edit_classify_2nd'])
->update(['sub_cls_name'=>$in_data['edit_sub_classify']]);
if (!$res && 0!==$res){
$this->Export(11103, '更新子分类失败');
}
$db->commit();
} catch (Exception $e) {
$db->rollback();
$this->Export(111, '新增分类失败');
}
}
$this->Export(0, '操作成功');
}
//更新分类
private function updateClassify($db, $in_data){
if (!empty($in_data['sel_edit_sub_classify'])){
$cls_id = $in_data['sel_edit_sub_classify'];
$res = $db->table('lie_msg_classify')->where('cls_id',$cls_id)->update(['name'=>$in_data['edit_classify']]);
if (!$res && $res !== 0){
$this->Export(111, '编辑子分类失败');
}
}else {
$cls_id = $in_data['sel_edit_classify'];
$db->beginTransaction();
try {
$res = $db->table('lie_msg_classify')->where('cls_id',$cls_id)->update(['name'=>$in_data['edit_classify']]);
if (!$res && $res !== 0){
$this->Export(111, '编辑子分类失败');
}
$res = $db->table('lie_msg_classify')->where('parent_id',$cls_id)->update(['parent_name'=>$in_data['edit_classify']]);
if (!$res && $res !== 0){
$this->Export(111, '编辑子分类失败');
}
$db->commit();
} catch (Exception $e) {
$db->rollback();
$this->Export(111, '编辑子分类失败');
}
}
}
//构建消息分类模型
private function constructClassifyModel($db, $classifyModel, $in_data) {
$depth = 0;//分类深度
//检测表中是否有数据,没有则为根节点
$res = $db->table('lie_msg_classify')->select('cls_id')->first();
if (!$res) {
$depth = 1;
} else {
if (empty($in_data['sel_add_classify'])) {
$depth = 2;
} else {
$depth = 3;
}
}
$classify_model['depth'] = $depth;
$classify_model['status'] = 1;
$classify_model['name'] = $in_data['add_classify'];
if ($depth==1) {
$classify_model['parent_id'] = 0;
$classify_model['parent_name'] = '';
$classify_model['id_path'] = $this->getParentIdPath($db, $classify_model['parent_id']);
}elseif($depth==2) {
$classify_model['parent_id'] = 1;
$parent_name = $db->table('lie_msg_classify')->select('name')->where('cls_id',$classify_model['parent_id'])->first();
$classify_model['parent_name'] = $parent_name->name;
}elseif($depth==3) {
$classify_model['parent_id'] = $in_data['sel_add_classify'];
$parent_name = $db->table('lie_msg_classify')->select('name')->where('cls_id',$classify_model['parent_id'])->first();
$classify_model['parent_name'] = $parent_name->name;
}else {
$this->Export(111, '参数错误');
}
return $classify_model;
}
//验证修改分类数据的合理性
private function verifyClassifyData($in_data){
if (1 == $in_data['edit_type']){
if (empty($in_data['add_classify']) && empty($in_data['add_sub_classify'])){
$this->Export(11104, '请填写要添加的分类或子分类');
}
if (!empty($in_data['add_sub_classify']) && empty($in_data['sel_add_classify'])){
$this->Export(11105, '请选择要添加的子分类的上级分类');
if (empty($in_data['add_classify'])){
$this->Export(11104, '请填写要添加的分类名称');
}
}else{
if (empty($in_data['edit_classify']) && empty($in_data['edit_sub_classify'])){
$this->Export(11106, '请填写要编辑的分类或子分类');
if (empty($in_data['sel_edit_classify']) && empty($in_data['sel_edit_sub_classify'])){
$this->Export(11106, '请选择要编辑的分类或子分类');
}
if (!empty($in_data['edit_classify']) && empty($in_data['sel_edit_classify_1st'])){
$this->Export(11107, '请选择要编辑的分类');
if (empty($in_data['edit_classify'])){
$this->Export(11107, '请填写要编辑的分类名称');
}
if (!empty($in_data['edit_sub_classify']) && (empty($in_data['sel_edit_classify_2nd']) || empty($in_data['sel_edit_sub_classify']))){
$this->Export(11108, '请选择要编辑的子分类及其上级分类');
}
//去字符串空格
if (!empty($in_data)){
foreach ($in_data as &$d){
$d = trim($d);
}
unset($d);
}
return $in_data;
}
}
\ No newline at end of file
......@@ -187,9 +187,8 @@ class MessageController extends Controller
$info = [];
$db = DB::connection('message');
if (!empty($conditions['page']) && !empty($conditions['limit'])){
$info = $db->table('lie_msg_tpl as mt')->select('mt.tpl_id','mt.channels','mt.description','mt.ex_str','mtc.cls_name','mtsc.sub_cls_name','mtsc.sub_cls_id','mtsc.cls_id')
->leftjoin('lie_msg_tpl_sub_classify as mtsc','mtsc.sub_cls_id','=','mt.sub_cls_id')
->leftjoin('lie_msg_tpl_classify as mtc','mtc.cls_id','=','mtsc.cls_id')
$info = $db->table('lie_msg_tpl as mt')->select('mt.tpl_id', 'mt.channels', 'mt.description', 'mt.ex_str', 'mc.cls_id', 'mc.name', 'mc.depth', 'mc.id_path', 'mc.parent_id', 'mc.parent_name')
->leftjoin('lie_msg_classify as mc','mc.cls_id','=','mt.cls_id')
->where(function($query) use($conditions){
if (!empty($conditions['msg_key'])){
$query->where('mt.description','like','%'.$conditions['msg_key'].'%');
......@@ -197,36 +196,31 @@ class MessageController extends Controller
if (!empty($conditions['msg_channel'])){
$query->where('mt.channels','like','%'.$conditions['msg_channel'].'%');
}
if (!empty($conditions['msg_tpl_cls'])){
$query->where('mtsc.cls_id',$conditions['msg_tpl_cls']);
if (!empty($conditions['msg_cls'])){
$query->where('mc.parent_id',$conditions['msg_cls']);
}
if (!empty($conditions['msg_tpl_sub_cls'])){
$query->where('mtsc.sub_cls_id',$conditions['msg_tpl_sub_cls']);
if (!empty($conditions['msg_sub_cls'])){
$query->where('mc.cls_id',$conditions['msg_sub_cls']);
}
// $query->where('mc.depth', 3);
$query->where('mt.status', 0);
})
->where('status',0)
->where('source_type',1)
->orderby('tpl_id','desc')
->paginate($conditions['limit'],['*'],'page',$conditions['page'])->toArray();
foreach ($info['data'] as &$item){
$item = objectToArray($item);
$item['cls_name'] = !empty($item['cls_name'])?$item['cls_name']:'' ;
$item['sub_cls_name'] = !empty($item['sub_cls_name'])?$item['sub_cls_name']:'' ;
$item['cls_name'] = !empty($item['parent_name'])?$item['parent_name']:'' ;
$item['sub_cls_name'] = !empty($item['name'])?$item['name']:'' ;
$item['show_channels_str'] = $this->changeNumberStrToChineseStr(['站内信','短信','邮箱','微信通知','钉钉消息'],$item['channels']);
}
unset($item);
return json_encode(['code'=>0,'count'=>$info['total'],'msg'=>'success','data'=>$info['data']]);
}
//消息模板分类
$clses = [];
$cls = $db->table('lie_msg_tpl_classify')->select('cls_id','cls_name')->get();
foreach ($cls as &$c){
$c = objectToArray($c);
$clses[$c['cls_id']] = $c['cls_name'];
}
unset($c);
//消息模板一级分类
$clses = $this->getClassify($db);
$data=[
'title'=>'asd',
......@@ -308,13 +302,13 @@ class MessageController extends Controller
$res_perm = $this->getUserPerms($request,$perms_arr);
$allhistorylist_check = $res_perm['allhistorylist_check'];
$db = DB::connection('message');
$conditions = $request->input();
if(!empty($conditions['page']) && !empty($conditions['limit'])){
$items = DB::connection('message')->table('lie_msg_log as ml')
$items = $db->table('lie_msg_log as ml')
->leftjoin('lie_msg_tpl as mt','ml.tpl_id','=','mt.tpl_id')
->leftjoin('lie_msg_tpl_sub_classify as mtsc','mtsc.sub_cls_id','=','mt.sub_cls_id')
->leftjoin('lie_msg_tpl_classify as mtc','mtc.cls_id','=','mtsc.cls_id')
->select('ml.log_id','ml.status','ml.obj_user','ml.source_type','ml.tpl_id','ml.channel_type','ml.create_time','ml.expect_send_time','ml.actual_send_time','ml.title','ml.content','ml.wechat_tpl_id','mt.ex_str','mtc.cls_name','mtsc.sub_cls_name','mtsc.sub_cls_id','mtsc.cls_id')
->leftjoin('lie_msg_classify as mc','mc.cls_id','=','mt.cls_id')
->select('ml.log_id','ml.status','ml.obj_user','ml.source_type','ml.tpl_id','ml.channel_type','ml.create_time','ml.expect_send_time','ml.actual_send_time','ml.title','ml.content','ml.wechat_tpl_id','mt.ex_str','mc.name','mc.parent_id','mc.depth','mc.parent_name','mc.cls_id')
->where(function($query) use($conditions){
if(!empty($conditions['msg_tpl_desc']))
{
......@@ -340,11 +334,11 @@ class MessageController extends Controller
{
$query->where('ml.status',$conditions['msg_status']);
}
if (!empty($conditions['msg_tpl_cls'])){
$query->where('mtsc.cls_id',$conditions['msg_tpl_cls']);
if (!empty($conditions['msg_cls'])){
$query->where('mc.parent_id',$conditions['msg_cls']);
}
if (!empty($conditions['msg_tpl_sub_cls'])){
$query->where('mtsc.sub_cls_id',$conditions['msg_tpl_sub_cls']);
if (!empty($conditions['msg_sub_cls'])){
$query->where('mc.cls_id',$conditions['msg_sub_cls']);
}
})
// ->groupBy('ml.log_id') //todo:这里要改一下 想下怎么改 用mysql作groupby+分页
......@@ -358,21 +352,15 @@ class MessageController extends Controller
$item['status_str'] = Config('msgconfig.msg_status')[$item['status']];
$item['channel_type_str'] = Config('msgconfig.msg_channels')[$item['channel_type']];
$item['msg_tpl_str'] = $item['ex_str'];
$item['cls_name'] = !empty($item['cls_name'])?$item['cls_name']:'' ;
$item['sub_cls_name'] = !empty($item['sub_cls_name'])?$item['sub_cls_name']:'' ;
$item['cls_name'] = !empty($item['parent_name'])?$item['parent_name']:'' ;
$item['sub_cls_name'] = !empty($item['name'])?$item['name']:'' ;
}
unset($item);
return json_encode(['code'=>0,'count'=>$items['total'],'msg'=>'success','data'=>$items['data']]);
}
//消息模板分类
$clses = [];
$cls = DB::connection('message')->table('lie_msg_tpl_classify')->select('cls_id','cls_name')->get();
foreach ($cls as &$c){
$c = objectToArray($c);
$clses[$c['cls_id']] = $c['cls_name'];
}
unset($c);
//消息模板一级分类
$clses = $this->getClassify($db);
$data=[
'title'=>'asd',
......@@ -397,11 +385,7 @@ class MessageController extends Controller
$db = DB::connection('message');
//消息模板一级分类
$msg_tpl_cls = $db->table('lie_msg_tpl_classify')->orderby('cls_id','asc')->get();
$msg_tpl_clses = [];
foreach ($msg_tpl_cls as $k=>$v){
$msg_tpl_clses[$v->cls_id] = $v->cls_name;
}
$msg_tpl_clses = $this->getClassify($db);
//消息模板二级分类
$msg_tpl_sub_clses = [];
......@@ -409,17 +393,16 @@ class MessageController extends Controller
if(!empty($rq_tpl_id))
{
//通过tpl_id找到模板的渠道们 和 描述等
$info = $db->table('lie_msg_tpl as mt')->select('mt.tpl_id','mt.description','mt.channels','mt.msg_type','mt.creater','mt.source_type','mt.obj_user','mt.ex_str','mtsc.sub_cls_id','mtsc.sub_cls_name','mtsc.cls_id','mtc.cls_name')
->leftjoin('lie_msg_tpl_sub_classify as mtsc','mt.sub_cls_id','=','mtsc.sub_cls_id')
->leftjoin('lie_msg_tpl_classify as mtc','mtc.cls_id','=','mtsc.cls_id')
$info = $db->table('lie_msg_tpl as mt')->select('mt.tpl_id','mt.description','mt.channels','mt.msg_type','mt.creater','mt.source_type','mt.obj_user','mt.ex_str','mc.parent_id','mc.parent_name','mc.cls_id','mc.name')
->leftjoin('lie_msg_classify as mc','mt.cls_id','=','mc.cls_id')
->where('tpl_id',$rq_tpl_id)->first();
//获取消息模板二级分类
if (!empty($info->cls_id)){
$msg_tpl_sub_cls = $db->table('lie_msg_tpl_sub_classify')->select('sub_cls_id','sub_cls_name','cls_id')
->where('cls_id',$info->cls_id)->get();
$msg_tpl_sub_cls = $db->table('lie_msg_classify')->select('cls_id','name')
->where('parent_id',$info->parent_id)->get();
foreach ($msg_tpl_sub_cls as $k=>$v){
$msg_tpl_sub_clses[$v->sub_cls_id] = $v->sub_cls_name;
$msg_tpl_sub_clses[$v->cls_id] = $v->name;
}
}
//通过找到的 channels 去渠道模板表里 把每个channel找出来
......@@ -590,16 +573,8 @@ class MessageController extends Controller
//添加分类
private function addclassify(Request $request,$id,$viewId){
$info = [];
$db = DB::connection('message');
$infos = $db->table('lie_msg_tpl_classify')->select('cls_id','cls_name')->get();
if (!empty($infos)){
foreach ($infos as &$in){
$in = objectToArray($in);
$info[$in['cls_id']] = $in['cls_name'];
}
unset($in);
}
$info = $this->getClassify($db);
$data = [
'title' => 'asd',
'id' => $id,
......@@ -608,6 +583,19 @@ class MessageController extends Controller
return view($viewId, $data);
}
private function getClassify($db) {
$info = [];
$infos = $db->table('lie_msg_classify')->select('cls_id','name')->where('depth',2)->where('status', 1)->get();
if (!empty($infos)){
foreach ($infos as &$in){
$in = objectToArray($in);
$info[$in['cls_id']] = $in['name'];
}
unset($in);
}
return $info;
}
//--------------------------------------------inner methods-----------------------------------------
//数字字符串转为对应中文字符串 eg:1,2,3-->站内信,短信,邮件
......
......@@ -16,8 +16,7 @@ class AppServiceProvider extends ServiceProvider
{
//
//sql调试
$sql_debug = config('database.sql_debug');
if ($sql_debug) {
if (config('database.sql_debug')) {
DB::listen(function ($sql) {
foreach ($sql->bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
......@@ -30,7 +29,7 @@ class AppServiceProvider extends ServiceProvider
}
$query = str_replace(array('%', '?'), array('%%', '%s'), $sql->sql);
$query = vsprintf($query, $sql->bindings);
print_r($query);
dd($query);
echo '<br />';
});
}
......
......@@ -6,31 +6,19 @@ layui.use('form', function(){
showOrHide(data.value);
});
// form.on('select(sel_add_classify)', function (data) {
// console.log(data.value);
// });
// form.on('select(sel_edit_classify)', function (data) {
// console.log(data.value);
// });
// form.on('select(sel_edit_sub_classify)', function (data) {
// console.log(data.value);
// });
//监听模板分类选择 并刷新二级分类数据
form.on('select(sel_edit_classify_2nd)', function(data){
var sel_msg_tpl_cls = data.value;
form.on('select(sel_edit_classify)', function(data){
var sel_edit_cls = data.value;
$.ajax({
url: "/msgapi/getSubTplCls",
dataType: 'json',
data: {
sel_msg_tpl_cls: sel_msg_tpl_cls
sel_edit_cls: sel_edit_cls
},
success: function (result) {
var optionstring = '';
$.each(result.data, function(i,item){
optionstring += "<option value=" + item.sub_cls_id + ">" + item.sub_cls_name + "</option>";
optionstring += "<option value=" + item.cls_id + ">" + item.name + "</option>";
});
$("#sel_edit_sub_classify").html('<option value=""></option>' + optionstring);
form.render('select');
......@@ -49,14 +37,10 @@ layui.use('form', function(){
function showOrHide(type){
if ('1'===type){
$('#add_classify_div').show();
$('#add_sub_classify_div').show();
$('#edit_classify_div').hide();
$('#edit_sub_classify_div').hide();
}else{
$('#add_classify_div').hide();
$('#add_sub_classify_div').hide();
$('#edit_classify_div').show();
$('#edit_sub_classify_div').show();
}
}
......
......@@ -5,20 +5,20 @@ layui.use(['jquery','element', 'layer', 'form'], function(){
var form = layui.form;
//监听模板分类选择 并刷新二级分类数据
form.on('select(msg_tpl_cls)', function(data){
var sel_msg_tpl_cls = data.value;
form.on('select(msg_cls)', function(data){
var sel_edit_cls = data.value;
$.ajax({
url: "/msgapi/getSubTplCls",
dataType: 'json',
data: {
sel_msg_tpl_cls: sel_msg_tpl_cls
sel_edit_cls: sel_edit_cls
},
success: function (result) {
var optionstring = "";
$.each(result.data, function(i,item){
optionstring += "<option value=" + item.sub_cls_id + ">" + item.sub_cls_name + "</option>";
optionstring += "<option value=" + item.cls_id + ">" + item.name + "</option>";
});
$("#msg_tpl_sub_cls").html('<option value=""></option>' + optionstring);
$("#msg_sub_cls").html('<option value=""></option>' + optionstring);
form.render('select');
}
});
......@@ -142,8 +142,8 @@ function addTemplate()
tpl_id:$('#tpl-id').val(),
channels:getChosenMsgChannels(),
msg_type:$('#inner-tpl-type option:selected').val(),
cls_id:$('#msg_tpl_cls option:selected').val(),
sub_cls_id:$('#msg_tpl_sub_cls option:selected').val(),
// cls_id:$('#msg_cls option:selected').val(),
sub_cls_id:$('#msg_sub_cls option:selected').val(),
source_type:1,
creater:$('#creater').val(),
tpl_key:$('#msg-tpl-desc1').val(),
......
......@@ -53,20 +53,20 @@ layui.use(['laydate','form','table'], function(){
});
//监听模板分类选择 并刷新二级分类数据
form.on('select(msg_tpl_cls)', function(data){
var sel_msg_tpl_cls = data.value;
form.on('select(msg_cls)', function(data){
var sel_edit_cls = data.value;
$.ajax({
url: "/msgapi/getSubTplCls",
dataType: 'json',
data: {
sel_msg_tpl_cls: sel_msg_tpl_cls
sel_edit_cls: sel_edit_cls
},
success: function (result) {
var optionstring = "";
$.each(result.data, function(i,item){
optionstring += "<option value=" + item.sub_cls_id + ">" + item.sub_cls_name + "</option>";
optionstring += "<option value=" + item.cls_id + ">" + item.name + "</option>";
});
$("#msg_tpl_sub_cls").html('<option value=""></option>' + optionstring);
$("#msg_sub_cls").html('<option value=""></option>' + optionstring);
form.render('select');
}
});
......
......@@ -6,20 +6,20 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate'], fun
var table = layui.table;
//监听模板分类选择 并刷新二级分类数据
form.on('select(msg_tpl_cls)', function(data){
var sel_msg_tpl_cls = data.value;
form.on('select(msg_cls)', function(data){
var sel_edit_cls = data.value;
$.ajax({
url: "/msgapi/getSubTplCls",
dataType: 'json',
data: {
sel_msg_tpl_cls: sel_msg_tpl_cls
sel_edit_cls: sel_edit_cls
},
success: function (result) {
var optionstring = "";
$.each(result.data, function(i,item){
optionstring += "<option value=" + item.sub_cls_id + ">" + item.sub_cls_name + "</option>";
optionstring += "<option value=" + item.cls_id + ">" + item.name + "</option>";
});
$("#msg_tpl_sub_cls").html('<option value=""></option>' + optionstring);
$("#msg_sub_cls").html('<option value=""></option>' + optionstring);
form.render('select');
}
});
......
......@@ -2,9 +2,6 @@
label{
box-sizing:content-box;
}
.number-input{
width:60px;
}
.top-20{
margin-top: 30px;
}
......@@ -22,14 +19,6 @@
<div class="layui-form-item top-20" id="add_classify_div">
<label class="layui-form-label" >添加分类:</label>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="add_classify" id="add_classify" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item top-20" id="add_sub_classify_div">
<label class="layui-form-label" >添加子分类:</label>
<div class="layui-input-inline" style="width: 150px">
<select name="sel_add_classify" lay-filter="sel_add_classify" id="sel_add_classify" >
<option value="">请选择一级分类</option>
......@@ -42,36 +31,15 @@
</div>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="add_sub_classify" id="add_sub_classify" placeholder="请输入子分类名称" autocomplete="off" class="layui-input">
<input type="text" name="add_classify" id="add_classify" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item top-20" id="edit_classify_div" hidden>
<label class="layui-form-label" >编辑分类:</label>
<div class="layui-input-inline" style="width: 150px">
<select name="sel_edit_classify_1st" lay-filter="sel_edit_classify_1st" id="sel_edit_classify_1st" >
<option value="">请选择一级分类</option>
@if(!empty($info))
@foreach($info as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="edit_classify" id="edit_classify" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item top-20" id="edit_sub_classify_div" hidden>
<label class="layui-form-label" >编辑子分类:</label>
<div class="layui-input-inline" style="width: 150px">
<select name="sel_edit_classify_2nd" lay-filter="sel_edit_classify_2nd" id="sel_edit_classify_2nd" >
<select name="sel_edit_classify" lay-filter="sel_edit_classify" id="sel_edit_classify" >
<option value="">请选择一级分类</option>
@if(!empty($info))
@foreach($info as $k=>$v)
......@@ -88,7 +56,7 @@
</div>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="edit_sub_classify" id="edit_sub_classify" placeholder="请输入子分类名称" autocomplete="off" class="layui-input">
<input type="text" name="edit_classify" id="edit_classify" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
</div>
</div>
......
......@@ -117,10 +117,10 @@
<div class="layui-form-item" style="margin-top: 30px;">
<label class="layui-form-label title-width">消息模板分类:</label>
<div class="layui-input-inline" style="width: 200px;">
<select name="msg_tpl_cls" lay-filter="msg_tpl_cls" id="msg_tpl_cls">
<select name="msg_cls" lay-filter="msg_cls" id="msg_cls">
<option value="" selected="">请选择</option>
@foreach($msg_tpl_clses as $key=>$value)
<option value="{{$key}}" @if(!empty($info->cls_id) && $key==$info->cls_id) selected @endif>{{$value}}</option>
<option value="{{$key}}" @if(!empty($info->parent_id) && $key==$info->parent_id) selected @endif>{{$value}}</option>
@endforeach
</select>
</div>
......@@ -129,10 +129,10 @@
<div class="layui-form-item" style="margin-top: 30px;">
<label class="layui-form-label title-width">消息模板二级分类:</label>
<div class="layui-input-inline" style="width: 200px;">
<select name="msg_tpl_sub_cls" lay-filter="msg_tpl_sub_cls" id="msg_tpl_sub_cls">
<select name="msg_sub_cls" lay-filter="msg_sub_cls" id="msg_sub_cls">
<option value="" selected="">请选择</option>
@foreach($msg_tpl_sub_clses as $key=>$value)
<option value="{{$key}}" @if(!empty($info->sub_cls_id) && $key==$info->sub_cls_id) selected @endif>{{$value}}</option>
<option value="{{$key}}" @if(!empty($info->cls_id) && $key==$info->cls_id) selected @endif>{{$value}}</option>
@endforeach
</select>
</div>
......
......@@ -72,7 +72,7 @@
<label class="layui-form-label filter-label-left first-label">消息模板分类:</label>
<div class="layui-input-inline filter-select">
<select name="msg_tpl_cls" lay-filter="msg_tpl_cls" id="msg_tpl_cls">
<select name="msg_cls" lay-filter="msg_cls" id="msg_cls">
<option value="">请选择</option>
@foreach($clses as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
......@@ -82,7 +82,7 @@
<label class="layui-form-label filter-label-left first-label">消息模板二级分类:</label>
<div class="layui-input-inline filter-select">
<select name="msg_tpl_sub_cls" lay-filter="msg_tpl_sub_cls" id="msg_tpl_sub_cls">
<select name="msg_sub_cls" lay-filter="msg_sub_cls" id="msg_sub_cls">
<option value="">请选择</option>
</select>
</div>
......
......@@ -40,7 +40,7 @@
<label class="layui-form-label filter-label-left">消息模板分类:</label>
<div class="layui-input-inline filter-select">
<select name="msg_tpl_cls" lay-filter="msg_tpl_cls" id="msg_tpl_cls">
<select name="msg_cls" lay-filter="msg_cls" id="msg_cls">
<option value="">请选择</option>
@foreach($clses as $k=>$v)
<option value="{{$k}}">{{$v}}</option>
......@@ -50,7 +50,7 @@
<label class="layui-form-label filter-label-left">消息模板二级分类:</label>
<div class="layui-input-inline filter-select">
<select name="msg_tpl_sub_cls" lay-filter="msg_tpl_sub_cls" id="msg_tpl_sub_cls">
<select name="msg_sub_cls" lay-filter="msg_sub_cls" id="msg_sub_cls">
<option value="">请选择</option>
</select>
</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