feat(address): 增加行政区划校验及地址类型相关字段处理
- 新增行政区划(regionName)必填校验规则 - 增强经度和纬度的空值校验,改为显示错误提示 - 选择来源主数据时,完善表单字段自动赋值及清空逻辑 - 地址类型变更时,动态禁用或启用相关字段(含行政区划和经纬度) - 保存地址时增加行政区划、经纬度非空校验提示 - 统一处理表单中行政区划(regionCode)字段的读写 - 地图点选功能同步更新行政区划字段内容
This commit is contained in:
@@ -189,7 +189,7 @@ export default {
|
||||
data() {
|
||||
const validateLongitude = (rule, value, callback) => {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
callback();
|
||||
callback(new Error('经度不能为空'));
|
||||
} else if (Number(value) < -180 || Number(value) > 180) {
|
||||
callback(new Error('经度范围为 -180 到 180'));
|
||||
} else {
|
||||
@@ -198,7 +198,7 @@ export default {
|
||||
};
|
||||
const validateLatitude = (rule, value, callback) => {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
callback();
|
||||
callback(new Error('纬度不能为空'));
|
||||
} else if (Number(value) < -90 || Number(value) > 90) {
|
||||
callback(new Error('纬度范围为 -90 到 90'));
|
||||
} else {
|
||||
@@ -306,34 +306,45 @@ export default {
|
||||
},
|
||||
handleSourceChange(value) {
|
||||
const source = this.sourceOptions.find(item => item.sourceId === value);
|
||||
if (!source) return;
|
||||
this.form.addressName = this.form.addressName || source.addressName;
|
||||
if (!source) {
|
||||
this.clearTypeRelatedFields('');
|
||||
return;
|
||||
}
|
||||
this.form.addressName = source.addressName;
|
||||
this.form.siteCode = source.siteCode;
|
||||
this.form.siteCodeDisplay = source.siteCode;
|
||||
this.form.detailAddress = source.detailAddress;
|
||||
this.form.regionCode = source.regionCode;
|
||||
this.form.regionName = source.regionName;
|
||||
this.form.longitude = source.longitude;
|
||||
this.form.latitude = source.latitude;
|
||||
},
|
||||
clearTypeRelatedFields(siteCode = '') {
|
||||
this.form.sourceId = undefined;
|
||||
this.form.siteCode = siteCode;
|
||||
this.form.siteCodeDisplay = siteCode;
|
||||
this.form.detailAddress = '';
|
||||
this.form.regionCode = '';
|
||||
this.form.regionName = '';
|
||||
this.form.longitude = '';
|
||||
this.form.latitude = '';
|
||||
},
|
||||
handleAddressTypeChange(value, reset = true) {
|
||||
const sourceColumn = this.findColumn(this.option.column, 'sourceId');
|
||||
sourceColumn.rules = value === '常规地址' ? [] : [{ required: true, message: '请选择来源主数据', trigger: 'change' }];
|
||||
const sourceDisabled = value === '常规地址';
|
||||
this.findColumn(this.option.column, 'regionName').disabled = !sourceDisabled;
|
||||
this.findColumn(this.option.column, 'longitude').disabled = !sourceDisabled;
|
||||
this.findColumn(this.option.column, 'latitude').disabled = !sourceDisabled;
|
||||
if (value === '常规地址') {
|
||||
if (reset) {
|
||||
this.form.sourceId = undefined;
|
||||
this.form.siteCode = '/';
|
||||
this.form.siteCodeDisplay = '/';
|
||||
this.clearTypeRelatedFields('/');
|
||||
this.sourceOptions = [];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (reset) {
|
||||
this.form.sourceId = undefined;
|
||||
this.form.siteCode = '';
|
||||
this.form.siteCodeDisplay = '';
|
||||
this.clearTypeRelatedFields('');
|
||||
}
|
||||
this.loadSourceOptions();
|
||||
},
|
||||
@@ -343,6 +354,7 @@ export default {
|
||||
addressName: String(row.addressName || '').trim(),
|
||||
addressType: String(row.addressType || '').trim(),
|
||||
detailAddress: String(row.detailAddress || '').trim(),
|
||||
regionCode: String(row.regionCode || '').trim(),
|
||||
regionName: String(row.regionName || '').trim(),
|
||||
contactName: String(row.contactName || '').trim(),
|
||||
contactPhone: String(row.contactPhone || '').trim(),
|
||||
@@ -367,6 +379,18 @@ export default {
|
||||
this.$message.warning('请输入详细地址');
|
||||
return false;
|
||||
}
|
||||
if (!row.regionName) {
|
||||
this.$message.warning('请输入行政区划');
|
||||
return false;
|
||||
}
|
||||
if (row.longitude === undefined || row.longitude === null || row.longitude === '') {
|
||||
this.$message.warning('经度不能为空');
|
||||
return false;
|
||||
}
|
||||
if (row.latitude === undefined || row.latitude === null || row.latitude === '') {
|
||||
this.$message.warning('纬度不能为空');
|
||||
return false;
|
||||
}
|
||||
if (row.addressType !== '常规地址' && !row.sourceId) {
|
||||
this.$message.warning('请选择来源主数据');
|
||||
return false;
|
||||
@@ -497,6 +521,7 @@ export default {
|
||||
addressName: this.form.addressName,
|
||||
siteCode: this.form.siteCode,
|
||||
detailAddress: this.form.detailAddress,
|
||||
regionCode: this.form.regionCode,
|
||||
regionName: this.form.regionName,
|
||||
longitude: this.form.longitude,
|
||||
latitude: this.form.latitude,
|
||||
@@ -583,6 +608,7 @@ export default {
|
||||
lat: this.form.latitude,
|
||||
address: this.form.detailAddress,
|
||||
regionName: this.form.regionName,
|
||||
regionCode: this.form.regionCode,
|
||||
});
|
||||
this.mapStatus = this.mapSelected.longitude ? '已加载当前经纬度,可重新选点' : '可搜索地址或点击地图选点';
|
||||
this.mapBox = true;
|
||||
|
||||
Reference in New Issue
Block a user