table=D("craft_template_param"); } public function index(){ //搜索 $where=array(); //工艺名称 $template_id=I("template_id"); if($template_id){ $where['template_id'] = $template_id; } else{ $this->error('非法操作,无工艺选择'); } $listRows=C("display.admin_shownum");//每页显示多少条 $total=$this->table->where($where)->count(); $page = new \Think\Page($total, $listRows); $data=$this->table->where($where)->order("param_id")->limit($page->firstRow, $page->listRows)->select(); $listpage = $page->show(); $this->assign("listpage", $listpage); $this->data=$data; // $this->craft = D('flow_craft')->relation(true)->find($flow_craft_id); // $flow_id = $this->craft['flow']['flow_id']; // $used = false; // if(D('product')->where(array('flow_id'=>$flow_id))->find()){ // $used = true; // } // $this->used = $used; $this->template_name = D('craft_template')->find($template_id)['template_name']; $this->display(); } public function add(){ if(IS_POST){ $data=$this->table->create(); if (!$data){//验证 $this->error($this->table->getError()); } //数据添加 $result=$this->table->data_add(); if(!$result){ $this->error($this->table->getError()); } D("UserLog")->add("add",$this->table->getTableName(),$result); $this->success($data); } else{ $this->template_id = I('template_id'); $this->display(); } } // public function editor(){ if(IS_POST){ $data=$this->table->create(); if (!$data){//验证 $this->error($this->table->getError()); } $result=$this->table->data_save(); if(!$result){ $this->error($this->table->getError()); } D("UserLog")->add("update",$this->table->getTableName(),$result); $this->success($data); } else{ $param_id = I('param_id'); $data= $this->table->find($param_id); $this->data = $data; $this->display(); } } //删除 public function delete(){ $param_id=I('param_id'); $this->table->delete($param_id); D("UserLog")->add("delete",$this->table->getTableName(),$param_id); $this->success("操作成功"); } }