import{r,o as g}from"./vendor-39c32a1b.js";import{n as y}from"./index-8fa791df.js";const R={__name:"aiCustomerRecordViews",setup(i){const t=r([]),e=r([]),s=r([]),a=r({}),o=r({}),l=r({wechat_room:"",content__contains:"",offset:0,ordering:"-id",limit:15,type:0}),v=r(0),u=r(!1),d=r();g(()=>{f()});function f(){let c={type:0};HTTP.get("train_ai_database_readonly",c).then(n=>{n.code===0&&(t.value=n.data.results,n.data.count&&p(t.value[0]))})}function p(c){s.value=[],a.value=c;let n={database_id:a.value.id};HTTP.getRead("train_wechat_room",n).then(_=>{_.code===0&&(e.value=_.data.results,_.data.count&&(o.value=e.value[0],h()))})}function h(){l.value.wechat_room=o.value.id,u.value=!0,l.value.offset=0,HTTP.get("train_ai_chat_record_readonly",l.value).then(c=>{u.value=!1,c.code===0&&(v.value=c.data.count,s.value=c.data.results.reverse())})}function m(){const c=d.value.getBoundingClientRect().height,n=d.value.scrollHeight,_=d.value.scrollTop;n===c+_&&C()}function C(){u.value||(l.value.offset+=l.value.limit,!(l.value.offset>v.value)&&(u.value=!0,HTTP.get("train_ai_chat_record_readonly",l.value).then(c=>{u.value=!1,s.value=s.value.concat(c.data.results)})))}return{__sfc:!0,aiCustomerList:t,aiWechatList:e,aiRecordList:s,currCustomer:a,currWechat:o,recordFilter:l,total:v,loading:u,scrollContent:d,getCustomerList:f,getWechat:p,getRecord:h,handleScroll:m,getMoreData:C}}};var x=function(){var t=this,e=t._self._c,s=t._self._setupProxy;return e("div",{staticClass:"row ai-record-container"},[e("div",{staticClass:"col-auto ai-customer-list"},[t._m(0),e("div",{staticClass:"data-list"},t._l(s.aiCustomerList,function(a,o){return e("div",{key:o,staticClass:"list",class:{active:a.id===s.currCustomer.id},on:{click:function(l){return s.getWechat(a)}}},[t._v(" "+t._s(a.name)+" ")])}),0)]),e("div",{staticClass:"col-auto ai-customer-list"},[t._m(1),e("div",{staticClass:"data-list"},t._l(s.aiWechatList,function(a,o){return e("div",{key:o,staticClass:"list",class:{active:a.id===s.currWechat.id},on:{click:function(l){s.currWechat=a,s.getRecord()}}},[t._v(" "+t._s(a.wechat)+" ")])}),0)]),e("div",{staticClass:"col ai-record-list"},[e("div",{staticClass:"part-title"},[e("div",{staticClass:"title-line"}),t._v(" \u5BA2\u6237\u804A\u5929\u8BB0\u5F55 "),e("el-input",{attrs:{placeholder:"\u5173\u952E\u5B57\u67E5\u8BE2",clearable:!0},on:{blur:s.getRecord,clear:s.getRecord},model:{value:s.recordFilter.content__contains,callback:function(a){t.$set(s.recordFilter,"content__contains",a)},expression:"recordFilter.content__contains"}},[e("el-button",{attrs:{slot:"append",icon:"el-icon-search"},slot:"append"})],1)],1),e("div",{ref:"scrollContent",staticClass:"data-list",on:{scroll:s.handleScroll}},[t._l(s.aiRecordList,function(a,o){return e("div",{key:o,staticClass:"record-list",class:{is_ai:a.chat_type}},[e("div",{staticClass:"date"},[t._v(t._s(a.create_date))]),e("div",{class:a.chat_type==1?"record-user ai":"record-user"},[t._v(" "+t._s(a.chat_type?"AI\u5BA2\u670D":a.from_name)+" ")]),e("div",{staticClass:"record-con"},[e("span",{class:a.chat_type==1?"con-text ai-text":"con-text"},[t._v(t._s(a.content))])])])}),s.loading?e("div",{staticClass:"loading-spinner"},[t._v("\u52A0\u8F7D\u4E2D...")]):t._e()],2)])])},T=[function(){var i=this,t=i._self._c;return i._self._setupProxy,t("div",{staticClass:"part-title"},[t("div",{staticClass:"title-line"}),i._v(" AI\u5BA2\u670D ")])},function(){var i=this,t=i._self._c;return i._self._setupProxy,t("div",{staticClass:"part-title"},[t("div",{staticClass:"title-line"}),i._v(" \u5BA2\u6237\u5FAE\u4FE1\u53F7 ")])}],w=y(R,x,T,!1,null,"431f5819",null,null);const W=w.exports;export{W as default};
