From 01e1c68190cccad16257dbf2823270246c6bd445 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Thu, 19 Sep 2024 16:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=95=E6=96=B9=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/index.php | 17 +++++-- view/templates/index/formula_add.html | 58 +++++++++-------------- view/templates/index/home.html | 88 ++++++++++++++++++++++------------- view/templates/index/login.html | 84 +++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 72 deletions(-) create mode 100644 view/templates/index/login.html diff --git a/control/index.php b/control/index.php index f4a50aa..c752112 100644 --- a/control/index.php +++ b/control/index.php @@ -10,7 +10,6 @@ include_once(SERVER_ROOT . "/model/mPage.php"); class index extends publicBase { private function _check_login() { -// return array('uid'=>$this->post('uid')); $uid = $this->post('uid'); $token = $this->post('token'); if ($uid < 0 || !$token) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE)); @@ -48,19 +47,29 @@ class index extends publicBase { $user_info = json_decode($user_info, true); if (empty($user_info)) header('Location: /index/login'); + $this->view['uid'] = $user_info['uid']; + $this->view['token'] = $user_info['token']; + $is_all = $this->get('is_all') + 0; $name = trim($this->get('name')); $condition = array(); - if ($name) $condition['name'] = $name; - if (!$is_all) $condition['uid'] = 0; + $url = "/index/home"; + if ($name) { + $condition['name'] = $name; + $url .= "/name/{$name}"; + } + if (!$is_all) { + $condition['uid'] = 0; + $url .= "/is_all/{$is_all}"; + } $total = $mformula->getFormulaTotal($condition); // 分页 $page = new Page(); $page->setTotalnum($total); - $page->setUrl('/index/home/page/'); + $page->setUrl($url . '/page/'); $curpage = $this->get('page') > 0 ? $this->get('page') : 1; $page->setPage($curpage); diff --git a/view/templates/index/formula_add.html b/view/templates/index/formula_add.html index 4f6e124..0e65183 100644 --- a/view/templates/index/formula_add.html +++ b/view/templates/index/formula_add.html @@ -88,7 +88,7 @@
- +
 
@@ -142,11 +142,13 @@ const form = document.getElementById('prescription-form'); const formData = new FormData(form); - const uid = 'admin'; + const uid = {/literal}{$uid}{literal}; + const token = {/literal}'{$token}'{literal}; const data = { id: formData.get('id'), uid: uid, + token: token, name: formData.get('name'), source: formData.get('source'), method: formData.get('method'), @@ -168,42 +170,26 @@ }); data.herbs = JSON.stringify(herbs); - - if (data.id.length > 0) { - $.ajax({ - url: 'ajax_update_formula', // 替换为你的服务器端处理文件 - type: 'POST', - data: data, - dataType: 'json', - success: function (response) { - alert(response.info); - if (response.status == true) { - window.location.reload(); - } - }, - error: function (xhr, status, error) { - console.error('错误:', response); - alert('提交失败,请重试。'); + $.ajax({ + url: '/ajax_save_formula', // 替换为你的服务器端处理文件 + type: 'POST', + data: data, + dataType: 'json', + success: function (response) { + alert(response.info); + if (response.status == true) { + window.location.href = "/index/home" } - }); - } else { - $.ajax({ - url: 'ajax_save_formula', // 替换为你的服务器端处理文件 - type: 'POST', - data: data, - dataType: 'json', - success: function (response) { - alert(response.info); - if (response.status == true) { - window.location.href = "/index/home" - } - }, - error: function (xhr, status, error) { - console.error('错误:', response); - alert('提交失败,请重试。'); + + if(response.data.code == 40002){ + window.location.href = "/index/login"; } - }); - } + }, + error: function (xhr, status, error) { + console.error('错误:', response); + alert('提交失败,请重试。'); + } + }); } diff --git a/view/templates/index/home.html b/view/templates/index/home.html index a02a84c..e339394 100644 --- a/view/templates/index/home.html +++ b/view/templates/index/home.html @@ -72,24 +72,35 @@ - - - - - - + + + + + + + {foreach from=$list key=key item=item} - + - - + + + {/foreach} @@ -118,31 +129,44 @@ function to_add(){ location.href = '/index/formula_add'; } - - -{/literal} - - - -{literal} - - - - {/literal} + diff --git a/view/templates/index/login.html b/view/templates/index/login.html new file mode 100644 index 0000000..250abce --- /dev/null +++ b/view/templates/index/login.html @@ -0,0 +1,84 @@ + + + + + + + + + 登录 + + + + + +
+
+
+
+ + +
 
+ +
+ + +
+ +
 
+ +
+ + +
+ +
 
+ +
+ + + +
+ + +
+ +
+ +
+ +{literal} + + +{/literal} + + +
ID录方者药方名称药方来源使用次数操作ID录方者uid药方名称药方来源使用次数药方详情操作
{$item.id}{$item.uid}{if $item.uid eq 0}-{else}{$item.uid}{/if} {$item.name} {$item.source} {$item.use_num}{if $item.uid == 0}编辑{/if} + {foreach from=$item.formula item=value} + {$value.name} {$value.num_str} + {/foreach} + + {if $item.uid == 0} + 编辑 + 删除 + {/if} +