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