import{n as o,q as c,_ as n}from"./index.13f93d3a.js";const d={name:"upload-oem",data(){return{category:{},categories:[]}},mounted(){const s=JSON.parse(sessionStorage.getItem("conf_categories"));this.category=s.find(e=>e.id===this.id);const t=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:this.id}}).then(e=>{const{code:a,msg:i=t,data:r=[]}=e.data;a==0?this.categories=this.rebuild(r):this.$message.error(i||t)}).catch(()=>{this.$message.error(t)})},methods:{checkUpload(s){c.includes(s)?this.uploadFile(s):this.$router.push({path:"/upload/oem/search",query:{pid:this.id,id:s}})},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)})},rebuild(s){return s.map(t=>({...t,children:t.describe.split(" ").filter(e=>!!e)}))},backToInformation(){const{id:s}=this.$route.query;this.$router.push({path:"/upload/information",query:{id:s,category:"oem"}})}},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-oem"},[e("div",{staticClass:"back",on:{click:t.backToInformation}},[e("img",{attrs:{src:n,alt:"back"}})]),e("div",{staticClass:"center"},[e("div",{staticClass:"center-title"},[e("b",{domProps:{innerHTML:t._s(t.$t("upload.index.select"))}})]),e("div",{staticClass:"center-sub-title"},[e("div",{staticClass:"dot green"}),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.checkUpload(a.id)}}},[t._v(t._s(t.$t("common.select")))])],1)])}),0)])])},u=[],_=o(d,l,u,!1,null,"9eccd11e",null,null);const h=_.exports;export{h as default};
