Config.php
3 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
<?php
namespace app\admin\controller\fastflow\flow;
use app\admin\model\AuthRule;
use app\common\controller\Backend;
/**
* 系统设置
*
* @icon fa fa-handshake-o
*/
class Config extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\fastflow\flow\Config;
}
public function index()
{
$config_rows = $this->model->select();
if ($this->request->isAjax()) {
$params = input('row/a');
if ($params == null) {
$this->error('暂无可用配置项,请待后续版本更新');
}
foreach ($params as $key => $value) {
for ($i = 0; $i < count($config_rows); $i++) {
if ($config_rows[$i]['name'] == $key) {
$config_rows[$i]['value'] = $value;
$config_rows[$i]->save();
break;
}
}
if ($key == 'billshowway') {
$this->handleBillShowWay($value);
}
}
$this->success('操作成功');
}
$config_temp = [];
foreach ($config_rows as &$config) {
$config = $config->toArray();
$config_temp[$config['name']] = $config;
}
$this->assign(['config_rows' => $config_temp]);
return $this->view->fetch();
}
private function handleBillShowWay($value)
{
$authRuleModel = new AuthRule();
$bill_rule = $authRuleModel->where('name', 'fastflow/bill')->find();
$billlist_rule = $authRuleModel->where('name', 'fastflow/billlist')->find();
if ($billlist_rule['ismenu'] == 0) {
$billlist_rule['ismenu'] = 1;
$billlist_rule->save();
}
if ($value == 'menu') {
if ($bill_rule) {
$bill_rule->status = 'normal';
$bill_rule->save();
$billlist_rule->status = 'hidden';
$billlist_rule->save();
}
} elseif ($value == 'page') {
if ($bill_rule) {
$bill_rule->status = 'hidden';
$bill_rule->save();
$billlist_rule->status = 'normal';
$billlist_rule->save();
}
}
}
public function handleBillShowWayAjax()
{
if ($this->request->isAjax()) {
$params = input('');
if (isset($params['billshowway'])) {
$value = $params['billshowway'];
$this->handleBillShowWay($value);
$billShowWayRow = $this->model->where('name','billshowway')->find();
if ($billShowWayRow) {
$billShowWayRow['value'] = $value;
$billShowWayRow->save();
}
$this->success('操作成功');
}
$this->error('参数错误');
}
$this->error('非法访问');
}
}