Forráskód Böngészése

模板基本信息修改

zhaoyk 3 éve
szülő
commit
438e9f5d2a

+ 2 - 1
adm_comp/public/serverAddress.js

@@ -1,2 +1,3 @@
-const serverAddress = 'http://develop.ysbdtp.com/adm-diagram'; //http://192.168.0.48:8833
+const serverAddress = 'http://develop.ysbdtp.com/adm-diagram';
+// const serverAddress = 'http://192.168.0.48:8833'
 window['serverAddress'] = serverAddress;

+ 61 - 2
adm_comp/src/views/DiagramTemplate.vue

@@ -7,7 +7,8 @@
 				<el-tree :data="templates" :props="{children: 'children', label: nodeLabel, value: 'id'}"
 					@node-click="openTemplate"
 					default-expand-all
-					:expand-on-click-node="false">
+					:expand-on-click-node="false"
+					style="width: 500px;">
 					<span class="custom-tree-node" slot-scope="{ node, data }">
 						<span>{{ node.label}}</span>
 						<span style="padding-left: 10px;">
@@ -17,6 +18,7 @@
 							<el-popconfirm title="确定删除模板?" v-if="data.diagramType" @onConfirm="() => delTemplate(node)">
 							  <el-button slot="reference" type="text" size="mini" icon="el-icon-remove">删除</el-button>
 							</el-popconfirm>
+							<el-button slot="reference" type="text" @click="() => editTemplate(node)" v-if="data.diagramType" size="mini" icon="el-icon-edit">修改</el-button>
 						</span>
 					</span>
 				</el-tree>
@@ -74,6 +76,29 @@
 		  </el-col>
 		</el-row>
 
+		<!-- 模板信息对话框 -->
+		<el-dialog title="容器属性" :visible.sync="dlgTemplateVisible">
+			<div class="el-dialog-div">
+				<el-form :model="propsData" label-width="130px">
+					<el-form-item label="模板名称">
+						<el-input v-model="propsData.name"></el-input>
+					</el-form-item>
+					<el-form-item label="备注">
+						<el-input
+						  type="textarea"
+						  :rows="2"
+						  v-model="propsData.remark">
+						</el-input>
+					</el-form-item>
+				</el-form>
+			</div>
+			
+			<div slot="footer" class="dialog-footer">
+				<el-button @click="dlgTemplateVisible = false">取 消</el-button>
+				<el-button type="primary" @click='modifyTemplate'>确 定</el-button>
+			</div>
+		</el-dialog>
+
 		<!-- 编辑容器对话框 -->
 		<el-dialog title="容器属性" :visible.sync="dlgConVisible">
 			<div class="el-dialog-div">
@@ -353,6 +378,7 @@
 		editor:TemplateEditor = null;
 		state = -1; //编辑状态(-1:关闭; 0:打开; 1:选中容器; 2:选中干管; 9:绘制干管)
 
+		dlgTemplateVisible = false;
 		dlgConVisible = false;
 		dlgLineVisible = false;
 		dlgFilterVisible = false;
@@ -465,6 +491,39 @@
 				});	
 		}
 		
+		//编辑模板信息
+		editTemplate(node){
+			const props: any = {id: node.data.id, name: node.data.name, remark: node.data.remark};
+			this.propsData = props;
+			this.dlgTemplateVisible = true;
+		}
+		
+		//修改模板信息
+		modifyTemplate(){
+			if(!this.propsData.name) {
+				this.$message({
+					type: 'warning',
+					message: '名称不合法'
+				});
+				return;
+			}
+						
+			this['$axios'].post(this['$common'].url + "template/editTemplateInfo", this.propsData)
+				.then(res => {
+					const root = res.data;
+					if(root.data == true) {
+						this.currentTemplate.name = this.propsData.name;
+						this.currentTemplate.remark = this.propsData.remark;
+						this.propsData = {};
+						
+						this.dlgTemplateVisible = false;
+					}
+				})
+				.catch(err => {
+					console.log(err);
+				});	
+		}
+		
 		//在编辑器中打开模板文件
 		openTemplate(data){
 			if(data.type) //文件夹
@@ -516,7 +575,7 @@
 			}
 			return false;
 		}
-		
+
 		//添加容器
 		addCon(){
 			this.$prompt('请输入容器id', '提示', {

+ 24 - 2
adm_comp/src/views/LegendIcon.vue

@@ -29,12 +29,12 @@
 			</div>
 		</div>
 
-		<el-dialog title="图例属性" :visible.sync="dlgIconVisible">
+		<el-dialog title="图例图标 开发中,尚未完成..." :visible.sync="dlgIconVisible">
 			<div>
 				<el-form>
 					<el-upload
 					  class="avatar-uploader"
-					  action="https://jsonplaceholder.typicode.com/posts/"
+					  :action="iconAction"
 					  :show-file-list="false"
 					  :on-success="handleAvatarSuccess"
 					  :before-upload="beforeAvatarUpload"
@@ -83,6 +83,9 @@
 		
 		currentAnchor: any;
 		
+		iconAction = '';
+		imageUrl = '';
+		
 		sysChange(){
 			this.currentSys = this.sysVal[this.sysVal.length - 1];
 			
@@ -147,9 +150,28 @@
 		}
 		
 		manageIcon(){
+			const legend: any = this.editor.getSelComp();
+			this.iconAction = this['$common'].url + "legend/uploadIcon?legendId=" + legend.id; //TODO上传action路径
+			this.imageUrl = ''; //TODO 获取已有的图标链接
 			this.dlgIconVisible = true;
 		}
 		
+		handleAvatarSuccess(res, file) {
+			this.imageUrl = URL.createObjectURL(file.raw);
+		}
+		
+		beforeAvatarUpload(file) {
+			const isSVG = file.type.indexOf('image/svg') >= 0;
+			const isLt2M = file.size / 1024 / 1024 < 2;
+
+			if (!isSVG) {
+				this.$message.error('上传头像图片只能是 SVG 格式!');
+			}
+			if (!isLt2M) {
+				this.$message.error('上传头像图片大小不能超过 2MB!');
+			}
+			return isSVG && isLt2M;
+		}
 	}
 </script>