Browse Source

后台录药方审核

pull/1/head
pengda 8 months ago
parent
commit
1b7e86ed05
  1. 4
      config/define.php
  2. 14
      control/index.php
  3. 17
      model/mFormula.php
  4. 4
      view/templates/index/formula_add.html
  5. 56
      view/templates/index/formula_list.html

4
config/define.php

@ -14,8 +14,8 @@
define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/tcm/'); 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('LOG_TRACK_SAVE_PATH', LOG_PATH_BASE.'track/%s/%s.log'); // 监控日志的路径,如2014-02-14/1(检测类型).log
define('TCM_DOMAIN', 'http://tcm.pengda.checkcopy.com'); define('TCM_DOMAIN', 'https://yian.kuailebangshou.cn');
define('CSS_URL', '//tcm.pengda.checkcopy.com'); define('CSS_URL', '//yian.kuailebangshou.cn');
// 小程序获取openid // 小程序获取openid
define('MP_APPID',"wx7b28b3159197282d"); // 公众号APPID define('MP_APPID',"wx7b28b3159197282d"); // 公众号APPID

14
control/index.php

@ -50,6 +50,7 @@ class index extends publicBase {
$this->view['uid'] = $_COOKIE['uid']; $this->view['uid'] = $_COOKIE['uid'];
$this->view['token'] = $_COOKIE['token']; $this->view['token'] = $_COOKIE['token'];
$status = $this->get('status') + 0;
$is_all = $this->get('is_all') + 0; $is_all = $this->get('is_all') + 0;
$name = trim($this->get('name')); $name = trim($this->get('name'));
@ -63,6 +64,14 @@ class index extends publicBase {
$condition['uid'] = 0; $condition['uid'] = 0;
} }
if ($status == 0) {
$condition['is_delete'] = array(0, 2);
} elseif ($status == 1) {
$condition['is_delete'] = 2;
} elseif ($status == 2) {
$condition['is_delete'] = 0;
}
$mformula = new mFormula(); $mformula = new mFormula();
$total = $mformula->getFormulaTotal($condition); $total = $mformula->getFormulaTotal($condition);
@ -126,9 +135,10 @@ class index extends publicBase {
$uinfo = $this->_check_login(); $uinfo = $this->_check_login();
$id = $this->post('id') + 0; $id = $this->post('id') + 0;
$is_delete = $this->post('is_delete') + 0;
$mformula = new mFormula(); $mformula = new mFormula();
$id = $mformula->deleteFormula($uinfo['uid'], $id); $id = $mformula->deleteFormula($uinfo['uid'], $id, $is_delete);
if (!$id) $this->ajax_json(false, $mformula->getError()); if (!$id) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '请求成功'); $this->ajax_json(true, '请求成功');
@ -145,6 +155,7 @@ class index extends publicBase {
$condition = array(); $condition = array();
$condition['uid'] = $uinfo['uid']; $condition['uid'] = $uinfo['uid'];
$condition['is_delete'] = 0;
if ($content) $condition['name'] = $content; if ($content) $condition['name'] = $content;
$mformula = new mFormula(); $mformula = new mFormula();
@ -186,6 +197,7 @@ class index extends publicBase {
$condition = array(); $condition = array();
$condition['uid'] = array(0, $uinfo['uid']); $condition['uid'] = array(0, $uinfo['uid']);
$condition['is_delete'] = 0;
if ($content) $condition['name'] = $content; if ($content) $condition['name'] = $content;
$mformula = new mFormula(); $mformula = new mFormula();

17
model/mFormula.php

@ -25,7 +25,7 @@ class mFormula extends mBase {
public function getFormulaByCondition($condition, $page_num, $page_size) { public function getFormulaByCondition($condition, $page_num, $page_size) {
$offset = ($page_num - 1) * $page_size; $offset = ($page_num - 1) * $page_size;
$where = "is_delete=0"; $where = "1=1";
$use_limit = ""; $use_limit = "";
if (!empty($condition)) { if (!empty($condition)) {
foreach ($condition as $key => $val) { foreach ($condition as $key => $val) {
@ -33,11 +33,13 @@ class mFormula extends mBase {
$where .= " and s.{$key} like '%{$val}%'"; $where .= " and s.{$key} like '%{$val}%'";
} elseif ($key == 'uid' && is_array($val)) { } elseif ($key == 'uid' && is_array($val)) {
$val = implode(',', $val); $val = implode(',', $val);
$where .= " and s.{$key} in ({$val})"; $where .= " and s.{$key} in ({$val})";
//兼容查药方只计算当前用户对药方的使用次数 //兼容查药方只计算当前用户对药方的使用次数
$use_limit .= " and u.uid in ({$val})"; $use_limit .= " and u.uid in ({$val})";
} elseif ($key == 'is_delete' && is_array($val)) {
$val = implode(',', $val);
$where .= " and {$key} in ({$val})";
} else { } else {
$where .= " and s.{$key}={$val}"; $where .= " and s.{$key}={$val}";
} }
@ -76,14 +78,16 @@ class mFormula extends mBase {
} }
public function getFormulaTotal($condition) { public function getFormulaTotal($condition) {
$where = "is_delete=0"; $where = "1=1";
if (!empty($condition)) { if (!empty($condition)) {
foreach ($condition as $key => $val) { foreach ($condition as $key => $val) {
if ($key == 'name') { if ($key == 'name') {
$where .= " and {$key} like '%{$val}%'"; $where .= " and {$key} like '%{$val}%'";
} elseif ($key == 'uid' && is_array($val)) { } elseif ($key == 'uid' && is_array($val)) {
$val = implode(',', $val); $val = implode(',', $val);
$where .= " and {$key} in ({$val})";
} elseif ($key == 'is_delete' && is_array($val)) {
$val = implode(',', $val);
$where .= " and {$key} in ({$val})"; $where .= " and {$key} in ({$val})";
} else { } else {
$where .= " and {$key}={$val}"; $where .= " and {$key}={$val}";
@ -407,6 +411,7 @@ class mFormula extends mBase {
//更新原方和用法 //更新原方和用法
$data['original'] = json_encode($org_herb, JSON_UNESCAPED_UNICODE); $data['original'] = json_encode($org_herb, JSON_UNESCAPED_UNICODE);
$data['method'] = $method; $data['method'] = $method;
$data['is_delete'] = 2;
} }
//格式化药方对应的药材数据 //格式化药方对应的药材数据
@ -455,7 +460,7 @@ class mFormula extends mBase {
return $id; return $id;
} }
public function deleteFormula($uid, $id) { public function deleteFormula($uid, $id, $is_delete) {
$formula = $this->getFormulaById($id); $formula = $this->getFormulaById($id);
if (empty($formula)) { if (empty($formula)) {
$this->setError('抱歉,未找到匹配的药方'); $this->setError('抱歉,未找到匹配的药方');
@ -466,7 +471,7 @@ class mFormula extends mBase {
return false; return false;
} }
$res = $this->updateFormula($id, array('is_delete' => 1)); $res = $this->updateFormula($id, array('is_delete' => $is_delete));
if (!$res) { if (!$res) {
$this->setError('删除药方失败'); $this->setError('删除药方失败');
return false; return false;

4
view/templates/index/formula_add.html

@ -46,7 +46,7 @@
<div class="row"> <div class="row">
<label for="source">药方来源<font color='red'>*</font></label> <label for="source">药方来源<font color='red'>*</font></label>
<input type="text" id="source" name="source" maxlength="" style="width:280px" value="{$data.source}"> <input type="text" id="source" name="source" maxlength="" style="width:280px" value="{if $data.source}$data.source{else}伤寒杂病论{/if}">
</div> </div>
<div class="row">&nbsp;</div> <div class="row">&nbsp;</div>
@ -178,7 +178,7 @@
success: function (response) { success: function (response) {
alert(response.info); alert(response.info);
if (response.status == true) { if (response.status == true) {
window.location.href = "/index/home" window.location.href = "/index/formula_list"
} }
if(response.data.code == 40002){ if(response.data.code == 40002){

56
view/templates/index/formula_list.html

@ -28,6 +28,13 @@
<option value="1" {if $smarty.get.is_all==1}selected{/if}></option> <option value="1" {if $smarty.get.is_all==1}selected{/if}></option>
</select> </select>
&nbsp;审核状态:&nbsp;
<select id="status">
<option value="0" {if $smarty.get.status==0}selected{/if}>全部</option>
<option value="1" {if $smarty.get.status==1}selected{/if}>待审核</option>
<option value="2" {if $smarty.get.status==2}selected{/if}>已审核</option>
</select>
&nbsp;药方名称:&nbsp; &nbsp;药方名称:&nbsp;
<input type="text" id='name' value="{$smarty.get.name}"> <input type="text" id='name' value="{$smarty.get.name}">
@ -96,8 +103,11 @@
</td> </td>
<td> <td>
{if $item.is_delete == 2}
<a href="javascript:;" onclick="to_status({$item.id})">审核通过</a>
{/if}
{if $item.uid == 0} {if $item.uid == 0}
<a href="/index/formula_add/id/{$item.id}">编辑</a> <a href="/admin/formula_add/id/{$item.id}">编辑</a>
<a href="javascript:;" onclick="to_delete({$item.id})">删除</a> <a href="javascript:;" onclick="to_delete({$item.id})">删除</a>
{/if} {/if}
</td> </td>
@ -116,12 +126,14 @@
{literal} {literal}
<script type="text/javascript"> <script type="text/javascript">
function searchList() { function searchList() {
var status = $('#status').val();
var is_all = $('#is_all').val(); var is_all = $('#is_all').val();
var name = $.trim($('#name').val()); var name = $.trim($('#name').val());
var url = '/index/home'; var url = '/index/formula_list';
if(is_all > 0) url += '/is_all/' + is_all; if(is_all > 0) url += '/is_all/' + is_all;
if(status > 0) url += '/status/' + status;
if(name) url += '/name/' + name; if(name) url += '/name/' + name;
location.href = url; location.href = url;
@ -140,6 +152,7 @@
const data = { const data = {
id: id, id: id,
is_delete: 1,
uid: uid, uid: uid,
token: token, token: token,
}; };
@ -152,7 +165,7 @@
success: function (response) { success: function (response) {
alert(response.info); alert(response.info);
if (response.status == true) { if (response.status == true) {
// window.location.reload(); window.location.reload();
} }
if(response.data.code == 40002){ if(response.data.code == 40002){
@ -165,6 +178,43 @@
} }
}); });
} }
function to_status(id) {
if (!confirm("确定要操作吗?")) {
console.log("用户选择了确认");
return false;
}
const uid = {/literal}{$uid}{literal};
const token = {/literal}'{$token}'{literal};
const data = {
id: id,
is_delete: 0,
uid: uid,
token: token,
};
$.ajax({
url: '/ajax_delete_formula', // 替换为你的服务器端处理文件
type: 'POST',
data: data,
dataType: 'json',
success: function (response) {
if (response.status == true) {
window.location.reload();
return true;
}
alert(response.info);
if(response.data.code == 40002){
window.location.href = "/index/login";
}
},
error: function (xhr, status, error) {
console.error('错误:', response);
alert('提交失败,请重试。');
}
});
}
</script> </script>
{/literal} {/literal}

Loading…
Cancel
Save