作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

后台设备模块开发

... ... @@ -146,7 +146,7 @@ class AdminLightOrderController extends AdminBaseController
$this->assign('temple', $temple);
$area = Db::name('temple_area')->where('temple_id', $data['temple_id'])->select();
$this->assign('area', $area);
$location=json_decode($this->getLocation($id=$data['area_id'],$locationId=$data['id']),true);
$location=json_decode($this->getLocation($id=$data['area_id']),true);
$this->assign('location', $location);
$this->assign('list', $data);
... ... @@ -194,4 +194,31 @@ class AdminLightOrderController extends AdminBaseController
$this->success('删除成功');
}
//获取区域下所有位置
public function getLocation($id="")
{
if (empty($id)) {
$id = $this->request->param('id');
}
$data = Db::name('temple_area')->where('id', $id)->find();
$arr = [];
for ($r = 1; $r <= $data['rows']; $r++) {
for ($c = 1; $c <= $data['columns']; $c++) {
array_push($arr, [$r,$c]);
}
}
$is_set = Db::name('light_order')
->alias('lo')
->join('light l','lo.light_id=l.id')
->where('l.area_id', $id)->field('l.row,l.column')->select()->toArray();
foreach ($arr as $k=>$v){
foreach ($is_set as $k1=>$v1){
if (array_values($v)==array_values($v1)){
unset($arr[$k]);
// $arr = array_values($arr);
}
}
}
return json_encode($arr);
}
}
... ...