Browse Source

录方列表

pull/1/head
pengda 8 months ago
parent
commit
3264b6ec0d
  1. 6
      config/define.php
  2. 75
      control/index.php
  3. 96
      model/mFormula.php
  4. 86
      model/mPage.php
  5. 6993
      view/css/global.css
  6. 223
      view/templates/index/formula_add.html
  7. 351
      view/templates/index/home.html

6
config/define.php

@ -11,7 +11,7 @@
date_default_timezone_set("Asia/Shanghai");
define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/');
define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/tcm/');
define('LOG_TRACK_SAVE_PATH', LOG_PATH_BASE.'track/%s/%s.log'); // 监控日志的路径,如2014-02-14/1(检测类型).log
define('TCM_DOMAIN', 'http://tcm.pengda.checkcopy.com');
@ -72,6 +72,9 @@
$GLOBALS['weight_list'] = array(
"汉" => array(
'少许'=>'',
'少量'=>'',
'等分'=>'',
'铢'=>0.65,
'厘'=>0.156,
'分'=>1.56,
@ -151,7 +154,6 @@
'茎'=>array(
'葱白'=>0,
),
'少许'=>'',
),
);

75
control/index.php

@ -5,10 +5,14 @@
*/
include_once(dirname(dirname(__FILE__)) . "/library/publicBase.php");
include_once(SERVER_ROOT . "/model/mPage.php");
class index extends publicBase {
private function _check_login() {
if ($this->post('uid') == 'admin') {
return array('uid' => 0);
}
$uid = $this->post('uid');
$token = $this->post('token');
if (empty($uid) || empty($token)) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE));
@ -25,12 +29,44 @@ class index extends publicBase {
}
public function home() {
$id = $this->get('id');
$mformula = new mFormula();
$data = $mformula->getFormulaInfo($id);
$this->view['data'] = $data;
$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;
$total = $mformula->getAllFormulaTotal($condition);
// 分页
$page = new Page();
$page->setTotalnum($total);
$page->setUrl('/index/home/page/');
$curpage = $this->get('page') > 0 ? $this->get('page') : 1;
$page->setPage($curpage);
$this->view['page_list'] = $page->getPageList();
$this->view['curpage'] = $curpage;
if ($curpage > 1) $this->view['prev_page'] = $page->url . ($curpage - 1); //上一页连接
if ($curpage < $page->totalpage) $this->view['post_page'] = $page->url . ($curpage + 1); //下一页连接
//只取出当前页显示
$list = $mformula->getAllFormulaList($condition, $curpage, $page->pagesize);
$this->view['list'] = $list;
}
public function formula_add() {
$id = $this->get('id');
if ($id) {
$mformula = new mFormula();
$data = $mformula->getFormulaInfo($id, 0);
$this->view['data'] = $data;
}
}
public function ajax_save_formula() {
@ -116,8 +152,8 @@ class index extends publicBase {
$page_size = $this->post('page_size') ? $this->post('page_size') : 20;
$mformula = new mFormula();
$list = $mformula->getFormulaList($uinfo['uid'], $page_num, $page_size, $content);
$total = $mformula->getFormulaTotal($uinfo['uid'], $content);
$list = $mformula->getSearchFormulaList($uinfo['uid'], $page_num, $page_size, $content);
$total = $mformula->getSearchFormulaTotal($uinfo['uid'], $content);
$rdata = array(
'total' => $total,
@ -162,7 +198,7 @@ class index extends publicBase {
$m_user_case = new mUserCase();
//生成唯一id 防止重复请求
$request_id = md5($uinfo['uid'] . $formula_id . $data['name'] . $data['patient_name']);
$request_id = md5($uinfo['uid'] . $formula_id . $data['name'] . $data['patient_name'] . $data['prescribe_herb']);
$request_times = $m_user_case->requestLimit(sprintf(_QR_REQUEST_LIMIT, $request_id), 1, 60);
if (!$request_times) $this->ajax_json(false, $m_user_case->getError());
@ -184,7 +220,7 @@ class index extends publicBase {
);
$m_user_case = new mUserCase();
$res = $m_user_case->updateUserCase($uinfo['uid'], $id, $data);
$res = $m_user_case->saveUserCase($uinfo['uid'], $id, $data);
if (!$res) $this->ajax_json(false, $m_user_case->getError());
$this->ajax_json(true, '保存成功', array('id' => $id));
@ -274,16 +310,23 @@ class index extends publicBase {
$uinfo = $this->_check_login();
$id = $this->post('id') + 0;
if ($id) {
//导出单个医案
if ($id > 0) {
$post_url = USER_CASE_HTML_URL;
$data = array(
"uid" => $uinfo['uid'],
"id" => $id,
);
} else {
}
//导出全部医案
if ($id == 0) {
$post_url = USER_CASE_LIST_HTML_URL;
$data = array(
"uid" => $uinfo['uid'],
"start_date" => $this->post('start_date'),
"end_date" => $this->post('end_date'),
);
}
@ -311,14 +354,20 @@ class index extends publicBase {
$uid = $this->post('uid') + 0;
if (empty($uid)) $this->ajax_json(false, '参数错误');
$start_date = $this->post('start_date');
if (empty($start_date)) $this->ajax_json(false, '请选择导出开始时间');
$end_date = $this->post('end_date');
if (empty($end_date)) $this->ajax_json(false, '请选择导出结束时间');
$page_num = $this->post('page_num') ? $this->post('page_num') : 1;
$page_size = $this->post('page_size') ? $this->post('page_size') : 500;
$m_user_case = new mUserCase();
$data = $m_user_case->getUserCaseListPdfInfo($uid, $page_num, $page_size);
$data = $m_user_case->getUserCaseListPdfInfo($uid, $page_num, $page_size, $start_date, $end_date);
if (!$data) $this->ajax_json(false, $m_user_case->getError());
$this->view['data'] = $data['user_case'];
$this->view['data'] = $data;
$this->setViewTpl('index/export_pdf.html');
}
@ -331,7 +380,7 @@ class index extends publicBase {
$data = $m_user_case->getUserCasePdfInfo($uid, $id);
if (!$data) $this->ajax_json(false, $m_user_case->getError());
$this->view['data'] = $data['user_case'];
$this->view['data'] = array($data);
$this->setViewTpl('index/export_pdf.html');
}
}

96
model/mFormula.php

@ -22,6 +22,74 @@ class mFormula extends mBase {
$this->formula_use_log_tbl = 'tcm_formula_use_log';
}
public function getFormulaByCondition($condition, $page_num, $page_size) {
$offset = ($page_num - 1) * $page_size;
$where = "1=1";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
if ($key == 'name') {
$where .= " and s.{$key} like '%{$val}%'";
} else {
$where .= " and s.{$key}={$val}";
}
}
}
$sql = "select s.*,COALESCE(SUM(u.use_num), 0) AS use_num from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id where {$where} group by s.id order by use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
return $this->obj->execute($sql, true, true);
}
public function getAllFormulaList($condition, $page_num, $page_size) {
$data = $this->getFormulaByCondition($condition, $page_num, $page_size);
$formula_ids = array_column($data, 'id');
$formula_arr = $this->getFormulaHerbData($formula_ids);
foreach ($data as &$da) {
if (isset($formula_arr[$da['id']])) {
$da['formula'] = $formula_arr[$da['id']];
}
$original = array();
if (!empty($da['original'])) {
$original = json_decode($da['original'], true);
$original = array_column($original, null, 'name');
}
unset($da['original']);
foreach ($da['formula'] as &$v) {
//药方克重为0 去查询原方
if (isset($original[$v['name']]) && $v['num'] == 0) {
$v['num_str'] = $original[$v['name']]['num'];
//$v['desc'] = $original[$v['name']]['desc'];
}
}
}
return $data;
}
public function getAllFormulaTotal($condition) {
$where = "1=1";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
if ($key == 'name') {
$where .= " and {$key} like '%{$val}%'";
} else {
$where .= " and {$key}={$val}";
}
}
}
$sql = "select count(*) as count from $this->tbl where {$where}";
$res = $this->obj->execute($sql, true, true);
$num = $res[0]['count'];
return $num;
}
public function createFormula($uid, $name, $source, $method, $herbs) {
if (empty($name)) {
$this->setError('药方名称不能为空');
@ -149,13 +217,11 @@ class mFormula extends mBase {
$herb_ids = array();
foreach ($herbs as $key => $item) {
$name = trim($item['name']);
$num = trim($item['num']);
//自拟药方 克重不能为0
if ($uid != 0 && $num == 0) {
if ($uid > 0 && $num == 0) {
$this->setError("{$name}克重不能为零");
return false;
}
@ -378,8 +444,8 @@ class mFormula extends mBase {
$this->setError('查询不到此药方');
return false;
}
//uid==0 不判断药方归属
if ($uid != 0 && $formula['uid'] != $uid) {
//自拟药方药方归属
if ($formula['uid'] != $uid) {
$this->setError('这不是你的药方');
return false;
}
@ -407,19 +473,16 @@ class mFormula extends mBase {
public function getFormulaByName($uid, $page_num, $page_size, $name) {
$offset = ($page_num - 1) * $page_size;
$where = "1=1";
if ($uid != 0) {
$where .= " and s.uid in (0,{$uid})";
}
$where = $uid > 0 ? "s.uid in (0,{$uid})" : "s.uid=0";
if ($name) {
$where .= " and s.`name` like '%{$name}%'";
}
$sql = "select s.id,s.uid,s.name,s.source,s.original,s.method,u.use_num,s.sort from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id where {$where} order by u.use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
$sql = "select s.id,s.uid,s.name,s.source,s.original,s.method,COALESCE(u.use_num, 0) AS use_num,s.sort from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id and u.uid={$uid} where {$where} order by use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
return $this->obj->execute($sql, true, true);
}
public function getFormulaList($uid, $page_num, $page_size, $name = '') {
public function getSearchFormulaList($uid, $page_num, $page_size, $name = '') {
$data = $this->getFormulaByName($uid, $page_num, $page_size, $name);
$formula_ids = array_column($data, 'id');
@ -470,11 +533,8 @@ class mFormula extends mBase {
return $formula_arr;
}
public function getFormulaTotal($uid, $name = '') {
$where = "1=1";
if ($uid != 0) {
$where .= " and s.uid in (0,{$uid})";
}
public function getSearchFormulaTotal($uid, $name = '') {
$where = $uid > 0 ? "uid in (0,{$uid})" : "uid=0";
if ($name) {
$where .= " and `name` like '%{$name}%'";
}
@ -494,8 +554,8 @@ class mFormula extends mBase {
return false;
}
//uid==0 不判断药方归属
if ($uid != 0 && $formula['uid'] > 0 && $formula['uid'] != $uid) {
//自拟药方 判断药方归属
if ($formula['uid'] > 0 && $formula['uid'] != $uid) {
$this->setError('这不是你的药方');
return false;
}

86
model/mPage.php

@ -0,0 +1,86 @@
<?php
//include_once(dirname(dirname(__FILE__))."/publicBase.php");
class Page extends publicBase {
public $totalnum; // 总记录数[必填],例:$page->setTotalnum(100);
public $page; // 当前页码[必填]
public $url; // 分页URL[必填]
public $pagesize=100; // 每页记录数
public $viewpagenum=7; // 每页看到的页码数
public $virtualpage='...'; // 省略或跨越页码
public $totalpage;
//mysql表中数据量过多时采用的分页改造
public $first_page_url; //点击”首页“跳转链接
public $end_page_url; //点击”尾页“跳转链接
public $prev_page_url; //点击”上一页“跳转链接
public $next_page_url; //点击”下一页“跳转链接
public $endpage=false; //跳转到尾页标识
public $jump_to_page_url; //跳转到某一页链接
public $maxid; //点击上一页时 当前页面最大id
public $minid; //点击下一页时 当前页面最小id
/*
* $pageobj = new Page();
$pageobj->setTotalnum($totalnum);
$pageobj->setPage($page);
$pageobj->setPagesize($pagesize);
$pageobj->setUrl('/comment/black/page/');
$plist = $pageobj->getPageList();
*/
/*
listnum 显示页码数, 默认展示7页
*/
public function getPageList() {
$pagelist = array(); // 构造的翻页数据
$begin = $last = array(); // 开始,结尾数据
$totalpage = ceil($this->totalnum/$this->pagesize); // 总页数
$this->totalpage = $totalpage;
$middle_page = ceil($this->viewpagenum/2); // 每页中间页码值
if($this->page > $middle_page && $totalpage > $this->viewpagenum) { // 开头有...时
$begin[] = array('page' => 1, 'url' => $this->url . '1');
$begin[] = array('page' => $this->virtualpage, 'url' => '');
$firstpage = $totalpage-$this->viewpagenum+2;
$endpage = $totalpage;
if($totalpage-$this->page > $middle_page) { // 结尾也有...时
$last[$totalpage-1] = array('page' => $this->virtualpage, 'url'=>'');
$last[$totalpage] = array('page' => $totalpage, 'url' => $this->url . $totalpage);
$firstpage = $this->page-$middle_page+2;
$endpage = $this->page+$middle_page-2;
}
} elseif($totalpage-$this->page > $middle_page && $totalpage > $this->viewpagenum) { // 只有结尾的...时
$last[$totalpage-1] = array('page' => $this->virtualpage, 'url' => '');
$last[$totalpage] = array('page' => $totalpage, 'url' => $this->url . $totalpage);
$firstpage = 1;
$endpage = $this->viewpagenum-1;
} else { // 没有...时
$firstpage = 1;
$endpage = $totalpage;
}
// 中间页码数据
for ($i=$firstpage; $i<=$endpage; $i++) {
$pagelist[$i-1]['page'] = $i;
$pagelist[$i-1]['url'] = $this->url . $i;
}
return $begin + $pagelist + $last;
}
public function getLimitInfo() {
$this->first_page_url = $this->url."/page/1"; //首页链接
$this->end_page_url = $this->url."/end_page/1"; //尾页链接
$this->jump_to_page_url = $this->url."/jump_to_page"; //跳转到某一页
if($this->totalnum>0) $this->page = ceil($this->totalnum/$this->pagesize);
if ($this->page > 1 || $this->endpage) $this->prev_page_url = $this->url.'/page/'.($this->page-1).'/maxid/'.$this->maxid; //上一页连接
if (!$this->endpage) $this->next_page_url = $this->url.'/page/'.($this->page+1).'/minid/'.$this->minid; //下一页连接
}
}

6993
view/css/global.css

File diff suppressed because it is too large

223
view/templates/index/formula_add.html

@ -0,0 +1,223 @@
<!DOCTYPE html>
<html lang="en">
<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">
<div id="main-content">
<div class="record-control">
<div class="header">
<span style="font-size:14px;padding:5px">添加药方</span>
<div class="row">&nbsp;</div>
<div class="flash-message"></div>
<ul class="tabs"><li></li></ul>
</div>
</div>
<div id="domain-list">
<div class="entry">
<div class="modal-body">
<div class="wizard-container"><div>
<div class="inputs">
<div id="form_area">
<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="source" name="source" maxlength="" style="width:280px" value="{$data.source}">
</div>
<div class="row">&nbsp;</div>
<div class="row">
<label for="method">用法<font color='red'></font></label>
<input type="text" id="method" name="method" maxlength="" style="width:280px" value="{$data.method}">
<span id="author_limit"></span>
</div>
<div class="row">&nbsp;</div>
<div class="row" style="position:relative;">
<label>药材<font color='red'>*</font></label>
<button class="add-button" type="button" onclick="addIngredient()">+</button>
</div>
<div id="ingredient-list" class="row">
{foreach from=$data.formula key=key item=item}
<div class="row">
<label>&nbsp;</label>
<div class="herb_input">
<input type="text" name="herb_name[]" value="{$item.name}" placeholder="药材名" required/>
<input type="text" name="herb_num[]" value="{$item.num_str}"
placeholder="用量" required/>
<!-- /-->
<!-- <input style="width: 80px" type="text" value="{$item.num}克" disabled/>-->
<!-- <input type="text" name="herb_desc[]" value="{$item.desc}" placeholder="说明"/>-->
<button class="" type="button" onclick="removeIngredient(this)">X</button>
</div>
</div>
{/foreach}
</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>
<div class="row">&nbsp;</div>
</form>
</div>
</div>
</div>
</div></div>
<div style="display: none;" id="formtips">
<div class="alert-message block-message info" style="color:red;"></div>
</div>
</div>
<!--end of a domain entry-->
</div>
<!-- 批量上传 <div id="onetickupload"></div> -->
</div>
</div></section>
<!--end of main section-->
</div><!--end of container-->
</div><!--end of #page-->
{literal}
<script type="text/javascript">
// 动态添加药材输入字段
function addIngredient() {
const ingredientList = document.getElementById('ingredient-list');
const ingredientDiv = document.createElement('div');
ingredientDiv.classList.add('row');
ingredientDiv.innerHTML = `
<label>&nbsp;</label>
<div class="herb_input">
<input type="text" name="herb_name[]" placeholder="药材名" required />
<input type="text" name="herb_num[]" placeholder="药量" required />
<!-- <input type="text" name="herb_desc[]" placeholder="说明"/>-->
<button class="" type="button" onclick="removeIngredient(this)">X</button>
</div>
`;
ingredientList.appendChild(ingredientDiv);
}
// 移除药材输入字段
function removeIngredient(button) {
button.parentElement.parentElement.remove();
}
function submitForm(e) {
e.preventDefault(); // 阻止默认表单提交
const form = document.getElementById('prescription-form');
const formData = new FormData(form);
const uid = 'admin';
const data = {
id: formData.get('id'),
uid: uid,
name: formData.get('name'),
source: formData.get('source'),
method: formData.get('method'),
herbs: ""
};
// 收集所有药材名称和重量
const herb_name = formData.getAll('herb_name[]');
const herb_num = formData.getAll('herb_num[]');
const herb_desc = formData.getAll('herb_desc[]');
const herbs = [];
herb_name.forEach((name, index) => {
herbs.push({
name: name,
num: herb_num[index],
desc: herb_desc[index]
});
});
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', // 替换为你的服务器端处理文件
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('提交失败,请重试。');
}
});
}
}
</script>
<style>
.add-button {
width: 20px;
height: 20px;
background-color: #DD4B38;
border: none;
border-radius: 50px;
color: #fff;
}
</style>
{/literal}
</body>
</html>

351
view/templates/index/home.html

@ -1,231 +1,148 @@
<!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 charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>首页</title>
<title>药方列表</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
{literal}
<style>
#prescription-form{
width: 800px;
margin-left: 100px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 10px;
}
.form-group input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.form-group textarea {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.ingredient-list {
margin-top: 20px;
}
.add-button{
width: 20px;
height: 20px;
background-color: #DD4B38;
border: none;
border-radius: 50px;
color: #fff;
float: right;
}
.submit-btn{
margin-top: 50px;
width: 150px;
height: 45px;
background-color: #DD4B38;
border: none;
border-radius:5px;
color: #fff;
}
.herb_item{
width: 800px;
position: relative;
display: flex;
line-height: 50px;
margin-top: 15px;
}
.herb_item button{
position: absolute;
left:620px;
top:15px;
width: 20px;
height: 20px;
background-color: #C28A2F;
border: none;
border-radius: 30px;
color: #fff;
}
.herb_input{
/*width: 800px;*/
}
.herb_input input{
height: 50px;
margin-right: 30px;
text-indent: 10px;
}
#change{
position: absolute;
left: 1000px;
top:500px
}
</style>
<script>
// 动态添加药材输入字段
function addIngredient() {
const ingredientList = document.getElementById('ingredient-list');
const ingredientDiv = document.createElement('div');
ingredientDiv.classList.add('herb_item');
ingredientDiv.innerHTML = `
<div class="herb_input">
<input type="text" name="herb_name[]" placeholder="药材名" required />
<input type="text" name="herb_num[]" placeholder="药量" required />
<input type="text" name="herb_desc[]" placeholder="说明"/>
</div>
<button class="" type="button" onclick="removeIngredient(this)">X</button>
`;
ingredientList.appendChild(ingredientDiv);
}
// 移除药材输入字段
function removeIngredient(button) {
button.parentElement.remove();
}
function submitForm(e) {
e.preventDefault(); // 阻止默认表单提交
const form = document.getElementById('prescription-form');
const formData = new FormData(form);
const data = {
id: formData.get('id'),
name: formData.get('name'),
source: formData.get('source'),
method: formData.get('method'),
herbs: []
};
// 收集所有药材名称和重量
const herb_name = formData.getAll('herb_name[]');
const herb_num = formData.getAll('herb_num[]');
const herb_desc = formData.getAll('herb_desc[]');
herb_name.forEach((name, index) => {
data.herbs.push({
name: name,
num: herb_num[index],
desc: herb_desc[index]
});
});
if(data.id.length>0){
$.ajax({
url: 'ajax_update_case', // 替换为你的服务器端处理文件
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_case', // 替换为你的服务器端处理文件
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('提交失败,请重试。');
}
});
}
}
</script>
{/literal}
<link href="{$smarty.const.CSS_URL}/css/global.css?v={$smarty.const.CSS_JS_VERSION}" media="screen" rel="stylesheet" type="text/css">
</head>
<body>
<h2 style="margin-left: 100px">添加药方</h2>
<form id="prescription-form" onsubmit="submitForm(event)">
<input id="id" name="id" type="hidden" value="{$data.case.id}">
<div class="form-group">
<label for="name">药方名称:</label>
<input type="text" id="name" name="name" value="{$data.case.name}" required>
</div>
<div class="form-group">
<label for="source">药方来源:</label>
<textarea id="source" name="source" rows="4">{$data.case.source}</textarea>
</div>
<div class="form-group">
<label for="method">用法:</label>
<textarea id="method" name="method" rows="4" required>{$data.case.method}</textarea>
</div>
{if $data.case.original}
<h3>原方 <button class="add-button" type="button" onclick="addIngredient()">+</button></h3>
{else}
<h3>药材 <button class="add-button" type="button" onclick="addIngredient()">+</button></h3>
{/if}
<div id="ingredient-list" class="ingredient-list">
<!-- 动态添加药材输入字段 -->
{foreach from=$data.case.original key=key item=item}
<div class="herb_item">
<div class="herb_input">
<input type="text" name="herb_name[]" value="{$item.name}" placeholder="药材名" required />
<input type="text" name="herb_num[]" value="{$item.num}" placeholder="用量" required/>
<input type="text" name="herb_desc[]" value="{$item.desc}" placeholder="说明" required />
<div id="page">
<div class="container">
<section id="main">
<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>
<button class="" type="button" onclick="removeIngredient(this)">X</button>
</div>
{/foreach}
</div>
<div id="change" class="form-group">
<label for="method">转换后:</label>
{foreach from=$data.case_herb key=key item=item}
<div style="display: flex;line-height: 50px">
<div style="margin-right: 20px">{if $data.herb[$item.herb_id]}{$data.herb[$item.herb_id].name}{/if}</div>
<div style="margin-right: 20px">{$item.num} 克</div>
<div>{if $data.herb[$item.herb_id]}{$data.herb[$item.herb_id].desc}{/if}</div>
</div>
{/foreach}
</div>
<div class="form-group" style="text-align: center">
<button class="submit-btn" type="submit">提交药方</button>
</div>
</form>
<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>ID</th>
<th>录方者</th>
<th>药方名称</th>
<th>药方来源</th>
<th>使用次数</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{foreach from=$list key=key item=item}
<tr>
<td>{$item.id}</td>
<td>{$item.uid}</td>
<td>{$item.name}</td>
<td>{$item.source}</td>
<td>{$item.use_num}</td>
<td>{if $item.uid == 0}<a href="/index/formula_add/id/{$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';
}
</script>
<style>
</style>
{/literal}
<!-- UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0 -->
{literal}
<!--[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/"
}
</script>
<script type="text/javascript" src="https://statics.dnspod.cn/zhanjiang/javascripts/ie6update.v2.js"></script>
-->
<!--[if lt IE 7]>
<![endif]-->
{/literal}
</body>
</html>

Loading…
Cancel
Save