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.
713 lines
25 KiB
713 lines
25 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;
|
|
|
|
class News extends Base
|
|
{
|
|
protected $table_name='news';
|
|
protected $controller_name='news';
|
|
protected $has_img=true;
|
|
protected $has_imgs=true;
|
|
protected $has_source=true;
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->assign('table_name',$this->table_name);
|
|
$this->assign('controller',$this->controller_name);
|
|
$this->assign('has_img',$this->has_img);
|
|
$this->assign('has_imgs',$this->has_imgs);
|
|
$this->assign('has_source',$this->has_source);
|
|
}
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function apply_del()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p=input('p');
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
|
|
$rst=Db::name('apply')->delete(input('n_id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function apply_alldel()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p = input('p');
|
|
$ids = input('n_id/a');
|
|
$n_cid=input('cid',0,'intval');
|
|
$n_kind=input('kind','','intval');
|
|
$jumpParam=['kind'=>$n_kind,'p' => $p,'cid'=>$n_cid,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",$jump);
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'id='.$ids;
|
|
}
|
|
$rst=Db::name('apply')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function apply_edit()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$jumpParam=['kind'=>$n_kind,'cid'=>$n_cid,'page'=>$page];
|
|
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
|
|
$n_id = input('id');
|
|
if (empty($n_id)) {
|
|
$this->error('参数错误', $jump);
|
|
}
|
|
$this->assign('n_cid', $n_cid);
|
|
$this->assign('n_kind', $n_kind);
|
|
$news_list = Db::name('apply')->find($n_id);
|
|
$poster=$news_list['cred_poster'];
|
|
if($poster){
|
|
$news_list['cred_poster']=explode(';', $poster);
|
|
}
|
|
|
|
|
|
$this->assign('list', $news_list);
|
|
return $this->fetch('apply/news_edit');
|
|
|
|
}
|
|
public function apply_list(){
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$page=input('page',1,'intval');
|
|
$postPage=input('post.page','','intval');
|
|
if($postPage)$page=$postPage;
|
|
$this->assign('page',$page);
|
|
$this->assign('n_kind',$n_kind);
|
|
$where=[];
|
|
if($n_cid)$where['cid']=$n_cid;
|
|
if($n_kind)$where['kind']=$n_kind;
|
|
$news=Db::name('apply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
|
|
$show = $news->render();
|
|
|
|
|
|
$this->assign('pageshow',$show);
|
|
$this->assign('news',$news);
|
|
$this->assign('n_cid',$n_cid);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('apply/ajax_news_list'.$n_cid);
|
|
}else{
|
|
return $this->fetch('apply/news_list'.$n_cid);
|
|
}
|
|
}
|
|
/**
|
|
* 导出名单
|
|
*/
|
|
public function export(){
|
|
$id=input('cid');
|
|
$kind=input('kind',1);
|
|
if(empty($kind))$this->error("请选择平台");
|
|
$map=['cid'=>$id,'kind'=>$kind];
|
|
$applys=Db::name('apply')->where($map)->select();
|
|
|
|
$expTitle="古建收藏俱乐部申请表(机构)";
|
|
if($id==2)$expTitle="古建收藏俱乐部申请表(个人)";
|
|
|
|
$expCellName=[];
|
|
if($id==1){
|
|
array_push($expCellName,['org_name','机构名称']);
|
|
array_push($expCellName,['org_code','机构信用代码']);
|
|
array_push($expCellName,['address','联系地址']);
|
|
array_push($expCellName,['username','法人代表人']);
|
|
array_push($expCellName,['cred_num','身份证号码']);
|
|
array_push($expCellName,['contact','联系人']);
|
|
array_push($expCellName,['mobile','联系电话']);
|
|
array_push($expCellName,['direction','古建收藏或意向投资方向']);
|
|
array_push($expCellName,['org_desc','机构简介']);
|
|
}
|
|
if($id==2){
|
|
array_push($expCellName,['username','姓名']);
|
|
array_push($expCellName,['cred_type','证件类型']);
|
|
array_push($expCellName,['cred_num','证件号码']);
|
|
array_push($expCellName,['address','联系地址']);
|
|
array_push($expCellName,['contact','联系人']);
|
|
array_push($expCellName,['mobile','联系电话']);
|
|
array_push($expCellName,['join_year','古建收藏/投资经验']);
|
|
array_push($expCellName,['infor','古建藏品介绍']);
|
|
array_push($expCellName,['experience','个人简介']);
|
|
}
|
|
array_push($expCellName,['create_time','报名时间','','date']);
|
|
foreach ($applys as &$row){
|
|
$ctype=$row['cred_type'];
|
|
if($ctype==1)$ctype="身份证";
|
|
if($ctype==2)$ctype="护照";
|
|
if($ctype==3)$ctype="军人证";
|
|
$row['cred_type']=$ctype;
|
|
}
|
|
$expTableData=$applys;
|
|
$res=exportExcel($expTitle,$expCellName,$expTableData);
|
|
}
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function buildapply_del()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p=input('p');
|
|
$jumpParam=['p' => $p,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
|
|
$rst=Db::name('buildapply')->delete(input('id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function buildapply_alldel()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p = input('p');
|
|
$ids = input('n_id/a');
|
|
$jumpParam=['p' => $p,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",$jump);
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'id='.$ids;
|
|
}
|
|
$rst=Db::name('buildapply')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function buildapply_edit()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$jumpParam=['page'=>$page];
|
|
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
|
|
$n_id = input('id');
|
|
if (empty($n_id)) {
|
|
$this->error('参数错误', $jump);
|
|
}
|
|
$news_list = Db::name('buildapply')->find($n_id);
|
|
$poster=$news_list['closepic'];
|
|
if($poster){
|
|
$news_list['closepic']=explode(';', $poster);
|
|
}
|
|
$style=$news_list['style'];
|
|
if($style){
|
|
$temp=['A'=>[],'B'=>[],'C'=>[],'D'=>[]];
|
|
try {
|
|
$style=json_decode($style,true);
|
|
} catch (Exception $e) {
|
|
$style=array();
|
|
}
|
|
if(!is_array($style))$style=[];
|
|
$temp=array_merge($temp,$style);
|
|
$news_list['style']=$temp;
|
|
}else{
|
|
$news_list['style']=['A'=>[],'B'=>[],'C'=>[],'D'=>[]];
|
|
}
|
|
$poster=$news_list['visionpic'];
|
|
if($poster){
|
|
$news_list['visionpic']=explode(';', $poster);
|
|
}
|
|
$poster=$news_list['allpic'];
|
|
if($poster){
|
|
$news_list['allpic']=explode(';', $poster);
|
|
}
|
|
$poster=$news_list['planepic'];
|
|
if($poster){
|
|
$news_list['planepic']=explode(';', $poster);
|
|
}
|
|
|
|
$service=$news_list['tgservice'];
|
|
if($service){
|
|
$news_list['tgservice']=explode(';', $service);
|
|
}else{
|
|
$news_list['tgservice']=[];
|
|
}
|
|
$service=$news_list['mgservice'];
|
|
if($service){
|
|
$news_list['mgservice']=explode(';', $service);
|
|
}else{
|
|
$news_list['mgservice']=[];
|
|
}
|
|
$service=$news_list['tfservice'];
|
|
if($service){
|
|
$news_list['tfservice']=explode(';', $service);
|
|
}else{
|
|
$news_list['tfservice']=[];
|
|
}
|
|
$service=$news_list['useservice'];
|
|
if($service){
|
|
$news_list['useservice']=explode(';', $service);
|
|
}else{
|
|
$news_list['useservice']=[];
|
|
}
|
|
$this->assign('list', $news_list);
|
|
return $this->fetch('apply/build_edit');
|
|
|
|
}
|
|
public function buildapply_list(){
|
|
$page=input('page',1,'intval');
|
|
$postPage=input('post.page','','intval');
|
|
if($postPage)$page=$postPage;
|
|
$this->assign('page',$page);
|
|
$where=[];
|
|
$news=Db::name('buildapply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
|
|
$show = $news->render();
|
|
|
|
$this->assign('pageshow',$show);
|
|
$this->assign('news',$news);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('apply/ajax_build_list');
|
|
}else{
|
|
return $this->fetch('apply/build_list');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function cultureapply_del()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p=input('p');
|
|
$jumpParam=['p' => $p,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
|
|
$rst=Db::name('cultureapply')->delete(input('id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function cultureapply_alldel()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p = input('p');
|
|
$ids = input('n_id/a');
|
|
$jumpParam=['p' => $p,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",$jump);
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'id='.$ids;
|
|
}
|
|
$rst=Db::name('cultureapply')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function cultureapply_edit()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$jumpParam=['page'=>$page];
|
|
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
|
|
$n_id = input('id');
|
|
if (empty($n_id)) {
|
|
$this->error('参数错误', $jump);
|
|
}
|
|
$news_list = Db::name('cultureapply')->find($n_id);
|
|
$legal=$news_list['legal'];
|
|
if($legal){
|
|
$news_list['legal']=json_decode($legal);
|
|
}
|
|
$org=$news_list['org'];
|
|
if($org){
|
|
$news_list['org']=json_decode($org);
|
|
}
|
|
$cont=$news_list['cont'];
|
|
if($cont){
|
|
$news_list['cont']=json_decode($cont);
|
|
}
|
|
|
|
$this->assign('list', $news_list);
|
|
return $this->fetch('apply/culture_edit');
|
|
|
|
}
|
|
public function cultureapply_list(){
|
|
$page=input('page',1,'intval');
|
|
$postPage=input('post.page','','intval');
|
|
if($postPage)$page=$postPage;
|
|
$this->assign('page',$page);
|
|
$where=[];
|
|
$news=Db::name('cultureapply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
|
|
$show = $news->render();
|
|
|
|
$this->assign('pageshow',$show);
|
|
$this->assign('news',$news);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('apply/ajax_culture_list');
|
|
}else{
|
|
return $this->fetch('apply/culture_list');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
public function news_list()
|
|
{
|
|
//栏目
|
|
$search_name=input('search_name','','trim');
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$page=input('page','','intval');
|
|
$postPage=input('post.page','','intval');
|
|
if($postPage)$page=$postPage;
|
|
$this->assign('page',$page);
|
|
$this->assign('n_kind',$n_kind);
|
|
$this->assign('search_name',$search_name);
|
|
$where=[];
|
|
if($n_cid)$where['n_cid']=$n_cid;
|
|
if($n_kind)$where['n_kind']=$n_kind;
|
|
if($search_name){
|
|
$where['n_title|n_content']=array('like',['%'.$search_name.'%','%'.$search_name,$search_name.'%',$search_name],'or');
|
|
}
|
|
$order=['n_order'=>'asc','n_time'=>'desc'];
|
|
if($this->table_name=='bsgg'||$this->table_name=='bsyw'){
|
|
$order=['n_top'=>'desc','n_order'=>'asc','n_time'=>'desc'];
|
|
}
|
|
$query=get_query();
|
|
if(isset($query)&&$page){
|
|
$query['page']=$page;
|
|
}
|
|
$news=Db::name($this->table_name)->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>$query]);
|
|
|
|
$show = $news->render();
|
|
$this->assign('pageshow',$show);
|
|
$this->assign('news',$news);
|
|
$this->assign('n_cid',$n_cid);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('news/ajax_news_list');
|
|
}else{
|
|
return $this->fetch('news/news_list');
|
|
}
|
|
}
|
|
/**
|
|
* 添加显示
|
|
*/
|
|
public function news_add()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$this->assign('n_kind',$n_kind);
|
|
if (!request()->isAjax()){
|
|
//栏目
|
|
$this->assign('n_cid',$n_cid);
|
|
$source=Db::name('source')->select();
|
|
$this->assign('source',$source);
|
|
|
|
$source=Db::name('finance')->field('c_id,c_name')->where(['c_status'=>1,'c_kind'=>4])->select();
|
|
$keys=array_column($source,'c_id');
|
|
$vals=array_column($source,'c_name');
|
|
$source=array_combine($keys, $vals);
|
|
$this->assign('flist',$source);
|
|
$this->assign('fjson',json_encode($source));
|
|
|
|
$this->assign('tablename',$this->table_name);
|
|
return $this->fetch('news/news_add');
|
|
}else{
|
|
//上传图片部分
|
|
$img_one='';
|
|
$picall_url='';
|
|
$file = request()->file('pic_one');
|
|
$files = request()->file('pic_all');
|
|
$jumpParam=['cid'=>$n_cid,'page'=>$page];
|
|
if($this->table_name!='bsgg'){
|
|
$jumpParam['kind']=$n_kind;
|
|
}
|
|
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
|
|
|
|
$n_time=input('n_time','');
|
|
if(empty($n_time))$n_time=time();
|
|
else $n_time=strtotime($n_time);
|
|
$ret=$this->dealFile($file,$files);
|
|
if(isset($ret['error'])){
|
|
$this->error($ret['error'],$jump);
|
|
}else{
|
|
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
|
|
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
|
|
}
|
|
$n_pids=isset($_POST['n_pids'])?$_POST['n_pids']:'';
|
|
$n_order=input('n_order','','intval');
|
|
$ncid=input('n_cid','','intval');
|
|
if($ncid)$n_cid=$ncid;
|
|
$sl_data=array(
|
|
'n_title'=>input('n_title'),
|
|
'n_cid'=>$n_cid,
|
|
'n_source'=>input('n_source',''),
|
|
'n_pics'=>$picall_url,//多图路径
|
|
'n_img'=>$img_one,//封面图片路径
|
|
'n_status'=>input('n_status',0),
|
|
'n_desc'=>input('n_desc',''),
|
|
'n_content'=>htmlspecialchars_decode(input('n_content')),
|
|
'n_uid'=>session('admin_auth.aid'),
|
|
'n_time'=>$n_time,
|
|
'n_order'=>$n_order,
|
|
);
|
|
if($n_pids)$sl_data['n_pids']=is_array($n_pids)?implode(';',$n_pids):'';
|
|
if($n_kind)$sl_data['n_kind']=$n_kind;
|
|
$n_top=input('n_top',0,'intval');
|
|
if($n_top!=='')$sl_data['n_top']=$n_top;
|
|
$rst=Db::name($this->table_name)->insert($sl_data);
|
|
$this->assign('tablename',$this->table_name);
|
|
if($rst){
|
|
if(empty($n_order)){
|
|
$lastId=Db::name($this->table_name)->getLastInsID();
|
|
Db::name($this->table_name)->where(['n_id'=>$lastId])->update(['n_order'=>$lastId]);
|
|
}
|
|
$this->success('添加成功',$jump);
|
|
}else{
|
|
$this->error('添加失败',$jump);
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function news_edit()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$this->assign('n_kind',$n_kind);
|
|
$jumpParam=['cid'=>$n_cid,'page'=>$page];
|
|
if($this->table_name!='bsgg'){
|
|
$jumpParam['kind']=$n_kind;
|
|
}
|
|
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
|
|
if (!request()->isAjax()) {
|
|
$n_id = input('n_id');
|
|
if (empty($n_id)) {
|
|
$this->error('参数错误', $jump);
|
|
}
|
|
$this->assign('n_cid', $n_cid);
|
|
|
|
$source=Db::name('finance')->field('c_id,c_name')->where(['c_status'=>1,'c_kind'=>4])->select();
|
|
$keys=array_column($source,'c_id');
|
|
$vals=array_column($source,'c_name');
|
|
$source=array_combine($keys, $vals);
|
|
$this->assign('flist',$source);
|
|
$this->assign('fjson',json_encode($source));
|
|
|
|
$news_list = Db::name($this->table_name)->find($n_id);
|
|
if(isset($news_list['n_pids'])){
|
|
$pids = array_filter(explode(";", $news_list['n_pids']));
|
|
$this->assign('pids',json_encode($pids));
|
|
}else{
|
|
$this->assign('pids',json_encode([]));
|
|
}
|
|
|
|
//多图字符串转换成数组
|
|
$pic_list = array_filter(explode(",", $news_list['n_pics']));
|
|
$this->assign('pic_list', $pic_list);
|
|
$source = Db::name('source')->select();//来源
|
|
$this->assign('source', $source);
|
|
$this->assign('news_list', $news_list);
|
|
$this->assign('tablename',$this->table_name);
|
|
return $this->fetch('news/news_edit');
|
|
}else{
|
|
$pic_oldlist=input('pic_oldlist');//老多图字符串
|
|
$img_one='';
|
|
$picall_url='';
|
|
$file = request()->file('pic_one');
|
|
$files = request()->file('pic_all');
|
|
//单图
|
|
$ret=$this->dealFile($file,$files);
|
|
if(isset($ret['error'])){
|
|
$this->error($ret['error'],$jump);
|
|
}else{
|
|
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
|
|
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
|
|
}
|
|
$n_pids=isset($_POST['n_pids'])?$_POST['n_pids']:'';
|
|
$sl_data=array(
|
|
'n_id'=>input('n_id'),
|
|
'n_title'=>input('n_title'),
|
|
'n_source'=>input('n_source',''),
|
|
'n_status'=>input('n_status',0),
|
|
'n_desc'=>input('n_desc',''),
|
|
'n_content'=>htmlspecialchars_decode(input('n_content')),
|
|
'n_order'=>input('n_order',50,'intval'),
|
|
);
|
|
if($n_pids){
|
|
$sl_data['n_pids']=is_array($n_pids)?implode(';',$n_pids):'';
|
|
}
|
|
$ncid=input('n_cid','','intval');
|
|
if($ncid)$sl_data['n_cid']=$ncid;
|
|
$n_time=input('n_time','');
|
|
if($n_time)$sl_data['n_time']=strtotime($n_time);
|
|
if($n_kind)$sl_data['n_kind']=$n_kind;
|
|
$n_top=input('n_top',0,'intval');
|
|
if($n_top!=='')$sl_data['n_top']=$n_top;
|
|
//图片字段处理
|
|
if(!empty($img_one)){
|
|
$sl_data['n_img']=$img_one;
|
|
}
|
|
$sl_data['n_pics']=$pic_oldlist.$picall_url;
|
|
$rst=Db::name($this->table_name)->update($sl_data);
|
|
$this->assign('tablename',$this->table_name);
|
|
if($rst!==false){
|
|
$this->success('修改成功',$jump);
|
|
}else{
|
|
$this->error('修改失败',$jump);
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 排序
|
|
*/
|
|
public function news_order()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$this->assign('n_kind',$n_kind);
|
|
$jumpParam=['cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
|
|
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
|
|
if (!request()->isAjax()){
|
|
$this->error('提交方式不正确',$jump);
|
|
}else{
|
|
foreach (input('post.') as $n_id => $n_order){
|
|
Db::name($this->table_name)->update(['n_id'=>$n_id,'n_order'=>$n_order]);
|
|
}
|
|
$this->success('排序更新成功',$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function news_del()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p=input('p');
|
|
$n_cid=input('cid','','intval');
|
|
$n_kind=input('kind','','intval');
|
|
$this->assign('n_kind',$n_kind);
|
|
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
|
|
$rst=Db::name($this->table_name)->delete(input('n_id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function news_alldel()
|
|
{
|
|
$page=input('page','','intval');
|
|
$this->assign('page',$page);
|
|
$p = input('p');
|
|
$ids = input('n_id/a');
|
|
$n_cid=input('cid',0,'intval');
|
|
$n_kind=input('kind',0,'intval');
|
|
$this->assign('n_kind',$n_kind);
|
|
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
|
|
|
|
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",$jump);
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'n_id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'n_id='.$ids;
|
|
}
|
|
$rst=Db::name($this->table_name)->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",$jump);
|
|
}else{
|
|
$this -> error("删除失败!",$jump);
|
|
}
|
|
}
|
|
/**
|
|
* 审核/取消审核
|
|
*/
|
|
public function news_state()
|
|
{
|
|
$id=input('x');
|
|
$status=Db::name($this->table_name)->where(array('n_id'=>$id))->value('n_status');
|
|
if($status==1){
|
|
$statedata = array('n_status'=>0);
|
|
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
|
|
$this->success('未审');
|
|
}else{
|
|
$statedata = array('n_status'=>1);
|
|
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
|
|
$this->success('已审');
|
|
}
|
|
}
|
|
}
|
|
|