index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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="nickName">
  5. <el-input
  6. v-model="queryParams.nickName"
  7. placeholder="请输入用户昵称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="客服角色" prop="roleId">
  14. <el-select v-model="queryParams.roleId" placeholder="请选择客服角色" clearable size="small">
  15. <el-option
  16. v-for="item in roles"
  17. :key="item.roleId"
  18. :label="item.roleName"
  19. :value="item.roleId"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="消息类型" prop="msgType">
  24. <el-select v-model="queryParams.msgType" placeholder="请选择类型" clearable size="small">
  25. <el-option
  26. v-for="item in typeOptions"
  27. :key="item.dictValue"
  28. :label="item.dictLabel"
  29. :value="item.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="发送时间" prop="createTime">
  34. <el-date-picker
  35. style="width:220px"
  36. clearable size="small"
  37. v-model="dateRange"
  38. type="daterange"
  39. value-format="yyyy-MM-dd"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期">
  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="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. :loading="exportLoading"
  57. @click="handleExport"
  58. v-hasPermi="['chat:chatMsg:export']"
  59. >导出</el-button>
  60. </el-col>
  61. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  62. </el-row>
  63. <el-table border v-loading="loading" :data="chatMsgList" @selection-change="handleSelectionChange">
  64. <el-table-column type="selection" width="55" align="center" />
  65. <el-table-column label="ID" align="center" prop="msgId" />
  66. <el-table-column label="用户" align="center" prop="nickName" />
  67. <el-table-column label="头像" width="150" align="center">
  68. <template slot-scope="scope">
  69. <img :src="scope.row.avatar" style="height: 80px">
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="AI客服" align="center" prop="roleName" />
  73. <el-table-column show-overflow-tooltip label="消息内容" align="center" prop="content" />
  74. <el-table-column label="消息类型" align="center" prop="msgType">
  75. <template slot-scope="scope">
  76. <el-tag prop="type" v-for="(item, index) in typeOptions" v-if="scope.row.msgType==item.dictValue">{{item.dictLabel}}</el-tag>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="发送方式" align="center" prop="sendType">
  80. <template slot-scope="scope">
  81. <el-tag prop="type" v-for="(item, index) in sendTypeOptions" v-if="scope.row.sendType==item.dictValue">{{item.dictLabel}}</el-tag>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="发送时间" align="center" prop="createTime" />
  85. </el-table>
  86. <pagination
  87. v-show="total>0"
  88. :total="total"
  89. :page.sync="queryParams.pageNum"
  90. :limit.sync="queryParams.pageSize"
  91. @pagination="getList"
  92. />
  93. </div>
  94. </template>
  95. <script>
  96. import { listFastGptChatMsg, getFastGptChatMsg, delFastGptChatMsg, addFastGptChatMsg, updateFastGptChatMsg, exportFastGptChatMsg } from "@/api/fastGpt/fastGptChatMsg";
  97. import { getAllRoleList } from "@/api/fastGpt/fastGptRole";
  98. export default {
  99. name: "ChatMsg",
  100. data() {
  101. return {
  102. show:{
  103. title:"聊天详情",
  104. open:false,
  105. },
  106. roles:[],
  107. dateRange:[],
  108. typeOptions:[],
  109. sendTypeOptions:[],
  110. // 遮罩层
  111. loading: true,
  112. // 导出遮罩层
  113. exportLoading: false,
  114. // 选中数组
  115. ids: [],
  116. // 非单个禁用
  117. single: true,
  118. // 非多个禁用
  119. multiple: true,
  120. // 显示搜索条件
  121. showSearch: true,
  122. // 总条数
  123. total: 0,
  124. // 聊天消息记录表格数据
  125. chatMsgList: [],
  126. // 弹出层标题
  127. title: "",
  128. // 是否显示弹出层
  129. open: false,
  130. // 查询参数
  131. queryParams: {
  132. pageNum: 1,
  133. pageSize: 10,
  134. chatId: null,
  135. content: null,
  136. msgType: null,
  137. sendType: null,
  138. companyId: null,
  139. roleId: null,
  140. companyUserId: null,
  141. msgJson: null
  142. },
  143. // 表单参数
  144. form: {},
  145. // 表单校验
  146. rules: {
  147. }
  148. };
  149. },
  150. created() {
  151. this.getDicts("chat_msg_type").then((response) => {
  152. this.typeOptions = response.data;
  153. });
  154. this.getDicts("chat_msg_send_type").then((response) => {
  155. this.sendTypeOptions = response.data;
  156. });
  157. getAllRoleList().then(response => {
  158. this.roles = response.data;
  159. });
  160. this.getList();
  161. },
  162. methods: {
  163. handleShow(){
  164. },
  165. /** 查询聊天消息记录列表 */
  166. getList() {
  167. this.loading = true;
  168. listFastGptChatMsg(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  169. this.chatMsgList = response.rows;
  170. this.total = response.total;
  171. this.loading = false;
  172. });
  173. },
  174. // 取消按钮
  175. cancel() {
  176. this.open = false;
  177. this.reset();
  178. },
  179. // 表单重置
  180. reset() {
  181. this.form = {
  182. msgId: null,
  183. chatId: null,
  184. content: null,
  185. msgType: null,
  186. sendType: null,
  187. companyId: null,
  188. roleId: null,
  189. companyUserId: null,
  190. createTime: null,
  191. msgJson: null
  192. };
  193. this.resetForm("form");
  194. },
  195. /** 搜索按钮操作 */
  196. handleQuery() {
  197. this.queryParams.pageNum = 1;
  198. this.getList();
  199. },
  200. /** 重置按钮操作 */
  201. resetQuery() {
  202. this.resetForm("queryForm");
  203. this.dateRange=null
  204. this.handleQuery();
  205. },
  206. // 多选框选中数据
  207. handleSelectionChange(selection) {
  208. this.ids = selection.map(item => item.msgId)
  209. this.single = selection.length!==1
  210. this.multiple = !selection.length
  211. },
  212. /** 新增按钮操作 */
  213. handleAdd() {
  214. this.reset();
  215. this.open = true;
  216. this.title = "添加聊天消息记录";
  217. },
  218. /** 修改按钮操作 */
  219. handleUpdate(row) {
  220. this.reset();
  221. const msgId = row.msgId || this.ids
  222. getFastGptChatMsg(msgId).then(response => {
  223. this.form = response.data;
  224. this.open = true;
  225. this.title = "修改聊天消息记录";
  226. });
  227. },
  228. /** 提交按钮 */
  229. submitForm() {
  230. this.$refs["form"].validate(valid => {
  231. if (valid) {
  232. if (this.form.msgId != null) {
  233. updateFastGptChatMsg(this.form).then(response => {
  234. this.msgSuccess("修改成功");
  235. this.open = false;
  236. this.getList();
  237. });
  238. } else {
  239. addFastGptChatMsg(this.form).then(response => {
  240. this.msgSuccess("新增成功");
  241. this.open = false;
  242. this.getList();
  243. });
  244. }
  245. }
  246. });
  247. },
  248. /** 删除按钮操作 */
  249. handleDelete(row) {
  250. const msgIds = row.msgId || this.ids;
  251. this.$confirm('是否确认删除聊天消息记录编号为"' + msgIds + '"的数据项?', "警告", {
  252. confirmButtonText: "确定",
  253. cancelButtonText: "取消",
  254. type: "warning"
  255. }).then(function() {
  256. return delFastGptChatMsg(msgIds);
  257. }).then(() => {
  258. this.getList();
  259. this.msgSuccess("删除成功");
  260. }).catch(() => {});
  261. },
  262. /** 导出按钮操作 */
  263. handleExport() {
  264. const queryParams = this.queryParams;
  265. this.$confirm('是否确认导出所有聊天消息记录数据项?', "警告", {
  266. confirmButtonText: "确定",
  267. cancelButtonText: "取消",
  268. type: "warning"
  269. }).then(() => {
  270. this.exportLoading = true;
  271. return exportFastGptChatMsg(queryParams);
  272. }).then(response => {
  273. this.download(response.msg);
  274. this.exportLoading = false;
  275. }).catch(() => {});
  276. }
  277. }
  278. };
  279. </script>
  280. <style lang="css">
  281. .el-tooltip__popper{
  282. max-width:40%
  283. }
  284. </style>