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

修改产品系列后台编辑

... ... @@ -14,6 +14,7 @@ use app\portal\model\SeriesModel;
use cmf\controller\AdminBaseController;
use think\Db;
use think\db\Query;
use app\portal\model\PortalPostModel;
class AdminSeriesController extends AdminBaseController
{
... ... @@ -83,9 +84,18 @@ class AdminSeriesController extends AdminBaseController
//编辑页面
public function edit(){
$id = $this->request->param('id');
$post = Db::name('advantage')
$post = Db::name('series')
->where(['id'=>$id])
->find();
$contentModel = new PortalPostModel();
$post['detail'] = $contentModel->getPostContentAttr($post['detail']);
$post['detail_en'] = $contentModel->getPostContentAttr($post['detail_en']);
//查询分类名称
$type = Db::name('type')->where(['id'=>$post['t_id']])->find();
if($type){
$post['children_name'] = $type['name'];
}
$this->assign('post',$post);
return $this->fetch();
}
... ...
... ... @@ -29,17 +29,24 @@
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminAdvantage/index')}">优势列表</a></li>
<li class="active"><a href="#">编辑优势</a></li>
<li><a href="{:url('AdminSeries/index')}">产品系列列表</a></li>
<li class="active"><a href="#">编辑产品</a></li>
</ul>
<form action="{:url('AdminAdvantage/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<form action="{:url('AdminSeries/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="150">标题<span class="form-required">*</span></th>
<th width="150">分类<span class="form-required">*</span></th>
<input type="hidden" name="id" value="{$post.id}">
<td>
<input class="form-control" type="text" style="width:400px;" required value="{$post.children_name}" placeholder="请选择分类" onclick="doSelectCategory();" id="js-categories-name-input" readonly/>
<input class="form-control" type="hidden" value="{$post.t_id}" name="t_id" id="js-categories-id-input"/>
</td>
</tr>
<tr>
<th>标题<span class="form-required">*</span></th>
<td>
<input type="hidden" name="id" required value="{$post.id}"/>
<input class="form-control" type="text" name="title" required placeholder="请输入标题" value="{$post.title}"/>
</td>
</tr>
... ... @@ -50,15 +57,44 @@
</td>
</tr>
<tr>
<th>简介<span class="form-required">*</span></th>
<th>电话咨询<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" name="hotline" required placeholder="请输入电话咨询" value="{$post.hotline}"/>
</td>
</tr>
<tr>
<th>详情<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce" required placeholder="请输入简介">{$post.introduce}</textarea>
<script type="text/plain" id="content" name="detail">{$post.detail}</script>
</td>
</tr>
<tr>
<th>简介(英文)<span class="form-required">*</span></th>
<th>详情(英文)<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce_en" required placeholder="请输入简介(英文)">{$post.introduce_en}</textarea>
<script type="text/plain" id="content_en" name="detail_en">{$post.detail_en}</script>
</td>
</tr>
</table>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>缩略图<span class="form-required">*</span></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="thumbnail" id="thumbnail" value="{$post.thumbnail|default=''}">
<a href="javascript:uploadOneImage('图片上传','#thumbnail');">
<if condition="empty($post.thumbnail)">
<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumbnail-preview" width="135" style="cursor: pointer"/>
<else/>
<img src="{:cmf_get_image_preview_url($post.thumbnail)}" id="thumbnail-preview" width="135" style="cursor: pointer"/>
</if>
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
</td>
</tr>
</table>
... ... @@ -89,11 +125,44 @@
} catch (err) {
}
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content_en');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
function doSelectCategory() {
openIframeLayer("{:url('AdminSeriesType/select')}", '请选择分类', {
area: ['700px', '400px'],
btn: ['确定', '取消'],
yes: function (index, layero) {
var iframeWin = window[layero.find('iframe')[0]['name']];
var selectedCategories = iframeWin.confirm();
var data = selectedCategories.selectedCategories[0];
if(data == undefined){
layer.msg('请选择分类');
return;
}
var id = data['id'];
var pid = data['pid'];
var name = data['name'];
if (pid == 0) {
layer.msg('请选择二级分类');
return;
}
$('#js-categories-id-input').val(id);
$('#js-categories-name-input').val(name);
layer.close(index); //如果设定了yes回调,需进行手工关闭
}
});
}
</script>
</body>
</html>
... ...