You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							255 lines
						
					
					
						
							12 KiB
						
					
					
				
			
		
		
	
	
							255 lines
						
					
					
						
							12 KiB
						
					
					
				| @@master_page.html | |
| <link href="css/page_table_list.css" rel="stylesheet" /> | |
| <div id="apibox" class="card"> | |
|     <div class="search-bar"> | |
|  | |
|         <form id="frmSearach" action="lyear_forms_elements.html" method="post" onsubmit="return false;"> | |
|             <div class="form-group"> | |
|                 <div class="row"> | |
|                     <div class="col-md-1"><label class="form-control" t>名称:</label></div> | |
|                     <div class="col-md-3"><input class="form-control" type="text" id="txtSearch" name="example-text-input" placeholder="分类名称"></div> | |
|                     <div class="col-md-3"> | |
|                         <button @click="onSearch()" id="btnSearch" class="btn btn-secondary"><i class="mdi mdi-magnify"></i>搜索</button> | |
|                         <button onclick="frmSearach.reset()" class="btn btn-close m-l-15" type="submit">清空</button> | |
|  | |
|                     </div> | |
|                     <div class="col-md-4"></div> | |
|                 </div> | |
|             </div> | |
|         </form> | |
|         <div class="toolbar-btn-action"> | |
|             <button @click="openAddDiv()" class="btn btn-primary m-l-15 " data-toggle="modal" data-target="#gridSystemModal"><i class="mdi mdi-plus"></i> 新增</button> | |
|             <button @click="openTutorials(1)" class="btn btn-success m-l-15 " data-toggle="modal" data-target="#"><i class="mdi mdi-book-open-variant"></i> 复制实体模版</button> | |
|             <button @click="openTutorials(2)" class="btn btn-cyan m-l-15 " data-toggle="modal" data-target="#"><i class="mdi mdi-book-open-variant"></i>  复制接口模版</button> | |
|         </div> | |
|     </div> | |
|     <div class="card-body"> | |
|  | |
|         <h5> </h5> | |
|         <div class="table-responsive"> | |
|             <table class="table table-bordered"> | |
|                 <thead> | |
|                     <tr v-if="data && data.Columns && data.Columns.length > 0"> | |
|                         <th class="mi-w-100" v-for="column in data.Columns">{{column.ColumnDescription}}</th> | |
|                         <th>操作</th> | |
|                     </tr> | |
|                 </thead> | |
|                 <tbody v-if="data &&data.Data"> | |
|                     <tr v-if="data.Columns && data.Columns.length > 0" v-for="item in data.Data"> | |
|  | |
|                         <td v-for="column in data.Columns"> | |
|                             {{ item[column.PropertyName] }} | |
|                         </td> | |
|  | |
|                         <td class="table_opt"> | |
|                             <button data-toggle="modal" @click="openEditDiv(item)" data-target="#gridSystemModal" class="btn btn-link" type="button"> | |
|                                 <i class="mdi mdi-lead-pencil"></i> 修改 | |
|                             </button> | |
|                             <button data-toggle="modal" @click="deleteAndConfirm(item)" data-target="#divDelBox" class="btn btn-link" type="button"> | |
|                                 <i class="mdi mdi-do-not-disturb"></i> 删除 | |
|                             </button> | |
|                         </td> | |
|                     </tr> | |
|  | |
|                 </tbody> | |
|             </table> | |
|         </div> | |
|  | |
|     </div> | |
|     @@page_control.html | |
|     <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="gridSystemModal" style="display: none;"> | |
|         <div class="modal-dialog width1000" role="document"> | |
|             <div class="modal-content"> | |
|                 <div class="modal-header"> | |
|                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
|                     <h4 class="modal-title" id="exampleModalLabel">{{title}}</h4> | |
|                 </div> | |
|                 <div class="modal-body"> | |
|                     <form id="frmEdit"> | |
|                         <input type="hidden" v-model="formData.Id" name="Id" /> | |
|                         <div class="form-group"> | |
|                             <label for="recipient-name" class="control-label">名称:</label> | |
|                             <input type="text" v-model="formData.Title" name="Title" class="form-control" id="recipient-name"> | |
|                         </div> | |
|                         <div class="form-group"> | |
|                             <label for="message-text" class="control-label">模版分类:</label> | |
|                             <select v-model="formData.TypeId" name="TypeId" class="form-control"> | |
|                                 <option></option> | |
|                                 <option value="1">实体</option> | |
|                                 <option value="2">接口</option> | |
|                             </select> | |
|                         </div> | |
|                         <div class="form-group"> | |
|                             <label for="message-text" class="control-label">编辑框样式:</label> | |
|                             <select @change="setEditorValue" class="form-control" v-model="formData.TemplateContentStyle"> | |
|                                 <option>csharp</option> | |
|                                 <option>javascript</option> | |
|                                 <option>typescript</option> | |
|                             </select> | |
|                         </div> | |
|                         <div class="form-group"> | |
|                             <label for="recipient-name" class="control-label">生成地址:</label> | |
|                             <input type="text" v-model="formData.Url" name="Url"   class="form-control" id="recipient-name"> | |
|                         </div> | |
|                         <div class="form-group"> | |
|                             <label for="message-text" class="control-label">内容(复制进来):</label> | |
|                             <div id="editor" style="width: 100%; height: calc(100vh - 580px);"></div> | |
|                             <textarea class="form-control hidden" v-model="formData.TemplateContent" name="TemplateContent" id="message-text"></textarea> | |
|                         </div> | |
|                     </form> | |
|                 </div> | |
|                 <div class="modal-footer"> | |
|                     <button type="button" id="btnCloseEdit" class="btn btn-default" data-dismiss="modal">关闭</button> | |
|                     <button type="button" @click="addOrUpdate()" class="btn btn-primary">保存</button> | |
|                 </div> | |
|             </div> | |
|         </div> | |
|     </div> | |
| </div> | |
| <script src="js/ace/src-min/ace.js"></script> | |
| <script src="js/ace/src-min/ext-language_tools.js"></script> | |
| <script> | |
|     var vueObj = new Vue({ | |
|         el: '#apibox', | |
|         data: { | |
|             data: null, | |
|             error: null, | |
|             addTitle: "添加模版", | |
|             editTitle: "修改模版", | |
|             title: "", | |
|             formData: { | |
|              | |
|             } | |
|         }, | |
|         mounted() { | |
|             this.fetchData(""); | |
|         }, | |
|         methods: { | |
|             fetchData(append) { | |
|                 var url = "/PrivateReZeroRoute/100003/GetTemplatePageList?v=1" + append; | |
|                 axios.get(url, jwHeader) | |
|                     .then(response => { | |
|                         this.data = response.data; | |
|                         this.error = null; | |
|                     }) | |
|                     .catch(error => { | |
|                         this.error = error.message; | |
|                         this.data = null; | |
|                     }); | |
|             }, | |
|             onSearch: function (page) { | |
|  | |
|                 var urlParameters = "&" + tools.objectToQueryString({ | |
|                     Name: txtSearch.value, | |
|                     __pageNumber: page, | |
|                    __pageSize: tools.getValue("selPageSize"), | |
|                 }); | |
|                 this.fetchData(urlParameters); | |
|             }, | |
|             deleteAndConfirm: function (item) { | |
|                 if (item == null) { | |
|                     if (localStorage.delId == 200100) { | |
|                         tools.alert("初始化分类不能删除"); | |
|                         btnDelClose.click(); | |
|                         return; | |
|                     } | |
|                     var url = "/PrivateReZeroRoute/100003/DeleteTemplate?IsDeleted=true&Id=" + localStorage.delId; | |
|                     axios.get(url, jwHeader) | |
|                         .then(response => { | |
|                             this.data = response.data; | |
|                             this.error = null; | |
|                             this.onSearch(); | |
|                             btnDelClose.click(); | |
|                         }) | |
|                         .catch(error => { | |
|                             this.error = error.message; | |
|                             this.data = null; | |
|                         }); | |
|                 } else { | |
|                     localStorage.delId = item.Id; | |
|                 } | |
|             }, | |
|             openEditDiv: function (item) { | |
|                 var urlById = "/PrivateReZeroRoute/100003/GetTemplateById?id=" + item.Id; | |
|                 if (item.Id) { | |
|                     this.title = this.editTitle; | |
|                     axios.get(urlById, jwHeader) | |
|                         .then(response => { | |
|                             this.formData = response.data; | |
|                             this.setEditorValue(); | |
|                         }) | |
|                         .catch(error => { | |
|                             this.error = error.message; | |
|                             this.data = null; | |
|                         }); | |
|                 } | |
|             }, | |
|             openAddDiv: function (item) { | |
|                 this.title = this.addTitle; | |
|                 this.formData = { Url: "{project}\\Models\\{0}.cs" }; | |
|                 this.setEditorValue(); | |
|             }, | |
|             addOrUpdate: function () { | |
|                 var th = this; | |
|                 var frmId = "frmEdit"; | |
|                 var json = this.formData; | |
|                 var url = json.Id ? | |
|                     "/PrivateReZeroRoute/100003/UpdateTemplate" : | |
|                     "/PrivateReZeroRoute/100003/AddTemplate"; | |
|                 this.addOrUpdateSubmit(url, json); | |
|             }, | |
|             addOrUpdateSubmit: function (url, json) { | |
|                 if (this.formData.TypeId == 2) | |
|                 { | |
|                     return tools.alert("接口模版还在开发中,现在只支持实体"); | |
|                 } | |
|                 var th = this; | |
|                 var editor = ace.edit("editor"); | |
|                 this.formData.TemplateContent = editor.getValue(); | |
|                 axios.post(url, json, jwHeader) | |
|                     .then(response => { | |
|                         this.error = null; | |
|                         this.onSearch(); | |
|                         if (response.data == true) { | |
|                             frmEdit.reset(); | |
|                             btnCloseEdit.click(); | |
|                         } | |
|                         else { | |
|                             tools.highlightErrorFields(response.data) | |
|                         } | |
|                     }) | |
|                     .catch(error => { | |
|                         this.error = error.message; | |
|                         this.data = null; | |
|                     }); | |
|             }, | |
|             setEditorValue: function () { | |
|                 if (this.formData.TemplateContentStyle == null) { | |
|                     this.formData.TemplateContentStyle = "csharp"; | |
|                 } | |
|                 var editor = ace.edit("editor");   | |
|                 editor.setTheme("ace/theme/twilight"); | |
|                 editor.setOption("showPrintMargin", false); | |
|                 editor.setOption("enableBasicAutocompletion", true); | |
|                 editor.setOption("enableSnippets", true); | |
|                 editor.setOption("useWorker", false); | |
|                 editor.setOption("enableLiveAutocompletion", true) | |
|                 editor.session.setMode("ace/mode/" + this.formData.TemplateContentStyle); | |
|                 editor.setValue(this.formData.TemplateContent); | |
|                 editor.selection.clearSelection(); | |
|                 editor.resize(); | |
|  | |
|             }, | |
|             openTutorials: function (item) | |
|             { | |
|                 if (item == 1) { | |
|                     var url = "/rezero/tutorials.html?type=" + item + "&style=csharp"; | |
|                     url = tools.appendQueryParams(url); | |
|                     window.open(url); | |
|                 } else | |
|                 { | |
|                     tools.alert("根据接口生成还在开发中"); | |
|                 } | |
|             } | |
|         } | |
|     });</script> |