importTableFromDB.js 2.0 KB

1
  1. var validForm,inputForm=new Vue({el:"#inputForm",data:function(){return{entity:{dataLogicType:"",genDatasource:{id:""},name:"",tableAlias:""},datasourceList:[],pageDictMap:{}}},computed:{formUrl:function(){var e=window.__CODEGEN_CONFIG__;return(new ProjectConfig).proxyPath+e.gatewayRoute+e.direwolfAdmin+"/codegen/importTableFromDB"},requestPrefix:function(){var e=window.__CODEGEN_CONFIG__;return e.gatewayRoute+e.direwolfAdmin+"/codegen"}},created:function(){var t=this;checkPagePermission(t.requestPrefix+"/checkImportTablePermission");var a="获取数据源列表";axios.get(t.requestPrefix+"/getDatasourceList").then(function(e){t.datasourceList=getDataFromAxiosResponse(e,a).data}).catch(function(e){axiosErrorTips(e,a+"异常")})},mounted:function(){var o=this;validForm=$("#inputForm").validate({errorPlacement:function(e,t){t.is(":checkbox")||t.is(":radio")||t.parent().is(".input-append")?e.insertAfter(t.parent()):e.insertAfter(t)}});var i={no_results_text:"没有找到",placeholder_text_single:"当前未选择记录"};$("#selectName").chosen(i);var c=null;$("#selectDataSource").change(function(e){var t,a,n=e.currentTarget,r=n[n.selectedIndex].value;""!==r&&(t=new ProjectConfig,"success"===(a=$.parseJSON($.ajax({url:t.proxyPath+o.requestPrefix+"/getTableList?genDatasourceId="+r,async:!1}).responseText)).type?($("#selectName").chosen("destroy"),$("#selectName").val(""),$("#selectName").empty(),0<(c=a.data).length&&$.each(c,function(e,t){$("#selectName").append($('<option value="'+t.name+'">'+t.nameAndComments+"</option>"))}),$("#selectName").chosen(i),$("#selectName").trigger("change")):toastr.error("获取列表失败,请确认数据源配置是否正确!"))}),$("#selectName").change(function(e){var t=e.currentTarget,a=t[t.selectedIndex].value;if(""!==a){o.entity.name=a;for(var n=0;n<c.length;n++)a===c[n].name&&(o.entity.dataLogicType=c[n].dataLogicType)}else o.entity.dataLogicType="",o.entity.name=""})}});function doSubmit(e){if(!validForm.form())return!1;formAjaxSubmit($("#inputForm"),e)}