This commit is contained in:
xman 2025-07-08 10:13:33 +08:00
parent 14c3e4e692
commit 8185086e5c

View File

@ -58,28 +58,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts','echarts-th
// 为表格2绑定事件
Table.api.bindevent(table2);
// ✅ 延迟初始化 citypicker 避免 dropdown 位置异常
setTimeout(function () {
var $city = $('#select_city');
if (!$city.data('citypicker')) {
$city.citypicker();
}
$city.off("cp:updated").on("cp:updated", function () {
var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
$("#select_area_id").val(code);
});
}, 100);
// ✅ 清理掉异常 dropdown保险
$('.city-picker-dropdown').each(function () {
var offset = $(this).offset();
if (offset.top === 0 && offset.left === 0) {
$(this).remove();
// 手动调整dropdown位置确保它跟输入框对齐
var $dropdown = $('.city-picker-dropdown');
if ($dropdown.length) {
var offset = $city.offset();
$dropdown.css({
top: offset.top + $city.outerHeight() + 2, // +2像素做一点距离
left: offset.left,
display: 'block',
position: 'absolute',
'z-index': 9999
});
}
});
}, 500);
}