Commit ae036501 by 肖康
parents 0aa203fe 608e8d11
...@@ -8,6 +8,7 @@ use DB; ...@@ -8,6 +8,7 @@ use DB;
use App\Model\TemplateListModel; use App\Model\TemplateListModel;
use App\Model\SaleOrderListsModel; use App\Model\SaleOrderListsModel;
use App\Model\TmplRelationsModel; use App\Model\TmplRelationsModel;
use App\Model\TemplateExtendModel;
Class AjaxController extends Controller Class AjaxController extends Controller
{ {
...@@ -159,4 +160,64 @@ Class AjaxController extends Controller ...@@ -159,4 +160,64 @@ Class AjaxController extends Controller
} }
} }
/*
* 添加模板
*/
public function add_template($request){
$template_name = $request->input("designName",'');
$html = $request->input("html",'');
$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,"模板标签是空!");
}
$attribute["lableBg"] = $lableBg;
$attribute["lableBorder"] = $lableBorder;
$attribute["lableSize"] = $lableSize;
$data['template_name'] = $template_name;
$data['html'] = $html;
$data['attribute'] = $attribute;
try{
DB::Connection("label")->transaction(function () use($data,$request) {
//创建模板
$templateList = TemplateListModel::create([
"template_name"=>$data['$template_name'],
"create_userid"=>$request->user->userId,
"create_username"=>$request->user->name,
"create_time"=>time(),
"update_time"=>time(),
]);
if(!$templateList){
throw new \Exception("添加模板失败",-1);
}
//创建模板扩展信息 属性
$templateExtend = TemplateExtendModel::create([
"template_id"=>$templateList->id,
"html"=>$data['html'],
"attribute"=>json_encode($data['attribute']),
]);
if(!$templateExtend){
throw new \Exception("添加模板失败",-1);
}
});
}catch(\Exception $e){
return $this->ajaxReturn(-1,"添加模板失败");
}
}
} }
\ No newline at end of file
...@@ -84,7 +84,6 @@ class WebController extends Controller ...@@ -84,7 +84,6 @@ class WebController extends Controller
public function design($request,$info){ public function design($request,$info){
$info['title'] = '标签设计'; $info['title'] = '标签设计';
return view('web', $info); return view('web', $info);
} }
......
<?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
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<script type="text/html" id="action"> <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-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" lay-event="show">预览</a>
<a class="btn btn-xs btn-outline btn-success" href="/web/editLabel?t_id=@{{ d.id }}" target="_blank">编辑</a> <a class="btn btn-xs btn-outline btn-success" href="/web/design?t_id=@{{ d.id }}" target="_blank">编辑</a>
@{{# if (d.status == -1) { }} @{{# if (d.status == -1) { }}
<a class="btn btn-xs btn-outline layui-btn-primary" lay-event="enable">启用</a> <a class="btn btn-xs btn-outline layui-btn-primary" lay-event="enable">启用</a>
@{{# }else{ }} @{{# }else{ }}
......
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