WasteConfig.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\model\Config;
  4. use app\common\model\User;
  5. use think\App;
  6. use think\Db;
  7. class WasteConfig extends Auth {
  8. public function index() {
  9. if (request()->isAjax()) {
  10. $data = request()->post();
  11. $model = (new Config());
  12. $res = $model->saveData($data);
  13. if ($res) {
  14. $this->success('保存成功', url('index'));
  15. }
  16. $this->error($model->getError());
  17. }
  18. else {
  19. $waste_status = db('config')
  20. ->where('name', 'waste_status')
  21. ->value('value');
  22. $waste_time = db('config')
  23. ->where('name', 'waste_time')
  24. ->value('value');
  25. $waste_user = db('config')
  26. ->where('name', 'waste_user')
  27. ->value('value');
  28. $waste_user = $waste_user ? explode(',', $waste_user) : [];
  29. $this->assign('user', (new User())->getWasteWorkerList());
  30. $this->assign('waste_status', $waste_status);
  31. $this->assign('waste_time', $waste_time);
  32. $this->assign('waste_user', $waste_user);
  33. return $this->fetch();
  34. }
  35. }
  36. }