sopUserLogsScheduleOld.vue 19 KB

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