SessionHistory.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. evaluateId(row, column) {
  129. // console.log(row.evaluate_id)
  130. if (row.evaluate_id == 0) {
  131. return '未评价'
  132. } else if (row.evaluate_id == 1) {
  133. return "满意"
  134. } else if (row.evaluate_id == 2) {
  135. return '一般'
  136. } else {
  137. return '不满意'
  138. }
  139. },
  140. // 关键字查询
  141. searchText(value){
  142. // console.log(value);
  143. this.keyText = value;
  144. this.getSessionHistory();
  145. },
  146. // 时间查询
  147. searchDate(value) {
  148. var date = new Date();
  149. var seperator1 = "-";
  150. var year = date.getFullYear();
  151. var month = date.getMonth() + 1;
  152. var strDate = date.getDate();
  153. if (month >= 1 && month <= 9) {
  154. month = "0" + month;
  155. }
  156. if (strDate >= 0 && strDate <= 9) {
  157. strDate = "0" + strDate;
  158. }
  159. var currentdate = year + seperator1 + month + seperator1 + strDate;
  160. if (value == 1) {
  161. this.startTime = currentdate;
  162. this.getNewData(currentdate, 0);
  163. this.getSessionHistory();
  164. } else if (value == 3) {
  165. this.startTime = currentdate;
  166. this.getNewData(currentdate, 2);
  167. this.getSessionHistory();
  168. } else if(value == 7){
  169. this.startTime = currentdate;
  170. this.getNewData(currentdate, 6);
  171. this.getSessionHistory();
  172. } else if (value == 15){
  173. this.startTime = currentdate;
  174. this.getNewData(currentdate, 14);
  175. this.getSessionHistory();
  176. }else {
  177. this.startTime = currentdate;
  178. this.getNewData(currentdate, 29);
  179. this.getSessionHistory();
  180. }
  181. },
  182. // 获取结束时间
  183. getNewData(currentdate, days) {
  184. var dateTemp = currentdate.split("-");
  185. var nDate = new Date(dateTemp[1] + '-' + dateTemp[2] + '-' + dateTemp[0]);
  186. var millSeconds = Math.abs(nDate) + (days * 24 * 60 * 60 * 1000);
  187. var rDate = new Date(millSeconds);
  188. var year = rDate.getFullYear();
  189. var month = rDate.getMonth() + 1;
  190. if (month < 10) month = "0" + month;
  191. var date = rDate.getDate();
  192. if (date < 10) date = "0" + date;
  193. this.endTime = (year + "-" + month + "-" + date);
  194. console.log(this.endTime);
  195. },
  196. // 获取会话记录
  197. getSessionHistory(page, size = 10) {
  198. let obj = {
  199. headers: {
  200. // "Content-Type": "application/json",
  201. 'apiToken': this.$md5("historylist" + "customer-service" + "history" + this.time[0] + "service"),
  202. 'userToken': this.token
  203. }
  204. }
  205. this.loading = true;
  206. this.post("api/service/history/historyList", {
  207. currentPage: page,
  208. pageSize: size,
  209. start: this.startTime,
  210. end: this.endTime,
  211. user_name: this.keyText,
  212. }, obj).then(res => {
  213. if (res.data.code == 1) {
  214. console.log(res.data.data.list);
  215. this.tableData = res.data.data.list;
  216. this.tableData.forEach(e => {
  217. e.end_time = this.$public.customFormatDateTime(e.end_time);
  218. e.intime = this.$public.customFormatDateTime(e.intime);
  219. e.start_time = this.$public.customFormatDateTime(e.start_time);
  220. })
  221. this.pages = res.data.data.total;
  222. }
  223. this.loading = false;
  224. });
  225. },
  226. /******************************************/
  227. //查看详情会话记录
  228. click_row(row, column, event) {
  229. // console.log(row, "历史记录");
  230. this.user_name = row.user_name;
  231. this.uid = row.servicelog_id;
  232. this.isShow = true;
  233. },
  234. /******************************************/
  235. //关闭会话详情记录
  236. childValue(e) {
  237. console.log(e);
  238. this.isShow = e;
  239. },
  240. /******************上一页*****************/
  241. upData(e) {
  242. this.getSessionHistory(e)
  243. },
  244. /*********************下一页******************/
  245. downData(e) {
  246. this.getSessionHistory(e)
  247. },
  248. /*******************选择页数******************/
  249. current_page(e) {
  250. this.getSessionHistory(e)
  251. }
  252. }
  253. };
  254. </script>
  255. <style scoped>
  256. .el-pagination .btn-next .el-icon {
  257. display: none;
  258. }
  259. .cell {
  260. text-align: center;
  261. }
  262. .el-pagination {
  263. text-align: center;
  264. font-size: 0;
  265. }
  266. .el-table::before {
  267. z-index: 0 !important;
  268. }
  269. /* .el-table td{
  270. padding: 12px 0;
  271. } */
  272. .input-with-select {
  273. width: 100%;
  274. }
  275. .name_box {
  276. margin-left: 20px;
  277. font-size: 14px;
  278. font-weight: bold;
  279. color: rgba(102, 102, 102, 1);
  280. }
  281. .div_box {
  282. width: 100%;
  283. }
  284. .right_box {
  285. position: fixed;
  286. top: 33px;
  287. right: 0;
  288. width: 100%;
  289. /* height: 100vh;
  290. background: red; */
  291. /* //background: rgba(255, 255, 255, 0.315); */
  292. }
  293. </style>