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.
244 lines
9.2 KiB
244 lines
9.2 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2018/3/27
|
|
* Time: 9:25
|
|
*/
|
|
|
|
namespace app\admin\controller;
|
|
use think\Db;
|
|
|
|
class Lcwhcyb extends Base
|
|
{
|
|
public $types=[
|
|
1=>[1=>'国有产权指定进场业务','文化和旅游产业专项债中介服务','文化产权登记托管平台','文化艺术资产托管','深圳市文化金融服务中心','区域股权中介服务','文化金融城市学院','','登记备案','托管转让','组织交易','交易见证'],
|
|
2=>[13=>'艺投资','艺术品资产管配','文化金融大讲堂','常态路演平台','上市公司艺术资产管理办公室','家族艺术资产管理办公室','深圳文化产权交易所俱乐部',],
|
|
];
|
|
/**
|
|
* 楼层文化产业列表
|
|
*/
|
|
public function whcyb_list()
|
|
{
|
|
|
|
//栏目
|
|
$whcyb_type='';
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('cid',$whcyb_cid);
|
|
$whcyb=Db::name('lc_whcyb')->where(['whcyb_cid'=>$whcyb_cid])->order('whcyb_sort desc,whcyb_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
$show = $whcyb->render();
|
|
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
|
|
$this->assign('page',$show);
|
|
$this->assign('whcyb',$whcyb);
|
|
$this->assign('whcyb_type',$whcyb_type);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('lc/ajax_lc_list');
|
|
}else{
|
|
return $this->fetch('lc/lc_list');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加显示
|
|
*/
|
|
public function whcyb_add()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('types',$this->types[$whcyb_cid]);
|
|
$this->assign('cid',$whcyb_cid);
|
|
$whcyb_type=input('whcyb_type');
|
|
if (!request()->isAjax()){
|
|
$this->assign('whcyb_type',$whcyb_type);
|
|
return $this->fetch('lc/lc_add');
|
|
}else{
|
|
$type=input('whcyb_type');
|
|
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type,'whcyb_cid'=>$whcyb_cid])->count();
|
|
if($count>=1){
|
|
$status=0;
|
|
}else{
|
|
$status=input('whcyb_status',0);
|
|
}
|
|
$name=$this->types[$whcyb_cid][$whcyb_type];
|
|
$sl_data=array(
|
|
'whcyb_name'=>$name,
|
|
'whcyb_sort'=>input('whcyb_sort'),
|
|
'whcyb_type'=>$type,
|
|
'whcyb_cid'=>$whcyb_cid,
|
|
'whcyb_status'=>$status,
|
|
'whcyb_time'=>input('whcyb_time','')?strtotime(input('whcyb_time','')):time(),
|
|
'whcyb_content'=>htmlspecialchars_decode(input('whcyb_content')),
|
|
'whcyb_uid'=>session('admin_auth.aid'),
|
|
);
|
|
$img_one=$this->_uploadOne();
|
|
//图片字段处理
|
|
if(!empty($img_one)){
|
|
$sl_data['whcyb_img']=$img_one;
|
|
}
|
|
$rst=Db::name('lc_whcyb')->insert($sl_data);
|
|
if($rst){
|
|
$this->success('新增成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}else{
|
|
$this->error('新增失败',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* \删除(单个)
|
|
*/
|
|
public function whcyb_del()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('cid',$whcyb_cid);
|
|
$type=input('whcyb_type');
|
|
$rst=Db::name('lc_whcyb')->delete(input('whcyb_id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function whcyb_alldel()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('cid',$whcyb_cid);
|
|
$type=input('whcyb_type');
|
|
$ids = input('whcyb_id/a');
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除的数据",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'whcyb_id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'whcyb_id='.$ids;
|
|
}
|
|
$rst=Db::name('lc_whcyb')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 状态修改
|
|
*/
|
|
public function whcyb_state()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('cid',$whcyb_cid);
|
|
$id=input('whcyb_id');
|
|
$status=Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->value('whcyb_status');
|
|
if($status==1){
|
|
$statedata = array('whcyb_status'=>0);
|
|
Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->setField($statedata);
|
|
$this->success('未审');
|
|
}else{
|
|
$type=input('whcyb_type');
|
|
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type])->count();
|
|
if($count<1){
|
|
$statedata = array('whcyb_status'=>1);
|
|
Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->setField($statedata);
|
|
$this->success('已审');
|
|
}else{
|
|
$this -> error("状态个数已达到!",url('admin/Lcwhcyb/whcyb_list',['cid'=>$whcyb_cid]));
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 上传单张图片
|
|
* @return string
|
|
*/
|
|
protected function _uploadOne(){
|
|
$validate = config('upload_validate');
|
|
$img_one='';
|
|
$file = request()->file('pic_one');
|
|
//单图
|
|
if ($file) {
|
|
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
|
|
if ($info) {
|
|
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
|
|
//写入数据库
|
|
$data['uptime'] = time();
|
|
$data['filesize'] = $info->getSize();
|
|
$data['path'] = $img_url;
|
|
Db::name('plug_files')->insert($data);
|
|
$img_one = $img_url;
|
|
} else {
|
|
$this->error($file->getError(), url('admin/Gpgl/gp_list'));
|
|
}
|
|
}
|
|
return $img_one;
|
|
}
|
|
/**
|
|
* 排序
|
|
*/
|
|
public function whcyb_order()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$jumpParam=['cid'=>$whcyb_cid];
|
|
$jump=url('admin/Lcwhcyb/whcyb_list',$jumpParam);
|
|
if (!request()->isAjax()){
|
|
$this->error('提交方式不正确',$jump);
|
|
}else{
|
|
foreach (input('post.') as $n_id => $n_order){
|
|
Db::name('lc_whcyb')->update(['whcyb_id'=>$n_id,'whcyb_sort'=>$n_order]);
|
|
}
|
|
$this->success('排序更新成功',$jump);
|
|
}
|
|
}
|
|
//修改
|
|
public function whcyb_edit()
|
|
{
|
|
$whcyb_cid=input('cid','');
|
|
$this->assign('cid',$whcyb_cid);
|
|
$this->assign('types',$this->types[$whcyb_cid]);
|
|
if(!request()->isAjax()) {
|
|
|
|
$whcyb_id= input('whcyb_id', 0, 'intval');
|
|
if (!$whcyb_id) $this->error('参数错误', url('admin/Lcwhcyb/whcyb_list',['cid'=>$whcyb_cid]));
|
|
$gp_list = Db::name('lc_whcyb')->where('whcyb_id', $whcyb_id)->find();
|
|
$this->assign('gp_list',$gp_list);
|
|
return $this->fetch('lc/lc_edit');
|
|
}else{
|
|
$type=input('whcyb_type');
|
|
$name=$this->types[$whcyb_cid][$type];
|
|
$content=input('whcyb_content','','htmlspecialchars_decode');
|
|
|
|
$status=input('whcyb_status',0);
|
|
|
|
$sl_data=array(
|
|
'whcyb_name'=>$name,
|
|
'whcyb_id'=>input('whcyb_id'),
|
|
'whcyb_sort'=>input('whcyb_sort'),
|
|
'whcyb_type'=>$type,
|
|
'whcyb_cid'=>$whcyb_cid,
|
|
'whcyb_status'=>$status,
|
|
'whcyb_time'=>input('whcyb_time','')?strtotime(input('whcyb_time','')):time(),
|
|
'whcyb_content'=>$content,
|
|
'whcyb_uid'=>session('admin_auth.aid'),
|
|
);
|
|
|
|
$img_one=$this->_uploadOne();
|
|
//图片字段处理
|
|
if(!empty($img_one)){
|
|
$sl_data['whcyb_img']=$img_one;
|
|
}
|
|
$rst=Db::name('lc_whcyb')->update($sl_data);
|
|
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type])->count();
|
|
if($count>1){
|
|
$rst=Db::name('lc_whcyb')->where(array('whcyb_id'=>input('whcyb_id')))->update(array('whcyb_status'=>0));
|
|
}
|
|
if($rst!==false){
|
|
$this->success('修改成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}else{
|
|
$this->error('修改失败',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|