postdata; return json_encode($str); } public function getListAction() { $data = m("repair_fault")->getall("1=1", "*"); $this->showreturn($data); } public function getTypeListAction() { $data = m("repair_type")->getall("1=1", "id, name, dept"); $this->showreturn($data); } public function addAction() { $arr = $this->postdata; if(empty($arr))return returnerror('not data'); $arr = json_decode($this->postdata, true); if (empty($arr['site']) || empty($arr['reporter']) || empty($arr['mobile']) || empty($arr['type']) || empty($arr['type_id']) ) { return returnerror('参数缺失'); } $ipAddr = $_SERVER['REMOTE_ADDR']; $where = " site='{$arr['site']}' and "; $where .= " reporter='{$arr['reporter']}' and "; $where .= " mobile='{$arr['mobile']}' and "; $where .= " ip_addr='{$ipAddr}' and "; $where .= " type_id='{$arr['type_id']}' "; $haveData = m("repair_fault")->getall($where); if (!empty($haveData)) { return returnerror('请勿重复添加'); } $arr['pic'] = implode(',', $arr['pic']); $arr['comid'] = 1; $arr['uid'] = 1; $arr['optid'] = 1; $arr['optname'] = "管理员"; $arr['optdt'] = date("Y-m-d H:i:s", time()); $arr['ip_addr']=$ipAddr; // 插入数据 m("repair_fault")->insert($arr); // 更新图片信息 m('file')->update(["mknum"=>"repair_fault", "optid"=>1, "optname"=>"管理员"], "id in ({$arr['pic']})"); $this->showreturn([],"success"); } }