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.
168 lines
4.7 KiB
168 lines
4.7 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2017/11/24
|
|
* Time: 14:04
|
|
*/
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
/**
|
|
* 市场数据后台管理页面
|
|
*/
|
|
class Scsj extends Base
|
|
{
|
|
protected $table_name='scsj';
|
|
protected $controller_name='scsj';
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->assign('table_name',$this->table_name);
|
|
$this->assign('controller',$this->controller_name);
|
|
}
|
|
/**
|
|
* 列表
|
|
*/
|
|
public function scsj_list()
|
|
{
|
|
//栏目
|
|
$scsj=Db::name($this->table_name)->order('n_order,n_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
$show = $scsj->render();
|
|
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
|
|
$this->assign('page',$show);
|
|
//市场分类
|
|
$hylb=Db::name('type')->where('type_type',49)->select();
|
|
$this->assign('hylb', $hylb);
|
|
$this->assign('scsj',$scsj);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('scsj/ajax_scsj_list');
|
|
}else{
|
|
return $this->fetch('scsj/scsj_list');
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* 添加
|
|
*/
|
|
public function scsj_add()
|
|
{
|
|
$auth_group = Db::name('auth_group')->where('status', '1')->select();
|
|
//市场分类
|
|
$hylb=Db::name('type')->where('type_type',49)->select();
|
|
$this->assign('hylb', $hylb);
|
|
$this->assign('auth_group', $auth_group);
|
|
return $this->fetch();
|
|
}
|
|
|
|
/**
|
|
* 添加操作
|
|
*/
|
|
public function scsj_runadd()
|
|
{
|
|
$sl_data=array(
|
|
'n_title'=>input('n_title'),
|
|
'n_company'=>input('n_company'),
|
|
'n_type'=>input('n_type'),
|
|
'n_status'=>input('n_status',0),
|
|
'n_content'=>input('n_content'),
|
|
'n_uid'=>session('admin_auth.aid'),
|
|
'n_time'=>time(),
|
|
'n_order'=>input('n_order',50,'intval'),
|
|
);
|
|
$rst=Db::name($this->table_name)->insert($sl_data);
|
|
if($rst){
|
|
$this->success('添加成功',url('admin/Scsj/scsj_list'));
|
|
}else{
|
|
$this->error('添加失败',url('admin/Scsj/scsj_list'));
|
|
}
|
|
}
|
|
/**
|
|
* 编辑
|
|
*/
|
|
public function scsj_edit()
|
|
{
|
|
$n_id = input('n_id');
|
|
if (empty($n_id)) {
|
|
$this->error('参数错误', url('admin/Scsj/scsj_list'));
|
|
}
|
|
$scsj_list = Db::name($this->table_name)->find($n_id);
|
|
//市场分类
|
|
$hylb=Db::name('type')->where('type_type',49)->select();
|
|
$this->assign('hylb', $hylb);
|
|
$this->assign('scsj_list', $scsj_list);
|
|
return $this->fetch('scsj/scsj_edit');
|
|
}
|
|
/**
|
|
* 编辑保存
|
|
*/
|
|
public function scsj_runedit()
|
|
{
|
|
$data=input('post.');
|
|
$rst=Db::name('scsj')->update($data);
|
|
if($rst){
|
|
$this->success('修改成功',url('admin/Scsj/scsj_list'));
|
|
}else{
|
|
$this->error('修改失败',url('admin/Scsj/scsj_list'));
|
|
}
|
|
}
|
|
/**
|
|
* 删除
|
|
*/
|
|
public function scsj_del()
|
|
{
|
|
$n_id=input('n_id');
|
|
if (empty($n_id)){
|
|
$this->error('ID不存在',url('admin/Scsj/scsj_list'));
|
|
}
|
|
$rst=Db::name('scsj')->delete($n_id);
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('admin/Scsj/scsj_list'));
|
|
}else{
|
|
$this->error('删除失败',url('admin/Scsj/scsj_list'));
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function scsj_alldel()
|
|
{
|
|
$p = input('p');
|
|
$ids = input('n_id/a');
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",url('admin/Scsj/scsj_list'));
|
|
}
|
|
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("删除成功",url('admin/Scsj/scsj_list'));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Scsj/scsj_list'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 审核/取消审核
|
|
*/
|
|
public function scsj_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('已审');
|
|
}
|
|
}
|
|
}
|