作者 jinglong
1 个管道 的构建 通过 耗费 2 秒

修改产品系列后台编辑

@@ -14,6 +14,7 @@ use app\portal\model\SeriesModel; @@ -14,6 +14,7 @@ use app\portal\model\SeriesModel;
14 use cmf\controller\AdminBaseController; 14 use cmf\controller\AdminBaseController;
15 use think\Db; 15 use think\Db;
16 use think\db\Query; 16 use think\db\Query;
  17 +use app\portal\model\PortalPostModel;
17 18
18 class AdminSeriesController extends AdminBaseController 19 class AdminSeriesController extends AdminBaseController
19 { 20 {
@@ -83,9 +84,18 @@ class AdminSeriesController extends AdminBaseController @@ -83,9 +84,18 @@ class AdminSeriesController extends AdminBaseController
83 //编辑页面 84 //编辑页面
84 public function edit(){ 85 public function edit(){
85 $id = $this->request->param('id'); 86 $id = $this->request->param('id');
86 - $post = Db::name('advantage') 87 + $post = Db::name('series')
87 ->where(['id'=>$id]) 88 ->where(['id'=>$id])
88 ->find(); 89 ->find();
  90 + $contentModel = new PortalPostModel();
  91 + $post['detail'] = $contentModel->getPostContentAttr($post['detail']);
  92 + $post['detail_en'] = $contentModel->getPostContentAttr($post['detail_en']);
  93 +
  94 + //查询分类名称
  95 + $type = Db::name('type')->where(['id'=>$post['t_id']])->find();
  96 + if($type){
  97 + $post['children_name'] = $type['name'];
  98 + }
89 $this->assign('post',$post); 99 $this->assign('post',$post);
90 return $this->fetch(); 100 return $this->fetch();
91 } 101 }
@@ -29,17 +29,24 @@ @@ -29,17 +29,24 @@
29 <body> 29 <body>
30 <div class="wrap js-check-wrap"> 30 <div class="wrap js-check-wrap">
31 <ul class="nav nav-tabs"> 31 <ul class="nav nav-tabs">
32 - <li><a href="{:url('AdminAdvantage/index')}">优势列表</a></li>  
33 - <li class="active"><a href="#">编辑优势</a></li> 32 + <li><a href="{:url('AdminSeries/index')}">产品系列列表</a></li>
  33 + <li class="active"><a href="#">编辑产品</a></li>
34 </ul> 34 </ul>
35 - <form action="{:url('AdminAdvantage/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20"> 35 + <form action="{:url('AdminSeries/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
36 <div class="row"> 36 <div class="row">
37 <div class="col-md-9"> 37 <div class="col-md-9">
38 <table class="table table-bordered"> 38 <table class="table table-bordered">
39 <tr> 39 <tr>
40 - <th width="150">标题<span class="form-required">*</span></th> 40 + <th width="150">分类<span class="form-required">*</span></th>
  41 + <input type="hidden" name="id" value="{$post.id}">
  42 + <td>
  43 + <input class="form-control" type="text" style="width:400px;" required value="{$post.children_name}" placeholder="请选择分类" onclick="doSelectCategory();" id="js-categories-name-input" readonly/>
  44 + <input class="form-control" type="hidden" value="{$post.t_id}" name="t_id" id="js-categories-id-input"/>
  45 + </td>
  46 + </tr>
  47 + <tr>
  48 + <th>标题<span class="form-required">*</span></th>
41 <td> 49 <td>
42 - <input type="hidden" name="id" required value="{$post.id}"/>  
43 <input class="form-control" type="text" name="title" required placeholder="请输入标题" value="{$post.title}"/> 50 <input class="form-control" type="text" name="title" required placeholder="请输入标题" value="{$post.title}"/>
44 </td> 51 </td>
45 </tr> 52 </tr>
@@ -50,15 +57,44 @@ @@ -50,15 +57,44 @@
50 </td> 57 </td>
51 </tr> 58 </tr>
52 <tr> 59 <tr>
53 - <th>简介<span class="form-required">*</span></th> 60 + <th>电话咨询<span class="form-required">*</span></th>
  61 + <td>
  62 + <input class="form-control" type="text" name="hotline" required placeholder="请输入电话咨询" value="{$post.hotline}"/>
  63 + </td>
  64 + </tr>
  65 + <tr>
  66 + <th>详情<span class="form-required">*</span></th>
54 <td> 67 <td>
55 - <textarea class="form-control" rows="3" name="introduce" required placeholder="请输入简介">{$post.introduce}</textarea> 68 + <script type="text/plain" id="content" name="detail">{$post.detail}</script>
56 </td> 69 </td>
57 </tr> 70 </tr>
58 <tr> 71 <tr>
59 - <th>简介(英文)<span class="form-required">*</span></th> 72 + <th>详情(英文)<span class="form-required">*</span></th>
60 <td> 73 <td>
61 - <textarea class="form-control" rows="3" name="introduce_en" required placeholder="请输入简介(英文)">{$post.introduce_en}</textarea> 74 + <script type="text/plain" id="content_en" name="detail_en">{$post.detail_en}</script>
  75 + </td>
  76 + </tr>
  77 + </table>
  78 + </div>
  79 +
  80 + <div class="col-md-3">
  81 + <table class="table table-bordered">
  82 + <tr>
  83 + <th>缩略图<span class="form-required">*</span></th>
  84 + </tr>
  85 + <tr>
  86 + <td>
  87 + <div style="text-align: center;">
  88 + <input type="hidden" name="thumbnail" id="thumbnail" value="{$post.thumbnail|default=''}">
  89 + <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
  90 + <if condition="empty($post.thumbnail)">
  91 + <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumbnail-preview" width="135" style="cursor: pointer"/>
  92 + <else/>
  93 + <img src="{:cmf_get_image_preview_url($post.thumbnail)}" id="thumbnail-preview" width="135" style="cursor: pointer"/>
  94 + </if>
  95 + </a>
  96 + <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
  97 + </div>
62 </td> 98 </td>
63 </tr> 99 </tr>
64 </table> 100 </table>
@@ -89,11 +125,44 @@ @@ -89,11 +125,44 @@
89 } catch (err) { 125 } catch (err) {
90 } 126 }
91 127
  128 + editorcontent = new baidu.editor.ui.Editor();
  129 + editorcontent.render('content_en');
  130 + try {
  131 + editorcontent.sync();
  132 + } catch (err) {
  133 + }
  134 +
92 $('.btn-cancel-thumbnail').click(function () { 135 $('.btn-cancel-thumbnail').click(function () {
93 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png'); 136 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
94 $('#thumbnail').val(''); 137 $('#thumbnail').val('');
95 }); 138 });
96 }); 139 });
  140 +
  141 + function doSelectCategory() {
  142 + openIframeLayer("{:url('AdminSeriesType/select')}", '请选择分类', {
  143 + area: ['700px', '400px'],
  144 + btn: ['确定', '取消'],
  145 + yes: function (index, layero) {
  146 + var iframeWin = window[layero.find('iframe')[0]['name']];
  147 + var selectedCategories = iframeWin.confirm();
  148 + var data = selectedCategories.selectedCategories[0];
  149 + if(data == undefined){
  150 + layer.msg('请选择分类');
  151 + return;
  152 + }
  153 + var id = data['id'];
  154 + var pid = data['pid'];
  155 + var name = data['name'];
  156 + if (pid == 0) {
  157 + layer.msg('请选择二级分类');
  158 + return;
  159 + }
  160 + $('#js-categories-id-input').val(id);
  161 + $('#js-categories-name-input').val(name);
  162 + layer.close(index); //如果设定了yes回调,需进行手工关闭
  163 + }
  164 + });
  165 + }
97 </script> 166 </script>
98 </body> 167 </body>
99 </html> 168 </html>