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

后台设备模块开发

@@ -146,7 +146,7 @@ class AdminLightOrderController extends AdminBaseController @@ -146,7 +146,7 @@ class AdminLightOrderController extends AdminBaseController
146 $this->assign('temple', $temple); 146 $this->assign('temple', $temple);
147 $area = Db::name('temple_area')->where('temple_id', $data['temple_id'])->select(); 147 $area = Db::name('temple_area')->where('temple_id', $data['temple_id'])->select();
148 $this->assign('area', $area); 148 $this->assign('area', $area);
149 - $location=json_decode($this->getLocation($id=$data['area_id'],$locationId=$data['id']),true); 149 + $location=json_decode($this->getLocation($id=$data['area_id']),true);
150 150
151 $this->assign('location', $location); 151 $this->assign('location', $location);
152 $this->assign('list', $data); 152 $this->assign('list', $data);
@@ -194,4 +194,31 @@ class AdminLightOrderController extends AdminBaseController @@ -194,4 +194,31 @@ class AdminLightOrderController extends AdminBaseController
194 $this->success('删除成功'); 194 $this->success('删除成功');
195 } 195 }
196 196
  197 + //获取区域下所有位置
  198 + public function getLocation($id="")
  199 + {
  200 + if (empty($id)) {
  201 + $id = $this->request->param('id');
  202 + }
  203 + $data = Db::name('temple_area')->where('id', $id)->find();
  204 + $arr = [];
  205 + for ($r = 1; $r <= $data['rows']; $r++) {
  206 + for ($c = 1; $c <= $data['columns']; $c++) {
  207 + array_push($arr, [$r,$c]);
  208 + }
  209 + }
  210 + $is_set = Db::name('light_order')
  211 + ->alias('lo')
  212 + ->join('light l','lo.light_id=l.id')
  213 + ->where('l.area_id', $id)->field('l.row,l.column')->select()->toArray();
  214 + foreach ($arr as $k=>$v){
  215 + foreach ($is_set as $k1=>$v1){
  216 + if (array_values($v)==array_values($v1)){
  217 + unset($arr[$k]);
  218 +// $arr = array_values($arr);
  219 + }
  220 + }
  221 + }
  222 + return json_encode($arr);
  223 + }
197 } 224 }