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 @@
- ID |
- 录方者 |
- 药方名称 |
- 药方来源 |
- 使用次数 |
- 操作 |
+ ID |
+ 录方者uid |
+ 药方名称 |
+ 药方来源 |
+ 使用次数 |
+ 药方详情 |
+ 操作 |
{foreach from=$list key=key item=item}
{$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}
+ |
{/foreach}
@@ -118,31 +129,44 @@
function to_add(){
location.href = '/index/formula_add';
}
-
-
-{/literal}
-
-
-
-{literal}
-
-
-
-
{/literal}
+