From 2f152a5c67a56d55adb1f4ac97c263768d816263 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Tue, 22 Oct 2024 15:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8D=AF=E6=96=B9=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/admin.php | 27 ++++++++++++++++++++++----- data/dFormula.php | 3 +++ model/mFormula.php | 6 +++++- view/templates/admin/formula_add.html | 10 +++++++++- view/templates/admin/formula_list.html | 12 ++++++++++-- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/control/admin.php b/control/admin.php index 39c5315..6a40819 100644 --- a/control/admin.php +++ b/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, '操作成功'); } diff --git a/data/dFormula.php b/data/dFormula.php index a3421be..6949ed6 100644 --- a/data/dFormula.php +++ b/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( diff --git a/model/mFormula.php b/model/mFormula.php index 984c5e8..eb6e98e 100644 --- a/model/mFormula.php +++ b/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; } //格式化药方对应的药材数据 diff --git a/view/templates/admin/formula_add.html b/view/templates/admin/formula_add.html index 7169070..549ea48 100644 --- a/view/templates/admin/formula_add.html +++ b/view/templates/admin/formula_add.html @@ -94,6 +94,13 @@
 
+
+ + +
+ +
 
+
@@ -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: "" }; diff --git a/view/templates/admin/formula_list.html b/view/templates/admin/formula_list.html index 2560127..42c5f7a 100644 --- a/view/templates/admin/formula_list.html +++ b/view/templates/admin/formula_list.html @@ -105,7 +105,8 @@ {$value.name}{if $value.desc}({$value.desc}){/if} {$value.num_str} {/foreach}
-
{$item.method}
+
用法:{$item.method}
+
备注:{$item.remark}
{if $item.uid==0} @@ -119,6 +120,8 @@ 审核 编辑 {/if} +
{if $user_list[$item.user_id]}{$user_list[$item.user_id].username}{/if}
+
{if $user_list[$item.user_id]}{$item.update_time}{/if}
{/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; }