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