From 3af8479684945caed1aa7b8830bdc8d59643be60 Mon Sep 17 00:00:00 2001
From: pengda <10266652509@qq.com>
Date: Mon, 28 Oct 2024 10:04:13 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8D=AF=E6=96=B9=E5=A4=87=E6=B3=A8=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
control/admin.php | 12 +--
view/templates/admin/formula_add.html | 4 +-
view/templates/admin/formula_list.html | 157 +++++++++++++++++++++------------
3 files changed, 111 insertions(+), 62 deletions(-)
diff --git a/control/admin.php b/control/admin.php
index ea843a0..c781a65 100644
--- a/control/admin.php
+++ b/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() {
diff --git a/view/templates/admin/formula_add.html b/view/templates/admin/formula_add.html
index 2ad3309..597735a 100644
--- a/view/templates/admin/formula_add.html
+++ b/view/templates/admin/formula_add.html
@@ -99,12 +99,12 @@
+
+
diff --git a/view/templates/admin/formula_list.html b/view/templates/admin/formula_list.html
index 91d6ac7..fe2540c 100644
--- a/view/templates/admin/formula_list.html
+++ b/view/templates/admin/formula_list.html
@@ -8,8 +8,54 @@
药方列表
-
+
+ {literal}
+
+ {/literal}
@@ -101,22 +147,22 @@
{$item.name} |
{$item.source} |
- |
{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}
|
@@ -124,8 +170,12 @@
审核
编辑
{/if}
- {if $user_list[$item.user_id]}{$user_list[$item.user_id].username}{/if}
- {if $user_list[$item.user_id]}{$item.update_time}{/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}
@@ -168,7 +218,7 @@
@@ -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('备注:');
-
+ if (remark.trim().length > 0) {
+ $('.remark_btn_' + id).html('修改备注');
+ $('.remark_txt_' + id).html('备注:');
+ } else {
+ $('.remark_btn_' + id).html('添加备注');
+ $('.remark_txt_' + id).html('');
+ }
+ $('.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 @@
});
};
-
{/literal}