You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
4.8 KiB
135 lines
4.8 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
use think\Request;
|
|
use app\admin\model\Asklog;
|
|
|
|
class Ask extends Base{
|
|
protected $table='asklog';
|
|
/**
|
|
* 首页数据展示
|
|
* @return mixed|string
|
|
*/
|
|
public function index(Request $request){
|
|
$search_name=input('search_name','');
|
|
$this->assign('search_name',$search_name);
|
|
$kind=$request->param('kind');
|
|
$page=$request->param('page');
|
|
$this->assign('kind',$kind);
|
|
|
|
$db=Db::name($this->table)->alias("a")->field("a.*,m.member_list_username as name")->join(config('database.prefix').'member_list m','a.uid =m.member_list_id')->where('kind',$kind);
|
|
if($search_name){
|
|
$db->where('name|code','like','%'.$search_name.'%');
|
|
}
|
|
$gp_list=$db->order('create_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
|
|
$show = $gp_list->render();
|
|
$this->assign('page',$page);
|
|
$this->assign('pageshow',$show);
|
|
$this->assign('showlist',$gp_list);
|
|
|
|
if(request()->isAjax()){
|
|
return $this->fetch('ajax_list');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
public function content(Request $request){
|
|
|
|
$kind=input('kind');
|
|
$page=input('page');
|
|
$this->assign('page',$page);
|
|
$this->assign('kind',$kind);
|
|
$id = input('id', 0, 'intval');
|
|
|
|
if (!$id) $this->error('参数错误', url('Ask/index',array('kind'=>$kind)));
|
|
$gp_list = Db::name($this->table)->alias("a")->field("a.*,m.member_list_username as name")->join(config('database.prefix').'member_list m','a.uid =m.member_list_id')->where('id', $id)->find();
|
|
|
|
$content =unserialize($gp_list['content']);
|
|
$this->assign('content', $content);
|
|
|
|
$this->assign('list', $gp_list);
|
|
return $this->fetch();
|
|
}
|
|
public function edit(Request $request)
|
|
{
|
|
$kind=input('kind');
|
|
$page=input('page');
|
|
$this->assign('page',$page);
|
|
$this->assign('kind',$kind);
|
|
if(!request()->isAjax()) {
|
|
$id = input('id', 0, 'intval');
|
|
$this->assign('id', $id);
|
|
$tpl='edit';
|
|
return $this->fetch($tpl);
|
|
}else{
|
|
$jump=url('Ask/index',array('kind'=>$kind,'page'=>$page));
|
|
|
|
$sl_data=[];
|
|
$id = input('id', 0, 'intval');
|
|
$replay=input('replay');
|
|
$gp_list = Db::name($this->table)->where('id', $id)->find();
|
|
$content =unserialize($gp_list['content']);
|
|
array_push($content,['ques'=>'','ans'=>$replay,'type'=>1,'time'=>time()]);
|
|
|
|
$sl_data['id']=$id;
|
|
$sl_data['flag']=2;
|
|
$sl_data['update_time']=time();
|
|
$sl_data['content']=serialize($content);
|
|
$item=new Asklog();
|
|
$rst=$item->allowField(true)->update($sl_data);
|
|
if($rst!==false){
|
|
$this->success('回复成功',$jump);
|
|
}else{
|
|
$this->error('回复失败',$jump);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 非文化资产挂牌删除(单个)
|
|
*/
|
|
public function del(){
|
|
$p=input('p');
|
|
$kind=input('kind');
|
|
$this->assign('kind',$kind);
|
|
$rst=Db::name($this->table)->delete(input('id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('Ask/index',array('p' => $p,'kind'=>$kind)));
|
|
}else{
|
|
$this -> error("删除失败!",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
|
|
}
|
|
}
|
|
/**
|
|
* 非文化资产删除挂牌(全选)
|
|
*/
|
|
public function alldel(){
|
|
$p = input('p');
|
|
$kind=input('kind');
|
|
$this->assign('kind',$kind);
|
|
$ids = input('id/a');
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除的数据",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'id='.$ids;
|
|
}
|
|
$rst=Db::name($this->table)->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
|
|
}else{
|
|
$this -> error("删除失败!",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
|
|
}
|
|
}
|
|
|
|
}
|