fix(vr_ticket): 修复硬删除按钮 + 清理残留代码
1. Admin.php SeatTemplateDelete/VenueDelete: - is_delete → is_delete_time(ShopXO Goods 表软删除字段) - VenueDelete 新增 value='hard' 参数支持(兼容 submit-ajax) 2. list.html: - 删除按钮从 btn-open-delete-confirm 改为 submit-ajax - 删除按钮移出条件判断,始终可见 - 移除残留的 old modal + custom JS handler 3. 清理 shopxo/app/event.php 变动(还原)council/ProductManager
parent
95346206dc
commit
9f3a46e5a1
|
|
@ -243,9 +243,10 @@ class Admin extends Common
|
|||
}
|
||||
|
||||
if ($hardDelete) {
|
||||
// 检查是否有关联商品(ShopXO 使用 is_delete_time 做软删除判断)
|
||||
$goods = \think\facade\Db::name('Goods')
|
||||
->where('vr_goods_config', 'like', '%"template_id":' . $id . '%')
|
||||
->where('is_delete', 0)
|
||||
->where('is_delete_time', 0)
|
||||
->find();
|
||||
\think\facade\Db::name('vr_seat_templates')->where('id', $id)->delete();
|
||||
\app\plugins\vr_ticket\service\AuditService::log(
|
||||
|
|
@ -850,7 +851,9 @@ class Admin extends Common
|
|||
}
|
||||
|
||||
/**
|
||||
* 删除场馆(软删除)
|
||||
* 删除场馆(软删除/硬删除)
|
||||
* @param hard_delete: 0=软删除(禁用), 1=硬删除 (兼容旧的自定义JS调用)
|
||||
* @param value: 'hard'=硬删除 (submit-ajax新方式)
|
||||
*/
|
||||
public function VenueDelete()
|
||||
{
|
||||
|
|
@ -863,16 +866,24 @@ class Admin extends Common
|
|||
return DataReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 兼容旧方式: hard_delete=1 为硬删除
|
||||
$hardDelete = input('hard_delete', 0, 'intval');
|
||||
// 新方式: value='hard' 为硬删除
|
||||
$value = input('value', '', null, 'trim');
|
||||
if ($value === 'hard') {
|
||||
$hardDelete = 1;
|
||||
}
|
||||
|
||||
$template = \think\facade\Db::name('vr_seat_templates')->where('id', $id)->find();
|
||||
if (empty($template)) {
|
||||
return DataReturn('记录不存在', -1);
|
||||
}
|
||||
|
||||
if ($hardDelete) {
|
||||
// 检查是否有关联商品(使用 is_delete_time 而不是 is_delete)
|
||||
$goods = \think\facade\Db::name('Goods')
|
||||
->where('vr_goods_config', 'like', '%"template_id":' . $id . '%')
|
||||
->where('is_delete', 0)
|
||||
->where('is_delete_time', 0)
|
||||
->find();
|
||||
\think\facade\Db::name('vr_seat_templates')->where('id', $id)->delete();
|
||||
\app\plugins\vr_ticket\service\AuditService::log(
|
||||
|
|
|
|||
|
|
@ -118,10 +118,11 @@
|
|||
<button class="am-btn am-btn-warning am-btn-xs am-radius am-margin-left-xs submit-ajax" data-url="{{:PluginsAdminUrl('vr_ticket', 'admin', 'VenueDelete')}}" data-id="{{$v.id}}" data-view="reload" data-msg="确定要禁用此场馆?">
|
||||
<i class="am-icon-ban"></i> 禁用
|
||||
</button>
|
||||
<button class="am-btn am-btn-danger am-btn-xs am-radius am-margin-left-xs btn-open-delete-confirm" data-id="{{$v.id}}">
|
||||
{{/if}}
|
||||
<button class="am-btn am-btn-danger am-btn-xs am-radius am-margin-left-xs submit-ajax" data-url="{{:PluginsAdminUrl('vr_ticket', 'admin', 'VenueDelete')}}" data-id="{{$v.id}}" data-value="hard" data-view="reload" data-msg="确定要删除此场馆?删除后关联商品的场馆信息将被自动清除。" data-is-loading="1">
|
||||
<i class="am-icon-trash-o"></i> 删除
|
||||
</button>
|
||||
{{else}}
|
||||
{{if $v.status eq 0}}
|
||||
<button class="am-btn am-btn-success am-btn-xs am-radius am-margin-left-xs submit-ajax" data-url="{{:PluginsAdminUrl('vr_ticket', 'admin', 'VenueEnable')}}" data-id="{{$v.id}}" data-view="reload" data-msg="确定要启用此场馆?">
|
||||
<i class="am-icon-check"></i> 启用
|
||||
</button>
|
||||
|
|
@ -137,61 +138,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全局删除确认弹窗(单个,供所有行共用) -->
|
||||
<div class="am-modal am-modal-confirm" id="venue-confirm-delete-modal">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">
|
||||
<i class="am-icon-exclamation-triangle am-text-warning" style="font-size:1.3em;vertical-align:middle;"></i>
|
||||
<span style="margin-left:6px;">确定删除此场馆?</span>
|
||||
<a class="am-modal-close" href="javascript:void(0)">×</a>
|
||||
</div>
|
||||
<div class="am-modal-bd am-text-left">
|
||||
<p style="color:#e00;font-weight:bold;margin-bottom:8px;">⚠️ 删除后,关联商品的场馆信息将被自动清除。</p>
|
||||
<p style="color:#555;">删除前已购买的用户不受影响(已有购买快照)。</p>
|
||||
</div>
|
||||
<div class="am-modal-footer">
|
||||
<button class="am-btn am-btn-default am-radius" data-am-modal-cancel>取消</button>
|
||||
<button class="am-btn am-btn-danger am-radius btn-do-real-delete">确认删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
// 删除按钮:打开弹窗并记录当前行 ID
|
||||
$(document).on('click', '.btn-open-delete-confirm', function() {
|
||||
var id = $(this).data('id');
|
||||
$('#venue-confirm-delete-modal').find('.btn-do-real-delete').attr('data-id', id);
|
||||
$('#venue-confirm-delete-modal').modal('open');
|
||||
});
|
||||
|
||||
// 弹窗确认删除:构造 hard_delete=1 参数并提交
|
||||
$(document).on('click', '.btn-do-real-delete', function() {
|
||||
var $modal = $('#venue-confirm-delete-modal');
|
||||
var id = $(this).attr('data-id');
|
||||
var url = '{{:PluginsAdminUrl("vr_ticket", "admin", "VenueDelete")}}';
|
||||
$modal.modal('close');
|
||||
AMUI.dialog.loading({ title: '正在删除...' });
|
||||
$.ajax({
|
||||
url: RequestUrlHandle(url),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { id: id, hard_delete: 1 },
|
||||
success: function(result) {
|
||||
$.AMUI.progress.done();
|
||||
Prompt(result.msg, result.code == 0 ? 'success' : 'warning');
|
||||
if (result.code == 0) {
|
||||
setTimeout(function() { location.reload(); }, 1200);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$.AMUI.progress.done();
|
||||
Prompt('删除失败');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="am-margin-top-sm">
|
||||
{{if !empty($list)}}
|
||||
{{$page|raw}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue