From 6fe44956401372297e687f7c8424167642b8103b Mon Sep 17 00:00:00 2001
From: pengda <10266652509@qq.com>
Date: Mon, 23 Sep 2024 09:51:53 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 control/index.php                      |  10 +-
 view/templates/index/formula_list.html | 172 +++++++++++++++++++++++++++++++++
 view/templates/index/home.html         | 172 ---------------------------------
 view/templates/index/login.html        |   3 +-
 4 files changed, 181 insertions(+), 176 deletions(-)
 create mode 100644 view/templates/index/formula_list.html
 delete mode 100644 view/templates/index/home.html

diff --git a/control/index.php b/control/index.php
index d32bdcd..c529cc9 100644
--- a/control/index.php
+++ b/control/index.php
@@ -25,6 +25,10 @@ class index extends publicBase {
         return $uinfo;
     }
 
+    public function home() {
+        exit;
+    }
+
     public function login() {
         $name = trim($this->get('name'));
         $password = trim($this->get('password'));
@@ -36,11 +40,11 @@ class index extends publicBase {
             $res = $m_user->checkAdminLogin($name, $password);
             if (!$res) $this->show_message($m_user->getError(), '/index/login');
 
-            header('Location: /index/home');
+            header('Location: /index/formula_list');
         }
     }
 
-    public function home() {
+    public function formula_list() {
         if ($_COOKIE['uid'] !== 0 && empty($_COOKIE['token'])) header('Location: /index/login');
 
         $this->view['uid'] = $_COOKIE['uid'];
@@ -50,7 +54,7 @@ class index extends publicBase {
         $name = trim($this->get('name'));
 
         $condition = array();
-        $url = "/index/home/is_all/{$is_all}";
+        $url = "/index/formula_list/is_all/{$is_all}";
         if ($name) {
             $condition['name'] = $name;
             $url .= "/name/{$name}";
diff --git a/view/templates/index/formula_list.html b/view/templates/index/formula_list.html
new file mode 100644
index 0000000..e562766
--- /dev/null
+++ b/view/templates/index/formula_list.html
@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html class="no-js" lang="zh-CN">
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <script type="text/javascript" src="{$smarty.const.CSS_URL}/js/jquery-1.8.1.min.js"></script>
+    <script type="text/javascript" src="{$smarty.const.CSS_URL}/js/jquery.form.js"></script>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <title>药方列表</title>
+    <meta name="viewport" content="width=device-width,initial-scale=1">
+    <link href="{$smarty.const.CSS_URL}/css/global.css?v={$smarty.const.CSS_JS_VERSION}" media="screen" rel="stylesheet" type="text/css">
+</head>
+<body>
+
+<div id="page">
+    <div class="container">
+        <section id="main" style="width: 100%;">
+            <div id="main-content">
+                <div class="entry">
+                    <div class="modal-body">
+                        <table class="table table-striped table-bordered table-condensed">
+                            <tbody class='js-bundle-record-list'>
+                            <tr>
+                                <td>
+                                    &nbsp;全部药方:&nbsp;
+                                    <select id="is_all">
+                                        <option value="0" {if $smarty.get.is_all==0}selected{/if}>否</option>
+                                        <option value="1" {if $smarty.get.is_all==1}selected{/if}>是</option>
+                                    </select>
+
+                                    &nbsp;药方名称:&nbsp;
+                                    <input type="text" id='name' value="{$smarty.get.name}">
+
+                                    <button onclick="searchList();" class="button primary next" id="btnVer">搜索</button>
+                                </td>
+                            </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+
+                <div class="record-control">
+                    <div class="flash-message"></div>
+                    <ul class="tabs">
+                        <li class="active"><a href="javascript:;">药方列表</a></li>
+                        <div style="display:inline-block;float: right;">
+                            <button class="button primary next" onclick="to_add()">添加药方</button>
+                        </div>
+                    </ul>
+                </div>
+            </div>
+
+            <div class="entry">
+                <div class="modal-body">
+                    {if count($page_list) > 1}
+                    <div class="modal-body">
+
+                        {if isset($prev_page)}
+                        <a href="{$prev_page}">上一页</a>
+                        {/if}
+
+                        {foreach from=$page_list key=key item=item}
+                        <a href="{$item.url}">{if $key+1 eq $curpage}<b>{/if}{$item.page}{if $key+1 eq $curpage}</b>{/if}</a>
+                        {/foreach}
+
+                        {if isset($post_page)}
+                        <a href="{$post_page}">下一页</a>
+                        {/if}
+
+                    </div>
+                    {/if}
+                    <table class="table table-striped table-bordered table-condensed">
+                        <thead>
+                        <tr>
+                            <th width="50">ID</th>
+                            <th width="50">录方者uid</th>
+                            <th width="200">药方名称</th>
+                            <th width="200">药方来源</th>
+                            <th width="50">使用次数</th>
+                            <th width="200">药方详情</th>
+                            <th width="50">操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {foreach from=$list key=key item=item}
+                        <tr>
+                            <td>{$item.id}</td>
+                            <td>{if $item.uid eq 0}-{else}{$item.uid}{/if}</td>
+                            <td>{$item.name}</td>
+                            <td>{$item.source}</td>
+                            <td>{$item.use_num}</td>
+                            <td style="display: flex;flex-wrap: wrap">
+                                {foreach from=$item.formula item=value}
+                                    <span style="margin-right: 20px">{$value.name}   {$value.num_str}</span>
+                                {/foreach}
+                            </td>
+
+                            <td>
+                                {if $item.uid == 0}
+                                <a href="/index/formula_add/id/{$item.id}">编辑</a>
+                                <a href="javascript:;" onclick="to_delete({$item.id})">删除</a>
+                                {/if}
+                            </td>
+                        </tr>
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+
+            </div></section><!--end of main section-->
+
+    </div><!--end of container-->
+
+</div><!--end of #page-->
+
+{literal}
+<script type="text/javascript">
+    function searchList() {
+        var is_all = $('#is_all').val();
+        var name = $.trim($('#name').val());
+
+        var url = '/index/home';
+
+        if(is_all > 0) url += '/is_all/' + is_all;
+        if(name) url += '/name/' + name;
+
+        location.href = url;
+    }
+    function to_add(){
+        location.href = '/index/formula_add';
+    }
+    function to_delete(id) {
+        if (!confirm("确定要删除吗?")) {
+            console.log("用户选择了确认");
+            return false;
+        }
+
+        const uid = {/literal}{$uid}{literal};
+        const token = {/literal}'{$token}'{literal};
+
+        const data = {
+            id: id,
+            uid:  uid,
+            token:  token,
+        };
+
+        $.ajax({
+            url: '/ajax_delete_formula', // 替换为你的服务器端处理文件
+            type: 'POST',
+            data: data,
+            dataType: 'json',
+            success: function (response) {
+                alert(response.info);
+                if (response.status == true) {
+                    // window.location.reload();
+                }
+
+                if(response.data.code == 40002){
+                    window.location.href = "/index/login";
+                }
+            },
+            error: function (xhr, status, error) {
+                console.error('错误:', response);
+                alert('提交失败,请重试。');
+            }
+        });
+    }
+</script>
+{/literal}
+
+</body>
+</html>
diff --git a/view/templates/index/home.html b/view/templates/index/home.html
deleted file mode 100644
index e562766..0000000
--- a/view/templates/index/home.html
+++ /dev/null
@@ -1,172 +0,0 @@
-<!DOCTYPE html>
-<html class="no-js" lang="zh-CN">
-<head>
-    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <script type="text/javascript" src="{$smarty.const.CSS_URL}/js/jquery-1.8.1.min.js"></script>
-    <script type="text/javascript" src="{$smarty.const.CSS_URL}/js/jquery.form.js"></script>
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <title>药方列表</title>
-    <meta name="viewport" content="width=device-width,initial-scale=1">
-    <link href="{$smarty.const.CSS_URL}/css/global.css?v={$smarty.const.CSS_JS_VERSION}" media="screen" rel="stylesheet" type="text/css">
-</head>
-<body>
-
-<div id="page">
-    <div class="container">
-        <section id="main" style="width: 100%;">
-            <div id="main-content">
-                <div class="entry">
-                    <div class="modal-body">
-                        <table class="table table-striped table-bordered table-condensed">
-                            <tbody class='js-bundle-record-list'>
-                            <tr>
-                                <td>
-                                    &nbsp;全部药方:&nbsp;
-                                    <select id="is_all">
-                                        <option value="0" {if $smarty.get.is_all==0}selected{/if}>否</option>
-                                        <option value="1" {if $smarty.get.is_all==1}selected{/if}>是</option>
-                                    </select>
-
-                                    &nbsp;药方名称:&nbsp;
-                                    <input type="text" id='name' value="{$smarty.get.name}">
-
-                                    <button onclick="searchList();" class="button primary next" id="btnVer">搜索</button>
-                                </td>
-                            </tr>
-                            </tbody>
-                        </table>
-                    </div>
-                </div>
-
-                <div class="record-control">
-                    <div class="flash-message"></div>
-                    <ul class="tabs">
-                        <li class="active"><a href="javascript:;">药方列表</a></li>
-                        <div style="display:inline-block;float: right;">
-                            <button class="button primary next" onclick="to_add()">添加药方</button>
-                        </div>
-                    </ul>
-                </div>
-            </div>
-
-            <div class="entry">
-                <div class="modal-body">
-                    {if count($page_list) > 1}
-                    <div class="modal-body">
-
-                        {if isset($prev_page)}
-                        <a href="{$prev_page}">上一页</a>
-                        {/if}
-
-                        {foreach from=$page_list key=key item=item}
-                        <a href="{$item.url}">{if $key+1 eq $curpage}<b>{/if}{$item.page}{if $key+1 eq $curpage}</b>{/if}</a>
-                        {/foreach}
-
-                        {if isset($post_page)}
-                        <a href="{$post_page}">下一页</a>
-                        {/if}
-
-                    </div>
-                    {/if}
-                    <table class="table table-striped table-bordered table-condensed">
-                        <thead>
-                        <tr>
-                            <th width="50">ID</th>
-                            <th width="50">录方者uid</th>
-                            <th width="200">药方名称</th>
-                            <th width="200">药方来源</th>
-                            <th width="50">使用次数</th>
-                            <th width="200">药方详情</th>
-                            <th width="50">操作</th>
-                        </tr>
-                        </thead>
-                        <tbody>
-                        {foreach from=$list key=key item=item}
-                        <tr>
-                            <td>{$item.id}</td>
-                            <td>{if $item.uid eq 0}-{else}{$item.uid}{/if}</td>
-                            <td>{$item.name}</td>
-                            <td>{$item.source}</td>
-                            <td>{$item.use_num}</td>
-                            <td style="display: flex;flex-wrap: wrap">
-                                {foreach from=$item.formula item=value}
-                                    <span style="margin-right: 20px">{$value.name}   {$value.num_str}</span>
-                                {/foreach}
-                            </td>
-
-                            <td>
-                                {if $item.uid == 0}
-                                <a href="/index/formula_add/id/{$item.id}">编辑</a>
-                                <a href="javascript:;" onclick="to_delete({$item.id})">删除</a>
-                                {/if}
-                            </td>
-                        </tr>
-                        {/foreach}
-                        </tbody>
-                    </table>
-                </div>
-
-            </div></section><!--end of main section-->
-
-    </div><!--end of container-->
-
-</div><!--end of #page-->
-
-{literal}
-<script type="text/javascript">
-    function searchList() {
-        var is_all = $('#is_all').val();
-        var name = $.trim($('#name').val());
-
-        var url = '/index/home';
-
-        if(is_all > 0) url += '/is_all/' + is_all;
-        if(name) url += '/name/' + name;
-
-        location.href = url;
-    }
-    function to_add(){
-        location.href = '/index/formula_add';
-    }
-    function to_delete(id) {
-        if (!confirm("确定要删除吗?")) {
-            console.log("用户选择了确认");
-            return false;
-        }
-
-        const uid = {/literal}{$uid}{literal};
-        const token = {/literal}'{$token}'{literal};
-
-        const data = {
-            id: id,
-            uid:  uid,
-            token:  token,
-        };
-
-        $.ajax({
-            url: '/ajax_delete_formula', // 替换为你的服务器端处理文件
-            type: 'POST',
-            data: data,
-            dataType: 'json',
-            success: function (response) {
-                alert(response.info);
-                if (response.status == true) {
-                    // window.location.reload();
-                }
-
-                if(response.data.code == 40002){
-                    window.location.href = "/index/login";
-                }
-            },
-            error: function (xhr, status, error) {
-                console.error('错误:', response);
-                alert('提交失败,请重试。');
-            }
-        });
-    }
-</script>
-{/literal}
-
-</body>
-</html>
diff --git a/view/templates/index/login.html b/view/templates/index/login.html
index 137e29a..07be775 100644
--- a/view/templates/index/login.html
+++ b/view/templates/index/login.html
@@ -22,7 +22,7 @@
             <div class="row">&nbsp;</div>
 
             <div class="row">
-                <label for="name">用户名<font color='red'>*</font>:</label>
+                <label for="name">账号<font color='red'>*</font>:</label>
                 <input type="text" id="name" name="name" maxlength="" style="width:280px" value="{$data.name}">
             </div>
 
@@ -76,6 +76,7 @@
 
     #prescription-form label {
         text-align: center;
+        width: 45px;
     }
 </style>
 {/literal}