123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?PHP
- namespace app\admin\controller;
- use app\admin\controller\Base;
- use app\admin\model\ChartModel;
- use think\Db;
- class Chart extends Base
- {
- public function index()
- {
- if(request()->isAjax ()){
- $model=new ChartModel();
- $count=Db::name("chart")->count();
- $lists=$model->index();
- //halt($lists);
- return json(['code'=>220,'count'=>$count,'data'=>$lists]);
- }
- return $this->fetch("index");
- }
- public function add()
- {
- if(request()->isAjax()){
- $data=input("post.");
- $model=new ChartModel();
- $add=$model->add($data);
- return $add;
- }
- return $this->fetch("add");
- }
- public function edit()
- {
- if(request()->isPost()){
- $data=input("post.");
- //halt($data);
- $model=new ChartModel();
- $edit=$model->edit($data);
- return $edit;
- }
- $id=input("id");
- //echo $id;die;
- $data=Db::name("chart")->where("cid",$id)->find();
- return $this->fetch("edit",["data"=>$data]);
- }
- public function del()
- {
- $id=input("id");
- $del=Db::name("chart")->where("cid",$id)->delete();
- if($del){
- return json(["code"=>200,"msg"=>"删除成功"]);
- }else{
- return json(["code"=>200,"msg"=>"删除失败"]);
- }
- }
- }
|