webpackJsonp([40],{"9lRX":function(t,e){},QiTB:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=a("mvHQ"),s=a.n(o),r=(a("ftAF"),a("wuJz")),l=a("9G5k"),n=a.n(l),i={created:function(){this.getTableBase()},data:function(){return{saving:!1,formData:{},rules:{},tableColumns:[],databasetype:"Mysql",tableName:"",modules:[]}},methods:{onSave:function(){var t=this;this.$refs.form.validate(function(e){if(!e)return!1;t.submit()})},submit:function(){var t=this,e=JSON.parse(s()(this.formData));for(var a in e){var o=0,l="text";this.tableColumns.forEach(function(t){t.value==a&&(o=1,l=t.type)}),o?"date"==l&&(e[a]=Object(r.format)(e[a],"YYYY/MM/DD HH:mm",{locale:n.a})):delete e[a]}var i={formData:s()(e),tableName:this.tableName,primaryKey:this.formData.id||this.formData.ID,databasetype:this.databasetype};this.$http.post({url:this.formData.id||this.formData.ID?"/commonQuery/update":"/commonQuery/save",data:i}).then(function(e){e.success?(t.$message.success("成功"),t.$router.go(-1)):t.$message.warning("失败")})},getData:function(){var t=this;this.$route.query.id&&this.$http.get({url:"/commonQuery/one",data:{tableName:this.tableName,primaryKey:this.$route.query.id,databasetype:this.databasetype}}).then(function(e){e.success&&(t.tableColumns.forEach(function(t){"date"==t.type&&(e.data[t.value]=new Date(e.data[t.value]))}),t.formData=e.data)})},getTableBase:function(){var t=this;this.$http.get({url:"/queryConfig/getOne",data:{code:this.$route.query.code}}).then(function(e){e.success&&(e.data&&(t.modules=e.data.modules.split(","),t.tableName=e.data.tableName,t.databasetype=e.data.databasetype,t.tableColumns=[],e.data.tablecolumns.split("_;").forEach(function(e){var a=e.split("_,"),o={label:a[0],value:a[1],type:a[2]?a[2]:"text",show:!0};t.tableColumns.push(o)}),t.getData()))})},onDelete:function(){var t=this;this.$route.query.id&&this.$alert("删除将无法恢复，确认要删除么？","警告",{type:"error"}).then(function(){return t.$http.post({url:"/commonQuery/del",data:{tableName:t.tableName,primaryKey:t.$route.query.id,databasetype:t.databasetype}})}).then(function(){t.$message.success("删除成功"),t.$router.go(-1)}).catch(function(e){"cancel"===e?t.$message.info("删除取消"):t.$message.error("删除失败")})},isModulesShow:function(t){return!!this.modules.find(function(e){return e===t})}}},u={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("el-form",{ref:"form",staticStyle:{"max-width":"500px"},attrs:{model:t.formData,rules:t.rules,"label-width":"80px","label-position":"right",size:"small"}},[t._l(t.tableColumns,function(e){return[a("el-form-item",{attrs:{prop:e.value,label:e.label}},["text"==e.type?a("el-input",{model:{value:t.formData[e.value],callback:function(a){t.$set(t.formData,e.value,a)},expression:"formData[item.value]"}}):t._e(),t._v(" "),"date"==e.type?[a("div",{staticClass:"block"},[a("el-date-picker",{attrs:{type:"datetime",placeholder:"选择日期"},model:{value:t.formData[e.value],callback:function(a){t.$set(t.formData,e.value,a)},expression:"formData[item.value]"}})],1)]:t._e(),t._v(" "),"image"==e.type?a("single-upload",{model:{value:t.formData[e.value],callback:function(a){t.$set(t.formData,e.value,a)},expression:"formData[item.value]"}}):t._e()],2)]}),t._v(" "),a("el-form-item",[a("el-button",{attrs:{loading:t.$store.state.fetchingData,type:"primary"},on:{click:t.onSave}},[t._v("保存")]),t._v(" "),t.$route.query.id&&t.isModulesShow("del")?a("el-button",{attrs:{type:"danger"},on:{click:t.onDelete}},[t._v("删除")]):t._e(),t._v(" "),a("el-button",{on:{click:function(e){t.$router.go(-1)}}},[t._v("取消")])],1)],2)],1)},staticRenderFns:[]};var m=a("VU/8")(i,u,!1,function(t){a("9lRX")},"data-v-122c6946",null);e.default=m.exports}});
//# sourceMappingURL=40.5cd19b450406f979d822.js.map