作者 董瑞恩
1 个管道 的构建 通过 耗费 1 秒

cost

... ... @@ -12,6 +12,7 @@ namespace app\portal\controller;
use app\portal\model\EquipmentModel;
use cmf\controller\AdminBaseController;
use QRcode;
use think\Db;
/**
* Class AdminEquipmentController
... ... @@ -41,7 +42,14 @@ class AdminEquipmentController extends AdminBaseController{
}
public function addPost(){
$data=$this->request->post();
$Equipment=new EquipmentModel();
$res=$Equipment->save($data);
if ($res){
$this->apiResponse(200,'保存成功');
}else{
$this->apiResponse(301,'error');
}
}
//批量导入设备信息
... ...
... ... @@ -122,8 +122,27 @@
//do something
var iframeWin = window[layero.find('iframe')[0]['name']];
var data = iframeWin.confirm();
$.ajax({
url:"{:url('AdminEquipment/addPost')}",
type:"POST",
data:{
serial_number:data.serial_number,
mac_address:data.mac_address,
name:data.name,
hospital:data.hospital,
note:data.note,
create_time:data.create_time
},
dataType:"JSON",
success:function (data) {
if (data.code===200){
alert('添加成功');
}
},
error:function () {
alert('接口异常')
}
});
console.log(data);
... ...
... ... @@ -105,4 +105,15 @@ class AdminBaseController extends BaseController
}
}
public function apiResponse($status = '', $msg = '',$data = array()){
header('Access-Control-Allow-Origin: *');
header('Content-Type:application/json; charset=utf-8');
$result = array(
'code'=>$status,
'msg'=>$msg,
'data'=>$data,
);
die(json_encode($result,JSON_UNESCAPED_UNICODE));
}
}
\ No newline at end of file
... ...