sopLogsList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
  4. <el-form-item label="企微员工账号" prop="qwUserid" v-if="queryParams.type==2">
  5. <el-input
  6. v-model="queryParams.qwUserid"
  7. placeholder="请输入企微员工账号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="销售昵称" prop="qwUserName" v-if="queryParams.type==1">
  14. <el-input
  15. v-model="queryParams.qwUserName"
  16. placeholder="请输入销售昵称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="客户昵称" prop="externalUserName">
  23. <el-input
  24. v-model="queryParams.externalUserName"
  25. placeholder="请输入客户昵称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="发送类型" prop="sendType" >
  32. <el-select v-model="queryParams.sendType" placeholder="请选择发送类型" clearable size="small">
  33. <el-option
  34. v-for="dict in sysQwSopType"
  35. :key="dict.dictValue"
  36. :label="dict.dictLabel"
  37. :value="dict.dictValue"
  38. />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="发送(成员)状态" prop="sendStatus">
  42. <el-select v-model="queryParams.sendStatus" placeholder="请选择发送(成员)状态" clearable size="small">
  43. <el-option
  44. v-for="dict in sysQwSopLogsStatus"
  45. :key="dict.dictValue"
  46. :label="dict.dictLabel"
  47. :value="dict.dictValue"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="预计发送时间" prop="scheduleTime">
  52. <!-- <el-date-picker clearable size="small"-->
  53. <!-- v-model="queryParams.sendTime"-->
  54. <!-- type="datetime"-->
  55. <!-- value-format="yyyy-MM-dd HH:mm:ss"-->
  56. <!-- placeholder="选择预计发送时间">-->
  57. <!-- </el-date-picker>-->
  58. <el-date-picker
  59. clearable size="small"
  60. v-model="scheduleTime"
  61. type="datetimerange"
  62. range-separator="至"
  63. start-placeholder="开始日期"
  64. end-placeholder="结束日期"
  65. placeholder="选择预计发送时间"
  66. @change="handleScheduleTimeChange"
  67. >
  68. </el-date-picker>
  69. </el-form-item>
  70. <el-form-item label="接收(客户)状态" prop="receivingStatus">
  71. <el-select v-model="queryParams.receivingStatus" placeholder="请选择接收(客户)状态" clearable size="small">
  72. <el-option
  73. v-for="dict in groupMsgSendStatusOptions"
  74. :key="dict.dictValue"
  75. :label="dict.dictLabel"
  76. :value="dict.dictValue"
  77. />
  78. </el-select>
  79. </el-form-item>
  80. <el-form-item>
  81. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  82. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  83. </el-form-item>
  84. </el-form>
  85. <el-row :gutter="10" class="mb8">
  86. <el-col :span="1.5">
  87. <el-button
  88. type="warning"
  89. plain
  90. icon="el-icon-download"
  91. size="mini"
  92. :loading="exportLoading"
  93. @click="handleExport"
  94. v-hasPermi="['qw:sopLogs:export']"
  95. >导出</el-button>
  96. <el-button
  97. type="danger"
  98. plain
  99. icon="el-icon-delete"
  100. size="mini"
  101. :disabled="multiple"
  102. @click="handleDelete"
  103. v-hasPermi="['qw:sopLogs:remove']"
  104. >批量删除</el-button>
  105. <el-button
  106. type="success"
  107. plain
  108. icon="el-icon-edit"
  109. size="mini"
  110. :disabled="multiple"
  111. @click="handleEditCourse"
  112. v-hasPermi="['qw:sopLogs:editCourse']"
  113. >再次发送记录</el-button>
  114. </el-col>
  115. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  116. </el-row>
  117. <el-table v-loading="loading" :data="qwSopLogsList" @selection-change="handleSelectionChange">
  118. <el-table-column type="selection" width="55" align="center" />
  119. <el-table-column label="编号" align="center" prop="id" />
  120. <el-table-column label="发送类型" align="center" prop="sendType" width="80">
  121. <template slot-scope="scope">
  122. <dict-tag :options="sysQwSopType" :value="scope.row.sendType"/>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="企微成员账号" align="center" prop="qwUserid" />
  126. <el-table-column label="企微成员昵称" align="center" prop="qwUserName" v-if="queryParams.type==2" />
  127. <!-- <el-table-column label="系统后台昵称" align="center" prop="userName" />-->
  128. <el-table-column label="客户昵称" align="center" prop="externalUserName" />
  129. <el-table-column label="发送的消息" align="center" prop="contentJson" >
  130. <template slot-scope="scope">
  131. <el-button type="text" @click="showContentDialog(scope.row.contentJson)">
  132. 查看详情
  133. </el-button>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="成员状态" align="center" prop="sendStatus" >
  137. <template slot-scope="scope">
  138. <dict-tag :options="sysQwSopLogsStatus" :value="scope.row.sendStatus"/>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="预计发送时间" align="center" prop="sendTime" width="180"/>
  142. <el-table-column label="实际发送时间" align="center" prop="realSendTime" width="180"/>
  143. <!-- <el-table-column label="获取记录" align="center" prop="takeRecords" width="180">-->
  144. <!-- <template slot-scope="scope">-->
  145. <!-- <span v-if="scope.row.takeRecords == 0" :style="{ color: 'red' }" >未获取</span>-->
  146. <!-- <span v-else-if="scope.row.takeRecords == 1" :style="{ color: 'green' }" >已获取</span>-->
  147. <!-- <span v-else :style="{ color: 'gray' }" >未知状态</span>-->
  148. <!-- </template>-->
  149. <!-- </el-table-column>-->
  150. <el-table-column label="客户" align="center" prop="receivingStatus" >
  151. <template slot-scope="scope">
  152. <dict-tag :options="groupMsgSendStatusOptions" :value="scope.row.receivingStatus"/>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="生成时间" align="createTime" prop="createTime" width="180" />
  156. <el-table-column label="消息ID" align="center" prop="msgId" />
  157. <el-table-column label="备注" align="center" prop="remark" />
  158. </el-table>
  159. <el-dialog :visible.sync="contentDialog.isDialogVisible" title="消息详情" width="30%" append-to-body>
  160. <div>
  161. <div v-for="(item, index) in contentDialog.json || []" :key="index">
  162. <el-card class="box-card" style="margin-top: 2%">
  163. <div slot="header" class="clearfix" style="display: flex;justify-content: space-between;align-items: center;">
  164. <div>
  165. <span>类型:</span>
  166. <span v-if="item.contentType == 1">文本</span>
  167. <span v-if="item.contentType == 2">图片</span>
  168. <span v-if="item.contentType == 3">卡片</span>
  169. <span v-if="item.contentType == 4">小程序</span>
  170. <span v-if="item.contentType == 5">文件</span>
  171. <span v-if="item.contentType == 6">视频</span>
  172. <span v-if="item.contentType == 7">语音</span>
  173. <span v-if="item.contentType == 9">APP</span>
  174. </div>
  175. <div v-if="item.sendStatus">
  176. <span>发送状态:</span>
  177. <el-tag type="success" v-if="item.sendStatus == 1">发送成功</el-tag>
  178. <el-tag type="danger" v-if="item.sendStatus == 2">发送失败</el-tag>
  179. </div>
  180. </div>
  181. <div v-if="item.sendStatus && item.sendStatus == 2">发送失败原因:<span style="color: #ff4949">{{item.sendRemarks}}</span></div>
  182. <div v-if="item.contentType == 1" v-html="item.value"></div>
  183. <div v-if="item.contentType == 2">
  184. <el-image
  185. style="width: 100px; height: 100px"
  186. :src="item.imgUrl"
  187. fit="contain"
  188. @click.prevent="openImageViewer(item.imgUrl)" />
  189. </div>
  190. <div v-if="item.contentType == 3 || item.contentType == 9" class="message-style">
  191. <div
  192. style="background-color: white; padding: 10px; width: 100%"
  193. @click="openLink(item.linkUrl)">
  194. <span>{{ item.linkTitle }}</span>
  195. <div style="display: flex; justify-content: space-between; width: 100%">
  196. <span style="font-size: 13px; flex: 1">{{ item.linkDescribe }}</span>
  197. <!-- 点击图片时停止事件冒泡 -->
  198. <el-image
  199. style="width: 50px; height: 50px; flex-shrink: 0"
  200. :src="item.linkImageUrl"
  201. fit="contain"
  202. @click.stop="openImageViewer(item.linkImageUrl)" />
  203. </div>
  204. </div>
  205. </div>
  206. <div v-if="item.contentType == 4" class="message-style">
  207. <div style="display: flex; justify-content: space-between; width: 100%">
  208. <span style="font-size: 13px; flex: 1">{{ item.miniprogramTitle }}</span>
  209. <el-image
  210. style="width: 50px; height: 50px; flex-shrink: 0"
  211. :src="item.miniprogramPicUrl"
  212. fit="contain"
  213. @click.stop="openImageViewer(item.miniprogramPicUrl)" />
  214. </div>
  215. </div>
  216. <div v-if="item.contentType == 5" class="message-style">
  217. <el-link type="primary" :href="item.fileUrl" download style="padding: 10px">
  218. {{ item.fileUrl }}
  219. </el-link>
  220. </div>
  221. <div v-if="item.contentType == 6" class="message-style">
  222. <video
  223. :src="item.videoUrl"
  224. controls
  225. style="width: 200px; height: 100px">
  226. </video>
  227. </div>
  228. <div v-if="item.contentType == 7">
  229. <span>
  230. {{ item.value }}
  231. </span>
  232. <div v-if="!item.voiceUrl" style="margin-top: 3px" >
  233. <span style="color: red">无语音地址</span>
  234. </div>
  235. </div>
  236. <div v-if="item.contentType == 8" class="message-style">
  237. <el-card class="box-card" v-if="item.coverUrl">
  238. <el-form-item label="封面标题:" label-width="100px">
  239. <el-input v-model="item.nickname" style="width: 90%;margin-bottom: 1%" disabled/>
  240. </el-form-item>
  241. <el-form-item label="头像:" label-width="100px" >
  242. <el-image
  243. v-if="item.avatar != null"
  244. :src="item.avatar"
  245. :preview-src-list="[item.avatar]"
  246. :style="{ width: '50px', height: '50px' }"
  247. ></el-image>
  248. </el-form-item>
  249. <el-form-item label="封面:" label-width="100px" >
  250. <el-image
  251. v-if="item.coverUrl != null"
  252. :src="item.coverUrl"
  253. :preview-src-list="[item.coverUrl]"
  254. :style="{ width: '200px', height: '200px' }"
  255. ></el-image>
  256. </el-form-item>
  257. <el-form-item label="简介:" label-width="100px" >
  258. <el-input type="textarea" :rows="3" v-model="item.desc" style="width: 90%;margin-top: 1%;" disabled />
  259. </el-form-item>
  260. <el-form-item label="视频地址:" label-width="100px" style="margin-top: 1%" >
  261. <el-input v-model="item.url" style="width: 90%;" disabled />
  262. </el-form-item >
  263. </el-card>
  264. </div>
  265. </el-card>
  266. </div>
  267. </div>
  268. <span slot="footer" class="dialog-footer">
  269. <el-button @click="contentDialog.isDialogVisible = false">关闭</el-button>
  270. </span>
  271. </el-dialog>
  272. <!-- 大图预览对话框 -->
  273. <el-dialog
  274. :visible.sync="dialogVisible"
  275. :modal="false"
  276. width="500"
  277. append-to-body>
  278. <img
  279. :src="this.dialogImageUrl"
  280. style="display: block; max-width: 100%; margin: 0 auto"
  281. />
  282. </el-dialog>
  283. <pagination
  284. v-show="total>0"
  285. :total="total"
  286. :page.sync="queryParams.pageNum"
  287. :limit.sync="queryParams.pageSize"
  288. @pagination="getList"
  289. />
  290. </div>
  291. </template>
  292. <script>
  293. import {
  294. listQwSopLogs,
  295. exportQwSopLogs,
  296. listQwSopLogsList,
  297. delQwSopLogs,
  298. editCourseQwSopLogs
  299. } from '../../../api/qw/sopLogs'
  300. import {delSopUserLogsInfo} from "@/api/qw/sopUserLogsInfo";
  301. export default {
  302. name: "sopLogsList",
  303. props:{
  304. rowDetailFrom:{},
  305. },
  306. watch:{
  307. rowDetailFrom:{
  308. handler(newVal){
  309. // 当formData变化时重新查询
  310. this.getList(newVal);
  311. },
  312. deep: true
  313. }
  314. },
  315. data() {
  316. return {
  317. //图片放大
  318. dialogVisible: false,
  319. dialogImageUrl:null,
  320. //时间选择
  321. scheduleTime: null,
  322. // 遮罩层
  323. loading: true,
  324. // 导出遮罩层
  325. exportLoading: false,
  326. // 选中数组
  327. ids: [],
  328. // 非单个禁用
  329. single: true,
  330. // 非多个禁用
  331. multiple: true,
  332. // 显示搜索条件
  333. showSearch: true,
  334. // 总条数
  335. total: 0,
  336. // 企业微信SOP 定时任务表格数据
  337. qwSopLogsList: [],
  338. //成员状态
  339. sysQwSopLogsStatus:[],
  340. //客户接收状态
  341. groupMsgSendStatusOptions:[],
  342. //企微SOP发送类型
  343. sysQwSopType: [],
  344. //发送的消息
  345. contentDialog:{
  346. isDialogVisible:false,
  347. json: [],
  348. },
  349. // 弹出层标题
  350. title: "",
  351. // 是否显示弹出层
  352. open: false,
  353. // 查询参数
  354. queryParams: {
  355. pageNum: 1,
  356. pageSize: 10,
  357. qwUserName: null,
  358. qwUserid: null,
  359. externalUserName: null,
  360. sendStatus: null,
  361. sendTime: null,
  362. corpId:null,
  363. receivingStatus: null,
  364. sendType: null,
  365. type:null,
  366. scheduleEndTime:null,
  367. scheduleStartTime:null,
  368. },
  369. // 表单参数
  370. form: {},
  371. // 表单校验
  372. rules: {
  373. }
  374. };
  375. },
  376. created() {
  377. this.getList(this.rowDetailFrom);
  378. //成员状态
  379. this.getDicts("sys_qw_sopLogs_status").then(response => {
  380. this.sysQwSopLogsStatus = response.data;
  381. });
  382. //客户接收状态
  383. this.getDicts("sys_qw_groupMsg_SendStatus").then(response => {
  384. this.groupMsgSendStatusOptions = response.data;
  385. });
  386. //发送消息类型
  387. this.getDicts("sys_qw_sop_course_type").then(response => {
  388. this.sysQwSopType = response.data;
  389. });
  390. },
  391. methods: {
  392. /** 查询企业微信SOP 定时任务列表 */
  393. getList(val) {
  394. this.queryParams.sopId = val.id || this.rowDetailFrom.id;
  395. this.queryParams.corpId= val.corpId || this.rowDetailFrom.corpId;
  396. this.queryParams.type= val.type || this.rowDetailFrom.type;
  397. this.loading = true;
  398. listQwSopLogsList(this.queryParams).then(response => {
  399. // console.log("response.rows",response.rows)
  400. this.qwSopLogsList = response.rows;
  401. this.total = response.total;
  402. this.loading = false;
  403. });
  404. },
  405. handleScheduleTimeChange(val) {
  406. if (val) {
  407. this.queryParams.scheduleStartTime = this.formatDateTime(val[0]);
  408. this.queryParams.scheduleEndTime = this.formatDateTime(val[1]);
  409. } else {
  410. this.queryParams.scheduleStartTime = null;
  411. this.queryParams.scheduleEndTime = null;
  412. }
  413. },
  414. // 格式化日期为 yyyy-MM-dd HH:mm:ss 的北京时间
  415. formatDateTime(date) {
  416. if (!date) return null;
  417. // 创建国际化时间格式,指定为 Asia/Shanghai 时区
  418. const options = {
  419. timeZone: 'Asia/Shanghai',
  420. year: 'numeric',
  421. month: '2-digit',
  422. day: '2-digit',
  423. hour: '2-digit',
  424. minute: '2-digit',
  425. second: '2-digit',
  426. hour12: false, // 24小时制
  427. };
  428. // 获取格式化的日期字符串(如 2025-01-23, 16:00:00)
  429. const formattedDate = new Intl.DateTimeFormat('zh-CN', options).format(new Date(date));
  430. // 转换为 yyyy-MM-dd HH:mm:ss 格式
  431. const [datePart, timePart] = formattedDate.replace(',', '').split(' ');
  432. return `${datePart} ${timePart}`;
  433. },
  434. // 取消按钮
  435. cancel() {
  436. this.open = false;
  437. this.reset();
  438. },
  439. // 表单重置
  440. reset() {
  441. this.form = {
  442. id: null,
  443. qwUserName: null,
  444. externalUserName: null,
  445. logType: null,
  446. contentJson: null,
  447. sendStatus: null,
  448. sendTime: null,
  449. companyId: null,
  450. receivingStatus: null,
  451. msgId: null,
  452. sendType: null,
  453. sopId: null
  454. };
  455. this.resetForm("form");
  456. },
  457. openImageViewer(url) {
  458. // 打开大图预览对话框
  459. this.dialogImageUrl=url
  460. this.dialogVisible = true;
  461. },
  462. openLink(url){
  463. // 使用 window.open 打开链接
  464. window.open(url, '_blank');
  465. },
  466. //查看发送的消息体
  467. showContentDialog(contentJson) {
  468. // 解析 JSON 字符串为 JavaScript 对象
  469. // 替换非法换行符等控制字符
  470. const sanitizedJson = contentJson.replace(/[\u0000-\u001F\u007F]/g, '');
  471. const parsedData = JSON.parse(sanitizedJson);
  472. this.contentDialog.json = parsedData.setting;
  473. this.contentDialog.isDialogVisible = true;
  474. },
  475. /** 搜索按钮操作 */
  476. handleQuery() {
  477. this.queryParams.pageNum = 1;
  478. this.getList(this.rowDetailFrom);
  479. },
  480. /** 重置按钮操作 */
  481. resetQuery() {
  482. this.resetForm("queryForm");
  483. this.queryParams.scheduleStartTime=null;
  484. this.queryParams.scheduleEndTime=null;
  485. this.handleQuery();
  486. },
  487. // 多选框选中数据
  488. handleSelectionChange(selection) {
  489. this.ids = selection.map(item => item.id)
  490. this.single = selection.length!==1
  491. this.multiple = !selection.length
  492. },
  493. /** 删除按钮操作 */
  494. handleDelete(row) {
  495. const ids = row.id || this.ids;
  496. this.$confirm('是否确认删除【执行详情】编号为"【' + ids + '】"的数据项?', "警告", {
  497. confirmButtonText: "确定",
  498. cancelButtonText: "取消",
  499. type: "warning"
  500. }).then(function() {
  501. return delQwSopLogs(ids);
  502. }).then(() => {
  503. this.getList(this.rowDetailFrom);
  504. this.msgSuccess("删除成功");
  505. }).catch(() => {});
  506. },
  507. /**
  508. * 批量修改发送记录
  509. */
  510. handleEditCourse(row){
  511. const ids = row.id || this.ids;
  512. this.$confirm('确认要再次发送【执行详情】编号为"【' + ids + '】"的记录?', "警告", {
  513. confirmButtonText: "确定",
  514. cancelButtonText: "取消",
  515. type: "warning"
  516. }).then(function() {
  517. return editCourseQwSopLogs(ids);
  518. }).then(() => {
  519. this.getList(this.rowDetailFrom);
  520. this.msgSuccess("已经 修改记录为 待发送~");
  521. }).catch(() => {});
  522. },
  523. /** 导出按钮操作 */
  524. handleExport() {
  525. const queryParams = this.queryParams;
  526. this.$confirm('是否确认导出所有企业微信SOP 定时任务数据项?', "警告", {
  527. confirmButtonText: "确定",
  528. cancelButtonText: "取消",
  529. type: "warning"
  530. }).then(() => {
  531. this.exportLoading = true;
  532. return exportQwSopLogs(queryParams);
  533. }).then(response => {
  534. this.download(response.msg);
  535. this.exportLoading = false;
  536. }).catch(() => {});
  537. }
  538. }
  539. };
  540. </script>
  541. <style scoped>
  542. .message-stayle{
  543. display: flex;
  544. justify-content: normal;
  545. align-items: center;
  546. margin-top: 10px;
  547. }
  548. .message-stayle .el-link {
  549. white-space: normal; /* 允许换行 */
  550. word-break: break-all; /* 单词中间断行 */
  551. overflow-wrap: break-word; /* 允许在单词内换行 */
  552. }
  553. .message-stayle span {
  554. word-break: break-all;
  555. }
  556. </style>