var $url="/common/tableStyle/layerEditor",data=utils.init({tableName:utils.getQueryString("tableName"),attributeName:utils.getQueryString("attributeName"),relatedIdentities:utils.getQueryString("relatedIdentities"),excludes:utils.getQueryStringList("excludes"),inputTypes:null,form:null}),methods={apiGet:function(){var t=this;utils.loading(this,!0),$api.get($url,{params:{tableName:this.tableName,attributeName:this.attributeName,relatedIdentities:this.relatedIdentities}}).then(function(e){var i=e.data;t.inputTypes=i.inputTypes.filter(function(e){return-1==t.excludes.indexOf(e.key)}),t.form=i.form,t.form.items&&0!==t.form.items.length||t.form.items.push({label:"",value:"",selected:!1})}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,_.assign({},this.form,{tableName:this.tableName,relatedIdentities:this.relatedIdentities})).then(function(e){e.data;utils.closeLayer(),""!==t.attributeName?utils.success("字段编辑成功!"):utils.success("字段新增成功!"),parent.$vue.runTableStyleLayerEditor&&parent.$vue.runTableStyleLayerEditor()}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},validateAttributeName:function(t,e,i){if(!/^\+?[A-Za-z0-9]+$/.test(e))return i(new Error("字段名称只允许输入字母或者数字"));i()},btnSubmitClick(){var t=[this.$refs.form1,this.$refs.form2,this.$refs.form3,this.$refs.form4],e=!0;_.forEach(t,function(t){t&&t.validate(function(t){t||(e=!1)})}),e&&this.apiSubmit()},btnCancelClick:function(){utils.closeLayer()},btnStyleItemRemoveClick:function(t){this.form.items.splice(t,1),0===this.form.items.length&&this.btnStyleItemAddClick()},btnStyleItemAddClick:function(){this.form.items.push({label:"",value:"",selected:!1})},btnRadioClick:function(t){for(var e=0;e<this.form.items.length;e++){this.form.items[e].selected=!1}this.form.items[t].selected=!0}},computed={isSelect:function(){return"CheckBox"===this.form.inputType||"Radio"===this.form.inputType||"SelectOne"===this.form.inputType||"SelectMultiple"===this.form.inputType}},$vue=new Vue({el:"#main",data:data,computed:computed,methods:methods,created:function(){this.apiGet()}});