search.b9b59055.js 2.7 KB

1
  1. import{n,_ as o}from"./index.4fdc1c7a.js";const l={name:"upload-oem-search",data(){return{loading:!0,categories:[],level1Id:"",level2Id:"",level3Id:""}},mounted(){this.getData(this.id).then(async s=>await Promise.all(s.map(async t=>{let e=await this.getData(t.id);return e=await Promise.all(e.map(async a=>{const i=await this.getData(a.id);return{...a,children:i}})),{...t,children:e}}))).then(s=>{this.categories=s,this.loading=!1})},methods:{toSuccess(){this.$router.push({path:"/upload/success"})},uploadFile(){const s=this.$t("common.failure"),t=JSON.parse(sessionStorage.getItem("conf_upload"));this.$axios.post("/api/product/add_product",{...t,type:[this.pid,this.id,this.level1Id,this.level2Id,this.level3Id]}).then(e=>{const{code:a,msg:i=s}=e.data;a==0?this.toSuccess():this.$message.error(i||s)})},changeSubcategory(s,t,e){this.level1Id=s,this.level2Id=t,this.level3Id=e},getData(s){const t=this.$t("common.failure");return this.$axios.get("/api/upload_type_list",{params:{pid:s}}).then(e=>{const{code:a,msg:i=t,data:r=[]}=e.data;return a==0?Promise.resolve(r):Promise.reject(new Error(i||t))}).catch(()=>Promise.reject(new Error(msg||t)))}},computed:{id(){const{id:s}=this.$route.query;return parseInt(s)},pid(){const{pid:s}=this.$route.query;return parseInt(s)},disabled(){return!this.level3Id},nameKey(){return this.$store.state.nameKey}}};var d=function(){var t=this,e=t._self._c;return e("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticClass:"upload-oem-search"},[e("div",{staticClass:"back"},[e("router-link",{attrs:{to:"/upload/oem"}},[e("img",{attrs:{src:o,alt:"back"}})])],1),e("div",{staticClass:"center"},[e("b",{domProps:{innerHTML:t._s(t.$t("upload.index.product"))}})]),e("div",{staticClass:"center-groups"},t._l(t.categories,function(a){return e("div",{key:a.id,staticClass:"groups-item"},[e("div",{staticClass:"groups-item-left"},[e("b",[t._v(t._s(a[t.nameKey]))])]),e("div",{staticClass:"groups-item-right"},[e("ul",{staticClass:"level1-list"},t._l(a.children,function(i){return e("li",{key:i.id,staticClass:"level1-item"},[e("div",{staticClass:"right-left"},[t._v(" "+t._s(i[t.nameKey])+" ")]),e("div",{staticClass:"right-right"},[e("ul",{staticClass:"level2-list"},t._l(i.children,function(r){return e("li",{key:r.id,class:["level2-item",t.level3Id===r.id?"selected":""],on:{click:function(h){return t.changeSubcategory(a.id,i.id,r.id)}}},[t._v(" "+t._s(r[t.nameKey])+" ")])}),0)])])}),0)])])}),0),e("div",{staticClass:"button"},[e("el-button",{attrs:{type:"primary",disabled:t.disabled,round:""},on:{click:t.uploadFile}},[t._v(t._s(t.$t("common.save")))])],1)])},c=[],u=n(l,d,c,!1,null,"0c101811",null,null);const p=u.exports;export{p as default};