chunk-3d9f8bb2.fcb5c2ad.js 6.7 KB

12
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-3d9f8bb2"],{3835:function(e,t,r){"use strict";function n(e){if(Array.isArray(e))return e}function i(e,t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done);n=!0)if(r.push(a.value),t&&r.length===t)break}catch(c){i=!0,o=c}finally{try{n||null==s["return"]||s["return"]()}finally{if(i)throw o}}return r}}r.d(t,"a",(function(){return s}));var o=r("06c5");function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){return n(e)||i(e,t)||Object(o["a"])(e,t)||a()}},"4aab":function(e,t,r){"use strict";r.r(t);var n=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("el-card",{staticClass:"create",scopedSlots:e._u([{key:"header",fn:function(){return[r("content-header")]},proxy:!0}])},[r("el-row",{attrs:{type:"flex",justify:"center"}},[r("configs-form")],1)],1)},i=[],o=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("lz-form",{ref:"form",attrs:{"get-data":e.getData,submit:e.onSubmit,errors:e.errors,form:e.form,"disable-stay":"","disable-redirect":"","edit-mode":""},on:{"update:errors":function(t){e.errors=t},"update:form":function(t){e.form=t}}},e._l(e.configs,(function(t){return r("el-form-item",{key:t.id,attrs:{prop:t.slug,label:t.name,helper:t.desc}},[r("type-input",{attrs:{type:t.type,options:t.options},model:{value:e.form[t.slug],callback:function(r){e.$set(e.form,t.slug,r)},expression:"form[i.slug]"}})],1)})),1)},a=[],s=(r("8e6e"),r("456d"),r("ac6a"),r("96cf"),r("1da1")),c=r("ade3"),u=r("ada3"),l=r("282a"),p=r("df78"),f=r("5d7e");function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){Object(c["a"])(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var m={name:"ConfigsForm",components:{TypeInput:p["a"],LzForm:u["a"]},data:function(){return{form:{},errors:{},configs:[]}},computed:b(b({},Object(f["e"])(["CONFIG_TYPES"])),{},{category:function(){return this.$route.params.categorySlug}}),methods:{getData:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,r,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(this.category){e.next=2;break}throw new Error("无法获取到 [ category ]");case 2:return e.next=4,Object(l["e"])(this.category);case 4:t=e.sent,r=t.data,this.configs=r,n={},r.forEach((function(e){n[e.slug]=e.value})),this.form=n;case 10:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}(),onSubmit:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(l["l"])(this.form);case 2:t=e.sent,r=t.data,this.$store.commit("SET_CONFIG",{path:f["d"].SLUG,value:r});case 5:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()}},y=m,O=r("2877"),d=Object(O["a"])(y,o,a,!1,null,null,null),v=d.exports,g={name:"ConfigValuesForm",components:{ConfigsForm:v}},j=g,E=Object(O["a"])(j,n,i,!1,null,null,null);t["default"]=E.exports},df78:function(e,t,r){"use strict";r("8e6e"),r("456d");var n=r("53ca"),i=r("3835"),o=(r("ac6a"),r("28a5"),r("ade3")),a=r("5d7e"),s=r("8e5b"),c=r("b047c"),u=r.n(c);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){Object(o["a"])(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f,h,b={name:"TypeInput",components:{FilePicker:s["a"]},inject:{elForm:{default:""},elFormItem:{default:""}},data:function(){return{filePickerKey:1}},props:{type:String,value:null,options:Object},computed:p(p({},Object(a["e"])(["CONFIG_TYPES"])),{},{selectOptions:function(){if(this.type!==this.CONFIG_TYPES.SINGLE_SELECT&&this.type!==this.CONFIG_TYPES.MULTIPLE_SELECT)return[];var e=this.options.options.split("\n"),t=[];return e.forEach((function(e){var r=e.split("=>").map((function(e){return e.trim()})),n=Object(i["a"])(r,2),o=n[0],a=n[1];a&&t.push({value:o,label:a})})),t}}),methods:{onInput:function(e){this.$emit("input",e)},initValue:function(){this.type===this.CONFIG_TYPES.FILE?this.options.max>1&&!Array.isArray(this.value)?this.onInput(this.value?[this.value]:[]):this.options.max<=1&&Array.isArray(this.value)&&this.onInput(this.value[0]||null):this.type===this.CONFIG_TYPES.MULTIPLE_SELECT?!Array.isArray(this.value)&&this.onInput([]):-1===["string","boolean","number"].indexOf(Object(n["a"])(this.value))&&this.onInput(null)},updateFilePicker:u()((function(){this.filePickerKey++}),200)},watch:{type:{handler:function(){this.initValue()},immediate:!0},"options.max":function(e,t){e>1&&t>1||this.updateFilePicker(),this.initValue(),e>1&&e<t&&this.onInput(this.value.slice(0,e))},"options.ext":function(){this.updateFilePicker()}},render:function(e){var t=null,r={props:{value:this.value},on:{input:this.onInput}},n=null,i=this.CONFIG_TYPES;switch(this.type){case i.INPUT:case i.OTHER:t="el-input";break;case i.TEXTAREA:t="el-input",Object.assign(r.props,{rows:4,type:"textarea"});break;case i.FILE:t="file-picker",Object.assign(r.props,{max:this.options.max,ext:this.options.ext,multiple:this.options.max>1}),r.key=this.filePickerKey;break;case i.SINGLE_SELECT:case i.MULTIPLE_SELECT:var o=this.type===i.MULTIPLE_SELECT;"input"===this.options.type?(t=o?"el-checkbox-group":"el-radio-group",n=this.selectOptions.map((function(t){return e(o?"el-checkbox":"el-radio",{props:{key:t.value,label:t.value}},t.label)}))):"select"===this.options.type&&(t="el-select",Object.assign(r.props,{multiple:o,clearable:o}),n=this.selectOptions.map((function(t){return e("el-option",{key:t.value,attrs:{value:t.value,label:t.label}})})));break;default:}return e(t,r,n)}},m=b,y=r("2877"),O=Object(y["a"])(m,f,h,!1,null,null,null);t["a"]=O.exports}}]);
  2. //# sourceMappingURL=chunk-3d9f8bb2.fcb5c2ad.js.map