From f59bb583f742edaa443acdfae620fb5acff70f98 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Tue, 15 Oct 2024 18:22:16 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/index.php | 34 +++++++++++++++++++++ data/dFormula.php | 22 +++++++++++++ model/mFormula.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) diff --git a/control/index.php b/control/index.php index c1639f1..cd256b7 100644 --- a/control/index.php +++ b/control/index.php @@ -327,4 +327,38 @@ class index extends publicBase { $this->view['data'] = array($data); $this->setViewTpl('index/export_pdf.html'); } + + public function ajax_unit_conv() { + $uinfo = $this->_check_login(); + + $name = trim($this->post('name')) ? trim($this->post('name')) : '两'; + + $m_formula = new mFormula(); + $unit = $m_formula->getUnitByName($name); + + $unit_conv = $m_formula->getUnitConvList($unit['id']); + + $user_conv = $m_formula->getUserConv($uinfo['uid'], $unit['id']); + foreach ($unit_conv as &$conv) { + $conv['conv_txt'] = "1{$unit['name']}={$conv['num']}g"; + if($user_conv['conv_id'] == $conv['id']){ + $user_conv['conv_txt'] = "当前1{$unit['name']}={$conv['num']}g"; + } + } + + $this->ajax_json(true, '获取成功', array('user_conv' => $user_conv, 'unit_conv' => $unit_conv)); + } + + public function ajax_set_user_conv() { + $uinfo = $this->_check_login(); + + $unit_id = trim($this->post('unit_id')) + 0; + $conv_id = trim($this->post('conv_id')) + 0; + + $m_formula = new mFormula(); + $res = $m_formula->saveUserConv($uinfo['uid'], $unit_id, $conv_id); + if (!$res) $this->ajax_json(false, $m_formula->getError()); + + $this->ajax_json(true, '保存成功'); + } } diff --git a/data/dFormula.php b/data/dFormula.php index bcbf2dd..518a5bb 100644 --- a/data/dFormula.php +++ b/data/dFormula.php @@ -44,6 +44,25 @@ class dFormula extends dBase { 'formula_id', 'use_num', ), + 'tcm_unit_list' => array( + 'id', + 'name', + ), + 'tcm_unit_conv' => array( + 'id', + 'uid', + 'unit_id', + 'num', + 'from', + 'is_delete', + 'create_date', + ), + 'tcm_user_conv' => array( + 'id', + 'uid', + 'unit_id', + 'conv_id', + ), ); protected $primary_keys = array( @@ -52,6 +71,9 @@ class dFormula extends dBase { 'tcm_herb' => 'id', 'tcm_collect_log' => 'id', 'tcm_formula_use_log' => 'id', + 'tcm_unit_list' => 'id', + 'tcm_unit_conv' => 'id', + 'tcm_user_conv' => 'id', ); } diff --git a/model/mFormula.php b/model/mFormula.php index f994194..58b1e44 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -12,6 +12,9 @@ class mFormula extends mBase { private $herb_tbl; private $collect_log_tbl; private $formula_use_log_tbl; + private $unit_list; + private $unit_conv; + private $user_conv; public function __construct() { $this->obj = new dFormula(); @@ -20,6 +23,9 @@ class mFormula extends mBase { $this->herb_tbl = 'tcm_herb'; $this->collect_log_tbl = 'tcm_collect_log'; $this->formula_use_log_tbl = 'tcm_formula_use_log'; + $this->unit_list = 'tcm_unit_list'; + $this->unit_conv = 'tcm_unit_conv'; + $this->user_conv = 'tcm_user_conv'; } public function searchFormulaList($condition, $page_num, $page_size) { @@ -59,6 +65,9 @@ class mFormula extends mBase { foreach ($da['formula'] as &$v) { if (isset($original[$v['name']])) { + $num = $this->convByUserChoice($uid, $original[$v['name']]['num']); + if ($num) $v['num'] = $num; + $v['num_str'] = $original[$v['name']]['num']; $v['desc'] = $original[$v['name']]['desc']; } @@ -70,6 +79,25 @@ class mFormula extends mBase { return $data; } + public function convByUserChoice($uid, $num_str) { + $unit_name = preg_replace('/\d/', '', $num_str); + $unit = $this->getUnitByName($unit_name); + if (!$unit) return false; + + $user_conv = $this->getUserConv($uid, $unit['id']); + if (!$user_conv) return false; + + $unit_conv = $this->getUnitConvById($user_conv['conv_id']); + if (!$unit_conv) return false; + + $unit_num = filter_var($num_str, FILTER_SANITIZE_NUMBER_INT); + + $num = $unit_num * $unit_conv['num']; + if (!$num) return false; + + return $num; + } + public function searchFormulaTotal($condition) { $where = "1=1"; if (!empty($condition)) { @@ -266,6 +294,9 @@ class mFormula extends mBase { $original = array_column($original, null, 'name'); foreach ($formulaHerb as &$v) { if (isset($original[$v['name']])) { + $num = $this->convByUserChoice($uid, $original[$v['name']]['num']); + if ($num) $v['num'] = $num; + $v['num_str'] = $original[$v['name']]['num']; $v['desc'] = $original[$v['name']]['desc']; } @@ -611,4 +642,63 @@ class mFormula extends mBase { return $this->obj->count($this->collect_log_tbl); } + public function getUnitByName($name) { + return $this->obj->select($this->unit_list, array('sql' => '`name`=?', 'vals' => array($name))); + } + + public function getUnitConvById($id) { + return $this->obj->select($this->unit_conv, array('sql' => '`id`=? and `is_delete`=?', 'vals' => array($id, 0))); + } + + public function getUnitConvList($unit_id) { + return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_id`=? and `is_delete`=?', 'vals' => array($unit_id, 0))); + } + + public function getUserConv($uid, $unit_id) { + return $this->obj->select($this->user_conv, array('sql' => '`uid`=? and `unit_id`=?', 'vals' => array($uid, $unit_id))); + } + + public function saveUserConv($uid, $unit_id, $conv_id) { + if (!$unit_id || !$conv_id) { + $this->setError('参数错误'); + return false; + } + + $user_conv = $this->getUserConv($uid, $unit_id); + if ($user_conv) { + $res = $this->updateUserConv($user_conv['id'], array('conv_id' => $conv_id)); + if (!$res) { + $this->setError('更新失败'); + return false; + } + return true; + } + + $res = $this->insertUserConv(array('uid' => $uid, 'unit_id' => $unit_id, 'conv_id' => $conv_id)); + if (!$res) { + $this->setError('设置失败'); + return false; + } + return true; + } + + public function updateUserConv($id, $info) { + $res = $this->obj->update($this->user_conv, $info, array('sql' => '`id`=?', 'vals' => array($id))); + if (!$res) { + $this->writeLog('formula', 'save_error_log', '更新用户计量单位转换设置失败|' . $id . '|' . json_encode($info, JSON_UNESCAPED_UNICODE)); + return false; + } + + return true; + } + + public function insertUserConv($info) { + $res = $this->obj->insert($this->user_conv, $info); + if (!$res) { + $this->writeLog('formula', 'save_error_log', '添加用户计量单位转换设置失败|' . json_encode($info)); + return false; + } + + return true; + } } \ No newline at end of file From 880bfd2b98b72b59543ce1a4328032c7586fb850 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Tue, 15 Oct 2024 18:47:37 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/define.php | 5 +++++ control/index.php | 17 ++++++++--------- data/dFormula.php | 9 ++------- model/mFormula.php | 28 +++++++++++----------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/config/define.php b/config/define.php index 70c30cc..e4f41e1 100644 --- a/config/define.php +++ b/config/define.php @@ -77,6 +77,11 @@ ) ); + define('WEIGHT_LIANG', 1); + $GLOBALS['weight_convert_list'] = array( + '两'=> WEIGHT_LIANG, + ); + $GLOBALS['weight_list'] = array( "汉" => array( '少许'=>'', diff --git a/control/index.php b/control/index.php index cd256b7..62cfc01 100644 --- a/control/index.php +++ b/control/index.php @@ -331,18 +331,17 @@ class index extends publicBase { public function ajax_unit_conv() { $uinfo = $this->_check_login(); - $name = trim($this->post('name')) ? trim($this->post('name')) : '两'; + $unit_name = '两'; + $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; $m_formula = new mFormula(); - $unit = $m_formula->getUnitByName($name); + $unit_conv = $m_formula->getUnitConvList($unit_type); - $unit_conv = $m_formula->getUnitConvList($unit['id']); - - $user_conv = $m_formula->getUserConv($uinfo['uid'], $unit['id']); + $user_conv = $m_formula->getUserConv($uinfo['uid'], $unit_type); foreach ($unit_conv as &$conv) { - $conv['conv_txt'] = "1{$unit['name']}={$conv['num']}g"; + $conv['conv_txt'] = "1{$unit_name}={$conv['num']}g"; if($user_conv['conv_id'] == $conv['id']){ - $user_conv['conv_txt'] = "当前1{$unit['name']}={$conv['num']}g"; + $user_conv['conv_txt'] = "当前1{$unit_name}={$conv['num']}g"; } } @@ -352,11 +351,11 @@ class index extends publicBase { public function ajax_set_user_conv() { $uinfo = $this->_check_login(); - $unit_id = trim($this->post('unit_id')) + 0; + $unit_type = trim($this->post('unit_type')) + 0; $conv_id = trim($this->post('conv_id')) + 0; $m_formula = new mFormula(); - $res = $m_formula->saveUserConv($uinfo['uid'], $unit_id, $conv_id); + $res = $m_formula->saveUserConv($uinfo['uid'], $unit_type, $conv_id); if (!$res) $this->ajax_json(false, $m_formula->getError()); $this->ajax_json(true, '保存成功'); diff --git a/data/dFormula.php b/data/dFormula.php index 518a5bb..72dba34 100644 --- a/data/dFormula.php +++ b/data/dFormula.php @@ -44,14 +44,10 @@ class dFormula extends dBase { 'formula_id', 'use_num', ), - 'tcm_unit_list' => array( - 'id', - 'name', - ), 'tcm_unit_conv' => array( 'id', 'uid', - 'unit_id', + 'unit_type', 'num', 'from', 'is_delete', @@ -60,7 +56,7 @@ class dFormula extends dBase { 'tcm_user_conv' => array( 'id', 'uid', - 'unit_id', + 'unit_type', 'conv_id', ), ); @@ -71,7 +67,6 @@ class dFormula extends dBase { 'tcm_herb' => 'id', 'tcm_collect_log' => 'id', 'tcm_formula_use_log' => 'id', - 'tcm_unit_list' => 'id', 'tcm_unit_conv' => 'id', 'tcm_user_conv' => 'id', ); diff --git a/model/mFormula.php b/model/mFormula.php index 58b1e44..efe8ad0 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -12,7 +12,6 @@ class mFormula extends mBase { private $herb_tbl; private $collect_log_tbl; private $formula_use_log_tbl; - private $unit_list; private $unit_conv; private $user_conv; @@ -23,7 +22,6 @@ class mFormula extends mBase { $this->herb_tbl = 'tcm_herb'; $this->collect_log_tbl = 'tcm_collect_log'; $this->formula_use_log_tbl = 'tcm_formula_use_log'; - $this->unit_list = 'tcm_unit_list'; $this->unit_conv = 'tcm_unit_conv'; $this->user_conv = 'tcm_user_conv'; } @@ -81,10 +79,10 @@ class mFormula extends mBase { public function convByUserChoice($uid, $num_str) { $unit_name = preg_replace('/\d/', '', $num_str); - $unit = $this->getUnitByName($unit_name); - if (!$unit) return false; + $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; + if (!$unit_type) return false; - $user_conv = $this->getUserConv($uid, $unit['id']); + $user_conv = $this->getUserConv($uid, $unit_type); if (!$user_conv) return false; $unit_conv = $this->getUnitConvById($user_conv['conv_id']); @@ -642,29 +640,25 @@ class mFormula extends mBase { return $this->obj->count($this->collect_log_tbl); } - public function getUnitByName($name) { - return $this->obj->select($this->unit_list, array('sql' => '`name`=?', 'vals' => array($name))); - } - public function getUnitConvById($id) { return $this->obj->select($this->unit_conv, array('sql' => '`id`=? and `is_delete`=?', 'vals' => array($id, 0))); } - public function getUnitConvList($unit_id) { - return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_id`=? and `is_delete`=?', 'vals' => array($unit_id, 0))); + public function getUnitConvList($unit_type) { + return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=? and `is_delete`=?', 'vals' => array($unit_type, 0))); } - public function getUserConv($uid, $unit_id) { - return $this->obj->select($this->user_conv, array('sql' => '`uid`=? and `unit_id`=?', 'vals' => array($uid, $unit_id))); + public function getUserConv($uid, $unit_type) { + return $this->obj->select($this->user_conv, array('sql' => '`uid`=? and `unit_type`=?', 'vals' => array($uid, $unit_type))); } - public function saveUserConv($uid, $unit_id, $conv_id) { - if (!$unit_id || !$conv_id) { + public function saveUserConv($uid, $unit_type, $conv_id) { + if (!$unit_type || !$conv_id) { $this->setError('参数错误'); return false; } - $user_conv = $this->getUserConv($uid, $unit_id); + $user_conv = $this->getUserConv($uid, $unit_type); if ($user_conv) { $res = $this->updateUserConv($user_conv['id'], array('conv_id' => $conv_id)); if (!$res) { @@ -674,7 +668,7 @@ class mFormula extends mBase { return true; } - $res = $this->insertUserConv(array('uid' => $uid, 'unit_id' => $unit_id, 'conv_id' => $conv_id)); + $res = $this->insertUserConv(array('uid' => $uid, 'unit_type' => $unit_type, 'conv_id' => $conv_id)); if (!$res) { $this->setError('设置失败'); return false; From cdc13670fd95f023a04e5d93d89cdfccc0524053 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Wed, 16 Oct 2024 09:38:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/mFormula.php | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/model/mFormula.php b/model/mFormula.php index efe8ad0..83e8370 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -53,6 +53,16 @@ class mFormula extends mBase { $formula_ids = array_column($data, 'id'); $formula_arr = $this->getFormulaHerbData($formula_ids); + $unit_conv = array(); + $user_conv = $this->getUserConvList($uid); + if ($user_conv) { + $conv_ids = array_column($user_conv, 'conv_id'); + if ($conv_ids) { + $unit_conv = $this->getUnitConvByIds($conv_ids); + $unit_conv = array_column($unit_conv, null, 'unit_type'); + } + } + foreach ($data as &$da) { if (isset($formula_arr[$da['id']])) $da['formula'] = $formula_arr[$da['id']]; @@ -63,7 +73,7 @@ class mFormula extends mBase { foreach ($da['formula'] as &$v) { if (isset($original[$v['name']])) { - $num = $this->convByUserChoice($uid, $original[$v['name']]['num']); + $num = $this->convByUserChoice($original[$v['name']]['num'], $unit_conv); if ($num) $v['num'] = $num; $v['num_str'] = $original[$v['name']]['num']; @@ -77,20 +87,19 @@ class mFormula extends mBase { return $data; } - public function convByUserChoice($uid, $num_str) { + public function convByUserChoice($num_str, $unit_conv) { + if (!$unit_conv) return false; + $unit_name = preg_replace('/\d/', '', $num_str); + $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; if (!$unit_type) return false; - - $user_conv = $this->getUserConv($uid, $unit_type); - if (!$user_conv) return false; - - $unit_conv = $this->getUnitConvById($user_conv['conv_id']); - if (!$unit_conv) return false; + if (!isset($unit_conv[$unit_type])) return false; $unit_num = filter_var($num_str, FILTER_SANITIZE_NUMBER_INT); + $conv_num = $unit_conv[$unit_type]['num']; - $num = $unit_num * $unit_conv['num']; + $num = $unit_num * $conv_num; if (!$num) return false; return $num; @@ -287,12 +296,22 @@ class mFormula extends mBase { return $formula; } + $unit_conv = array(); + $user_conv = $this->getUserConvList($uid); + if ($user_conv) { + $conv_ids = array_column($user_conv, 'conv_id'); + if ($conv_ids) { + $unit_conv = $this->getUnitConvByIds($conv_ids); + $unit_conv = array_column($unit_conv, null, 'unit_type'); + } + } + //原方信息 $original = json_decode($original, true); $original = array_column($original, null, 'name'); foreach ($formulaHerb as &$v) { if (isset($original[$v['name']])) { - $num = $this->convByUserChoice($uid, $original[$v['name']]['num']); + $num = $this->convByUserChoice($original[$v['name']]['num'], $unit_conv); if ($num) $v['num'] = $num; $v['num_str'] = $original[$v['name']]['num']; @@ -640,6 +659,10 @@ class mFormula extends mBase { return $this->obj->count($this->collect_log_tbl); } + public function getUnitConvByIds($ids) { + return $this->obj->selectIn($this->unit_conv, array('id' => $ids), array('sql' => '`is_delete`=?', 'vals' => array(0))); + } + public function getUnitConvById($id) { return $this->obj->select($this->unit_conv, array('sql' => '`id`=? and `is_delete`=?', 'vals' => array($id, 0))); } @@ -648,6 +671,10 @@ class mFormula extends mBase { return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=? and `is_delete`=?', 'vals' => array($unit_type, 0))); } + public function getUserConvList($uid) { + return $this->obj->selectAll($this->user_conv, array('sql' => '`uid`=?', 'vals' => array($uid))); + } + public function getUserConv($uid, $unit_type) { return $this->obj->select($this->user_conv, array('sql' => '`uid`=? and `unit_type`=?', 'vals' => array($uid, $unit_type))); } From c34eb9b6c466ce1c8255ba6e5de599f0a91ca795 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Wed, 16 Oct 2024 11:43:32 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/admin.php | 49 ++++++++- control/index.php | 2 +- data/dFormula.php | 1 - index.php | 2 +- model/mFormula.php | 61 +++++++++++- model/mPage.php | 2 +- view/css/global.css | 20 +++- view/images/index_logo.png | Bin 0 -> 7298 bytes view/js/common.js | 18 ++++ view/templates/admin/formula_add.html | 54 +++------- view/templates/admin/formula_list.html | 54 +++------- view/templates/admin/include/header.html | 18 ++++ view/templates/admin/include/leftmenu.html | 25 +++++ view/templates/admin/save_pass.html | 18 +++- view/templates/admin/unit_conv.html | 153 ++++++++++++++++++++++++++++ view/templates/admin/unit_conv_add.html | 155 +++++++++++++++++++++++++++++ view/templates/admin/user_add.html | 18 +++- view/templates/admin/user_list.html | 24 +++-- 18 files changed, 565 insertions(+), 109 deletions(-) create mode 100644 view/images/index_logo.png create mode 100644 view/js/common.js create mode 100644 view/templates/admin/include/header.html create mode 100644 view/templates/admin/include/leftmenu.html create mode 100644 view/templates/admin/unit_conv.html create mode 100644 view/templates/admin/unit_conv_add.html diff --git a/control/admin.php b/control/admin.php index ce38146..b50c575 100644 --- a/control/admin.php +++ b/control/admin.php @@ -22,6 +22,13 @@ class admin extends publicBase { } } + public function logout() { + setcookie("uid", '', time() + 3600 * 24, '/'); + setcookie("token", '', time() + 3600 * 24, '/'); + + header('Location: /admin/login'); + } + public function user_list() { $m_admin_user = new mAdminUser(); $list = $m_admin_user->getUserList(); @@ -32,8 +39,6 @@ class admin extends publicBase { public function user_add() {} public function ajax_save_user() { - $this->_check_login(true); - $name = trim($this->post('name')); $password = md5('123456'); @@ -166,4 +171,44 @@ class admin extends publicBase { $this->ajax_json(true, '操作成功'); } + + public function unit_conv() { + $this->view['unit_list'] = array_flip($GLOBALS['weight_convert_list']); + + $unit_type = trim($this->get('unit_type')) + 0; + if (!$unit_type) $unit_type = 1; + + $m_formula = new mFormula(); + $this->view['list'] = $m_formula->getUnitConvList($unit_type); + } + + public function ajax_change_unit_conv() { + $id = $this->post('id') + 0; + $data = array( + 'is_delete' => $this->post('is_delete') + 0 + ); + + $m_formula = new mFormula(); + $id = $m_formula->updateUnitConv($id, $data); + if (!$id) $this->ajax_json(false, '操作失败'); + + $this->ajax_json(true, '操作成功'); + } + + public function unit_conv_add() { + $this->view['unit_list'] = array_flip($GLOBALS['weight_convert_list']); + } + + public function ajax_save_unit_conv() { + $id = $this->post('id') + 0; + $unit_type = trim($this->post('unit_type')) + 0; + $num = trim($this->post('num')) + 0; + $from = trim($this->post('from')); + + $m_formula = new mFormula(); + $id = $m_formula->saveUnitConv($id, $unit_type, $num, $from); + if (!$id) $this->ajax_json(false, $m_formula->getError()); + + $this->ajax_json(true, '操作成功', array('id' => $id)); + } } diff --git a/control/index.php b/control/index.php index 62cfc01..7a9e160 100644 --- a/control/index.php +++ b/control/index.php @@ -335,7 +335,7 @@ class index extends publicBase { $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; $m_formula = new mFormula(); - $unit_conv = $m_formula->getUnitConvList($unit_type); + $unit_conv = $m_formula->getUnitTypeConv($unit_type); $user_conv = $m_formula->getUserConv($uinfo['uid'], $unit_type); foreach ($unit_conv as &$conv) { diff --git a/data/dFormula.php b/data/dFormula.php index 72dba34..d01d7d9 100644 --- a/data/dFormula.php +++ b/data/dFormula.php @@ -46,7 +46,6 @@ class dFormula extends dBase { ), 'tcm_unit_conv' => array( 'id', - 'uid', 'unit_type', 'num', 'from', diff --git a/index.php b/index.php index 6787a76..82aef90 100644 --- a/index.php +++ b/index.php @@ -129,7 +129,7 @@ if ($is_super && $uinfo['is_super'] != 1) $this->ajax_json(false, '你没有该权限'); - $this->para['_uinfo'] = $uinfo; + $this->view['_uinfo'] = $this->para['_uinfo'] = $uinfo; return true; } diff --git a/model/mFormula.php b/model/mFormula.php index 83e8370..a743a29 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -667,10 +667,69 @@ class mFormula extends mBase { return $this->obj->select($this->unit_conv, array('sql' => '`id`=? and `is_delete`=?', 'vals' => array($id, 0))); } - public function getUnitConvList($unit_type) { + public function getUnitTypeConv($unit_type) { return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=? and `is_delete`=?', 'vals' => array($unit_type, 0))); } + public function getUnitConvList($unit_type) { + return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=?', 'vals' => array($unit_type))); + } + + public function updateUnitConv($id, $info) { + return $this->obj->update($this->unit_conv, $info, array('sql' => '`id`=?', 'vals' => array($id))); + } + + public function insertUnitConv($info) { + $id = $this->obj->insert($this->unit_conv, $info); + if (empty($id)) { + $this->writeLog('formula', 'save_error_log', '添加计量单位转换失败|' . json_encode($info, JSON_UNESCAPED_UNICODE)); + return false; + } + + return $id; + } + + public function saveUnitConv($id, $unit_type, $num, $from) { + if (!$unit_type) { + $this->setError('请选择计量单位'); + return false; + } + if (!$num) { + $this->setError('请填写转换克重'); + return false; + } + if (empty($from)) { + $this->setError('请填写转换根据'); + return false; + } + + $data = array( + 'unit_type' => $unit_type, + 'num' => $num, + 'from' => $from, + 'is_delete' => 1, + ); + + if (!$id) { + //添加药方 并添加药方药材关联关系 + $id = $this->insertUnitConv($data); + if (!$id) { + $this->setError('添加失败'); + return false; + } + + } else { + //更新药方 并更新药方药材关联关系 + $res = $this->updateUnitConv($id, $data); + if (!$res) { + $this->setError('更新失败'); + return false; + } + } + + return $id; + } + public function getUserConvList($uid) { return $this->obj->selectAll($this->user_conv, array('sql' => '`uid`=?', 'vals' => array($uid))); } diff --git a/model/mPage.php b/model/mPage.php index 908a653..85d8a8d 100644 --- a/model/mPage.php +++ b/model/mPage.php @@ -5,7 +5,7 @@ class Page extends publicBase { public $totalnum; // 总记录数[必填],例:$page->setTotalnum(100); public $page; // 当前页码[必填] public $url; // 分页URL[必填] - public $pagesize=50; // 每页记录数 + public $pagesize=20; // 每页记录数 public $viewpagenum=7; // 每页看到的页码数 public $virtualpage='...'; // 省略或跨越页码 diff --git a/view/css/global.css b/view/css/global.css index a19c636..55c0510 100644 --- a/view/css/global.css +++ b/view/css/global.css @@ -3568,7 +3568,8 @@ body{ display: block; text-indent:-9999px; margin: 6px 57px 0 0; - background:url('/agentsite/0.png') no-repeat; + background:url('../images/index_logo.png') no-repeat; + background-size: 80%; } .topbar-inner-logo { @@ -6073,7 +6074,7 @@ table { border-radius: 0 0 4px 0; } .table-striped tbody tr:nth-child(odd) td, .table-striped tbody tr:nth-child(odd) th { - background-color: #f9f9f9; + /*background-color: #f9f9f9;*/ } .table tbody tr:hover td, .table tbody tr:hover th { background-color: #f5f5f5; @@ -6990,4 +6991,19 @@ button.danger:hover{ text-shadow: none; border-color: #d9534f; background-position: 0 -10px; +} + +/* 提示框的样式 */ +.custom-alert { + position: fixed; + top: 30%; + right: 50%; + background-color: #787878; + color: white; + padding: 15px; + border-radius: 5px; + z-index: 1000; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + opacity: 1; + transition: opacity 0.5s ease; } \ No newline at end of file diff --git a/view/images/index_logo.png b/view/images/index_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..efe20f645a36bd83fe53920184522ceafeb27c1a GIT binary patch literal 7298 zcmY+JcTiJN)BhvVk=~ImCG;jG^e%)JI#LBGB1#F;J0x@vLhm9$l-@%X2_Qrflnw%+ z_udhZ7oYd}&HUbf?%p%A=kA`}GjsPlpE!vA6H;O(VgLX@s;#AN1OVJizkBy2#J_uj zT%yD8%sp?TC#rzzA?8g0fLUH!UB$$IX4i%!TW^)=ud_N>Uwqlth$9QhO!SEv{E4~% zs6kIVq7kP~pW)u-Y0?JK7A{6YU?xji@n8)~N{MVS>92#?+p@Q)iLM5h;kLcbv%;qH zQ0)3;;i#BfP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he)#xc3v)UDW z?eHEhtS^n=bYT&G$)+WXYn{qK#e15W4Ona=%K#1xC;Oe0Ynx~w7n*9*`eGugqh^gH zJIblKb>ndD1qZbOCGj0NnZlpsypXnE8sBjwE)rC@gG_hbe-L$lW%ftn{dL}FGIzM? z|Kmk>py{p)0Dv-3^dD$qr(yWVqWn{a=?m7WI!v{a=*zk4XKOSN%g$ z3zR$WSMam*ONNc85t)mdcTmlnf_ltWcf`=eU>WmoIhFPgroH(OOw&Y}0{|TaztUtm zxWxikdA2^*b|{#>JnuFp0feLc`2QEzRnerG(ebzsPoItTBBz5s>PyIf`USteKcnJE Vt0Yb5dzTYHTSH&HTJ>4v{{XjZ!LR@T literal 0 HcmV?d00001 diff --git a/view/js/common.js b/view/js/common.js new file mode 100644 index 0000000..318693a --- /dev/null +++ b/view/js/common.js @@ -0,0 +1,18 @@ +function showAlert(text,href = ""){ + // 创建提示框元素 + var $alertBox = $('
'+text+'
'); + + // 将提示框添加到页面中 + $("#page").append($alertBox); + + //2秒后自动隐藏并移除提示框 + setTimeout(function() { + $alertBox.css("opacity", "0"); + if(href){ + window.location.href = href; + } + setTimeout(function() { + $alertBox.remove(); + }, 500); // 给提示框一些时间淡出,然后再移除 + }, 500); +} \ No newline at end of file diff --git a/view/templates/admin/formula_add.html b/view/templates/admin/formula_add.html index 39ba9b4..7eae55e 100644 --- a/view/templates/admin/formula_add.html +++ b/view/templates/admin/formula_add.html @@ -9,17 +9,22 @@ 添加药方 +
+ {include file="admin/include/header.html"}
-
+ +
-
-
-
+
{literal}
+ {include file="admin/include/header.html"}
-
+ +
-
  • 药方列表
  • @@ -93,13 +99,13 @@ {$item.id} {$item.name} {$item.source} - +
    {foreach from=$item.formula item=value} - {$value.name}{if $value.desc}({$value.desc}){/if} {$value.num_str} + {$value.name}{if $value.desc}({$value.desc}){/if} {$value.num_str} {/foreach}
    -
    {$item.method}
    +
    {$item.method}
    {if $item.uid==0} @@ -141,7 +147,7 @@
-
+
@@ -149,25 +155,6 @@ {literal} +{/literal} + + + \ No newline at end of file diff --git a/view/templates/admin/user_add.html b/view/templates/admin/user_add.html index 02f613b..5da0c17 100644 --- a/view/templates/admin/user_add.html +++ b/view/templates/admin/user_add.html @@ -9,19 +9,24 @@ 添加用户 +
+ {include file="admin/include/header.html"}
+
添加用户
 
-
-
@@ -81,14 +86,17 @@ data: {name:name}, dataType: 'json', success: function (response) { - alert(response.info); if (response.status == true) { - window.location.href = "/admin/user_list" + showAlert('操作成功', document.referrer) + return true; } if(response.data.code == 40002){ - window.location.href = "/admin/login"; + showAlert('请登录','/admin/login') + return true; } + + showAlert(response.info) }, error: function (xhr, status, error) { console.error('错误:', response); diff --git a/view/templates/admin/user_list.html b/view/templates/admin/user_list.html index 2b6a56a..98350c7 100644 --- a/view/templates/admin/user_list.html +++ b/view/templates/admin/user_list.html @@ -8,17 +8,22 @@ 管理员列表 - + +
+ {include file="admin/include/header.html"}
-
+ +
-
  • 管理员列表
  • @@ -88,14 +93,17 @@ data: data, dataType: 'json', success: function (response) { - alert(response.info); if (response.status == true) { - window.location.reload(); + showAlert('操作成功', window.location.href) + return true; } - if (response.data.code == 40002) { - window.location.href = "/admin/login"; + if(response.data.code == 40002){ + showAlert('请登录','/admin/login') + return true; } + + showAlert(response.info) }, error: function (xhr, status, error) { console.error('错误:', response); From 73efbbd3288e794c256541b1569c4dab8efe368e Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Wed, 16 Oct 2024 13:55:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/define.php | 4 +++- control/admin.php | 19 ++++++++++++++----- control/index.php | 4 ++-- data/dFormula.php | 2 +- model/mFormula.php | 23 ++++++++++++++++------- view/templates/admin/unit_conv.html | 12 +++++++----- view/templates/admin/unit_conv_add.html | 2 +- 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/config/define.php b/config/define.php index e4f41e1..7fb8da2 100644 --- a/config/define.php +++ b/config/define.php @@ -78,8 +78,10 @@ ); define('WEIGHT_LIANG', 1); + define('WEIGHT_SHENG', 2); $GLOBALS['weight_convert_list'] = array( - '两'=> WEIGHT_LIANG, + WEIGHT_LIANG => '两', + WEIGHT_SHENG => '升', ); $GLOBALS['weight_list'] = array( diff --git a/control/admin.php b/control/admin.php index b50c575..7bac4f5 100644 --- a/control/admin.php +++ b/control/admin.php @@ -173,19 +173,20 @@ class admin extends publicBase { } public function unit_conv() { - $this->view['unit_list'] = array_flip($GLOBALS['weight_convert_list']); + $this->view['unit_list'] = $GLOBALS['weight_convert_list']; $unit_type = trim($this->get('unit_type')) + 0; - if (!$unit_type) $unit_type = 1; $m_formula = new mFormula(); - $this->view['list'] = $m_formula->getUnitConvList($unit_type); + $condition = array(); + if ($unit_type) $condition['unit_type'] = $unit_type; + $this->view['list'] = $m_formula->getUnitConvList($condition); } public function ajax_change_unit_conv() { $id = $this->post('id') + 0; $data = array( - 'is_delete' => $this->post('is_delete') + 0 + 'status' => $this->post('status') + 0 ); $m_formula = new mFormula(); @@ -196,7 +197,15 @@ class admin extends publicBase { } public function unit_conv_add() { - $this->view['unit_list'] = array_flip($GLOBALS['weight_convert_list']); + $this->view['unit_list'] = $GLOBALS['weight_convert_list']; + + $id = $this->get('id'); + if ($id) { + $mformula = new mFormula(); + $data = $mformula->getUnitConvById($id); + + $this->view['data'] = $data; + } } public function ajax_save_unit_conv() { diff --git a/control/index.php b/control/index.php index 7a9e160..b167785 100644 --- a/control/index.php +++ b/control/index.php @@ -331,8 +331,8 @@ class index extends publicBase { public function ajax_unit_conv() { $uinfo = $this->_check_login(); - $unit_name = '两'; - $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; + $unit_type = WEIGHT_LIANG; + $unit_name = $GLOBALS['weight_convert_list'][$unit_type]; $m_formula = new mFormula(); $unit_conv = $m_formula->getUnitTypeConv($unit_type); diff --git a/data/dFormula.php b/data/dFormula.php index d01d7d9..a3421be 100644 --- a/data/dFormula.php +++ b/data/dFormula.php @@ -49,7 +49,7 @@ class dFormula extends dBase { 'unit_type', 'num', 'from', - 'is_delete', + 'status', 'create_date', ), 'tcm_user_conv' => array( diff --git a/model/mFormula.php b/model/mFormula.php index a743a29..4d5306a 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -92,7 +92,7 @@ class mFormula extends mBase { $unit_name = preg_replace('/\d/', '', $num_str); - $unit_type = $GLOBALS['weight_convert_list'][$unit_name]; + $unit_type = array_search($unit_name, $GLOBALS['weight_convert_list']); if (!$unit_type) return false; if (!isset($unit_conv[$unit_type])) return false; @@ -660,19 +660,28 @@ class mFormula extends mBase { } public function getUnitConvByIds($ids) { - return $this->obj->selectIn($this->unit_conv, array('id' => $ids), array('sql' => '`is_delete`=?', 'vals' => array(0))); + return $this->obj->selectIn($this->unit_conv, array('id' => $ids), array('sql' => '`status`=?', 'vals' => array(0))); } public function getUnitConvById($id) { - return $this->obj->select($this->unit_conv, array('sql' => '`id`=? and `is_delete`=?', 'vals' => array($id, 0))); + return $this->obj->select($this->unit_conv, array('sql' => '`id`=?', 'vals' => array($id))); } public function getUnitTypeConv($unit_type) { - return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=? and `is_delete`=?', 'vals' => array($unit_type, 0))); + return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=? and `status`=?', 'vals' => array($unit_type, 0))); } - public function getUnitConvList($unit_type) { - return $this->obj->selectAll($this->unit_conv, array('sql' => '`unit_type`=?', 'vals' => array($unit_type))); + public function getUnitConvList($condition, $page_num = 1, $page_size = 500) { + $offset = ($page_num - 1) * $page_size; + + $where = "1=1 "; + if (!empty($condition)) { + foreach ($condition as $key => $val) { + $where .= " and {$key}={$val}"; + } + } + + return $this->obj->selectAll($this->unit_conv, array('sql' => $where, 'vals' => array()), 'id desc ', array($offset, $page_size)); } public function updateUnitConv($id, $info) { @@ -707,7 +716,7 @@ class mFormula extends mBase { 'unit_type' => $unit_type, 'num' => $num, 'from' => $from, - 'is_delete' => 1, + 'status' => 1, ); if (!$id) { diff --git a/view/templates/admin/unit_conv.html b/view/templates/admin/unit_conv.html index b18b1f7..5d4f203 100644 --- a/view/templates/admin/unit_conv.html +++ b/view/templates/admin/unit_conv.html @@ -30,8 +30,9 @@  计量单位:      @@ -70,17 +71,18 @@ {foreach from=$list key=key item=item} {$item.id} - {$unit_list[$item.unit_type]} + 1{$unit_list[$item.unit_type]} {$item.num}g {$item.from} {if $item.is_super == 0} - {if $item.is_delete == 0} + {if $item.status == 0} 禁用 {else} 启用 {/if} {/if} + 编辑 {/foreach} @@ -111,7 +113,7 @@ location.href = url; } - function to_disabled(id, is_delete) { + function to_disabled(id, status) { if (!confirm("确定要禁用吗?")) { console.log("用户选择了确认"); return false; @@ -119,7 +121,7 @@ const data = { id: id, - is_delete: is_delete, + status: status, }; $.ajax({ diff --git a/view/templates/admin/unit_conv_add.html b/view/templates/admin/unit_conv_add.html index ea0871c..bb82067 100644 --- a/view/templates/admin/unit_conv_add.html +++ b/view/templates/admin/unit_conv_add.html @@ -46,7 +46,7 @@