"use strict";(self["webpackChunkautoshopee_kit"]=self["webpackChunkautoshopee_kit"]||[]).push([[5281],{85281:function(t,e,i){i.r(e),i.d(e,{default:function(){return O}});var s=function(){var t=this,e=t._self._c;return e("layout-single",{attrs:{"require-authed":""}},[e("template",{slot:"header"},[e("h1",{staticClass:"text-info"},[e("i",{staticClass:"fa fa-book",attrs:{"aria-hidden":"true"}}),e("span",{staticClass:"ml-5"},[t._v(t._s(t.$t("SHOPEE_KEYWORD")))])])]),e("div",[e("div",[e("Row",[e("Col",{attrs:{span:10,offset:7}},[e("keyword-list")],1)],1)],1)])],2)},o=[],n=function(){var t=this,e=t._self._c;return e("div",[e("div",{staticClass:"mb-10 text-right"},[e("Button",{attrs:{type:"primary"},on:{click:t.onCreate}},[t._v(" "+t._s(t.$t("KEYWORD_COLLECTION_CREATE_BTN"))+" ")])],1),e("div",[t.listCollection.length?t._e():e("div",[e("Alert",{attrs:{type:"warning","show-icon":""}},[t._v(" "+t._s(t.$t("KEYWORD_LIST_EMPTY"))+" ")])],1),e("List",t._l(t.listCollectionShow,(function(i,s){return e("ListItem",{key:i._id,scopedSlots:t._u([{key:"action",fn:function(){return[e("li",[e("Button",{staticClass:"text-success",attrs:{type:"text",size:"small",loading:i.loading},on:{click:function(e){return t.onExport(i,s)}}},[t._v(" "+t._s(t.$t("EXPORT_BTN"))+" ")])],1),e("li",[e("Button",{staticClass:"text-secondary",attrs:{type:"text",size:"small",loading:i.loading},on:{click:function(e){return t.onEdit(i)}}},[t._v(" "+t._s(t.$t("EDIT_BTN"))+" ")])],1),e("li",[e("Button",{staticClass:"text-primary",attrs:{type:"text",size:"small",loading:i.loading},on:{click:function(e){return t.onOpen(i)}}},[t._v(" "+t._s(t.$t("OPEN_BTN"))+" ")])],1),e("li",{staticStyle:{width:"50px"}},[e("Button",{staticClass:"text-danger",attrs:{type:"text",size:"small",loading:i.loading},on:{click:function(e){return t.onRemove(i)}}},[t._v(" "+t._s(t.$t("DELETE_BTN"))+" ")])],1)]},proxy:!0}],null,!0)},[e("ListItemMeta",{attrs:{title:i.title,description:i.description}})],1)})),1)],1),e("div",[e("Modal",{attrs:{title:t.$t("KEYWORD_COLLECTION_NEW")},on:{"on-ok":t.handlerPopup},model:{value:t.popupCreate,callback:function(e){t.popupCreate=e},expression:"popupCreate"}},[e("Form",[e("FormItem",{attrs:{label:t.$t("KEYWORD_COLLECTION_INPUT_NAME")}},[e("Input",{attrs:{type:"text"},model:{value:t.formCreate.name,callback:function(e){t.$set(t.formCreate,"name",e)},expression:"formCreate.name"}})],1),e("FormItem",{attrs:{label:t.$t("KEYWORD_COLLECTION_INPUT_DESCRIPTION")}},[e("Input",{attrs:{type:"text"},model:{value:t.formCreate.description,callback:function(e){t.$set(t.formCreate,"description",e)},expression:"formCreate.description"}})],1)],1)],1)],1)])},a=[],r=i(61264),l=i(90408),c=i(75511),d=(0,c.aZ)({data(){return{loadingData:!1,listCollection:[],popupCreate:!1,formCreate:{id:"",name:"",description:""}}},methods:{...(0,l.nv)(["ShopeeKeywordExport"]),onOpen(t){return this.openExternalUrl(this.createPopupUrl(`/shopee/keyword/${t._id}`),!0)},onRemove(t){const e=t._id;this.$Modal.confirm({content:this.$t("REMOVE_CONFIRM"),title:t.name,onOk:async()=>{this.$Message.success(this.$t("REMOVE_SUCCESS")),this.listCollection=this.listCollection.filter((t=>t._id!==e)),(0,r.St)(e)}})},async onExport(t,e){this.listCollection[e].loading=!0,await this.ShopeeKeywordExport({id:t._id,name:t.name}),this.listCollection[e].loading=!1},onCreate(){this.formCreate.id="",this.formCreate.name="",this.formCreate.description="",this.popupCreate=!0},onEdit(t){this.formCreate.id=t._id,this.formCreate.name=t.name,this.formCreate.description=t.description,this.popupCreate=!0},handlerPopup(){if(this.formCreate.id)return this.updateCollection();this.createCollection()},async getList(){this.loadingData=!0,this.listCollection=(await(0,r.uN)()).data.map((t=>({...t,loading:!1}))),this.loadingData=!1},async updateCollection(){const{success:t}=await(0,r.hj)(this.formCreate.id,{name:this.formCreate.name,description:this.formCreate.description});if(!t)return this.$Message.error(this.$t("UPDATE_ERROR"));const e=this.listCollection.find((t=>t._id===this.formCreate.id));e.name=this.formCreate.name,e.description=this.formCreate.description,this.$Message.success(this.$t("UPDATE_SUCCESS"))},async createCollection(){const{data:t,success:e}=await(0,r.Uq)({name:this.formCreate.name,description:this.formCreate.description});if(!e)return this.$Message.error(this.$t("CREATE_ERROR"));t.loading=!1,this.listCollection.push(t),this.$Message.success(this.$t("CREATE_SUCCESS"))}},created(){this.getList()},computed:{listCollectionShow(){return this.listCollection.map((t=>({...t,title:this.$t("KEYWORD_COLLECTION_GET_TITLE",{name:t.name,count:t.count,time:this.$d(new Date(t.timeCreate),"long")})})))}}}),p={name:"ShopeeKeywordList",mixins:[d]},u=p,C=i(1001),h=(0,C.Z)(u,n,a,!1,null,null,null),m=h.exports,_={name:"ShopeeKeywordIndex",metaInfo(){return{title:this.$t("SHOPEE_KEYWORD")}},components:{"keyword-list":m}},f=_,E=(0,C.Z)(f,s,o,!1,null,null,null),O=E.exports}}]);
//# sourceMappingURL=5281.8be33c62.js.map