Manage.php
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
namespace app\equipment\controller;
use app\common\controller\Frontend;
use think\Db;
class Manage extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->hardware = new \app\admin\model\reservoir\hkws\Hardware();
}
public function test()
{
return $this->view->fetch();
}
public function type()
{
return $this->view->fetch();
}
public function list()
{
if ($this->request->isPost()) {
$page = $this->request->param('page',1);
$limit = $this->request->param('limit',1);
$condtion = [];
$a = $this->request->param('a');
if ($a) {
$condtion['reservoirprovince.id'] = ['=',$a];
}
$b = $this->request->param('b');
if ($b) {
$condtion['reservoirstate.id'] = ['=',$b];
}
$c = $this->request->param('c');
if ($c) {
$condtion['reservoircounty.id'] = ['=',$c];
}
$d = $this->request->param('d');
if ($d) {
$condtion['reservoir_id'] = ['=',$d];
}
$e = $this->request->param('e');
if ($e) {
$condtion['type_child_name'] = ['=',$e];
}
$list = $this->hardware
->with(['reservoirprovince','reservoirstate','reservoircounty','reservoirlist'])
->where($condtion)
->page($page,$limit)
->select();
$total = $this->hardware
->with(['reservoirprovince','reservoirstate','reservoircounty','reservoirlist'])
->where($condtion)
->count();
return json(['code'=>1,'data'=>$list,'total'=>$total]);
}
$this->level();
return $this->view->fetch();
}
public function list2()
{
if ($this->request->isPost()) {
$page = $this->request->param('page',1);
$limit = $this->request->param('limit',1);
$condtion = [];
$a = $this->request->param('a');
if ($a) {
$condtion['reservoirprovince.id'] = ['=',$a];
}
$b = $this->request->param('b');
if ($b) {
$condtion['reservoirstate.id'] = ['=',$b];
}
$c = $this->request->param('c');
if ($c) {
$condtion['reservoircounty.id'] = ['=',$c];
}
$d = $this->request->param('d');
if ($d) {
$condtion['reservoir_id'] = ['=',$d];
}
$e = $this->request->param('e');
if ($e) {
$condtion['type_child_name'] = ['=',$e];
}
$list = $this->hardware
->with(['reservoirprovince','reservoirstate','reservoircounty','reservoirlist'])
->where($condtion)
->page($page,$limit)
->select();
$total = $this->hardware
->with(['reservoirprovince','reservoirstate','reservoircounty','reservoirlist'])
->where($condtion)
->count();
return json(['code'=>1,'data'=>$list,'total'=>$total]);
}
$this->level();
return $this->view->fetch();
}
public function add()
{
return $this->view->fetch();
}
private function level()
{
$province = Db::name('reservoir_province')->field('id,name')->select();
foreach ($province as $key=>$item) {
$state = Db::name('reservoir_state')->field('id,name')->where('province_id',$item['id'])->select();
if($state){
$province[$key]['son'] = $state;
foreach($state as $key2=>$item2){
$county = Db::name('reservoir_county')->field('id,name')->where('state_id',$item2['id'])->select();
if($county){
$province[$key]['son'][$key2]['son'] = $county;
foreach ($county as $key3=>$item3){
$shuiku = Db::name('reservoir_list')->field('id,name')->where('county_id',$item3['id'])->select();
if($shuiku){
$province[$key]['son'][$key2]['son'][$key3]['son'] = $shuiku;
}
}
}
}
}
}
$this->view->assign('level',$province);
}
}