Commit e7eb4ffc authored by hujun's avatar hujun

参数设置修改

parent d851f513
......@@ -10,35 +10,57 @@ namespace app\index\controller;
use app\index\extend\Basic;
use app\model\SystemConfig;
use think\Cache;
class Setting extends Basic
{
/**
* 页面视图
* 显示视图,新增和编辑设置数据
*
* @return \think\response\View
*/
public function index() {
return view('setting/index');
}
/**
* 修改和新增
*
* @return \think\Response
* @return \think\Response|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getSetting() {
$data = [];
if ($this->request->isGet()) {
$data = Cache::get('Setting');
if ($this->request->isAjax()) {
$data = [];
$config = new SystemConfig();
if ($this->request->isGet()) {
//获取数据
$data = $config->getSetting();
} else {
//新增或编辑数据
$data['is_privacy'] = $this->params['is_privacy'];
$data['day_num'] = $this->params['day_num'];
$data['down_time'] = $this->params['down_time'];
$config_data = [];
$config_data[0]['id'] = 1;
$config_data[0]['config_name'] = '商铺自动下架天数';
$config_data[0]['config_type'] = 10;
$config_data[0]['rule'] = json_encode(['down_time'=>$data['down_time']]);
$config_data[0]['agent_id'] = $this->userId;
$config_data[1]['id'] = 2;
$config_data[1]['config_name'] = '隐私号码';
$config_data[1]['config_type'] = 20;
$config_data[1]['rule'] = json_encode([
'is_privacy'=>$data['is_privacy'],
'day_num'=>$data['day_num']
]);
$config_data[1]['agent_id'] = $this->userId;
$config->insertSetting($config_data, true);
Cache::set('Setting',$data);
}
return $this->response(200, '', $data);
} else {
$data['is_privacy'] = $this->params['is_privacy'];
$data['day_num'] = $this->params['day_num'];
$data['down_time'] = $this->params['down_time'];
Cache::set('Setting',$data);
//视图显示
return view('setting/index');
}
return $this->response(200, '', $data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/4/24
* Time: 10:12
*/
namespace app\model;
class SystemConfig extends BaseModel
{
/**
* 批量插入数据
*
* @param array $data
* @param bool $replace
* @return int|string
*/
public function insertSetting(array $data, $replace = true) {
return $this->insertAll($data, $replace);
}
/**
* 获取参数设置
*
* @param array $where
* @param string $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getSetting(array $where = [], string $field = 'rule') : array {
$data = $this->field($field)
->where($where)
->select();
if ($data != NULL) {
foreach ($data as $k => $v) {
$result_arr = json_decode($v['rule'], true);
foreach ($result_arr as $kk=>$vv) {
$result[$kk] = $vv;
}
}
} else {
$result = [];
}
return $result;
}
}
\ No newline at end of file
......@@ -183,7 +183,6 @@ Route::group('index', [
'useraction_search' => ['index/remark/useraction_search', [ 'method' => 'get|post' ] ], //后台客户详情
'select_by_phone' => ['index/remark/select_by_phone', [ 'method' => 'get|post' ] ], //后台客户详情--客方搜索
'setting_index' => ['index/Setting/index', [ 'method' => 'get' ] ], //全局参数设置页面
'getSetting' => ['index/Setting/getSetting', [ 'method' => 'get|post' ] ], //新增和修改全局参数设置
'getMenu' => ['index/Auth/getMenu', [ 'method' => 'get|post' ] ], //新增和修改全局参数设置
'reportListAttache/:check_status' => ['index/Finance/reportList', [ 'method' => 'get' ] ,['check_status'=>0]], //财务 成交报告-未结单-专员审核
......
......@@ -21,7 +21,6 @@ define (['doT', 'text!temp/setting_template_tpl.html', 'css!style/home.css'], fu
$.ajax ({
url: '/admin.php/index/getSetting',
type: 'GET',
async: true,
data: param,
dataType: 'json',
success: function (data) {
......@@ -41,7 +40,6 @@ define (['doT', 'text!temp/setting_template_tpl.html', 'css!style/home.css'], fu
$.ajax ({
url: '/admin.php/index/getSetting',
type: 'POST',
async: true,
data: param,
dataType: 'json',
success: function (data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment