sopUserLogsSchedule.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div class="app-container">
  3. <div style="margin-bottom: 10px">
  4. <el-card>
  5. <span class="custom-style" style="display: block; margin-bottom: 10px">自动化规则名称:{{sopName}}</span>
  6. <span class="custom-style" style="display: block; margin-bottom: 10px">自动化规则编号:{{queryParams.sopId}}</span>
  7. <span class="custom-style" style="display: block;">模板编号:{{tempId}}</span>
  8. </el-card>
  9. </div>
  10. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  11. <el-form-item label="企微员工账号" prop="qwUserId">
  12. <el-input
  13. v-model="queryParams.qwUserId"
  14. placeholder="请输入企微员工账号"
  15. clearable
  16. size="small"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="企微员工昵称" prop="qwUserName">
  21. <el-input
  22. v-model="queryParams.qwUserName"
  23. placeholder="请输入企微员工昵称"
  24. clearable
  25. size="small"
  26. @keyup.enter.native="handleQuery"
  27. />
  28. </el-form-item>
  29. <el-form-item label="营期时间" prop="startTime">
  30. <el-date-picker clearable size="small"
  31. v-model="queryParams.startTime"
  32. type="date"
  33. value-format="yyyy-MM-dd"
  34. placeholder="选择营期时间">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item label="状态" prop="status">
  38. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  39. <el-option
  40. v-for="dict in sopUserLogsDelStatus"
  41. :key="dict.dictValue"
  42. :label="dict.dictLabel"
  43. :value="dict.dictValue"
  44. />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="客户名称" prop="externalUserName">
  48. <el-input
  49. v-model="queryParams.externalUserName"
  50. placeholder="请输入客户名称"
  51. clearable
  52. size="small"
  53. @keyup.enter.native="handleQuery"
  54. />
  55. </el-form-item>
  56. <el-form-item label="客户id" prop="externalId">
  57. <el-input
  58. v-model="queryParams.externalId"
  59. placeholder="请输入企微客户id"
  60. clearable
  61. size="small"
  62. @keyup.enter.native="handleQuery"
  63. />
  64. </el-form-item>
  65. <el-form-item>
  66. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  67. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  68. </el-form-item>
  69. </el-form>
  70. <el-row :gutter="10" class="mb8" v-if="filterMode == 1">
  71. <el-col :span="1.5">
  72. <el-tooltip class="item" effect="dark" content="此功能用于给 选中的 营期 内【所有的】客户发送 消息【或者发送草稿-/-清楚草稿】" placement="top">
  73. <el-button
  74. type="warning"
  75. icon="el-icon-s-promotion"
  76. size="medium"
  77. :disabled="multiple"
  78. @click="handleCampSendMsg"
  79. v-hasPermi="['qw:sopUserLogsInfo:msgSchedule']"
  80. >营期一键群发(或草稿)</el-button>
  81. </el-tooltip>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-tooltip class="item" effect="dark" content="删除营期之后,将不会在给原营期的客户发送消息,ps:删除之后不可恢复" placement="top">
  85. <el-button
  86. type="danger"
  87. icon="el-icon-s-promotion"
  88. size="medium"
  89. :disabled="multiple"
  90. @click="handleDeleteUserLogs"
  91. v-hasPermi="['qw:sopUserLogs:remove']"
  92. >批量删除营期</el-button>
  93. </el-tooltip>
  94. </el-col>
  95. </el-row>
  96. <el-row :gutter="10" class="mb8" v-if="filterMode == 2">
  97. <el-col :span="1.5">
  98. <el-tooltip class="item" effect="dark" content="添加新群聊进入任务" placement="top">
  99. <el-button
  100. type="warning"
  101. icon="el-icon-plus"
  102. size="medium"
  103. @click="addGroup"
  104. >追加群聊</el-button>
  105. </el-tooltip>
  106. </el-col>
  107. <el-col :span="1.5">
  108. <el-tooltip class="item" effect="dark" content="修改选择的群聊营期时间" placement="top">
  109. <el-button
  110. type="danger"
  111. icon="el-icon-edit"
  112. size="medium"
  113. :disabled="multiple"
  114. @click="updateGroupTime"
  115. >批量修改营期时间</el-button>
  116. </el-tooltip>
  117. </el-col>
  118. <el-col :span="1.5">
  119. <el-tooltip class="item" effect="dark" content="删除营期之后,将不会在给原营期的群发送消息,ps:删除之后不可恢复" placement="top">
  120. <el-button
  121. type="danger"
  122. icon="el-icon-s-promotion"
  123. size="medium"
  124. :disabled="multiple"
  125. @click="handleDeleteUserLogs"
  126. v-hasPermi="['qw:sopUserLogs:remove']"
  127. >批量删除营期</el-button>
  128. </el-tooltip>
  129. </el-col>
  130. </el-row>
  131. <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px" v-if="filterMode == 1">
  132. <i class="el-icon-info"></i>
  133. 【营期一键群发】:此功能用于给 选中的 营期 内【所有的】客户发送 消息【或者发送草稿-/-清楚草稿】
  134. </div>
  135. <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px" v-if="filterMode == 1">
  136. <i class="el-icon-info"></i>
  137. 【批量删除营期】:此功能用于删除选中的【整个营期】,删除之后将不会在给原营期的客户发送消息,ps:删除之后不可恢复
  138. </div>
  139. <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px" v-if="filterMode == 1">
  140. <i class="el-icon-info"></i>
  141. 【天数】:【列表:营期时间】对应列表中的天数是几 就代表着 插件助手 会发送【任务模板】里的第几天的消息
  142. </div>
  143. <el-table border v-loading="loading" :data="sopUserLogsList" @selection-change="handleSelectionChange">
  144. <el-table-column type="selection" width="55" align="center" />
  145. <el-table-column label="营期编号" align="center" prop="id" />
  146. <el-table-column label="企微员工账号" align="center" prop="qwUserId" />
  147. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  148. <el-table-column label="群聊" align="center" prop="chatName" v-if="filterMode == 2" />
  149. <el-table-column label="营期时间" align="center" prop="startTime" width="180">
  150. <template slot-scope="scope">
  151. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="天数" align="center" prop="countDays" />
  155. <el-table-column label="状态" align="center" prop="status" >
  156. <template slot-scope="scope">
  157. <div v-if="scope.row.userId && scope.row.userId.includes('null')">
  158. <span style="color: orange;">营期异常</span>
  159. </div>
  160. <div v-else>
  161. <dict-tag :options="sopUserLogsDelStatus" :value="scope.row.status"/>
  162. </div>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" v-if="filterMode == 1">
  166. <template slot-scope="scope">
  167. <el-button
  168. v-if="scope.row.status ==1"
  169. size="mini"
  170. type="text"
  171. icon="el-icon-edit"
  172. @click="handleSelect(scope.row)"
  173. v-hasPermi="['qw:sop:list']"
  174. >营期详情</el-button>
  175. <el-button
  176. v-if="scope.row.userId && scope.row.userId.includes('null')"
  177. size="mini"
  178. type="text"
  179. icon="el-icon-s-check"
  180. @click="handleRepairLogs(scope.row)"
  181. v-hasPermi="['qw:sop:list']"
  182. >修复营期</el-button>
  183. <!-- <el-button-->
  184. <!-- size="mini"-->
  185. <!-- type="text"-->
  186. <!-- icon="el-icon-edit"-->
  187. <!-- @click="handleTemp(scope.row)"-->
  188. <!-- >新建群发任务</el-button>-->
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. <pagination
  193. v-show="total>0"
  194. :total="total"
  195. :page.sync="queryParams.pageNum"
  196. :limit.sync="queryParams.pageSize"
  197. @pagination="getList"
  198. />
  199. <!-- 执行详情 -->
  200. <el-drawer :title="logsInfoDetailsOpen.title" :visible.sync="logsInfoDetailsOpen.open" size="88%" style="font-weight: bolder">
  201. <sop-user-logs-info-details ref="SopUserLogsInfoDetails" :rowDetailFrom="logsInfoDetailsOpen.item" @flashNotify="flashNotify"></sop-user-logs-info-details>
  202. </el-drawer>
  203. <send-msg-open-tool ref="sendMsgOpenTool" ></send-msg-open-tool>
  204. <el-dialog title="修改营期时间" :visible.sync="updateTimeData.open" width="800px" append-to-body>
  205. <p>
  206. <span>选择群聊:</span>
  207. <el-tag v-for="name in chatNames">{{name}}</el-tag>
  208. </p>
  209. <el-form ref="msgForm" :model="updateTimeData.form" label-width="100px">
  210. <el-form-item label="日期">
  211. <el-date-picker
  212. v-model="updateTimeData.form.date"
  213. type="date"
  214. value-format="yyyy-MM-dd"
  215. placeholder="选择日期">
  216. </el-date-picker>
  217. </el-form-item>
  218. </el-form>
  219. <div slot="footer" class="dialog-footer">
  220. <el-button type="primary" @click="submitUpdateTimeForm">确 定</el-button>
  221. <el-button @click="updateTimeData.open = false">取 消</el-button>
  222. </div>
  223. </el-dialog>
  224. <el-dialog title="选择企微" :visible.sync="addGroupData.userOpen" width="1300px" append-to-body>
  225. <qwUserList ref="QwUserList" @selectUserList="selectUserList"></qwUserList>
  226. </el-dialog>
  227. <el-dialog title="追加群聊" :visible.sync="addGroupData.open" width="800px" append-to-body>
  228. <el-form ref="msgForm" :model="addGroupData.form" label-width="100px">
  229. <el-form-item label="选择员工" prop="qwUserIds" style="margin-top: 2%">
  230. <div>
  231. <el-button
  232. size="medium"
  233. icon="el-icon-circle-plus-outline"
  234. plain
  235. @click="handleCompanyUser">请选择使用员工</el-button>
  236. </div>
  237. <div>
  238. <el-tag
  239. style="margin-left: 5px"
  240. size="medium"
  241. :key="id"
  242. v-for="id in userSelectList"
  243. closable
  244. :disable-transitions="false"
  245. @close="handleClosegroupUser(id)">
  246. <span v-for="list in companyUserLists " :key="list.userId" v-if="list.id == id">{{list.qwUserName}}</span>
  247. </el-tag>
  248. </div>
  249. </el-form-item>
  250. <el-form-item label="群聊">
  251. <el-select multiple filterable clearable v-model="addGroupData.form.chatIds">
  252. <el-option v-for="item in addGroupData.selectChat" :key="item.chatId" :label="item.name" :value="item.chatId"/>
  253. </el-select>
  254. </el-form-item>
  255. <el-form-item label="日期">
  256. <el-date-picker
  257. v-model="addGroupData.form.date"
  258. type="date"
  259. value-format="yyyy-MM-dd"
  260. placeholder="选择日期">
  261. </el-date-picker>
  262. </el-form-item>
  263. </el-form>
  264. <div slot="footer" class="dialog-footer">
  265. <el-button type="primary" @click="submitAddGroupForm">确 定</el-button>
  266. <el-button @click="addGroupData.open = false">取 消</el-button>
  267. </div>
  268. </el-dialog>
  269. </div>
  270. </template>
  271. <script>
  272. import {
  273. delSopUserLogs,
  274. exportSopUserLogs,
  275. listSopUserLogs,
  276. repairSopUserLogs,
  277. getSelectChat,
  278. addGroupChat,
  279. updateLogDate
  280. } from "../../../api/qw/sopUserLogs";
  281. import sopLogsDetails from "@/views/qw/sopLogs/sopLogsList.vue";
  282. import SopUserLogsInfoDetails from "@/views/qw/sopUserLogsInfo/sopUserLogsInfoDetails.vue";
  283. import sendMsgOpenTool from "../../../views/qw/sopUserLogsInfo/sendMsgOpenTool.vue";
  284. import {listAll as chatListAll} from "@/api/qw/groupChat";
  285. import companyUserList from "@/views/company/companyUser/companyUserList.vue";
  286. import qwUserList from "@/views/qw/user/qwUserList.vue";
  287. import {getQwAllUserList, listUser} from "@/api/company/companyUser";
  288. export default {
  289. name: "sopUserLogsSchedule",
  290. components: {qwUserList, companyUserList, SopUserLogsInfoDetails, sopLogsDetails,sendMsgOpenTool},
  291. props:{
  292. rowDetailFrom:{},
  293. },
  294. data() {
  295. return {
  296. qwUserIds: [],
  297. sopUserLogId:null,
  298. companyUserLists:[],
  299. sopName:'',
  300. tempId:'',
  301. // 遮罩层
  302. loading: true,
  303. // 导出遮罩层
  304. exportLoading: false,
  305. filterMode: 1,
  306. // 选中数组
  307. ids: [],
  308. chatNames: [],
  309. statusOptions: [],
  310. // 非单个禁用
  311. single: true,
  312. // 非多个禁用
  313. multiple: true,
  314. // 显示搜索条件
  315. showSearch: true,
  316. // 总条数
  317. total: 0,
  318. logsInfoDetailsOpen:{
  319. title:"",
  320. open:false,
  321. },
  322. sysQwSopAiContentType:[],
  323. userSelectList:[],
  324. // sopUserLogs表格数据
  325. sopUserLogsList: [],
  326. sopUserLogsDelStatus:[],
  327. // 弹出层标题
  328. title: "",
  329. // 是否显示弹出层
  330. open: false,
  331. // 查询参数
  332. addGroupData: {
  333. open: false,
  334. userOpen: false,
  335. selectChat: [],
  336. form: {
  337. chatIds: [],
  338. },
  339. },
  340. updateTimeData: {
  341. open: false,
  342. form: {
  343. date: null,
  344. },
  345. },
  346. queryParams: {
  347. pageNum: 1,
  348. pageSize: 10,
  349. sopId: null,
  350. userLogsId:null,
  351. externalUserName:null,
  352. externalId:null,
  353. sopTempId: null,
  354. qwUserId: null,
  355. qwUserName: null,
  356. corpId: null,
  357. startTime: null,
  358. status: null,
  359. userId: null,
  360. type:null,
  361. },
  362. sendMsgOpen:{
  363. title:'营期一键批量群发',
  364. open:false,
  365. ids:null,
  366. },
  367. setting:[],
  368. // 表单参数
  369. form: {},
  370. tempForm: {
  371. setting:null,
  372. videoIdSet:null,
  373. courseIdSet:null,
  374. },
  375. // 表单校验
  376. rules: {
  377. }
  378. };
  379. },
  380. created() {
  381. this.getDicts("sys_company_status").then(response => {
  382. this.statusOptions = response.data;
  383. });
  384. this.getDicts("sop_user_logs_del_status").then(response => {
  385. this.sopUserLogsDelStatus = response.data;
  386. });
  387. this.getDicts("sys_qwSopAi_contentType").then(response => {
  388. this.sysQwSopAiContentType = response.data;
  389. });
  390. this.queryParams.sopId = this.$route.params.id;
  391. this.sopName = this.$route.query.name;
  392. this.filterMode = this.$route.query.filterMode;
  393. this.tempId = this.$route.query.tempId;
  394. this.queryParams.corpId= this.$route.query.corpId;
  395. this.queryParams.type= this.$route.query.type;
  396. getQwAllUserList(this.queryParams.corpId).then(response => {
  397. this.companyUserLists = response.data;
  398. });
  399. this.getList()
  400. },
  401. methods: {
  402. /** 查询sopUserLogs列表 */
  403. getList() {
  404. this.loading = true;
  405. listSopUserLogs(this.queryParams).then(response => {
  406. this.sopUserLogsList = response.rows;
  407. this.total = response.total;
  408. this.loading = false;
  409. });
  410. },
  411. // 取消按钮
  412. cancel() {
  413. this.open = false;
  414. this.reset();
  415. },
  416. addSetList(){
  417. const newSetting = {
  418. contentType:'1',
  419. value: '',
  420. };
  421. // 将新设置项添加到 content.setting 数组中
  422. this.setting.push(newSetting);
  423. },
  424. // 表单重置
  425. reset() {
  426. this.form = {
  427. id: null,
  428. sopId: null,
  429. sopTempId: null,
  430. qwUserId: null,
  431. externalId:null,
  432. corpId: null,
  433. startTime: null,
  434. status: 0,
  435. userId: null
  436. };
  437. this.resetForm("form");
  438. },
  439. /**
  440. * 营期一键群发
  441. */
  442. handleCampSendMsg(){
  443. setTimeout(() => {
  444. this.$refs.sendMsgOpenTool.oneClickGroupSending(this.ids,2,this.queryParams.corpId);
  445. }, 500);
  446. },
  447. /**
  448. * 删除营期
  449. */
  450. handleDeleteUserLogs(){
  451. const ids = this.ids;
  452. this.$confirm('是否确认删除编号为"' + ids + '"的数据项【注意!!删除后不可恢复,请谨慎操作】?', "警告", {
  453. confirmButtonText: "确定",
  454. cancelButtonText: "取消",
  455. type: "warning"
  456. }).then(function() {
  457. return delSopUserLogs(ids);
  458. }).then(() => {
  459. this.getList();
  460. this.msgSuccess("删除成功");
  461. }).catch(() => {});
  462. },
  463. /** 搜索按钮操作 */
  464. handleQuery() {
  465. this.queryParams.pageNum = 1;
  466. this.getList();
  467. },
  468. /** 重置按钮操作 */
  469. resetQuery() {
  470. this.resetForm("queryForm");
  471. this.handleQuery();
  472. },
  473. flashNotify(){
  474. this.getList();
  475. },
  476. // 多选框选中数据
  477. handleSelectionChange(selection) {
  478. this.ids = selection.map(item => item.id)
  479. if(this.filterMode == 2){
  480. this.chatNames = selection.map(item => item.chatName);
  481. }
  482. this.single = selection.length!==1
  483. this.multiple = !selection.length
  484. },
  485. handleSelect(val){
  486. val.filterMode = this.filterMode;
  487. this.logsInfoDetailsOpen.title='企微账号:'+val.qwUserId+' '+'营期时间:'+val.startTime+' '+'天数:' + val.countDays;
  488. this.logsInfoDetailsOpen.open=true;
  489. const externalUserName = this.queryParams.externalUserName;
  490. setTimeout(() => {
  491. this.$refs.SopUserLogsInfoDetails.selectSopUserLogsInfo(val, externalUserName);
  492. }, 500);
  493. },
  494. handleRepairLogs(val) {
  495. this.loading = true;
  496. let loadingRock = this.$loading({
  497. lock: true,
  498. text: '正在修复中请稍后~~!!',
  499. spinner: 'el-icon-loading',
  500. background: 'rgba(0, 0, 0, 0.7)'
  501. });
  502. repairSopUserLogs(val).then(res => {
  503. this.msgSuccess("修复成功成功");
  504. }).catch(res => {
  505. }).finally(res => {
  506. loadingRock.close();
  507. this.loading = false;
  508. this.getList();
  509. })
  510. },
  511. /** 导出按钮操作 */
  512. handleExport() {
  513. const queryParams = this.queryParams;
  514. this.$confirm('是否确认导出所有sopUserLogs数据项?', "警告", {
  515. confirmButtonText: "确定",
  516. cancelButtonText: "取消",
  517. type: "warning"
  518. }).then(() => {
  519. this.exportLoading = true;
  520. return exportSopUserLogs(queryParams);
  521. }).then(response => {
  522. this.download(response.msg);
  523. this.exportLoading = false;
  524. }).catch(() => {
  525. });
  526. },
  527. addGroup() {
  528. this.addGroupData.open = true;
  529. this.addGroupData.form = {date: new Date(), chatIds: []};
  530. },
  531. updateGroupTime() {
  532. this.updateTimeData.open = true;
  533. this.updateTimeData.form = {date: new Date()};
  534. },
  535. submitUpdateTimeForm() {
  536. let form = {
  537. date: this.updateTimeData.form.date,
  538. ids: this.ids,
  539. }
  540. updateLogDate(form).then(e => {
  541. this.updateTimeData.open = false;
  542. this.getList();
  543. });
  544. },
  545. submitAddGroupForm() {
  546. let form = {
  547. id: this.queryParams.sopId,
  548. qwUserIds: this.userSelectList.join(),
  549. chatIds: this.addGroupData.form.chatIds.join(),
  550. date: this.addGroupData.form.date,
  551. }
  552. addGroupChat(form).then(e => {
  553. this.addGroupData.open = false;
  554. this.getList();
  555. });
  556. },
  557. handleCompanyUser() {
  558. setTimeout(() => {
  559. this.$refs.QwUserList.getDetails(this.queryParams.corpId, this.queryParams.type, 2);
  560. }, 1);
  561. this.addGroupData.userOpen = true;
  562. },
  563. handleClosegroupUser(list) {
  564. const index = this.userSelectList.findIndex(t => t === list);
  565. if (index !== -1) {
  566. this.userSelectList.splice(index, 1);
  567. this.qwUserIds.splice(index, 1);
  568. this.loadChatList()
  569. }
  570. },
  571. loadChatList() {
  572. chatListAll(this.qwUserIds.join(), this.queryParams.corpId, this.queryParams.sopId).then(e => {
  573. this.addGroupData.selectChat = e.data;
  574. })
  575. },
  576. selectUserList(list) {
  577. this.addGroupData.userOpen = false;
  578. list.forEach(obj => {
  579. if (!this.userSelectList.some(item => item == obj.id)) {
  580. console.info(this.userSelectList)
  581. this.userSelectList.push(obj.id);
  582. this.qwUserIds.push(obj.qwUserId);
  583. }
  584. });
  585. this.loadChatList()
  586. },
  587. }
  588. };
  589. </script>
  590. <style>
  591. .custom-style {
  592. font-weight: bold; /* 加粗 */
  593. }
  594. </style>