import{_ as c,a as l,b as d,c as p,d as u}from"./spray.a8864064.js";import{H as m}from"./header.332caed9.js";import{n as _,b as h,C as f,e as v}from"./index.13f93d3a.js";const g={name:"upload-makeup-pump",components:{Header:m},data(){return{containers:[],capacities:[],curContainerId:"",curCapacityId:""}},mounted(){const e=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:this.id}}).then(t=>{const{code:s,msg:a=e,data:i=[]}=t.data;if(s==0){const n=i.find(r=>r.id===this.containerId),o=i.find(r=>r.id===this.capacityId);this.getContainers(n),this.getCapacities(o)}else this.$message.error(a||e)}).catch(()=>{this.$message.error(e)})},methods:{toSuccess(){this.$router.push({path:"/upload/success"})},uploadFile(){const e=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.curContainerId,this.curCapacityId]}).then(s=>{const{code:a,msg:i=e}=s.data;a==0?this.toSuccess():this.$message.error(i||e)}).catch(()=>{this.$message.error(e)})},changeContainer(e){this.curContainerId=e},changeCapacity(e){this.curCapacityId=e},fillEmpty(e){for(let t=5;t>=0;t--)if(!e[t]){e[t]={type:"empty"};continue}return e},rebuildContainers(e){let t=h[this.id];t=t[this.containerId];const s=e.map(a=>{const i=t[a.id];return{...a,type:i,image:new URL(Object.assign({"../../../../assets/images/base/filter/containers/pump/essence.png":c,"../../../../assets/images/base/filter/containers/pump/foam.png":l,"../../../../assets/images/base/filter/containers/pump/milky.png":d,"../../../../assets/images/base/filter/containers/pump/oil.png":p,"../../../../assets/images/base/filter/containers/pump/spray.png":u})[`../../../../assets/images/base/filter/containers/pump/${i}.png`],self.location).href}});return this.fillEmpty(s)},getContainers({id:e}){const t=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:e}}).then(s=>{const{code:a,msg:i=t,data:n=[]}=s.data;a==0?this.containers=this.rebuildContainers(n):this.$message.error(i||t)}).catch(()=>{this.$message.error(t)})},getCapacities({id:e}){const t=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:e}}).then(s=>{const{code:a,msg:i=t,data:n=[]}=s.data;a==0?this.capacities=n:this.$message.error(i||t)}).catch(()=>{this.$message.error(t)})}},computed:{id(){const{id:e}=this.$route.query;return parseInt(e)},pid(){const{pid:e}=this.$route.query;return parseInt(e)},containerId(){return f[this.id]},capacityId(){return v[this.id]},disabled(){return!(this.curContainerId&&this.curCapacityId)},nameKey(){return this.$store.state.nameKey}}};var C=function(){var t=this,s=t._self._c;return s("div",{staticClass:"upload-makeup-pump"},[s("Header",{attrs:{id:t.id}}),s("div",{staticClass:"filter-container"},[s("div",{staticClass:"row"},[s("div",{staticClass:"all column-item vh-center"},[s("div",{staticClass:"selection"}),s("div",{staticClass:"content"},[t._v(" "+t._s(t.$t("common.filter.container"))+" ")])]),t._l(t.containers,function(a){return s("div",{key:a.id,class:["column-item",a.type,a.type==="other"?"vh-center":"",a.type==="empty"?"filter":"",t.curContainerId===a.id?"selected":""],on:{click:function(i){return t.changeContainer(a.id)}}},[a.type==="empty"?void 0:[t._m(0,!0),s("div",{staticClass:"content"},[s("div",{staticClass:"top"},[a.type==="other"?s("span",[t._v(t._s(a[t.nameKey]))]):s("img",{attrs:{src:a.image,alt:"plastic"}})]),a.type==="other"?s("div",{staticClass:"bottom"}):s("div",{staticClass:"bottom"},[t._v(" "+t._s(a[t.nameKey])+" ")])])]],2)})],2),s("div",{staticClass:"row horizontal"},[s("div",{staticClass:"column-item vh-center"},[s("div",{staticClass:"horizontal-item"}),s("div",{staticClass:"horizontal-item"},[t._v(" "+t._s(t.$t("common.filter.capacity"))+" ")])]),t._l(t.capacities,function(a){return s("div",{key:a.id,class:["column-item",t.curCapacityId===a.id?"selected":""],on:{click:function(i){return t.changeCapacity(a.id)}}},[t._m(1,!0),s("div",{staticClass:"horizontal-item"},[t._v(" "+t._s(a[t.nameKey])+" ")])])})],2)]),s("div",{staticClass:"upload-makeup-footer"},[s("el-button",{attrs:{type:"primary",disabled:t.disabled,round:""},on:{click:t.uploadFile}},[t._v(t._s(t.$t("common.resume")))])],1)],1)},y=[function(){var e=this,t=e._self._c;return t("div",{staticClass:"selection"},[t("i",{staticClass:"el-icon-success"})])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"horizontal-item"},[t("i",{staticClass:"el-icon-success"})])}],$=_(g,C,y,!1,null,"a6cd6390",null,null);const E=$.exports;export{E as default};
