Browse Source

Merge pull request 'wpd_setremark' (#35) from wpd_setremark into master

Reviewed-on: #35
pull/36/head
pengda 7 months ago
parent
commit
e4983a72ef
  1. 12
      control/admin.php
  2. 4
      view/templates/admin/formula_add.html
  3. 178
      view/templates/admin/formula_list.html

12
control/admin.php

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

4
view/templates/admin/formula_add.html

@ -94,12 +94,16 @@
<div class="row">&nbsp;</div> <div class="row">&nbsp;</div>
{if !$data.id}
<div class="row"> <div class="row">
<label for="remark">备注<font color='red'></font></label> <label for="remark">备注<font color='red'></font></label>
<textarea rows="3" cols="80" id="remark" name="remark">{$data.remark}</textarea> <textarea rows="3" cols="80" id="remark" name="remark">{$data.remark}</textarea>
</div> </div>
<div class="row">&nbsp;</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" id="" style="position:relative;"> <div class="row" id="" style="position:relative;">
<label>&nbsp;</label> <label>&nbsp;</label>

178
view/templates/admin/formula_list.html

@ -8,8 +8,54 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <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"> <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> <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> </head>
<body> <body>
@ -100,16 +146,17 @@
<td>{$item.id}</td> <td>{$item.id}</td>
<td>{$item.name}</td> <td>{$item.name}</td>
<td>{$item.source}</td> <td>{$item.source}</td>
<td style="padding: 10px"> <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} {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} {/foreach}
</div> </div>
<div style="line-height: 20px;padding-top: 10px">用法:{$item.method}</div> <div class="method">用法:{$item.method}</div>
<div style="line-height: 20px;padding-top: 10px"> <div class="remark-txt remark_txt_{$item.id}">
备注:<textarea cols="80" class="remark_{$item.id}" style="color: #0069d6">{$item.remark}</textarea>&nbsp;<a onclick="saveRemark({$item.id})">保存</a> {if $item.remark}备注:{/if}<span class="remark-span remark_{$item.id}">{$item.remark}</span>
</div> </div>
<a class="remark-btn remark_btn_{$item.id}" onclick="to_remark('{$item.id}')">{if $item.remark}修改备注{else}添加备注{/if}</a>
</td> </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}"> <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.uid==0}
@ -120,11 +167,15 @@
</td> </td>
<td> <td>
{if $item.uid == 0} {if $item.uid == 0}
<a href="javascript:;" onclick="to_check({$item.id})">审核</a> <a href="javascript:;" onclick="to_check('{$item.id}')">审核</a>
<a target="_blank" href="/admin/formula_add/id/{$item.id}">编辑</a> <a target="_blank" href="/admin/formula_add/id/{$item.id}">编辑</a>
{/if} {/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-name-{$item.id}">{if
<div style="color: #ccc;white-space: nowrap;" class="user-time-{$item.id}">{if $user_list[$item.user_id]}{$item.update_time}{/if}</div> $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> </td>
</tr> </tr>
{/foreach} {/foreach}
@ -139,8 +190,8 @@
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button id="close_tip" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="card_title">审核药方</h4> <h4 class="modal-title">审核药方</h4>
<br> <br>
</div> </div>
<div class="modal-body inputs" style="padding: 30px;"> <div class="modal-body inputs" style="padding: 30px;">
@ -153,6 +204,26 @@
</div> </div>
</div> </div>
<!-- 设置价格 --> <!-- 设置价格 -->
<!-- 设置备注 -->
<div class="modal" id="remark_div" style="width: 700px;left: 46%;display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">药方备注</h4>
<br>
</div>
<div class="modal-body" style="padding: 30px;">
<input type="hidden" name="id" id="remark_id">
<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>
</div>
</div>
</div>
</div>
<!-- 设置备注 -->
</section><!--end of main section--> </section><!--end of main section-->
</div><!--end of container--> </div><!--end of container-->
@ -168,27 +239,38 @@
var url = '/admin/formula_list'; var url = '/admin/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 (status > 0) url += '/status/' + status;
if(name) url += '/name/' + name; if (name) url += '/name/' + name;
location.href = url; location.href = url;
} }
function to_add(){
function to_add() {
location.href = '/admin/formula_add'; location.href = '/admin/formula_add';
} }
function to_check(id){
function to_check(id) {
$('#check_id').val(id); $('#check_id').val(id);
let status = $('.status_'+id).data('status') let status = $('.status_' + id).data('status')
if(status == 3){ if (status == 3) {
$('input[name="status"][value="3"]').prop("checked", true); $('input[name="status"][value="3"]').prop("checked", true);
}else{ } else {
$('input[name="status"][value="0"]').prop("checked", true); $('input[name="status"][value="0"]').prop("checked", true);
} }
$('#check_div').show() $('#check_div').show()
} }
$("#close_tip").click(function(){
function to_remark(id) {
$('#remark_id').val(id);
let remark = $('.remark_' + id).html();
$('#remark_text').val(remark);
$('#remark_div').show()
}
$(".close").click(function () {
$("#check_div").hide(); $("#check_div").hide();
$("#remark_div").hide();
}); });
function to_status() { function to_status() {
@ -210,25 +292,22 @@
success: function (response) { success: function (response) {
if (response.status == true) { if (response.status == true) {
showAlert('操作成功') showAlert('操作成功')
$('.status_'+id).data('status',status); $('.status_' + id).data('status', status);
if(status == 0){ if (status == 0) {
$('.status_'+id).html('通过'); $('.status_' + id).html('通过');
$('.status_'+id).css('color','#57a957'); $('.status_' + id).css('color', '#57a957');
} }
if(status == 3){ if (status == 3) {
$('.status_'+id).html('不通过'); $('.status_' + id).html('不通过');
$('.status_'+id).css('color','red'); $('.status_' + id).css('color', 'red');
} }
$('.user-name-'+id).html('{/literal}{$_uinfo.username}{literal}') $('.user-name-' + id).html('{/literal}{$_uinfo.username}{literal}')
$('.user-time-' + id).html(response.data.opt_time)
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; return true;
} }
if(response.data.code == 40002){ if (response.data.code == 40002) {
showAlert('请登录','/admin/login') showAlert('请登录', '/admin/login')
return true; return true;
} }
@ -241,8 +320,11 @@
}); });
} }
function saveRemark(id){ function saveRemark() {
let remark = $('.remark_'+id).val(); $("#remark_div").hide();
let id = $('#remark_id').val()
let remark = $('#remark_text').val();
const data = { const data = {
id: id, id: id,
remark: remark, remark: remark,
@ -256,11 +338,20 @@
success: function (response) { success: function (response) {
if (response.status == true) { if (response.status == true) {
showAlert('保存成功') showAlert('保存成功')
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; return true;
} }
if(response.data.code == 40002){ if (response.data.code == 40002) {
showAlert('请登录','/admin/login') showAlert('请登录', '/admin/login')
return true; return true;
} }
@ -291,7 +382,7 @@
}); });
} }
window.onload = function() { window.onload = function () {
const containers = document.querySelectorAll('.formula-item'); const containers = document.querySelectorAll('.formula-item');
containers.forEach(container => { containers.forEach(container => {
@ -307,13 +398,6 @@
}); });
}; };
</script> </script>
<style>
.disabled-row{
background-color: #f2f2f2; /* 变灰 */
color: #aaa; /* 文字颜色变淡 */
cursor: not-allowed; /* 禁用手型指针 */
}
</style>
{/literal} {/literal}
</body> </body>

Loading…
Cancel
Save