Browse Source

药方备注

pull/29/head
pengda 7 months ago
parent
commit
2f152a5c67
  1. 27
      control/admin.php
  2. 3
      data/dFormula.php
  3. 6
      model/mFormula.php
  4. 10
      view/templates/admin/formula_add.html
  5. 12
      view/templates/admin/formula_list.html

27
control/admin.php

@ -134,7 +134,13 @@ class admin extends publicBase {
//只取出当前页显示
$list = $mformula->getFormulaList($condition, $curpage, $page->pagesize);
//管理员列表
$m_admin_user = new mAdminUser();
$user_list = $m_admin_user->getUserList();
$user_list = array_column($user_list, null, 'id');
$this->view['list'] = $list;
$this->view['user_list'] = $user_list;
}
public function formula_add() {
@ -148,14 +154,17 @@ class admin extends publicBase {
}
public function ajax_save_formula() {
$user_info = $this->get_uinfo();
$id = $this->post('id') + 0;
$name = trim($this->post('name'));
$source = trim($this->post('source'));
$method = trim($this->post('method'));
$remark = trim($this->post('remark'));
$herbs = $this->post('herbs');
$mformula = new mFormula();
$id = $mformula->saveFormula(0, $id, $name, $source, $method, $herbs);
$id = $mformula->saveFormula(0, $id, $name, $source, $method, $herbs, $remark, $user_info['id']);
if (!$id) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '操作成功', array('id' => $id));
@ -170,13 +179,21 @@ class admin extends publicBase {
$this->ajax_json(true, '识别成功', $data);
}
public function ajax_delete_formula() {
public function ajax_update_formula() {
$user_info = $this->get_uinfo();
$id = $this->post('id') + 0;
$is_delete = $this->post('is_delete') + 0;
$is_delete = $this->post('is_delete');
$remark = trim($this->post('remark'));
$data = array();
if (!empty($is_delete)) $data['is_delete'] = $is_delete + 0;
if (!empty($remark)) $data['remark'] = $remark;
$data['user_id'] = $user_info['id'];
$mformula = new mFormula();
$id = $mformula->deleteFormula(0, $id, $is_delete);
if (!$id) $this->ajax_json(false, $mformula->getError());
$res = $mformula->updateFormula($id, $data);
if (!$res) $this->ajax_json(true, '操作失败');
$this->ajax_json(true, '操作成功');
}

3
data/dFormula.php

@ -16,8 +16,11 @@ class dFormula extends dBase {
'source',
'original',
'method',
'remark',
'sort',
'is_delete',
'user_id',
'update_time',
'create_time',
),
'tcm_formula_herb' => array(

6
model/mFormula.php

@ -328,6 +328,8 @@ class mFormula extends mBase {
$num_map = $GLOBALS['num_list'];
$num_list = implode('', array_keys($num_map));
$herb_arr = array();
foreach ($herbString_arr as $herbString) {
$pattern = '/^(.)(.*?)([' . $num_list . ']+)([^(]*)?((.*?))?/u';
preg_match($pattern, $herbString, $matches);
@ -579,7 +581,7 @@ class mFormula extends mBase {
return true;
}
public function saveFormula($uid, $id, $name, $source, $method, $herbs) {
public function saveFormula($uid, $id, $name, $source, $method, $herbs, $remark = "", $admin_user = 0) {
if (empty($name)) {
$this->setError('请填写药方名称');
return false;
@ -627,7 +629,9 @@ class mFormula extends mBase {
//更新原方和用法
$data['original'] = json_encode($org_herb, JSON_UNESCAPED_UNICODE);
$data['method'] = $method;
$data['remark'] = $remark;
$data['is_delete'] = 2;
$data['user_id'] = $admin_user;
}
//格式化药方对应的药材数据

10
view/templates/admin/formula_add.html

@ -94,6 +94,13 @@
<div class="row">&nbsp;</div>
<div class="row">
<label for="remark">备注<font color='red'></font></label>
<textarea rows="3" cols="80" id="remark" name="remark">{$data.remark}</textarea>
</div>
<div class="row">&nbsp;</div>
<div class="row" id="" style="position:relative;">
<label>&nbsp;</label>
@ -136,7 +143,7 @@
};
$.ajax({
url: '/admin/ajax_delete_formula', // 替换为你的服务器端处理文件
url: '/admin/ajax_update_formula', // 替换为你的服务器端处理文件
type: 'POST',
data: data,
dataType: 'json',
@ -209,6 +216,7 @@
name: formData.get('name'),
source: formData.get('source'),
method: formData.get('method'),
remark: formData.get('remark'),
herbs: ""
};

12
view/templates/admin/formula_list.html

@ -105,7 +105,8 @@
<span class="item" style="flex-basis: auto;white-space: nowrap;border: 1px dashed #f6f5f5;padding:0 20px 0 0">{$value.name}{if $value.desc}({$value.desc}){/if} {$value.num_str}</span>
{/foreach}
</div>
<div style="line-height: 20px;padding-top: 10px">{$item.method}</div>
<div style="line-height: 20px;padding-top: 10px">用法:{$item.method}</div>
<div style="line-height: 20px;padding-top: 10px">备注:{$item.remark}</div>
</td>
<td class="status_{$item.id}" data-status="{$item.is_delete}" style="{if $item.is_delete == 3}color:red{/if}">
{if $item.uid==0}
@ -119,6 +120,8 @@
<a href="javascript:;" onclick="to_check({$item.id})">审核</a>
<a target="_blank" href="/admin/formula_add/id/{$item.id}">编辑</a>
{/if}
<div style="color: #ccc;white-space: nowrap;" class="user-name-{$item.id}">{if $user_list[$item.user_id]}{$user_list[$item.user_id].username}{/if}</div>
<div style="color: #ccc;white-space: nowrap;" class="user-time-{$item.id}">{if $user_list[$item.user_id]}{$item.update_time}{/if}</div>
</td>
</tr>
{/foreach}
@ -197,7 +200,7 @@
};
$.ajax({
url: '/admin/ajax_delete_formula', // 替换为你的服务器端处理文件
url: '/admin/ajax_update_formula', // 替换为你的服务器端处理文件
type: 'POST',
data: data,
dataType: 'json',
@ -213,6 +216,11 @@
$('.status_'+id).html('不通过');
$('.status_'+id).css('color','red');
}
$('.user-name-'+id).html('{/literal}{$_uinfo.username}{literal}')
const now = new Date();
const formattedDate = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} ${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`;
$('.user-time-'+id).html(formattedDate)
return true;
}

Loading…
Cancel
Save