Browse Source

录方后台

pull/1/head
pengda 8 months ago
parent
commit
01e1c68190
  1. 17
      control/index.php
  2. 32
      view/templates/index/formula_add.html
  3. 82
      view/templates/index/home.html
  4. 84
      view/templates/index/login.html

17
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);

32
view/templates/index/formula_add.html

@ -88,7 +88,7 @@
<div class="row" id="" style="position:relative;">
<label>&nbsp;</label>
<button class="button primary next submitlock" id="submitbtn" onclick="check_submit()"><span class="tdesc_text" style="color:white;">提交</span></button>
<button class="button primary next submitlock" id="submitbtn" onclick="submitForm()"><span class="tdesc_text" style="color:white;">提交</span></button>
</div>
<div class="row">&nbsp;</div>
@ -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,27 +170,8 @@
});
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('提交失败,请重试。');
}
});
} else {
$.ajax({
url: 'ajax_save_formula', // 替换为你的服务器端处理文件
url: '/ajax_save_formula', // 替换为你的服务器端处理文件
type: 'POST',
data: data,
dataType: 'json',
@ -197,6 +180,10 @@
if (response.status == true) {
window.location.href = "/index/home"
}
if(response.data.code == 40002){
window.location.href = "/index/login";
}
},
error: function (xhr, status, error) {
console.error('错误:', response);
@ -204,7 +191,6 @@
}
});
}
}
</script>
<style>

82
view/templates/index/home.html

@ -72,24 +72,35 @@
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>ID</th>
<th>录方者</th>
<th>药方名称</th>
<th>药方来源</th>
<th>使用次数</th>
<th>操作</th>
<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>{$item.uid}</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>{/if}</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>
@ -118,31 +129,44 @@
function to_add(){
location.href = '/index/formula_add';
}
</script>
<style>
</style>
{/literal}
<!-- UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0 -->
function to_delete(id) {
if (!confirm("确定要删除吗?")) {
console.log("用户选择了确认");
return false;
}
{literal}
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 lt IE 7]>
<![endif]-->
<!--
<script type="text/javascript">
/*Load jQuery if not already loaded*/ if(typeof jQuery == 'undefined'){ document.write("<script type=\"text/javascript\" src=\"" + ('https:' == document.location.protocol ? 'https://' : 'http://')+ "ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></"+"script>"); var __noconflict = true; }
var IE6UPDATE_OPTIONS = {
url: "http://blog.dnspod.cn/2010/04/ie6-must-die/",
message: "DNSPod 新版已经完全取消对微软 Internet Explorer 6.0 浏览器的支持,IE6 用户无法正常使用 DNSPod。请升级您的IE6浏览器至IE8,或者升级至Chrome、火狐、Safari等其他浏览器。",
icons_path: "https://statics.dnspod.cn/zhanjiang/images/ie6update/"
if(response.data.code == 40002){
window.location.href = "/index/login";
}
},
error: function (xhr, status, error) {
console.error('错误:', response);
alert('提交失败,请重试。');
}
});
}
</script>
<script type="text/javascript" src="https://statics.dnspod.cn/zhanjiang/javascripts/ie6update.v2.js"></script>
-->
<!--[if lt IE 7]>
<![endif]-->
{/literal}
</body>
</html>

84
view/templates/index/login.html

@ -0,0 +1,84 @@
<!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">
<form id="prescription-form" onsubmit="submitForm(event)">
<input id="id" name="id" type="hidden" value="{$data.id}">
<div class="row">&nbsp;</div>
<div class="row">
<label for="name">用户名<font color='red'>*</font></label>
<input type="text" id="name" name="name" maxlength="" style="width:280px" value="{$data.name}">
</div>
<div class="row">&nbsp;</div>
<div class="row">
<label for="source">密码<font color='red'>*</font></label>
<input type="text" id="password" name="password" maxlength="" style="width:280px"
value="{$data.source}">
</div>
<div class="row">&nbsp;</div>
<div class="row" id="" style="position:relative;">
<label>&nbsp;</label>
<button class="button primary next submitlock" id="submitbtn" onclick="check_submit()"><span class="tdesc_text" style="color:white;">提交</span></button>
</div>
</form>
</section><!--end of main section-->
</div><!--end of container-->
</div><!--end of #page-->
{literal}
<script type="text/javascript">
function submitForm(e) {
e.preventDefault(); // 阻止默认表单提交
const form = document.getElementById('prescription-form');
const formData = new FormData(form);
const name = formData.get('name');
const password = formData.get('password');
location.href = "/index/login/name/" + name + "/password/" + password;
}
</script>
<style>
#main {
width: 600px;
height: 300px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -300px;
margin-top: -150px;
}
#prescription-form {
margin: 0 auto;
}
</style>
{/literal}
</body>
</html>
Loading…
Cancel
Save