Browse Source

药方备注修改

pull/35/head
pengda 7 months ago
parent
commit
3af8479684
  1. 12
      control/admin.php
  2. 4
      view/templates/admin/formula_add.html
  3. 157
      view/templates/admin/formula_list.html

12
control/admin.php

@ -185,19 +185,21 @@ class admin extends publicBase {
$user_info = $this->get_uinfo();
$id = $this->post('id') + 0;
$is_delete = $this->post('is_delete');
$remark = trim($this->post('remark'));
if (!$id) $this->ajax_json(true, '参数错误');
$update_time = date('Y-m-d H:i:s');
$data = array();
if (is_numeric($is_delete)) $data['is_delete'] = $is_delete + 0;
if (!empty($remark)) $data['remark'] = $remark;
$data['user_id'] = $user_info['id'];
$data['update_time'] = $update_time;
if (isset($_POST['is_delete'])) $data['is_delete'] = $this->post('is_delete') + 0;
if (isset($_POST['remark'])) $data['remark'] = trim($this->post('remark'));
$mformula = new mFormula();
$res = $mformula->updateFormula($id, $data);
if (!$res) $this->ajax_json(true, '操作失败');
$this->ajax_json(true, '操作成功');
$this->ajax_json(true, '操作成功', array('opt_time' => $update_time));
}
public function unit_conv() {

4
view/templates/admin/formula_add.html

@ -99,12 +99,12 @@
<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>
{else}
<textarea style="display: none" rows="3" cols="80" id="remark" name="remark">{$data.remark}</textarea>
{/if}
<div class="row">&nbsp;</div>
<div class="row" id="" style="position:relative;">
<label>&nbsp;</label>

157
view/templates/admin/formula_list.html

@ -8,8 +8,54 @@
<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">
<link href="{$smarty.const.CSS_URL}/css/global.css?v={$smarty.const.CSS_JS_VERSION}" media="screen" rel="stylesheet"
type="text/css">
<script src="{$smarty.const.CSS_URL}/js/common.js?v={$smarty.const.CSS_JS_VERSION}"></script>
{literal}
<style>
.formula-item {
display: flex;
flex-wrap: wrap;
border-bottom: 1px dashed #ccc;
padding-bottom: 10px;
}
.formula-item .item {
flex-basis: auto;
white-space: nowrap;
border: 1px dashed #f6f5f5;
padding: 0 20px 0 0;
}
.method {
line-height: 20px;
padding-top: 10px;
}
.disabled-row {
background-color: #f2f2f2; /* 变灰 */
color: #aaa; /* 文字颜色变淡 */
cursor: not-allowed; /* 禁用手型指针 */
}
.remark-txt {
height: 20px;
line-height: 20px;
padding-top: 10px
}
.remark-span {
color: #0069d6 !important;
padding: 0 !important;
}
.remark-btn {
position: absolute;
right: 10px;
bottom: 10px;
}
</style>
{/literal}
</head>
<body>
@ -101,22 +147,22 @@
<td>{$item.name}</td>
<td>{$item.source}</td>
<td style="padding: 10px;position: relative">
<div class="formula-item" style="display: flex;flex-wrap: wrap;border-bottom: 1px dashed #ccc;padding-bottom: 10px;">
<div class="formula-item">
{foreach from=$item.formula item=value}
<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>
<span class="item">{$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 class="remark_txt_{$item.id}" style="line-height: 20px;padding-top: 10px;">
<div class="method">用法:{$item.method}</div>
<div class="remark-txt remark_txt_{$item.id}">
{if $item.remark}备注:{/if}<span class="remark-span remark_{$item.id}">{$item.remark}</span>
</div>
<a style="position: absolute;right: 10px;bottom: 5px;" onclick="to_remark('{$item.id}')">修改备注</a>
<a class="remark-btn remark_btn_{$item.id}" onclick="to_remark('{$item.id}')">{if $item.remark}修改备注{else}添加备注{/if}</a>
</td>
<td class="status_{$item.id}" data-status="{$item.is_delete}" style="{if $item.is_delete == 0}color:#57a957{/if}{if $item.is_delete == 3}color:red{/if}">
{if $item.uid==0}
{if $item.is_delete == 0} 通过{/if}
{if $item.is_delete == 2} 待审核{/if}
{if $item.is_delete == 3} 不通过 {/if}
{if $item.is_delete == 0} 通过{/if}
{if $item.is_delete == 2} 待审核{/if}
{if $item.is_delete == 3} 不通过 {/if}
{/if}
</td>
<td>
@ -124,8 +170,12 @@
<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>
<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}
@ -168,7 +218,7 @@
<textarea cols="100" rows="5" id="remark_text"></textarea>
</div>
<div class="modal-footer inputs" style="padding: 30px;">
<button class="button primary" style="margin-left: 50px" onclick="saveRemark()">确定</button>
<button class="button primary" style="margin-left: 50px" onclick="saveRemark()">保存</button>
</div>
</div>
</div>
@ -189,32 +239,36 @@
var url = '/admin/formula_list';
if(is_all > 0) url += '/is_all/' + is_all;
if(status > 0) url += '/status/' + status;
if(name) url += '/name/' + name;
if (is_all > 0) url += '/is_all/' + is_all;
if (status > 0) url += '/status/' + status;
if (name) url += '/name/' + name;
location.href = url;
}
function to_add(){
function to_add() {
location.href = '/admin/formula_add';
}
function to_check(id){
function to_check(id) {
$('#check_id').val(id);
let status = $('.status_'+id).data('status')
if(status == 3){
let status = $('.status_' + id).data('status')
if (status == 3) {
$('input[name="status"][value="3"]').prop("checked", true);
}else{
} else {
$('input[name="status"][value="0"]').prop("checked", true);
}
$('#check_div').show()
}
function to_remark(id){
function to_remark(id) {
$('#remark_id').val(id);
let remark = $('.remark_'+id).html();
let remark = $('.remark_' + id).html();
$('#remark_text').val(remark);
$('#remark_div').show()
}
$(".close").click(function(){
$(".close").click(function () {
$("#check_div").hide();
$("#remark_div").hide();
});
@ -238,25 +292,22 @@
success: function (response) {
if (response.status == true) {
showAlert('操作成功')
$('.status_'+id).data('status',status);
if(status == 0){
$('.status_'+id).html('通过');
$('.status_'+id).css('color','#57a957');
$('.status_' + id).data('status', status);
if (status == 0) {
$('.status_' + id).html('通过');
$('.status_' + id).css('color', '#57a957');
}
if(status == 3){
$('.status_'+id).html('不通过');
$('.status_'+id).css('color','red');
if (status == 3) {
$('.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)
$('.user-name-' + id).html('{/literal}{$_uinfo.username}{literal}')
$('.user-time-' + id).html(response.data.opt_time)
return true;
}
if(response.data.code == 40002){
showAlert('请登录','/admin/login')
if (response.data.code == 40002) {
showAlert('请登录', '/admin/login')
return true;
}
@ -269,11 +320,11 @@
});
}
function saveRemark(){
function saveRemark() {
$("#remark_div").hide();
let id = $('#remark_id').val()
let remark = $('#remark_text').val();
let remark = $('#remark_text').val();
const data = {
id: id,
remark: remark,
@ -287,13 +338,20 @@
success: function (response) {
if (response.status == true) {
showAlert('保存成功')
$('.remark_txt_'+id).html('备注:<span class="remark-span remark_'+id+'">'+remark+'</span>');
if (remark.trim().length > 0) {
$('.remark_btn_' + id).html('修改备注');
$('.remark_txt_' + id).html('备注:<span class="remark-span remark_' + id + '">' + remark + '</span>');
} else {
$('.remark_btn_' + id).html('添加备注');
$('.remark_txt_' + id).html('<span class="remark-span remark_' + id + '">' + remark + '</span>');
}
$('.user-name-' + id).html('{/literal}{$_uinfo.username}{literal}')
$('.user-time-' + id).html(response.data.opt_time)
return true;
}
if(response.data.code == 40002){
showAlert('请登录','/admin/login')
if (response.data.code == 40002) {
showAlert('请登录', '/admin/login')
return true;
}
@ -324,7 +382,7 @@
});
}
window.onload = function() {
window.onload = function () {
const containers = document.querySelectorAll('.formula-item');
containers.forEach(container => {
@ -340,17 +398,6 @@
});
};
</script>
<style>
.disabled-row{
background-color: #f2f2f2; /* 变灰 */
color: #aaa; /* 文字颜色变淡 */
cursor: not-allowed; /* 禁用手型指针 */
}
.remark-span{
color: #0069d6 !important;
padding: 0 !important;
}
</style>
{/literal}
</body>

Loading…
Cancel
Save