DictionaryaController.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <?php
  2. /*
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/12
  6. * Time: 下午6:23
  7. **/
  8. namespace backend\controllers;
  9. //特色主题,价格区间,物业类型,建筑类别,楼盘标签,4=>装修品鉴
  10. use backend\base\CommonController;
  11. use backend\base\Help;
  12. use backend\server\UploadFile;
  13. use common\models\HousesPrice;
  14. use common\models\Characteristic;
  15. use common\models\CategoryLabel;
  16. use Yii;
  17. class DictionaryaController extends CommonController
  18. {
  19. //===============================价格区间================================
  20. /*
  21. * 区间价格显示页面
  22. * **/
  23. public function actionPrice()
  24. {
  25. return $this->render('price');
  26. }
  27. /*
  28. * 获取价格区间数据
  29. * **/
  30. public function actionPriceform()
  31. {
  32. $model = new HousesPrice();
  33. $rows = $model->getList(Yii::$app->request->post());
  34. if($rows != null)
  35. {
  36. foreach ($rows as &$val)
  37. {
  38. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  39. $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
  40. $val['state'] = Yii::$app->params['state'][$val['state']];
  41. }
  42. return Help::JsonData(0,'成功',$model->Total(),$rows);
  43. }
  44. }
  45. /*
  46. * 添加价格区间页面
  47. * **/
  48. public function actionPriceadd()
  49. {
  50. return $this->render('priceadd');
  51. }
  52. /*
  53. * 添加价格区间数据
  54. * **/
  55. public function actionPriceaddform()
  56. {
  57. $model = new HousesPrice();
  58. $model->load(Yii::$app->request->post('data'),'');
  59. if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
  60. return Help::JsonCode(Help::ERROR,'添加失败');
  61. }
  62. /*
  63. * 价格区间修改页面
  64. * **/
  65. public function actionPriceedit()
  66. {
  67. $model = new HousesPrice();
  68. $row = $model->FindById(Yii::$app->request->get('id'));
  69. if($row != null)
  70. {
  71. return $this->render('priceedit',['model'=>$row]);
  72. }
  73. }
  74. /*
  75. * 价格区间修改数据
  76. * **/
  77. public function actionPriceeditform()
  78. {
  79. $model = new HousesPrice();
  80. $model->load(Yii::$app->request->post('data'),'');
  81. if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
  82. $row = $model->FindById(Yii::$app->request->post('data')['id']);
  83. if($row != null)
  84. {
  85. $row->price = $model->price;
  86. $row->price_short = $model->price_short;
  87. $row->state = $model->state;
  88. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
  89. }
  90. return Help::JsonCode(Help::ERROR,'修改失败');
  91. }
  92. /*
  93. * 价格区间删除
  94. * **/
  95. public function actionPricedel()
  96. {
  97. $model = new HousesPrice();
  98. $row = $model->FindById(Yii::$app->request->post('id'));
  99. if($row != null)
  100. {
  101. $row->del = 2;
  102. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
  103. }
  104. return Help::JsonCode(Help::ERROR,'删除失败');
  105. }
  106. /*
  107. * 价格区间 排序
  108. * **/
  109. public function actionPricesort()
  110. {
  111. $model = new HousesPrice();
  112. $row = $model->FindById(Yii::$app->request->post('id'));
  113. if($row != null)
  114. {
  115. $row->sort = Yii::$app->request->post('sort');
  116. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
  117. }
  118. return Help::JsonCode(Help::ERROR,'删除失败');
  119. }
  120. //===============================特色主题================================
  121. /*
  122. * 特色主题显示页面
  123. * **/
  124. public function actionTheme()
  125. {
  126. return $this->render('theme');
  127. }
  128. /*
  129. * 获取特色主题数据
  130. * **/
  131. public function actionThemeform()
  132. {
  133. $model = new Characteristic();
  134. $rows = $model->getAllList(Yii::$app->request->post());
  135. if($rows != null)
  136. {
  137. foreach ($rows as &$val)
  138. {
  139. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  140. $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
  141. }
  142. return Help::JsonData(0,'成功',$model->Total(),$rows);
  143. }
  144. }
  145. /*
  146. * 特色主题添加页面
  147. * **/
  148. public function actionThemeadd()
  149. {
  150. return $this->render('themeadd');
  151. }
  152. /*
  153. * 特色主题添加数据
  154. * **/
  155. public function actionThemeaddform()
  156. {
  157. $model = new Characteristic();
  158. $model->scenario = 'add';
  159. $model->load(Yii::$app->request->post('data'),'');
  160. if($model->validate() && $model->save())
  161. {
  162. return Help::JsonCode(Help::SUCCESS,'添加成功');
  163. }
  164. return Help::JsonCode(Help::ERROR,'添加失败');
  165. }
  166. /*
  167. * 特色主题修改页面
  168. * **/
  169. public function actionThemeedit()
  170. {
  171. $model = new Characteristic();
  172. $row = $model->FindById(Yii::$app->request->get('id'));
  173. if($row != null)
  174. {
  175. return $this->render('themeedit',['model'=>$row]);
  176. }
  177. }
  178. public function actionThemeshow()
  179. {
  180. $input = Yii::$app->request->post();
  181. $model = new Characteristic();
  182. $row = $model->FindById($input['id']);
  183. if(!empty($row)){
  184. $row->is_show = $input['state'];
  185. if($row->save(false)){
  186. return Help::JsonCode(Help::SUCCESS, '修改成功');
  187. }
  188. return Help::JsonCode(Help::ERROR, '操作失败');
  189. }
  190. return Help::JsonCode(Help::ERROR, '操作失败');
  191. }
  192. /*
  193. * 特色主题修改数据
  194. * **/
  195. public function actionThemeeditform()
  196. {
  197. $model = new Characteristic();
  198. $model->load(Yii::$app->request->post('data'),'');
  199. if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
  200. $row = $model->FindById(Yii::$app->request->post('data')['id']);
  201. if($row != null)
  202. {
  203. $row->name = $model->name;
  204. if($row->update() == true)
  205. {
  206. return Help::JsonCode(Help::SUCCESS,'修改成功');
  207. }
  208. }
  209. return Help::JsonCode(Help::ERROR,'修改失败');
  210. }
  211. /*
  212. * 删除特色主题
  213. * **/
  214. public function actionThemedel()
  215. {
  216. $model = new Characteristic();
  217. $row = $model->FindById(Yii::$app->request->post('id'));
  218. if($row != null)
  219. {
  220. $row->del = 2;
  221. if($row->update() == true){
  222. return Help::JsonCode(Help::SUCCESS,'删除成功');
  223. }
  224. }
  225. return Help::JsonCode(Help::ERROR,'删除失败');
  226. }
  227. //===============================物业类型================================
  228. /*
  229. * 物业类型显示页面
  230. * **/
  231. public function actionLabel()
  232. {
  233. return $this->render('label');
  234. }
  235. /*
  236. * 获取物业类型数据页面
  237. * **/
  238. public function actionLabelform()
  239. {
  240. $model = new CategoryLabel();
  241. $model->type = 1;
  242. $rows = $model->getList(Yii::$app->request->post());
  243. if($rows != null)
  244. {
  245. foreach ($rows as &$val)
  246. {
  247. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  248. $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
  249. }
  250. return Help::JsonData(0,'成功',$model->Total(),$rows);
  251. }
  252. }
  253. /*
  254. * 添加物业类型页面
  255. * **/
  256. public function actionLabeladd()
  257. {
  258. return $this->render('labeladd',['type'=>1]);
  259. }
  260. /*
  261. * 添加物业类型数据
  262. * **/
  263. public function actionLabeladdform()
  264. {
  265. $model = $model = new CategoryLabel();
  266. $model->load(Yii::$app->request->post('data'),'');
  267. if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
  268. return Help::JsonCode(Help::ERROR,'添加失败');
  269. }
  270. /*
  271. * 物业类型修改页面
  272. * **/
  273. public function actionLabeledit()
  274. {
  275. $model = $model = new CategoryLabel();
  276. $row = $model->FindById(Yii::$app->request->get('id'));
  277. if($row != null)
  278. {
  279. return $this->render('labeledit',['model'=>$row]);
  280. }
  281. }
  282. /*
  283. * 修改物业类型数据
  284. * **/
  285. public function actionLabeleditform()
  286. {
  287. $model = $model = new CategoryLabel();
  288. $model->load(Yii::$app->request->post('data'),'');
  289. if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败',$model->errors);
  290. $row = $model->FindById(Yii::$app->request->post('data')['id']);
  291. if($row != null)
  292. {
  293. $row->name = $model->name;
  294. if($row->update(false) == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
  295. }
  296. return Help::JsonCode(Help::ERROR,'修改失败');
  297. }
  298. /*
  299. * 删除物业类型
  300. * **/
  301. public function actionLabeldel()
  302. {
  303. $model = $model = new CategoryLabel();
  304. $row = $model->FindById(Yii::$app->request->post('id'));
  305. if($row != null)
  306. {
  307. $row->del = 2;
  308. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
  309. }
  310. return Help::JsonCode(Help::ERROR,'删除失败');
  311. }
  312. //===============================建筑类别================================
  313. /*
  314. * 建筑类别显示页面
  315. * **/
  316. public function actionArchitecturetype()
  317. {
  318. return $this->render('architecturetype');
  319. }
  320. /*
  321. * 获取物业类型数据页面
  322. * **/
  323. public function actionArchitectureform()
  324. {
  325. $model = new CategoryLabel();
  326. $model->type = 2;
  327. $rows = $model->getList(Yii::$app->request->post());
  328. if($rows != null)
  329. {
  330. foreach ($rows as &$val)
  331. {
  332. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  333. $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
  334. }
  335. return Help::JsonData(0,'成功',$model->Total(),$rows);
  336. }
  337. }
  338. /*
  339. * 添加物业类型页面
  340. * **/
  341. public function actionArchitectureadd()
  342. {
  343. return $this->render('labeladd',['type'=>2]);
  344. }
  345. /*
  346. * 添加物业类型数据
  347. * **/
  348. public function actionArchitectureaddform()
  349. {
  350. $model = $model = new CategoryLabel();
  351. $model->load(Yii::$app->request->post('data'),'');
  352. if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
  353. return Help::JsonCode(Help::ERROR,'添加失败');
  354. }
  355. /*
  356. * 物业类型修改页面
  357. * **/
  358. public function actionArchitectureedit()
  359. {
  360. $model = $model = new CategoryLabel();
  361. $row = $model->FindById(Yii::$app->request->get('id'));
  362. if($row != null)
  363. {
  364. return $this->render('labeledit',['model'=>$row]);
  365. }
  366. }
  367. /*
  368. * 修改物业类型数据
  369. * **/
  370. public function actionArchitectureeditform()
  371. {
  372. $model = $model = new CategoryLabel();
  373. $model->load(Yii::$app->request->post('data'),'');
  374. if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
  375. $row = $model->FindById(Yii::$app->request->post('data')['id']);
  376. if($row != null)
  377. {
  378. $row->name = $model->name;
  379. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
  380. }
  381. return Help::JsonCode(Help::ERROR,'修改失败');
  382. }
  383. /*
  384. * 删除物业类型
  385. * **/
  386. public function actionArchitecturedel()
  387. {
  388. $model = $model = new CategoryLabel();
  389. $row = $model->FindById(Yii::$app->request->post('id'));
  390. if($row != null)
  391. {
  392. $row->del = 2;
  393. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
  394. }
  395. return Help::JsonCode(Help::ERROR,'删除失败');
  396. }
  397. //===============================楼盘标签================================
  398. /*
  399. * 建筑类别显示页面
  400. * **/
  401. public function actionHouselabel()
  402. {
  403. return $this->render('houselabel');
  404. }
  405. /*
  406. * 获取物业类型数据页面
  407. * **/
  408. public function actionHouselabelform()
  409. {
  410. $model = new CategoryLabel();
  411. $model->type = 3;
  412. $rows = $model->getList(Yii::$app->request->post());
  413. if($rows != null)
  414. {
  415. foreach ($rows as &$val)
  416. {
  417. $val['create_at'] = date('Y-m-d',$val['create_at']);
  418. $val['update_at'] = date('Y-m-d',$val['update_at']);
  419. }
  420. return Help::JsonData(0,'成功',$model->Total(),$rows);
  421. }
  422. }
  423. /*
  424. * 添加物业类型页面
  425. * **/
  426. public function actionHouselabeladd()
  427. {
  428. return $this->render('labeladd',['type'=>3]);
  429. }
  430. /*
  431. * 添加物业类型数据
  432. * **/
  433. public function actionHouselabeladdform()
  434. {
  435. $model = $model = new CategoryLabel();
  436. $model->load(Yii::$app->request->post('data'),'');
  437. if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
  438. return Help::JsonCode(Help::ERROR,'添加失败');
  439. }
  440. /*
  441. * 物业类型修改页面
  442. * **/
  443. public function actionHouselabeledit()
  444. {
  445. $model = $model = new CategoryLabel();
  446. $row = $model->FindById(Yii::$app->request->get('id'));
  447. if($row != null)
  448. {
  449. return $this->render('labeledit',['model'=>$row]);
  450. }
  451. }
  452. /*
  453. * 修改物业类型数据
  454. * **/
  455. public function actionHouselabeleditform()
  456. {
  457. $model = $model = new CategoryLabel();
  458. $model->load(Yii::$app->request->post('data'),'');
  459. if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
  460. $row = $model->FindById(Yii::$app->request->post('data')['id']);
  461. if($row != null)
  462. {
  463. $row->name = $model->name;
  464. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
  465. }
  466. return Help::JsonCode(Help::ERROR,'修改失败');
  467. }
  468. /*
  469. * 删除物业类型
  470. * **/
  471. public function actionHouselabeldel()
  472. {
  473. $model = $model = new CategoryLabel();
  474. $row = $model->FindById(Yii::$app->request->post('id'));
  475. if($row != null)
  476. {
  477. $row->del = 2;
  478. if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
  479. }
  480. return Help::JsonCode(Help::ERROR,'删除失败');
  481. }
  482. /*
  483. *装修品鉴 - 页面
  484. **/
  485. public function actionRenovation()
  486. {
  487. return $this->render('renovation');
  488. }
  489. /*
  490. *装修品鉴 - 数据
  491. **/
  492. public function actionRenovationform()
  493. {
  494. $model = new CategoryLabel();
  495. $model->type = 4;
  496. $rows = $model->getList(Yii::$app->request->post());
  497. if($rows != null)
  498. {
  499. foreach ($rows as &$val)
  500. {
  501. $val['create_at'] = date('Y-m-d',$val['create_at']);
  502. $val['update_at'] = date('Y-m-d',$val['update_at']);
  503. }
  504. return Help::JsonData(0,'成功',$model->Total(),$rows);
  505. }
  506. }
  507. /*
  508. *装修品鉴-添加页面
  509. **/
  510. public function actionRenovationadd()
  511. {
  512. return $this->render('renovationadd');
  513. }
  514. /*
  515. *
  516. **/
  517. public function actionRenovationedit()
  518. {
  519. $model = new CategoryLabel();
  520. $row = $model->FindById(Yii::$app->request->get('id'));
  521. if(!empty($row))
  522. {
  523. return $this->render('renovationedit',['model'=>$row]);
  524. }
  525. }
  526. /*
  527. *
  528. **/
  529. public function actionRenovationeditform()
  530. {
  531. $model = new CategoryLabel();
  532. $row = $model->FindById(Yii::$app->request->post('id'));
  533. if(!empty($row))
  534. {
  535. if(!empty($_FILES['img']))
  536. {
  537. $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pj']);
  538. if(is_string($img))
  539. {
  540. UploadFile::delImg(Yii::$app->params['img_url']['pj'],$row->img);
  541. $row->img = $img;
  542. }
  543. }
  544. if(!empty($_FILES['img1']))
  545. {
  546. $img = UploadFile::InstanceImgName('img1',Yii::$app->params['img_url']['pj']);
  547. if(is_string($img))
  548. {
  549. UploadFile::delImg(Yii::$app->params['img_url']['pj'],$row->img1);
  550. $row->img1 = $img;
  551. }
  552. }
  553. $row->name = Yii::$app->request->post('name');
  554. $row->sort = Yii::$app->request->post('sort');
  555. if($row->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  556. }
  557. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  558. }
  559. /*
  560. *装修品鉴 - 添加数据
  561. ***/
  562. public function actionRenovationaddform()
  563. {
  564. $model = $model = new CategoryLabel();
  565. $model->load(Yii::$app->request->post(),'');
  566. if($model->validate()){
  567. $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pj']);
  568. if(is_string($img))
  569. {
  570. $model->img = $img;
  571. }
  572. $img1 = UploadFile::InstanceImgName('img1',Yii::$app->params['img_url']['pj']);
  573. if(is_string($img1))
  574. {
  575. $model->img1 = $img1;
  576. }
  577. if($model->save(false)){
  578. return Help::JsonCode(Help::SUCCESS,'添加成功');
  579. }
  580. }
  581. return Help::JsonCode(Help::ERROR,'添加失败');
  582. }
  583. }