Commit 76355e8a by 孙龙

up

parent 2d39b246
...@@ -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
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