Compare commits
3
Commits
zzl
..
a228391ecc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a228391ecc | ||
|
|
6b1863a9e6 | ||
|
|
0a2e0f1784 |
@@ -86,7 +86,10 @@ export const createOption = ({ validateLongitude, validateLatitude }) => ({
|
||||
type: 'number',
|
||||
precision: 6,
|
||||
minWidth: 120,
|
||||
rules: [{ validator: validateLongitude, trigger: 'blur' }],
|
||||
rules: [
|
||||
{ required: true, message: '请输入经度', trigger: 'blur' },
|
||||
{ validator: validateLongitude, trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '纬度',
|
||||
@@ -94,13 +97,17 @@ export const createOption = ({ validateLongitude, validateLatitude }) => ({
|
||||
type: 'number',
|
||||
precision: 6,
|
||||
minWidth: 120,
|
||||
rules: [{ validator: validateLatitude, trigger: 'blur' }],
|
||||
rules: [
|
||||
{ required: true, message: '请输入纬度', trigger: 'blur' },
|
||||
{ validator: validateLatitude, trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '行政区划',
|
||||
prop: 'regionName',
|
||||
search: true,
|
||||
minWidth: 150,
|
||||
rules: [{ required: true, message: '请输入行政区划', trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
label: '组织',
|
||||
|
||||
@@ -306,36 +306,58 @@ 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.resetTypeRelatedFields();
|
||||
return;
|
||||
}
|
||||
this.form.addressName = source.addressName;
|
||||
this.form.siteCode = source.siteCode;
|
||||
this.form.siteCodeDisplay = source.siteCode;
|
||||
this.form.detailAddress = source.detailAddress;
|
||||
this.form.regionName = source.regionName;
|
||||
this.form.regionCode = source.regionCode;
|
||||
this.form.longitude = source.longitude;
|
||||
this.form.latitude = source.latitude;
|
||||
},
|
||||
handleAddressTypeChange(value, reset = true) {
|
||||
const sourceColumn = this.findColumn(this.option.column, 'sourceId');
|
||||
sourceColumn.rules = value === '常规地址' ? [] : [{ required: true, message: '请选择来源主数据', trigger: 'change' }];
|
||||
if (sourceColumn) {
|
||||
sourceColumn.rules =
|
||||
value === '常规地址' ? [] : [{ required: true, message: '请选择来源主数据', trigger: 'change' }];
|
||||
}
|
||||
const sourceDisabled = value === '常规地址';
|
||||
this.findColumn(this.option.column, 'longitude').disabled = !sourceDisabled;
|
||||
this.findColumn(this.option.column, 'latitude').disabled = !sourceDisabled;
|
||||
const longitudeColumn = this.findColumn(this.option.column, 'longitude');
|
||||
const latitudeColumn = this.findColumn(this.option.column, 'latitude');
|
||||
if (longitudeColumn) longitudeColumn.disabled = !sourceDisabled;
|
||||
if (latitudeColumn) latitudeColumn.disabled = !sourceDisabled;
|
||||
if (value === '常规地址') {
|
||||
if (reset) {
|
||||
this.form.sourceId = undefined;
|
||||
this.resetTypeRelatedFields();
|
||||
}
|
||||
this.form.siteCode = '/';
|
||||
this.form.siteCodeDisplay = '/';
|
||||
this.sourceOptions = [];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (reset) {
|
||||
this.resetTypeRelatedFields();
|
||||
}
|
||||
this.loadSourceOptions();
|
||||
},
|
||||
resetTypeRelatedFields() {
|
||||
this.form.addressName = '';
|
||||
this.form.sourceId = undefined;
|
||||
this.form.siteCode = '';
|
||||
this.form.siteCodeDisplay = '';
|
||||
}
|
||||
this.loadSourceOptions();
|
||||
this.form.detailAddress = '';
|
||||
this.form.regionName = '';
|
||||
this.form.regionCode = '';
|
||||
this.form.longitude = undefined;
|
||||
this.form.latitude = undefined;
|
||||
this.mapBox = false;
|
||||
this.mapKeyword = '';
|
||||
this.mapStatus = '可搜索地址或点击地图选点';
|
||||
this.mapSelected = {};
|
||||
},
|
||||
normalizeRow(row) {
|
||||
const submitRow = {
|
||||
@@ -344,6 +366,7 @@ export default {
|
||||
addressType: String(row.addressType || '').trim(),
|
||||
detailAddress: String(row.detailAddress || '').trim(),
|
||||
regionName: String(row.regionName || '').trim(),
|
||||
regionCode: String(row.regionCode || '').trim(),
|
||||
contactName: String(row.contactName || '').trim(),
|
||||
contactPhone: String(row.contactPhone || '').trim(),
|
||||
remark: String(row.remark || '').trim(),
|
||||
@@ -359,6 +382,10 @@ export default {
|
||||
this.$message.warning('请选择类型');
|
||||
return false;
|
||||
}
|
||||
if (row.addressType !== '常规地址' && !row.sourceId) {
|
||||
this.$message.warning('请选择来源主数据');
|
||||
return false;
|
||||
}
|
||||
if (!row.addressName) {
|
||||
this.$message.warning('请输入地址名称');
|
||||
return false;
|
||||
@@ -367,8 +394,16 @@ export default {
|
||||
this.$message.warning('请输入详细地址');
|
||||
return false;
|
||||
}
|
||||
if (row.addressType !== '常规地址' && !row.sourceId) {
|
||||
this.$message.warning('请选择来源主数据');
|
||||
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.remark && row.remark.length > 200) {
|
||||
@@ -479,9 +514,8 @@ export default {
|
||||
const addressTypeColumn = this.findColumn(this.option.column, 'addressType');
|
||||
addressTypeColumn.change = ({ value }) => this.handleAddressTypeChange(value);
|
||||
if (type === 'add') {
|
||||
this.form.addressType = this.form.addressType || '常规地址';
|
||||
this.form.siteCode = '/';
|
||||
this.form.siteCodeDisplay = '/';
|
||||
this.resetTypeRelatedFields();
|
||||
this.form.addressType = '常规地址';
|
||||
this.handleAddressTypeChange(this.form.addressType);
|
||||
done();
|
||||
return;
|
||||
@@ -498,10 +532,13 @@ export default {
|
||||
siteCode: this.form.siteCode,
|
||||
detailAddress: this.form.detailAddress,
|
||||
regionName: this.form.regionName,
|
||||
regionCode: this.form.regionCode,
|
||||
longitude: this.form.longitude,
|
||||
latitude: this.form.latitude,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
this.sourceOptions = [];
|
||||
}
|
||||
done();
|
||||
});
|
||||
@@ -583,6 +620,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;
|
||||
@@ -813,3 +851,6 @@ export default {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user