index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="医生名称" prop="doctorName" >
  5. <el-input
  6. v-model="queryParams.doctorName"
  7. placeholder="请输入医生名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="客户名称" prop="userName">
  14. <el-input
  15. v-model="queryParams.userName"
  16. placeholder="请输入客户名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态 " prop="status">
  23. <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
  24. <el-option
  25. v-for="item in sessionStatusOptions"
  26. :key="item.dictValue"
  27. :label="item.dictLabel"
  28. :value="item.dictValue"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="接待时间" prop="createTime">
  33. <el-date-picker
  34. style="width:220px"
  35. clearable size="small"
  36. v-model="dateRange"
  37. type="daterange"
  38. value-format="yyyy-MM-dd"
  39. start-placeholder="开始日期"
  40. end-placeholder="结束日期"
  41. @change="changeTime">
  42. </el-date-picker>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <!-- <el-button
  52. type="danger"
  53. plain
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['chat:chatSession:remove']"
  59. >删除</el-button> -->
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="warning"
  64. plain
  65. icon="el-icon-download"
  66. size="mini"
  67. :loading="exportLoading"
  68. @click="handleExport"
  69. v-hasPermi="['chat:chatSession:export']"
  70. >导出</el-button>
  71. </el-col>
  72. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  73. </el-row>
  74. <el-table border v-loading="loading" :data="chatSessionList" @selection-change="handleSelectionChange">
  75. <el-table-column type="selection" width="55" align="center" />
  76. <el-table-column label="ID" align="center" prop="sessionId" />
  77. <el-table-column label="医生" align="center" prop="doctorName" />
  78. <el-table-column label="用户" align="center" prop="userName" />
  79. <el-table-column label="接待时间" align="center" prop="createTime" >
  80. <template slot-scope="scope">
  81. <span v-if="!scope.row.updateTime && scope.row.status === 1">
  82. {{ scope.row.createTime }} - 未结束
  83. </span>
  84. <span v-else>
  85. {{ scope.row.createTime }} - {{ scope.row.updateTime }}
  86. </span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="服务状态" align="center" prop="status">
  90. <template slot-scope="scope">
  91. <el-tag prop="status" v-for="(item, index) in sessionStatusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  95. <template slot-scope="scope">
  96. <el-button
  97. size="mini"
  98. type="text"
  99. @click="handledetails(scope.row)"
  100. >查看</el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. v-show="total>0"
  106. :total="total"
  107. :page.sync="queryParams.pageNum"
  108. :limit.sync="queryParams.pageSize"
  109. @pagination="getList"
  110. />
  111. <!-- 添加或修改会话对话框 -->
  112. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  113. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  114. <el-form-item label="会话标识" prop="sessionCode">
  115. <el-input v-model="form.sessionCode" placeholder="请输入会话标识" />
  116. </el-form-item>
  117. <el-form-item label="客户ID" prop="userId">
  118. <el-input v-model="form.userId" placeholder="请输入客户ID" />
  119. </el-form-item>
  120. <el-form-item label="客服ID" prop="kfId">
  121. <el-input v-model="form.kfId" placeholder="请输入客服ID" />
  122. </el-form-item>
  123. <el-form-item label="状态 1会话中 2已结束">
  124. <el-radio-group v-model="form.status">
  125. <el-radio label="1">请选择字典生成</el-radio>
  126. </el-radio-group>
  127. </el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="submitForm">确 定</el-button>
  131. <el-button @click="cancel">取 消</el-button>
  132. </div>
  133. </el-dialog>
  134. <el-drawer
  135. :with-header="false"
  136. size="75%" @close="handleDrawerClose"
  137. :title="show.title" :visible.sync="show.open">
  138. <chatMsgDetails ref="Details" />
  139. </el-drawer>
  140. </div>
  141. </template>
  142. <script>
  143. import { listSession,delSession } from "@/api/aiDpctorChat/aiDoctorChat";
  144. import chatMsgDetails from '../components/doctorSessionDetails.vue';
  145. import { getAllRoleList } from "@/api/chat/chatRole";
  146. import {allList}from "@/api/company/company";
  147. export default {
  148. name: "ChatSession",
  149. components:{chatMsgDetails},
  150. data() {
  151. return {
  152. roles:[],
  153. companyList:[],
  154. show:{
  155. title:"聊天详情",
  156. open:false,
  157. },
  158. dateRange:[],
  159. sessionStatusOptions:[],
  160. sessionLookOptions:[],
  161. // 遮罩层
  162. loading: true,
  163. // 导出遮罩层
  164. exportLoading: false,
  165. // 选中数组
  166. ids: [],
  167. // 非单个禁用
  168. single: true,
  169. // 非多个禁用
  170. multiple: true,
  171. // 显示搜索条件
  172. showSearch: true,
  173. // 总条数
  174. total: 0,
  175. // 会话表格数据
  176. chatSessionList: [],
  177. // 弹出层标题
  178. title: "",
  179. // 是否显示弹出层
  180. open: false,
  181. // 查询参数
  182. queryParams: {
  183. pageNum: 1,
  184. pageSize: 10,
  185. sessionCode: null,
  186. userId: null,
  187. kfId: null,
  188. status: null,
  189. isLook:null
  190. },
  191. // 表单参数
  192. form: {},
  193. // 表单校验
  194. rules: {
  195. }
  196. };
  197. },
  198. created() {
  199. this.getList();
  200. this.getDicts("sys_chat_session_status").then(response => {
  201. this.sessionStatusOptions = response.data;
  202. });
  203. this.getDicts("sys_chat_session_look").then(response => {
  204. this.sessionLookOptions = response.data;
  205. });
  206. getAllRoleList().then(response => {
  207. this.roles = response.data;
  208. });
  209. this.getAllCompany();
  210. },
  211. methods: {
  212. getAllCompany() {
  213. allList().then(response => {
  214. this.companyList = response.rows;
  215. this.companyList.push({dictLabel: "无",
  216. dictValue: "0"})
  217. });
  218. },
  219. handleDrawerClose(){
  220. this.getList();
  221. },
  222. handledetails(row){
  223. this.show.open=true;
  224. setTimeout(() => {
  225. this.$refs.Details.getDetails(row.sessionId);
  226. }, 500);
  227. },
  228. /** 查询会话列表 */
  229. getList() {
  230. this.loading = true;
  231. listSession(this.queryParams).then(response => {
  232. this.chatSessionList = response.rows;
  233. this.total = response.total;
  234. this.loading = false;
  235. });
  236. },
  237. // 取消按钮
  238. cancel() {
  239. this.open = false;
  240. this.reset();
  241. },
  242. // 表单重置
  243. reset() {
  244. this.form = {
  245. sessionId: null,
  246. sessionCode: null,
  247. userId: null,
  248. kfId: null,
  249. createTime: null,
  250. updateTime: null,
  251. status: 0
  252. };
  253. this.resetForm("form");
  254. },
  255. changeTime(){
  256. if(this.dateRange!=null){
  257. this.queryParams.beginTime=this.dateRange[0];
  258. this.queryParams.endTime=this.dateRange[1];
  259. }else{
  260. this.queryParams.beginTime=null;
  261. this.queryParams.endTime=null;
  262. }
  263. },
  264. /** 搜索按钮操作 */
  265. handleQuery() {
  266. this.queryParams.pageNum = 1;
  267. this.getList();
  268. },
  269. /** 重置按钮操作 */
  270. resetQuery() {
  271. this.resetForm("queryForm");
  272. this.handleQuery();
  273. },
  274. // 多选框选中数据
  275. handleSelectionChange(selection) {
  276. this.ids = selection.map(item => item.sessionId)
  277. this.single = selection.length!==1
  278. this.multiple = !selection.length
  279. },
  280. /** 新增按钮操作 */
  281. handleAdd() {
  282. this.reset();
  283. this.open = true;
  284. this.title = "添加会话";
  285. },
  286. /** 修改按钮操作 */
  287. handleUpdate(row) {
  288. this.reset();
  289. const sessionId = row.sessionId || this.ids
  290. getChatSession(sessionId).then(response => {
  291. this.form = response.data;
  292. this.open = true;
  293. this.title = "修改会话";
  294. });
  295. },
  296. /** 提交按钮 */
  297. submitForm() {
  298. this.$refs["form"].validate(valid => {
  299. if (valid) {
  300. if (this.form.sessionId != null) {
  301. updateChatSession(this.form).then(response => {
  302. this.msgSuccess("修改成功");
  303. this.open = false;
  304. this.getList();
  305. });
  306. } else {
  307. addChatSession(this.form).then(response => {
  308. this.msgSuccess("新增成功");
  309. this.open = false;
  310. this.getList();
  311. });
  312. }
  313. }
  314. });
  315. },
  316. /** 删除按钮操作 */
  317. handleDelete(row) {
  318. const sessionIds = row.sessionId || this.ids;
  319. this.$confirm('是否确认删除会话编号为"' + sessionIds + '"的数据项?', "警告", {
  320. confirmButtonText: "确定",
  321. cancelButtonText: "取消",
  322. type: "warning"
  323. }).then(function() {
  324. return delSession(sessionIds);
  325. }).then(() => {
  326. this.getList();
  327. this.msgSuccess("删除成功");
  328. }).catch(() => {});
  329. },
  330. /** 导出按钮操作 */
  331. handleExport() {
  332. const queryParams = this.queryParams;
  333. this.$confirm('是否确认导出所有会话数据项?', "警告", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning"
  337. }).then(() => {
  338. this.exportLoading = true;
  339. return exportChatSession(queryParams);
  340. }).then(response => {
  341. this.download(response.msg);
  342. this.exportLoading = false;
  343. }).catch(() => {});
  344. }
  345. }
  346. };
  347. </script>