Kaynağa Gözat

图例图标管理

zhaoyk 3 yıl önce
ebeveyn
işleme
2192aacca8

+ 2 - 0
adm_comp/src/lib/DiagramModel.ts

@@ -149,6 +149,8 @@ export class Legend {
 
 	infos: Array<string>;
 	
+	iconId: string;
+	
 	static getPointsForAnchor(legend: Legend, location: Point): Array<Point4Anchor> {
 		const size = new Point(legend.width, legend.height);
 		

+ 3 - 0
adm_comp/src/lib/LegendEditor.ts

@@ -131,6 +131,9 @@ export class LegendEditor extends Editor{
 			info += ViewTool.filterToStr(legend.dataFilter);
 		if(legend.remark && legend.remark.length > 0)
 			info += '\n' + legend.remark;
+		
+		if(legend.iconId)
+			info += '\n*图标已上传';
 
 		ViewTool.drawText(this.ctx, info, new Point(l2.x, l2.y + legend.height + 5), new Point(this.legendSize - 20, 0));
 		

+ 36 - 7
adm_comp/src/views/LegendIcon.vue

@@ -29,7 +29,7 @@
 			</div>
 		</div>
 
-		<el-dialog title="图例图标 开发中,尚未完成..." :visible.sync="dlgIconVisible">
+		<el-dialog title="图例图标" :visible.sync="dlgIconVisible">
 			<div>
 				<el-form>
 					<el-upload
@@ -83,17 +83,34 @@
 		
 		currentAnchor: any;
 		
+		icons:any = {};
 		iconAction = '';
 		imageUrl = '';
 		
 		sysChange(){
 			this.currentSys = this.sysVal[this.sysVal.length - 1];
 			
-			const params:any = {sys: this.currentSys};
-			this['$axios'].get(this['$common'].url + "legend/getLegends?sys=" + this.currentSys)
+			this['$axios'].get(this['$common'].url + "icon/icons/type?system=" + this.currentSys)
 				.then(res => {
-					this.currentData = res.data.data;
-					this.openEditor(this.currentData);
+					const items = res.data.data;
+					this.icons = {};
+					for(const item of items) {
+						this.icons[item.legendId] = item;
+					}
+					
+					this['$axios'].get(this['$common'].url + "legend/getLegends?sys=" + this.currentSys)
+						.then(res => {
+							this.currentData = res.data.data;
+							for(const legend of this.currentData) {
+								const icon = this.icons[legend.id];
+								if(icon != null)
+									legend.iconId = icon.id;
+							}
+							this.openEditor(this.currentData);
+						})
+						.catch(err => {
+							//console.log(err);
+						});
 				})
 				.catch(err => {
 					//console.log(err);
@@ -151,13 +168,25 @@
 		
 		manageIcon(){
 			const legend: any = this.editor.getSelComp();
-			this.iconAction = this['$common'].url + "legend/uploadIcon?legendId=" + legend.id; //TODO上传action路径
-			this.imageUrl = ''; //TODO 获取已有的图标链接
+			this.iconAction = this['$common'].url + "icon/uploadIcon?legendId=" + legend.id + '&system=' + this.currentSys;
+			if(legend.iconId)
+				this.imageUrl = this['$common'].url + "icon/showImage?id=" + legend.iconId;
+			else
+				this.imageUrl = '';
+				
 			this.dlgIconVisible = true;
 		}
 		
 		handleAvatarSuccess(res, file) {
 			this.imageUrl = URL.createObjectURL(file.raw);
+			this.$message({
+				type: 'success',
+				message: '上传成功!'
+			});
+			const newIcon = res.data;
+			const legend: any = this.editor.getSelComp();
+			legend.iconId = newIcon.id;
+			this.editor.redraw();
 		}
 		
 		beforeAvatarUpload(file) {