var $url="/cms/settings/settingsStyleChannel",$urlImport="/cms/settings/settingsStyleChannel/actions/import",data=utils.init({siteId:utils.getQueryInt("siteId"),urlUpload:null,styles:null,tableName:null,relatedIdentities:null,channels:null,channelIds:[utils.getQueryInt("siteId")],uploadPanel:!1,uploadLoading:!1,uploadList:[]}),methods={runTableStyleLayerAddMultiple:function(){this.apiGet()},runTableStyleLayerEditor:function(){this.apiGet()},runTableStyleLayerValidate:function(){this.apiGet()},apiGet:function(){var t=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.siteId,channelId:this.channelIds[t.channelIds.length-1]}}).then(function(e){var i=e.data;t.inputTypes=i.inputTypes,t.styles=i.styles,t.tableName=i.tableName,t.relatedIdentities=i.relatedIdentities,t.channels||(t.channels=i.channels),t.urlUpload=$apiUrl+$urlImport+"?siteId="+t.siteId+"&channelId="+t.channelIds[t.channelIds.length-1]}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiDelete:function(t){var e=this;utils.loading(this,!0),$api.delete($url,{data:{siteId:this.siteId,channelId:this.channelIds[this.channelIds.length-1],attributeName:t}}).then(function(t){var i=t.data;e.styles=i.styles}).catch(function(t){utils.error(t)}).then(function(){utils.loading(e,!1)})},getInputType:function(t){var e=this.inputTypes.find(function(e){return e.value===t});return e?e.label:"文本输入框"},getRules:function(t){return t&&0!==t.length?_.map(t,function(t){return t.message}).join(","):"无验证"},handleChannelChange:function(){this.apiGet()},btnEditClick:function(t){utils.openLayer({title:"编辑字段",url:utils.getCommonUrl("tableStyleLayerEditor",{tableName:this.tableName,relatedIdentities:this.relatedIdentities,attributeName:t})})},btnValidateClick:function(t){utils.openLayer({title:"设置验证规则",url:utils.getCommonUrl("tableStyleLayerValidate",{tableName:this.tableName,relatedIdentities:this.relatedIdentities,attributeName:t})})},btnDeleteClick:function(t){var e=this;utils.alertDelete({title:"删除字段",text:"此操作将删除字段 "+t+"，确定吗？",callback:function(){e.apiDelete(t)}})},btnAddClick:function(){utils.openLayer({title:"新增字段",url:utils.getCommonUrl("tableStyleLayerEditor",{tableName:this.tableName,relatedIdentities:this.relatedIdentities})})},btnAddMultipleClick:function(){utils.openLayer({title:"批量新增字段",url:utils.getCommonUrl("tableStyleLayerAddMultiple",{tableName:this.tableName,relatedIdentities:this.relatedIdentities})})},btnImportClick:function(){this.uploadPanel=!0},uploadBefore(t){var e=-1!==t.name.indexOf(".zip",t.name.length-".zip".length);return e||utils.error("样式导入文件只能是 Zip 格式!"),e},uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(t,e){this.uploadList=[],this.uploadPanel=!1,utils.success("字段导入成功！"),this.apiGet()},uploadError:function(t){this.uploadList=[],utils.loading(this,!1);var e=JSON.parse(t.message);utils.error(e.message)},btnExportClick:function(){var t=this;utils.loading(this,!0),$api.post($url+"/actions/export",{siteId:this.siteId,channelId:this.channelIds[this.channelIds.length-1]}).then(function(t){var e=t.data;window.open(e.value)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});