import{n,_ as c}from"./index.13f93d3a.js";const d={name:"upload-design",data(){return{category:{},categories:[]}},mounted(){const s=parseInt(this.$route.query.id),t=JSON.parse(sessionStorage.getItem("conf_categories"));this.category=t.find(a=>a.id===s);const e=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:s}}).then(a=>{const{code:i,msg:r=e,data:o=[]}=a.data;i==0?this.categories=this.rebuild(o):this.$message.error(r||e)}).catch(()=>{this.$message.error(e)})},methods:{backToInformation(){const{id:s}=this.$route.query;this.$router.push({path:"/upload/information",query:{id:s,category:"design"}})},rebuild(s){return s.map(t=>({...t,children:t.describe.split(" ").filter(e=>!!e)}))},toSuccess(){this.$router.push({path:"/upload/success"})},uploadFile(s){const t=this.$t("common.failure"),e=JSON.parse(sessionStorage.getItem("conf_upload"));this.$axios.post("/api/product/add_product",{...e,type:[this.id,s]}).then(a=>{const{code:i,msg:r=t}=a.data;i==0?this.toSuccess():this.$message.error(r||t)}).catch(()=>{this.$message.error(t)})}},computed:{id(){const{id:s}=this.$route.query;return parseInt(s)},nameKey(){return this.$store.state.nameKey}}};var l=function(){var t=this,e=t._self._c;return e("div",{staticClass:"upload-design"},[e("div",{staticClass:"back",on:{click:t.backToInformation}},[e("img",{attrs:{src:c,alt:"back"}})]),e("div",{staticClass:"center"},[e("div",{staticClass:"center-title"},[e("b",{domProps:{innerHTML:t._s(t.$t("upload.index.title"))}})]),e("div",{staticClass:"center-sub-title"},[e("div",{staticClass:"dot yellow"}),t._v(" "+t._s(t.category[t.nameKey])+" ")]),e("ul",t._l(t.categories,function(a){return e("li",{key:a.id},[e("div",{staticClass:"left"},[e("div",{staticClass:"left-top"},[e("div",{staticClass:"point"}),e("b",[t._v(t._s(a[t.nameKey]))])]),e("div",{staticClass:"left-bottom"},[e("ul",t._l(a.children,function(i,r){return e("li",{key:r},[t._v(" "+t._s(i)+" ")])}),0)])]),e("div",{staticClass:"right"},[e("el-button",{attrs:{type:"primary",round:""},on:{click:function(i){return t.uploadFile(a.id)}}},[t._v(t._s(t.$t("common.select")))])],1)])}),0)])])},u=[],_=n(d,l,u,!1,null,"354ed713",null,null);const m=_.exports;export{m as default};
