SessionHistory.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div>
  3. <div class="row allAlignment" id="sessionHistory">
  4. <leftNav/>
  5. <div>
  6. <hader/>
  7. <messageCenter></messageCenter>
  8. <div class="column allAlignment div_box" style="background:#F6F8FF; ">
  9. <div style="height:8vh; background:#FFF; " class="row allAlignment">
  10. <div class="name_box row center">
  11. <span>历史会话</span>
  12. </div>
  13. <div style=" font-size: 0;" class="row center allAlignment">
  14. <el-select v-model="value" size="mini" style="width: 28%;" placeholder="请选择"
  15. @change="searchDate(value)">
  16. <el-option
  17. v-for="item in options"
  18. :key="item.value"
  19. :label="item.label"
  20. :value="item.value"
  21. ></el-option>
  22. </el-select>
  23. <div style="font-size: 0;padding-right: 20px;">
  24. <el-input
  25. placeholder="请输入访客名称"
  26. size="mini"
  27. v-model="input3"
  28. class="input-with-select"
  29. >
  30. <el-button slot="append" icon="el-icon-search" @click="searchText(input3)"></el-button>
  31. </el-input>
  32. </div>
  33. </div>
  34. </div>
  35. <div style="margin:0 20px;">
  36. <el-table
  37. v-loading="loading"
  38. element-loading-text="拼命加载中"
  39. element-loading-spinner="el-icon-loading"
  40. element-loading-background="rgba(0, 0, 0, 0.8)"
  41. :header-cell-style="{background:'#eef1f6',color:'#606266'}"
  42. :row-style="{background:'#ffffff',color:'#606266'}"
  43. :data="tableData" stripe @row-click="click_row" style="width: 100%">
  44. <el-table-column prop="servicelog_id" label="会话ID" width="100"></el-table-column>
  45. <el-table-column prop="intime" label="访客进线时间"></el-table-column>
  46. <!-- <el-table-column prop="name" label="接待客服"></el-table-column> -->
  47. <el-table-column prop="user_name" label="访客名"></el-table-column>
  48. <el-table-column prop="start_time" label="会话开始时间"></el-table-column>
  49. <el-table-column prop="end_time" label="会话结束时间"></el-table-column>
  50. <el-table-column :formatter="evaluateId" prop="evaluate_id" label="满意度" width="80">
  51. </el-table-column>
  52. </el-table>
  53. </div>
  54. <div v-show="pages > 9 " style=" padding: 10px;">
  55. <el-pagination background layout="prev, pager, next" prev-text='上一页' next-text='下一页'
  56. @prev-click='upData' @next-click="downData" @current-change="current_page"
  57. :total="pages"></el-pagination>
  58. </div>
  59. <div class="right_box" v-show="isShow">
  60. <historicalRecord :show="isShow" :uid="uid" :user_name="user_name"
  61. v-on:childValue="childValue"/>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import "@/css/index.css";
  70. import leftNav from "@/components/leftNav";
  71. import hader from "@/components/hader";
  72. import historicalRecord from "@/components/historicalRecord";
  73. import messageCenter from "@/components/messageCenter";
  74. export default {
  75. name: "SessionHistory",
  76. data() {
  77. return {
  78. isShow: false,
  79. uid: "",
  80. user_name: '',
  81. pages: 0,
  82. tableData: [],
  83. options: [
  84. {
  85. value: "1",
  86. label: "今日"
  87. },
  88. {
  89. value: "3",
  90. label: "最近3天"
  91. },
  92. {
  93. value: "7",
  94. label: "最近7天"
  95. },
  96. {
  97. value: "15",
  98. label: "最近15天"
  99. },
  100. {
  101. value: "30",
  102. label: "最近30天"
  103. }
  104. ],
  105. value: "",
  106. input3: "",
  107. token: "",
  108. time: "",
  109. loading: false,//加载条
  110. startTime: "", // 开始时间
  111. endTime: "",// 结束时间,
  112. keyText:"" // 关键词
  113. };
  114. },
  115. components: {
  116. leftNav,
  117. hader,
  118. historicalRecord,
  119. messageCenter
  120. },
  121. mounted() {
  122. this.value = this.options[2].value;
  123. this.token = this.$store.getters.get_user_info.token;
  124. this.time = JSON.parse(sessionStorage.getItem("time"));
  125. this.getSessionHistory(1);
  126. },
  127. methods: {
  128. // filterEndTime(row, column){
  129. // console.log(row)
  130. // },
  131. evaluateId(row, column) {
  132. // console.log(row.evaluate_id)
  133. if (row.evaluate_id == 0) {
  134. return '未评价'
  135. } else if (row.evaluate_id == 1) {
  136. return "满意"
  137. } else if (row.evaluate_id == 2) {
  138. return '一般'
  139. } else {
  140. return '不满意'
  141. }
  142. },
  143. // 关键字查询
  144. searchText(value){
  145. // console.log(value);
  146. this.keyText = value;
  147. this.getSessionHistory();
  148. },
  149. // 时间查询
  150. searchDate(value) {
  151. var date = new Date();
  152. var seperator1 = "-";
  153. var year = date.getFullYear();
  154. var month = date.getMonth() + 1;
  155. var strDate = date.getDate();
  156. if (month >= 1 && month <= 9) {
  157. month = "0" + month;
  158. }
  159. if (strDate >= 0 && strDate <= 9) {
  160. strDate = "0" + strDate;
  161. }
  162. var currentdate = year + seperator1 + month + seperator1 + strDate;
  163. if (value == 1) {
  164. this.startTime = currentdate;
  165. this.getNewData(currentdate, 0);
  166. this.getSessionHistory();
  167. } else if (value == 3) {
  168. this.startTime = currentdate;
  169. this.getNewData(currentdate, 2);
  170. this.getSessionHistory();
  171. } else if(value == 7){
  172. this.startTime = currentdate;
  173. this.getNewData(currentdate, 6);
  174. this.getSessionHistory();
  175. } else if (value == 15){
  176. this.startTime = currentdate;
  177. this.getNewData(currentdate, 14);
  178. this.getSessionHistory();
  179. }else {
  180. this.startTime = currentdate;
  181. this.getNewData(currentdate, 29);
  182. this.getSessionHistory();
  183. }
  184. },
  185. // 获取结束时间
  186. getNewData(currentdate, days) {
  187. var dateTemp = currentdate.split("-");
  188. var nDate = new Date(dateTemp[1] + '-' + dateTemp[2] + '-' + dateTemp[0]);
  189. var millSeconds = Math.abs(nDate) + (days * 24 * 60 * 60 * 1000);
  190. var rDate = new Date(millSeconds);
  191. var year = rDate.getFullYear();
  192. var month = rDate.getMonth() + 1;
  193. if (month < 10) month = "0" + month;
  194. var date = rDate.getDate();
  195. if (date < 10) date = "0" + date;
  196. this.endTime = (year + "-" + month + "-" + date);
  197. console.log(this.endTime);
  198. },
  199. // 获取会话记录
  200. getSessionHistory(page, size = 10) {
  201. let obj = {
  202. headers: {
  203. // "Content-Type": "application/json",
  204. 'apiToken': this.$md5("historylist" + "customer-service" + "history" + this.time[0] + "service"),
  205. 'userToken': this.token
  206. }
  207. }
  208. this.loading = true;
  209. this.post("api/service/history/historyList", {
  210. currentPage: page,
  211. pageSize: size,
  212. start: this.startTime,
  213. end: this.endTime,
  214. user_name: this.keyText,
  215. }, obj).then(res => {
  216. if (res.data.code == 1) {
  217. console.log(res.data.data.list);
  218. this.tableData = res.data.data.list;
  219. this.tableData.forEach(e => {
  220. e.end_time = this.$public.customFormatDateTime(e.end_time);
  221. e.intime = this.$public.customFormatDateTime(e.intime);
  222. e.start_time = this.$public.customFormatDateTime(e.start_time);
  223. })
  224. this.pages = res.data.data.total;
  225. }
  226. this.loading = false;
  227. });
  228. },
  229. /******************************************/
  230. //查看详情会话记录
  231. click_row(row, column, event) {
  232. //console.log('1231',row, column, event);
  233. this.user_name = row.user_name;
  234. this.uid = row.servicelog_id;
  235. this.isShow = true;
  236. },
  237. /******************************************/
  238. //关闭会话详情记录
  239. childValue(e) {
  240. //console.log(e);
  241. this.isShow = e;
  242. },
  243. /******************上一页*****************/
  244. upData(e) {
  245. this.getSessionHistory(e)
  246. },
  247. /*********************下一页******************/
  248. downData(e) {
  249. this.getSessionHistory(e)
  250. },
  251. /*******************选择页数******************/
  252. current_page(e) {
  253. this.getSessionHistory(e)
  254. }
  255. }
  256. };
  257. </script>
  258. <style scoped>
  259. .el-pagination .btn-next .el-icon {
  260. display: none;
  261. }
  262. .cell {
  263. text-align: center;
  264. }
  265. .el-pagination {
  266. text-align: center;
  267. font-size: 0;
  268. }
  269. .el-table::before {
  270. z-index: 0 !important;
  271. }
  272. /* .el-table td{
  273. padding: 12px 0;
  274. } */
  275. .input-with-select {
  276. width: 100%;
  277. }
  278. .name_box {
  279. margin-left: 20px;
  280. font-size: 14px;
  281. font-weight: bold;
  282. color: rgba(102, 102, 102, 1);
  283. }
  284. .div_box {
  285. width: 100%;
  286. }
  287. .right_box {
  288. position: fixed;
  289. top: 33px;
  290. right: 0;
  291. width: 100%;
  292. /* height: 100vh;
  293. background: red; */
  294. /* //background: rgba(255, 255, 255, 0.315); */
  295. }
  296. </style>