import{t as e}from"./_plugin-vue2_normalizer-BHc2Ljhs.js";import{n as t}from"./vuex.esm-CDgO7zd-.js";import{r as n}from"./utils-Cskn-wTg.js";import{c as r,s as i}from"./keyword-NqFX_pCW.js";import{n as a}from"./vue-composition-api-mb1sWs1Y.js";import{a as o,t as s}from"./SelectKeywordType-DVKzy_ZK.js";var c=e({name:`ShopeeKeywordDetail`,mixins:[a({props:{collectionId:{type:String,require:!0}},components:{"select-keyword-type":s},data(){return{loadingData:!1,formAdd:{input:``,list:[],keyword:``,price:0},tableKeyword:{column:o,data:[],loading:!1}}},methods:{...t([`ShopeeKeywordGet`]),async getDetail(){this.tableKeyword.loading=!0,this.tableKeyword.data=(await this.ShopeeKeywordGet(this.collectionId)).map((e,t)=>({...e,index:t+1})),this.tableKeyword.loading=!1},async addKeyword({keyword:e,price:t}){if(e=e.trim(),this.tableKeyword.data.some(t=>t.keyword===e))return this.$Message.error(this.$t(`KEYWORD_ADD_WAS_EXIST`,{keyword:e}));this.formAdd.loading=!0;let n=await this.ShopeeKeywordAdd({collectionId:this.collectionId,keyword:e,price:t});n.loading=!1,n.index=this.tableKeyword.data.length+1,this.tableKeyword.data.push(n),this.formAdd.loading=!1,this.$Message.success(this.$t(`KEYWORD_ADD_SUCCESS`,{keyword:e}))},handleSubmit(){this.addKeyword(this.formAdd)},handlerInput(){n(this.formAdd.input).forEach(e=>this.addKeyword(e))},async onChange(e,t){let n=e._id,i=e[t];r(n,{[t]:i})},onRemove(e){let t=e._id;this.$Modal.confirm({content:this.$t(`REMOVE_CONFIRM`),title:e.keyword,onOk:async()=>{this.$Message.success(this.$t(`REMOVE_SUCCESS`)),this.tableKeyword.data=this.tableKeyword.data.filter(e=>e._id!==t),i(t)}})}},created(){this.getDetail()},computed:{addBtnActive(){return this.formAdd.keyword&&Number(this.formAdd.price)}}})]},function(){var e=this,t=e._self._c;return t(`div`,[t(`div`,{staticClass:`text-center mb-20`},[t(`div`,{staticClass:`mb-5`},[t(`Form`,{attrs:{model:e.formAdd,inline:``}},[t(`FormItem`,{attrs:{prop:`user`}},[t(`Input`,{staticStyle:{width:`400px`},attrs:{type:`textarea`,placeholder:e.$t(`KEYWORD_MASS_INPUT`)},model:{value:e.formAdd.input,callback:function(t){e.$set(e.formAdd,`input`,t)},expression:`formAdd.input`}})],1),t(`FormItem`,[t(`Button`,{attrs:{type:`primary`,loading:e.formAdd.loading,disabled:!e.formAdd.input},on:{click:e.handlerInput}},[e._v(` `+e._s(e.$t(`KEYWORD_ADD_ITEM_MASS`))+` `)])],1)],1)],1),t(`div`,[t(`Form`,{attrs:{model:e.formAdd,inline:``}},[t(`FormItem`,{attrs:{prop:`user`}},[t(`Input`,{attrs:{type:`text`,placeholder:e.$t(`KEYWORD_ROW_KEYWORD`)},model:{value:e.formAdd.keyword,callback:function(t){e.$set(e.formAdd,`keyword`,t)},expression:`formAdd.keyword`}})],1),t(`FormItem`,{attrs:{prop:`password`}},[t(`Input`,{attrs:{type:`number`,placeholder:e.$t(`KEYWORD_ROW_PRICE`)},model:{value:e.formAdd.price,callback:function(t){e.$set(e.formAdd,`price`,t)},expression:`formAdd.price`}})],1),t(`FormItem`,[t(`Button`,{attrs:{type:`primary`,loading:e.formAdd.loading,disabled:!e.addBtnActive},on:{click:e.handleSubmit}},[e._v(` `+e._s(e.$t(`KEYWORD_ADD_ITEM_BTN`))+` `)])],1)],1)],1)]),t(`div`,[t(`Table`,{attrs:{loading:e.tableKeyword.loading,columns:e.tableKeyword.column,data:e.tableKeyword.data,"highlight-row":``,size:`small`},scopedSlots:e._u([{key:`keyword`,fn:function({row:n}){return[t(`Input`,{attrs:{type:`text`,size:`small`,readonly:``},model:{value:n.keyword,callback:function(t){e.$set(n,`keyword`,t)},expression:`row.keyword`}})]}},{key:`type`,fn:function({row:n}){return[t(`select-keyword-type`,{staticStyle:{width:`100px`},on:{change:function(t){return e.onChange(n,`type`)}},model:{value:n.type,callback:function(t){e.$set(n,`type`,t)},expression:`row.type`}})]}},{key:`price`,fn:function({row:n}){return[t(`Input`,{staticStyle:{width:`100px`},attrs:{type:`number`,size:`small`},on:{"on-change":function(t){return e.onChange(n,`price`)}},model:{value:n.price,callback:function(t){e.$set(n,`price`,t)},expression:`row.price`}})]}},{key:`note`,fn:function({row:n}){return[t(`Input`,{attrs:{size:`small`},on:{"on-change":function(t){return e.onChange(n,`note`)}},model:{value:n.note,callback:function(t){e.$set(n,`note`,t)},expression:`row.note`}})]}},{key:`active`,fn:function({row:n}){return[t(`Checkbox`,{on:{"on-change":function(t){return e.onChange(n,`active`)}},model:{value:n.active,callback:function(t){e.$set(n,`active`,t)},expression:`row.active`}}),t(`span`,[e._v(` `+e._s(e.$t(`STATUS_ACTIVE`))+` `)])]}},{key:`action`,fn:function({row:n}){return[t(`Button`,{attrs:{type:`error`,ghost:``,size:`small`},on:{click:function(t){return e.onRemove(n)}}},[t(`span`,[e._v(e._s(e.$t(`REMOVE_BTN`)))])])]}}])})],1)])},[],!1,null,null,null,null).exports,l=e({name:`ShopeeKeywordDetail`,components:{"keyword-detail":c},data(){return{collectionId:this.$route.params.id}}},function(){var e=this,t=e._self._c;return t(`div`,[t(`Row`,[t(`Col`,{attrs:{span:16,offset:4}},[t(`keyword-detail`,{attrs:{"collection-id":e.collectionId}})],1)],1)],1)},[],!1,null,null,null,null).exports;export{l as default};