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 0000000..efe20f6 Binary files /dev/null and b/view/images/index_logo.png differ 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);