From 56ca815fa294b50e52e29caeb9d48c2dff2c122a Mon Sep 17 00:00:00 2001 From: xxb Date: Thu, 5 Aug 2021 15:59:44 +0800 Subject: [PATCH] admin sys city update that add fee carno --- admin/controllers/sys/city/City.php | 25 ++++++++++++++++ admin/views/sys/city/lists.php | 46 ++++++++++++++++++++++++++++- sql/sys.sql | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/admin/controllers/sys/city/City.php b/admin/controllers/sys/city/City.php index 0209d70f..a0577645 100755 --- a/admin/controllers/sys/city/City.php +++ b/admin/controllers/sys/city/City.php @@ -11,12 +11,16 @@ class City extends HD_Controller{ private $city = array('北京市', '上海市', '重庆市', '天津市'); + protected $log_dir; + public function __construct() { parent::__construct(); $this->load->model("area_model"); $this->load->model("sys/sys_city_model"); $this->load->model('sys/sys_area_model'); + + $this->log_dir = 'sys_' . get_class($this); } public function index() { @@ -73,6 +77,7 @@ class City extends HD_Controller{ 'city_id' => $city_id, 'firstchar' => $v['firstchar'], 'name' => $v['name'], + 'fee_carno' => sprintf('%.2f', $v['fee_carno']), 'checked' => $city_checked[$city_id] ? 1 : 0, 'countys' => $map_checked[$city_id] ? $map_checked[$city_id] : array(), ); @@ -196,6 +201,26 @@ class City extends HD_Controller{ return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); } + /** + * 保存挂牌价 + * @return bool + */ + function edit_fee(){ + $lists = $this->input->post('lists'); + $lists = json_decode($lists, true); + foreach($lists as $k => $v){ + $upd = array('fee_carno' => $v['fee_carno']); + $where = array('id' => $v['id']); + //更新城市的状态 + $ret = $this->sys_city_model->update($upd, $where); + if(!$ret){ + debug_log("[error]# " . $this->sys_city_model->db->last_query(), __FUNCTION__, $this->log_dir); + } + } + + return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); + } + public function del() { $id = $this->input->post('id'); diff --git a/admin/views/sys/city/lists.php b/admin/views/sys/city/lists.php index 8e528a50..53472ef3 100755 --- a/admin/views/sys/city/lists.php +++ b/admin/views/sys/city/lists.php @@ -25,6 +25,7 @@ 城市ID 城市名称 + 挂牌价 操作 区域 @@ -33,6 +34,9 @@ {{v.city_id}} {{v.name}} + + + 删除 @@ -43,7 +47,10 @@ - + + + + @@ -126,6 +133,43 @@ layer.closeAll('loading'); } }); + }, + //保存挂牌价 + save_fee:function(){ + var vm = this; + if(1 == loading){ + return 0; + } + loading = 1; + + $.ajax({ + url: '/sys/city/city/edit_fee', + type: 'post', + dataType: 'json', + data: {lists:JSON.stringify(vm.lists)}, + beforeSend: function () { + layer.load(1, { + shade: [0.1, '#fff'] //0.1透明度的白色背景 + }); + }, + success: function (data) { + loading = 0; + if (data['code']) { + layer.msg(data.msg, { + icon: 1, + time: 2000 + }, function () { + $.form.reload(); + }); + } else { + layer.msg(data.msg, {icon: 2}); + } + }, + complete: function () { + loading = 0; + layer.closeAll('loading'); + } + }); } }, watch:{} diff --git a/sql/sys.sql b/sql/sys.sql index b597b778..46719eae 100644 --- a/sql/sys.sql +++ b/sql/sys.sql @@ -95,6 +95,7 @@ create table lc_sys_city( status tinyint(1) not null default 1 comment '状态 -1删除 0:禁用 1:启用', primary key(id) )ENGINE=InnoDB default CHARSET=utf8mb4 COMMENT='开通城市表'; + alter table lc_sys_city add column fee_carno decimal(12,2) not null default 0.00 comment '挂牌价' after firstchar; drop table if exists lc_sys_config;