修复内容
This commit is contained in:
@@ -298,43 +298,86 @@
|
||||
|
||||
setSelectFirst();
|
||||
function setSelectFirst(default_id) {
|
||||
console.log('setSelectFirst 被调用,default_id:', default_id);
|
||||
var category_select_html = '<option value="">请选择分类</option>';
|
||||
var foundMatch = false;
|
||||
for (var i in categorys) {
|
||||
if (categorys[i]['level'] == 1) {
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '">' + categorys[i]['name'] + '</option>';
|
||||
var selected = '';
|
||||
if (default_id && String(categorys[i]['id']) == String(default_id)) {
|
||||
selected = ' selected';
|
||||
foundMatch = true;
|
||||
console.log('找到匹配的省份:', categorys[i]['name'], 'ID:', categorys[i]['id']);
|
||||
}
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '"' + selected + '>' + categorys[i]['name'] + '</option>';
|
||||
}
|
||||
}
|
||||
$('select[name="first_category_id"]').html(category_select_html);
|
||||
$('select[name="first_category_id"]').val(default_id);
|
||||
if (default_id) {
|
||||
$('select[name="first_category_id"]').val(String(default_id));
|
||||
console.log('设置省份值:', String(default_id), '是否找到匹配:', foundMatch);
|
||||
}
|
||||
form.render('select');
|
||||
}
|
||||
function setSelectSecond(default_id, parent_id) {
|
||||
console.log('setSelectSecond 被调用,default_id:', default_id, 'parent_id:', parent_id);
|
||||
parent_id = parent_id === undefined ? $('select[name="first_category_id"]').val() : parent_id;
|
||||
if (!parent_id) {
|
||||
console.log('setSelectSecond: parent_id 为空,返回');
|
||||
return;
|
||||
}
|
||||
parent_id = String(parent_id);
|
||||
$('select[name="second_category_id"]').html('<option value="">请选择分类</option>');
|
||||
$('select[name="third_category_id"]').html('<option value="">请选择分类</option>');
|
||||
var category_select_html = '<option value="">请选择分类</option>';
|
||||
var foundMatch = false;
|
||||
|
||||
for (var i in categorys) {
|
||||
if (categorys[i]['parent_id'] == parent_id) {
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '">' + categorys[i]['name'] + '</option>';
|
||||
if (String(categorys[i]['parent_id']) == parent_id) {
|
||||
var selected = '';
|
||||
if (default_id && String(categorys[i]['id']) == String(default_id)) {
|
||||
selected = ' selected';
|
||||
foundMatch = true;
|
||||
console.log('找到匹配的城市:', categorys[i]['name'], 'ID:', categorys[i]['id']);
|
||||
}
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '"' + selected + '>' + categorys[i]['name'] + '</option>';
|
||||
}
|
||||
}
|
||||
$('select[name="second_category_id"]').html(category_select_html);
|
||||
$('select[name="second_category_id"]').val(default_id);
|
||||
if (default_id) {
|
||||
$('select[name="second_category_id"]').val(String(default_id));
|
||||
console.log('设置城市值:', String(default_id), '是否找到匹配:', foundMatch);
|
||||
}
|
||||
form.render('select');
|
||||
}
|
||||
function setSelectThird(default_id, parent_id) {
|
||||
console.log('setSelectThird 被调用,default_id:', default_id, 'parent_id:', parent_id);
|
||||
parent_id = parent_id === undefined ? $('select[name="second_category_id"]').val() : parent_id;
|
||||
if (!parent_id) {
|
||||
console.log('setSelectThird: parent_id 为空,返回');
|
||||
return;
|
||||
}
|
||||
parent_id = String(parent_id);
|
||||
$('select[name="third_category_id"]').html('<option value="">请选择分类</option>');
|
||||
var first_category_id = $('select[name="first_category_id"]').val();
|
||||
var category_select_html = '<option value="">请选择分类</option>';
|
||||
var foundMatch = false;
|
||||
|
||||
for (var i in categorys) {
|
||||
if (categorys[i]['parent_id'] == parent_id) {
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '">' + categorys[i]['name'] + '</option>';
|
||||
if (String(categorys[i]['parent_id']) == parent_id) {
|
||||
var selected = '';
|
||||
if (default_id && String(categorys[i]['id']) == String(default_id)) {
|
||||
selected = ' selected';
|
||||
foundMatch = true;
|
||||
console.log('找到匹配的区县:', categorys[i]['name'], 'ID:', categorys[i]['id']);
|
||||
}
|
||||
category_select_html += '<option value="' + categorys[i]['id'] + '"' + selected + '>' + categorys[i]['name'] + '</option>';
|
||||
}
|
||||
}
|
||||
$('select[name="third_category_id"]').html(category_select_html);
|
||||
$('select[name="third_category_id"]').val(default_id);
|
||||
if (default_id) {
|
||||
$('select[name="third_category_id"]').val(String(default_id));
|
||||
console.log('设置区县值:', String(default_id), '是否找到匹配:', foundMatch);
|
||||
}
|
||||
form.render('select');
|
||||
}
|
||||
|
||||
@@ -465,7 +508,7 @@
|
||||
}
|
||||
{notempty name='info'}
|
||||
var goods_info= {$info|raw|default=''};
|
||||
console.log(goods_info);
|
||||
console.log('订单数据:', goods_info);
|
||||
$('input[name="id"]').val(goods_info['id']);
|
||||
$('input[name="address"]').val(goods_info['address']);
|
||||
$('input[name="total_amount"]').val(goods_info['total_amount']);
|
||||
@@ -474,9 +517,89 @@
|
||||
$('input[name="phone"]').val(goods_info['mobile']);
|
||||
$('input[name="store_latitude"]').val(goods_info['lng']);
|
||||
$('input[name="store_longitude"]').val(goods_info['lat']);
|
||||
setSelectFirst(goods_info['province']);
|
||||
setSelectSecond(goods_info['city']);
|
||||
setSelectThird(goods_info['district']);
|
||||
|
||||
// 设置地区选择器,根据返回的 province、city、district 字段
|
||||
// 注意:需要检查值是否存在,包括0的情况(0是有效的ID值)
|
||||
var province_id = '';
|
||||
var city_id = '';
|
||||
var district_id = '';
|
||||
|
||||
// 检查province字段(包括0值)
|
||||
if (goods_info['province'] !== undefined && goods_info['province'] !== null && goods_info['province'] !== '') {
|
||||
province_id = goods_info['province'];
|
||||
}
|
||||
// 检查city字段(包括0值)
|
||||
if (goods_info['city'] !== undefined && goods_info['city'] !== null && goods_info['city'] !== '') {
|
||||
city_id = goods_info['city'];
|
||||
}
|
||||
// 检查district字段(包括0值)
|
||||
if (goods_info['district'] !== undefined && goods_info['district'] !== null && goods_info['district'] !== '') {
|
||||
district_id = goods_info['district'];
|
||||
}
|
||||
|
||||
console.log('地区数据:', {
|
||||
province: goods_info['province'],
|
||||
city: goods_info['city'],
|
||||
district: goods_info['district'],
|
||||
province_id: province_id,
|
||||
city_id: city_id,
|
||||
district_id: district_id
|
||||
});
|
||||
|
||||
// 初始化地区选择器的函数
|
||||
function initRegionSelectors() {
|
||||
if (province_id !== '') {
|
||||
// 转换为字符串,确保类型匹配
|
||||
province_id = String(province_id);
|
||||
|
||||
// 先设置省份
|
||||
setSelectFirst(province_id);
|
||||
|
||||
// 等待省份选择器渲染完成后再设置城市
|
||||
setTimeout(function() {
|
||||
// 验证省份值是否设置成功
|
||||
var selectedProvince = $('select[name="first_category_id"]').val();
|
||||
console.log('已选省份ID:', selectedProvince, '期望:', province_id);
|
||||
|
||||
if (city_id !== '' && selectedProvince == province_id) {
|
||||
city_id = String(city_id);
|
||||
setSelectSecond(city_id, province_id);
|
||||
|
||||
// 等待城市选择器渲染完成后再设置区县
|
||||
setTimeout(function() {
|
||||
// 验证城市值是否设置成功
|
||||
var selectedCity = $('select[name="second_category_id"]').val();
|
||||
console.log('已选城市ID:', selectedCity, '期望:', city_id);
|
||||
|
||||
if (district_id !== '' && selectedCity == city_id) {
|
||||
district_id = String(district_id);
|
||||
setSelectThird(district_id, city_id);
|
||||
|
||||
setTimeout(function() {
|
||||
var selectedDistrict = $('select[name="third_category_id"]').val();
|
||||
console.log('已选区县ID:', selectedDistrict, '期望:', district_id);
|
||||
// 最后重新渲染一次,确保所有选择器都正确显示
|
||||
form.render('select');
|
||||
}, 100);
|
||||
} else {
|
||||
form.render('select');
|
||||
}
|
||||
}, 300);
|
||||
} else {
|
||||
form.render('select');
|
||||
}
|
||||
}, 300);
|
||||
} else {
|
||||
form.render('select');
|
||||
}
|
||||
}
|
||||
|
||||
// 延迟执行,确保页面完全加载和选择器初始化完成
|
||||
setTimeout(function() {
|
||||
console.log('开始初始化地区选择器...');
|
||||
initRegionSelectors();
|
||||
}, 200);
|
||||
|
||||
setBrand(goods_info['channel_id']); //部门的修改
|
||||
setBrandss(goods_info['gord_id']); //部门的修改
|
||||
|
||||
|
||||
Reference in New Issue
Block a user