update 允许打开窗口副标题

This commit is contained in:
2021-05-21 14:51:44 +08:00
parent ca90ed7d44
commit e4696f678e
7 changed files with 154 additions and 98 deletions

View File

@@ -194,6 +194,20 @@
} }
} }
} }
.yo-layout-tab-subtitle {
line-height: 1;
display: inline-block;
overflow: hidden;
max-width: 150px;
transform: translateY(1px);
white-space: nowrap;
text-overflow: ellipsis;
opacity: .75;
}
+.ant-tabs-tab { +.ant-tabs-tab {
margin-left: 0; margin-left: 0;
} }

View File

@@ -1,5 +1,6 @@
export default { export default {
houseCodeAdd: ['/houseCode/add', 'post'], houseCodeAdd: ['/houseCode/add', 'post'],
houseCodeEdit: ['/houseCode/edit', 'post'],
houseCodePage: ['/houseCode/page', 'post'], houseCodePage: ['/houseCode/page', 'post'],
houseCodeNo: '/houseCode/getNextNoByCode', houseCodeNo: '/houseCode/getNextNoByCode',
} }

View File

@@ -96,6 +96,7 @@ export default {
* 对表单提交进行处理 * 对表单提交进行处理
*/ */
this.saving = true; this.saving = true;
if (!this.param.record) {
this.$api this.$api
.houseCodeAdd(formData) .houseCodeAdd(formData)
.then(({ success }) => { .then(({ success }) => {
@@ -115,6 +116,27 @@ export default {
.finally(() => { .finally(() => {
this.saving = false; this.saving = false;
}); });
} else {
this.$api
.houseCodeEdit(formData)
.then(({ success }) => {
if (success) {
this.$message.success('保存成功');
this.$confirm({
content: '编辑成功,是否继续保留当前页?',
onOk: () => {
this.$refs.forms[0].onProjectChange();
},
onCancel: () => {
this.closeContentWindow();
},
});
}
})
.finally(() => {
this.saving = false;
});
}
}, },
}, },
}; };

View File

@@ -251,10 +251,6 @@ export default {
this.onFillData(); this.onFillData();
}, },
mounted() {
this.onMapInit();
},
beforeDestroy() { beforeDestroy() {
if (this.map) this.map.destroy(); if (this.map) this.map.destroy();
}, },
@@ -289,6 +285,14 @@ export default {
if (this.form.id) { if (this.form.id) {
this.onAreaCodeChange(true); this.onAreaCodeChange(true);
} }
this.$nextTick(async () => {
await this.onMapInit();
if (this.form.lng && this.form.lat) {
this.setMarker([this.form.lng, this.form.lat]);
this.map.setCenter([this.form.lng, this.form.lat]);
}
});
}, },
/** /**
@@ -362,6 +366,7 @@ export default {
}, },
onMapInit() { onMapInit() {
return new Promise((resolve) => {
const city = '宁波市'; const city = '宁波市';
const district = new AMap.DistrictSearch({ const district = new AMap.DistrictSearch({
@@ -387,30 +392,12 @@ export default {
const geocoder = new AMap.Geocoder({ city }); const geocoder = new AMap.Geocoder({ city });
let marker;
const setMarker = (position) => {
if (marker) {
marker.setPosition(position);
} else {
marker = new AMap.Marker({
map: this.map,
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
position,
offset: new AMap.Pixel(-13, -30),
});
}
geocoder.getAddress(position, (status, result) => {
if (status === 'complete' && result.regeocode) {
this.onSetPosition(result.regeocode.formattedAddress, position);
} else {
console.error('根据经纬度查询地址失败');
}
});
};
this.map.on('click', (e) => { this.map.on('click', (e) => {
setMarker(e.lnglat); this.setMarker(e.lnglat, geocoder);
});
this.map.on('complete', () => {
resolve();
}); });
const auto = new AMap.AutoComplete({ const auto = new AMap.AutoComplete({
@@ -433,7 +420,7 @@ export default {
poiList: { pois }, poiList: { pois },
} = result; } = result;
pois.forEach((p) => { pois.forEach((p) => {
setMarker(p.location); this.setMarker(p.location, geocoder);
}); });
this.map.setFitView(); this.map.setFitView();
@@ -449,6 +436,30 @@ export default {
}); });
} }
}); });
});
},
setMarker(position, geocoder) {
if (this.marker) {
this.marker.setPosition(position);
} else {
this.marker = new AMap.Marker({
map: this.map,
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
position,
offset: new AMap.Pixel(-13, -30),
});
}
if (geocoder) {
geocoder.getAddress(position, (status, result) => {
if (status === 'complete' && result.regeocode) {
this.onSetPosition(result.regeocode.formattedAddress, position);
} else {
console.error('根据经纬度查询地址失败');
}
});
}
}, },
onSetPosition(address, { lng, lat }) { onSetPosition(address, { lng, lat }) {

View File

@@ -64,7 +64,7 @@
</a-form-model-item> </a-form-model-item>
</Auth> </Auth>
<Auth auth="authCode:add" slot="operator"> <Auth auth="authCode:add" slot="operator">
<a-button @click="onOpen()" icon="plus">新增编码</a-button> <a-button @click="onOpen()" icon="plus">新增房屋编码</a-button>
</Auth> </Auth>
<!-- 格式化字段内容 --> <!-- 格式化字段内容 -->
<!-- ... --> <!-- ... -->
@@ -254,7 +254,11 @@ export default {
*/ */
onOpen(record) { onOpen(record) {
this.openContentWindow({ this.openContentWindow({
title: '房屋编码', key: record ? record.id : 'business/house/houseCode/form',
title: record ? '修改房屋编码' : '新增房屋编码',
subTitle:
record &&
`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${`000${record.no}`.slice(-3)}`,
path: 'business/house/houseCode/form', path: 'business/house/houseCode/form',
param: { param: {
record, record,

View File

@@ -12,6 +12,9 @@
<div @click.middle="() => pane.closable && $emit('close', pane.key)"> <div @click.middle="() => pane.closable && $emit('close', pane.key)">
<a-icon :type="pane.icon" v-if="pane.icon" /> <a-icon :type="pane.icon" v-if="pane.icon" />
{{ pane.title }} {{ pane.title }}
<a-tooltip :title="pane.subTitle" placement="bottom" v-if="pane.subTitle">
<span class="yo-layout-tab-subtitle">{{`- ${pane.subTitle}`}}</span>
</a-tooltip>
</div> </div>
<a-menu slot="overlay"> <a-menu slot="overlay">
<template v-if="mode === 'development'"> <template v-if="mode === 'development'">

View File

@@ -119,6 +119,7 @@ export default {
closable: settings.closable === undefined ? true : settings.closable, closable: settings.closable === undefined ? true : settings.closable,
icon: settings.icon, icon: settings.icon,
title: settings.title || '新建窗口', title: settings.title || '新建窗口',
subTitle: settings.subTitle,
component: null, component: null,
path, path,
param: settings.param, param: settings.param,