This commit is contained in:
xman 2025-07-08 09:51:57 +08:00
parent 2cdf65b0fb
commit 4893a76b6c

View File

@ -59,26 +59,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts','echarts-th
Table.api.bindevent(table2); Table.api.bindevent(table2);
// ✅ 初始化 citypicker只初始化一次
var $city = $('#select_city'); var $city = $('#select_city');
if (!$city.data('citypicker')) { if (!$city.data('citypicker')) {
$city.citypicker(); // ✅ 初始化插件 $city.citypicker();
} }
$("#select_city").on("cp:updated", function () { // ✅ 绑定 updated 事件(也只绑定一次)
console.log(123); $city.off("cp:updated").on("cp:updated", function () {
var citypicker = $(this).data("citypicker"); var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province"); var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
console.log(code);
$("#select_area_id").val(code); $("#select_area_id").val(code);
}); });
$(function () { // ✅ 删除错误 dropdown
$('.city-picker-dropdown').each(function () { $('.city-picker-dropdown').each(function () {
var offset = $(this).offset(); var offset = $(this).offset();
if (offset.top === 0 && offset.left === 0) { if (offset.top === 0 && offset.left === 0) {
$(this).remove(); // 错误渲染的 dropdown 移除 $(this).remove();
} }
});
}); });
} }