sendMsgSopOpenTool.vue 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. <template>
  2. <div class="app-container">
  3. <el-dialog :title="sendMsgOpen.title" :visible.sync="sendMsgOpen.open" width="1000px" append-to-body>
  4. <el-alert
  5. type="error"
  6. :closable="false"
  7. show-icon>
  8. <template #title>
  9. <span style="font-size: 25px; line-height: 1.5;">
  10. 此功能用于给 选中的 SOP营期 内【所有的】客户发送 消息
  11. </span>
  12. </template>
  13. </el-alert>
  14. <el-form ref="msgForm" :model="msgForm" :rules="msgRules" label-width="100px">
  15. <el-form-item label="策略" prop="draftStrategy">
  16. <el-radio-group v-model="msgForm.draftStrategy">
  17. <el-radio :label="1">正常群发</el-radio>
  18. <el-radio :label="2">清除草稿</el-radio>
  19. <el-radio :label="3">发送草稿</el-radio>
  20. <el-radio :label="4">sip外呼</el-radio>
  21. </el-radio-group>
  22. </el-form-item>
  23. <el-form-item label="选择课程" v-if="msgForm.draftStrategy==1 || msgForm.draftStrategy==4" >
  24. <el-select v-model="msgForm.courseId" placeholder="请选择课程" style=" margin-right: 10px;" size="mini" filterable clearable @change="courseChange()">
  25. <el-option
  26. v-for="dict in courseList"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="parseInt(dict.dictValue)"
  30. />
  31. </el-select>
  32. <el-select v-model="msgForm.videoId" placeholder="请选择小节" size="mini" style=" margin-right: 10px;" filterable clearable @change="videoIdChange()" >
  33. <el-option
  34. v-for="dict in videoList"
  35. :key="dict.dictValue"
  36. :label="dict.dictLabel"
  37. :value="parseInt(dict.dictValue)"
  38. />
  39. </el-select>
  40. <el-select v-model="msgForm.courseType" placeholder="请选择消息类型" size="mini" style=" margin-right: 10px;" filterable clearable>
  41. <el-option
  42. v-for="dict in sysFsSopWatchStatus"
  43. :key="dict.dictValue"
  44. :label="dict.dictLabel"
  45. :value="parseInt(dict.dictValue)"
  46. />
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item label="规则" prop="setting" v-if="msgForm.draftStrategy==1" >
  50. <div v-for="(item, index) in setting" :key="index" style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  51. <el-row>
  52. <el-col :span="22">
  53. <el-form :model="item" label-width="70px">
  54. <el-form-item label="内容类别" style="margin: 2%">
  55. <el-radio-group v-model="item.contentType">
  56. <el-radio :label="item.dictValue" v-for="item in sysQwSopAiContentType" @change="handleContentTypeChange()">{{item.dictLabel}}</el-radio>
  57. </el-radio-group>
  58. </el-form-item>
  59. <el-form-item label="内容" style="margin-bottom: 2%" >
  60. <el-input
  61. v-if="item.contentType == 1 || item.contentType == 15"
  62. v-model="item.value"
  63. type="textarea"
  64. :rows="3"
  65. placeholder="内容"
  66. style="width: 90%; margin-top: 10px;"
  67. @keydown.native="handleKeydown($event, index)"
  68. :ref="`textarea-${index}`"
  69. >
  70. </el-input>
  71. <el-link
  72. v-if="item.contentType == 1 || item.contentType == 15"
  73. type="primary"
  74. @click="toggleSalesCall(index)"
  75. style="margin-top: 10px;"
  76. >
  77. {{ item.isSalesCallAdded ? '移除#销售称呼#' : '添加#销售称呼#' }}
  78. </el-link>
  79. <el-link
  80. v-if="item.contentType == 1 || item.contentType == 15"
  81. type="primary"
  82. @click="toggleSalesCallCustomer(index)"
  83. style="margin-top: 10px;margin-left: 2%"
  84. >
  85. {{ item.isSalesCallCustomerAdded ? '移除#客户称呼#' : '添加#客户称呼#' }}
  86. </el-link>
  87. <ImageUpload v-if="item.contentType == 2 " v-model="item.imgUrl" type="image" :num="1" :width="150" :height="150" />
  88. <div v-if="item.contentType == 3 || item.contentType ==9 ">
  89. <el-card class="box-card">
  90. <el-form-item label="链接标题:" label-width="100px">
  91. <el-input v-model="item.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  92. </el-form-item>
  93. <el-form-item label="链接描述:" label-width="100px" >
  94. <el-input type="textarea" :rows="3" v-model="item.linkDescribe" placeholder="请输入链接描述" style="width: 90%;margin-top: 1%;"/>
  95. </el-form-item>
  96. <el-form-item label="链接封面:" label-width="100px">
  97. <ImageUpload v-model="item.linkImageUrl" type="image" :num="1" :file-size="2" :width="150" :height="150" style="margin-top: 1%;" />
  98. </el-form-item>
  99. <el-form-item label="链接地址:" label-width="100px" >
  100. <el-tag type="warning" v-model="item.isBindUrl=1">选择的课程小节 即为卡片链接地址</el-tag>
  101. </el-form-item>
  102. </el-card>
  103. </div>
  104. <div v-if="item.contentType == 4 || item.contentType == 10 || item.contentType == 17 || item.contentType == 23">
  105. <el-card class="box-card">
  106. <el-form-item label="标题" prop="miniprogramTitle">
  107. <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字" />
  108. </el-form-item>
  109. <el-form-item label="封面" prop="miniprogramPicUrl">
  110. <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
  111. </el-form-item>
  112. <el-form-item label="appid" prop="miniprogramAppid" v-show="false" >
  113. <el-input v-model="item.miniprogramAppid='wx73f85f8d62769119' " disabled />
  114. </el-form-item>
  115. <el-form-item label="page路径" prop="miniprogramPage" v-show="item.contentType == 10" label-width="100px" style="margin-left: -30px" >
  116. <el-input v-model="item.miniprogramPage" placeholder="小程序消息打开后的路径" type="textarea" :rows="3" />
  117. </el-form-item>
  118. </el-card>
  119. </div>
  120. <div v-if="item.contentType == 5 ">
  121. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  122. <el-upload
  123. v-model="item.fileUrl"
  124. class="avatar-uploader"
  125. :action="uploadUrl"
  126. :show-file-list="false"
  127. :on-success="(res, file) => handleAvatarSuccessFile(res, file, item)"
  128. :before-upload="beforeAvatarUploadFile">
  129. <i class="el-icon-plus avatar-uploader-icon"></i>
  130. </el-upload>
  131. <el-link v-if="item.fileUrl" type="primary" :href="downloadUrl(item.fileUrl)" download>
  132. {{item.fileUrl}}
  133. </el-link>
  134. </el-form-item>
  135. </div>
  136. <div v-if="item.contentType == 6 ">
  137. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  138. <el-upload
  139. v-model="item.videoUrl"
  140. class="avatar-uploader"
  141. :action="uploadUrl"
  142. :show-file-list="false"
  143. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, item)"
  144. :before-upload="beforeAvatarUploadVideo">
  145. <i class="el-icon-plus avatar-uploader-icon"></i>
  146. </el-upload>
  147. <video v-if="item.videoUrl"
  148. :src="item.videoUrl"
  149. controls style="width: 200px;height: 100px">
  150. </video>
  151. </el-form-item>
  152. </div>
  153. <div v-if="item.contentType == 7 || item.contentType == 16">
  154. <el-input
  155. v-model="item.value"
  156. type="textarea" :rows="3" maxlength="66" show-word-limit
  157. placeholder="输入要转为语音的内容" style="width: 90%;margin-top: 10px;"
  158. @input="handleInputVideoText(item.value,item)"/>
  159. <el-button type="primary" size="mini" plain style="margin-top: 10px;" @click="openVoiceDialog(item)">快捷语音</el-button>
  160. </div>
  161. <div v-if="item.contentType == 8">
  162. <el-button type="primary"
  163. style="margin-bottom: 1%"
  164. @click="hanldeSelectVideoNum(setting,index)">
  165. 选择视频号
  166. </el-button>
  167. <el-card class="box-card" v-if="item.coverUrl">
  168. <el-form-item label="封面标题:" label-width="100px">
  169. <el-input v-model="item.nickname"
  170. style="width: 90%;margin-bottom: 1%" disabled/>
  171. </el-form-item>
  172. <el-form-item label="头像:" label-width="100px">
  173. <el-image
  174. v-if="item.avatar != null"
  175. :src="item.avatar"
  176. :preview-src-list="[item.avatar]"
  177. :style="{ width: '50px', height: '50px' }"
  178. ></el-image>
  179. </el-form-item>
  180. <el-form-item label="封面:" label-width="100px">
  181. <el-image
  182. v-if="item.coverUrl != null"
  183. :src="item.coverUrl"
  184. :preview-src-list="[item.coverUrl]"
  185. :style="{ width: '200px', height: '200px' }"
  186. ></el-image>
  187. </el-form-item>
  188. <el-form-item label="简介:" label-width="100px">
  189. <el-input type="textarea" :rows="3"
  190. v-model="item.desc"
  191. style="width: 90%;margin-top: 1%;" disabled/>
  192. </el-form-item>
  193. <el-form-item label="视频地址:" label-width="100px"
  194. style="margin-top: 1%">
  195. <el-input v-model="item.url"
  196. style="width: 90%;" disabled/>
  197. </el-form-item>
  198. </el-card>
  199. </div>
  200. <div v-if="item.contentType == 12 || item.contentType == 18 || item.contentType == 19 || item.contentType == 24">
  201. <el-card class="box-card">
  202. <el-form-item label="直播间" >
  203. <el-select v-model="item.liveId"
  204. filterable
  205. placeholder="请选择直播间" size="mini"
  206. @change="liveChange(item)" >
  207. <el-option
  208. v-for="dict in liveList"
  209. :key="dict.liveId"
  210. :label="dict.liveName"
  211. :value="dict.liveId"
  212. />
  213. </el-select>
  214. </el-form-item>
  215. <el-form-item label="标题" prop="miniprogramTitle">
  216. <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字节" :rows="2" maxlength="64"
  217. type="textarea" />
  218. </el-form-item>
  219. <el-form-item label="封面" prop="miniprogramPicUrl">
  220. <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
  221. </el-form-item>
  222. <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
  223. <el-input v-model="item.miniprogramAppid='wxcfd4cd6e2375e42f' " disabled />
  224. </el-form-item>
  225. <el-form-item label="page路径" prop="miniprogramPage" v-show="false" label-width="100px" style="margin-left: -30px">
  226. <el-input v-model="item.miniprogramPage" placeholder="小程序消息打开后的路径" disabled />
  227. </el-form-item>
  228. </el-card>
  229. </div>
  230. <div v-if="item.contentType == 14">
  231. <el-card class="box-card">
  232. <el-form-item label="福袋名称" >
  233. <el-select v-model="item.luckyBagId"
  234. placeholder="请选择福袋" size="mini"
  235. @change="getLuckyBagStatus(item)" >
  236. <el-option
  237. v-for="dict in luckyBagList"
  238. :key="dict.id"
  239. :label="dict.name"
  240. :value="dict.id"
  241. />
  242. </el-select>
  243. </el-form-item>
  244. <el-form-item label="福袋状态" >
  245. <el-tag :type="item.luckyBagDataStatus == 1 ? 'success' : 'danger'">
  246. {{ item.luckyBagDataStatus == 1 ? '启用' : '禁用' }}
  247. </el-tag>
  248. </el-form-item>
  249. </el-card>
  250. </div>
  251. </el-form-item>
  252. <el-form-item label="添加短链" v-if="item.contentType == 1 || item.contentType == 15" >
  253. <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark" :disabled="!!msgForm.videoId">
  254. <el-switch
  255. v-model="item.isBindUrl"
  256. :disabled="!msgForm.videoId"
  257. active-color="#13ce66"
  258. inactive-color="#DCDFE6"
  259. active-value="1"
  260. inactive-value="2">
  261. </el-switch>
  262. </el-tooltip>
  263. <span v-if="item.isBindUrl == '1'" style="margin-left: 10px; color: #13ce66">添加URL</span>
  264. <span v-if="item.isBindUrl == '2'" style="margin-left: 10px; color: #b1b4ba">不加URL</span>
  265. </el-form-item>
  266. <el-form-item label="课节过期时间" v-if="item.isBindUrl == '1'
  267. && item.contentType != 2
  268. && item.contentType != 5
  269. && item.contentType != 6
  270. && item.contentType != 8"
  271. style="margin-top: 1%" label-width="100px">
  272. <el-row>
  273. <el-input-number v-model="item.expiresDays" :min="1" :max="100" ></el-input-number>
  274. (天)
  275. </el-row>
  276. <el-row>
  277. <span class="tip">填写0或不填时,默认为系统配置的默认时间</span>
  278. </el-row>
  279. </el-form-item>
  280. </el-form>
  281. </el-col>
  282. <el-col :span="1" :offset="1">
  283. <i class="el-icon-delete" @click="delSetList(index)" style="margin-top: 20px;" v-if="setting.length>1"></i>
  284. </el-col>
  285. </el-row>
  286. </div>
  287. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetList()' >添加内容</el-link>
  288. </el-form-item>
  289. <el-form-item label="外呼任务" v-if="msgForm.draftStrategy==4" >
  290. <el-select v-model="msgForm.aiCustomerRoleId"
  291. placeholder="请选择外呼任务" size="mini"
  292. @change="getAiSipCallTask()" >
  293. <el-option
  294. v-for="template in aiSipCallTaskList"
  295. :key="template.batchId"
  296. :label="template.batchName"
  297. :value="template.batchId"
  298. />
  299. </el-select>
  300. </el-form-item>
  301. <el-form-item label="发送时间" prop="sendTime" v-if="msgForm.draftStrategy==1 || msgForm.draftStrategy==4" >
  302. <el-date-picker
  303. class="custom-input"
  304. v-model="msgForm.sendTime"
  305. type="datetime"
  306. value-format="yyyy-MM-dd HH:mm:ss"
  307. format="yyyy-MM-dd HH:mm:ss"
  308. placeholder="选择日期时间"
  309. :picker-options="pickerOptions"
  310. style="width: 220px;">
  311. </el-date-picker>
  312. <span class="tip" style="margin-left: 2%"> 不填时,默认为系统当前时间(立即发送)</span>
  313. </el-form-item>
  314. </el-form>
  315. <div slot="footer" class="dialog-footer">
  316. <el-button type="primary" @click="submitMsgForm">确 定</el-button>
  317. <el-button @click="cancelMsgForm">取 消</el-button>
  318. </div>
  319. </el-dialog>
  320. <el-dialog :title="videoNumOptions.title" :visible.sync="videoNumOptions.open" width="1500px" append-to-body>
  321. <userVideo ref="QwUserVideo" @videoResult="qwUserVideoResult"></userVideo>
  322. </el-dialog>
  323. <el-dialog :title="voiceOptions.title" :visible.sync="voiceOptions.open" width="800px" append-to-body>
  324. <div style="margin-bottom: 10px;">
  325. <el-input v-model="voiceOptions.keyword" placeholder="请输入关键词搜索" style="width: 300px;" clearable @clear="searchVoice" @keyup.enter.native="searchVoice">
  326. <el-button slot="append" icon="el-icon-search" @click="searchVoice">搜索</el-button>
  327. </el-input>
  328. </div>
  329. <el-table :data="voiceOptions.list" v-loading="voiceOptions.loading" highlight-current-row @current-change="handleVoiceSelect">
  330. <el-table-column prop="voiceTxt" label="语音内容" min-width="200" show-overflow-tooltip></el-table-column>
  331. <el-table-column label="操作" width="80" align="center">
  332. <template slot-scope="scope">
  333. <el-button type="text" size="mini" @click="selectVoice(scope.row)">选择</el-button>
  334. </template>
  335. </el-table-column>
  336. </el-table>
  337. <el-pagination
  338. style="margin-top: 10px; text-align: right;"
  339. background
  340. layout="total, prev, pager, next"
  341. :total="voiceOptions.total"
  342. :page-size="voiceOptions.pageSize"
  343. :current-page.sync="voiceOptions.pageNum"
  344. @current-change="searchVoice">
  345. </el-pagination>
  346. </el-dialog>
  347. </div>
  348. </template>
  349. <script>
  350. import { sendMsg,} from "../../../api/qw/sopUserLogsInfo";
  351. import ImageUpload from "@/views/qw/sop/ImageUpload.vue";
  352. import {courseList, videoList} from "@/api/qw/sop";
  353. import userVideo from "@/views/qw/userVideo/userVideo";
  354. import {listReward} from "@/api/qw/luckyBag";
  355. import {listToLiveNoEnd} from "@/api/live/live";
  356. import { getQwSopTempVoiceCompanyUser } from "@/api/qw/QwSopTempVoice";
  357. import { listAiSipCallTask } from '@/api/aiSipCall/aiSipCallTask'
  358. export default {
  359. name: "sendMsgSopOpenTool",
  360. components: {ImageUpload,userVideo},
  361. data() {
  362. return {
  363. aiSipCallTaskList: [],
  364. queryParams1: {
  365. pageNum: 1,
  366. pageSize: 10,
  367. dataStatus: '1',
  368. name: null,
  369. type: null
  370. },
  371. luckyBagList: [],
  372. projectFrom:process.env.VUE_APP_PROJECT_FROM,
  373. videoNumOptions: {
  374. title: '选择视频号',
  375. open: false,
  376. content: null,
  377. contentIndex: null,
  378. },
  379. voiceOptions: {
  380. title: '快捷语音',
  381. open: false,
  382. keyword: '',
  383. list: [],
  384. loading: false,
  385. total: 0,
  386. pageNum: 1,
  387. pageSize: 5,
  388. currentItem: null,
  389. },
  390. //上传语音的遮罩层
  391. voiceLoading :false,
  392. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  393. uploadUrlByVoice:process.env.VUE_APP_BASE_API+"/common/uploadOSSByHOOKVoice",
  394. // 遮罩层
  395. loading: true,
  396. // 导出遮罩层
  397. exportLoading: false,
  398. // 选中数组
  399. ids: [],
  400. // 非单个禁用
  401. single: true,
  402. // 非多个禁用
  403. multiple: true,
  404. // 显示搜索条件
  405. showSearch: true,
  406. // 总条数
  407. total: 0,
  408. // sopUserLogsInfo表格数据
  409. sopUserLogsInfoList: [],
  410. sysFsSopWatchStatus: [],
  411. isSalesCallAdded:false,
  412. isSalesCallCustomerAdded:false,
  413. tagList:[],
  414. selectTags:[],
  415. // 弹出层标题
  416. title: "",
  417. // 是否显示弹出层
  418. open: false,
  419. updateOpen:false,
  420. // 查询参数
  421. queryParams: {
  422. pageNum: 1,
  423. pageSize: 10,
  424. tagIds:null,
  425. remark:null,
  426. sopId: null,
  427. userLogsId: null,
  428. userIdParam:null,
  429. startTimeParam:null,
  430. externalContactId: null,
  431. qwUserId: null,
  432. corpId: null,
  433. externalId: null,
  434. fsUserId: null,
  435. externalUserName: null,
  436. createTime: null,
  437. },
  438. courseList:[],
  439. videoList:[],
  440. //插件版
  441. sysQwSopAiContentType:[],
  442. liveList: [],
  443. sendMsgOpen:{
  444. title:'一键批量群发',
  445. open:false,
  446. ids:null,
  447. },
  448. // 表单参数
  449. form: {},
  450. setting:[{contentType:'1', value: '',}],
  451. msgForm:{
  452. videoId:null,
  453. courseId:null,
  454. courseType:null,
  455. userIdParam:null,
  456. setting:null,
  457. ids:null,
  458. type:null,
  459. corpId:null,
  460. sopId: null,
  461. sopIds: null,
  462. startTime: null,
  463. sendTime: null,
  464. draftStrategy:1,
  465. },
  466. // 表单校验
  467. rules: {},
  468. batchRules:{
  469. paramTime: [
  470. { required: true, message: '选择的时间不能为空', trigger: 'blur' }
  471. ],
  472. },
  473. msgRules:{},
  474. pickerOptions: {
  475. shortcuts: [
  476. {
  477. text: '现在',
  478. onClick(picker) {
  479. picker.$emit('pick', new Date());
  480. }
  481. },
  482. {
  483. text: '1小时后',
  484. onClick(picker) {
  485. const date = new Date();
  486. date.setTime(date.getTime() + 3600 * 1000);
  487. picker.$emit('pick', date);
  488. }
  489. },
  490. {
  491. text: '明天此时',
  492. onClick(picker) {
  493. const date = new Date();
  494. date.setTime(date.getTime() + 3600 * 1000 * 24);
  495. picker.$emit('pick', date);
  496. }
  497. },
  498. {
  499. text: '后天此时',
  500. onClick(picker) {
  501. const date = new Date();
  502. date.setTime(date.getTime() + 3600 * 1000 * 24 * 2);
  503. picker.$emit('pick', date);
  504. }
  505. },
  506. {
  507. text: '一周后',
  508. onClick(picker) {
  509. const date = new Date();
  510. date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
  511. picker.$emit('pick', date);
  512. }
  513. }
  514. ]
  515. },
  516. };
  517. },
  518. created() {
  519. this.getDicts("sys_qwSopAi_contentType").then(response => {
  520. this.sysQwSopAiContentType = response.data;
  521. });
  522. this.getDicts("sys_fs_sop_watch_status").then(response => {
  523. this.sysFsSopWatchStatus = response.data;
  524. });
  525. listToLiveNoEnd().then(response => {
  526. this.liveList = response.rows;
  527. });
  528. courseList().then(response => {
  529. this.courseList = response.list;
  530. });
  531. listReward(this.queryParams1).then(response => {
  532. this.luckyBagList = response.rows;
  533. });
  534. this.loadSipTemplates();
  535. },
  536. methods: {
  537. loadSipTemplates() {
  538. if (this.aiSipCallTaskList.length > 0) {
  539. return; // 如果已经有数据,不再重复加载
  540. }
  541. listAiSipCallTask({taskType: 1,status: 0,pageNum: 1,pageSize: 100}).then(response => {
  542. this.aiSipCallTaskList = response.rows || response.data || [];
  543. if (this.aiSipCallTaskList.length === 0) {
  544. }
  545. }).catch(error => {
  546. console.error('加载sip模板失败:', error);
  547. this.$message.error('加载sip模板失败');
  548. });
  549. },
  550. // 获取sip模板信息
  551. getAiSipCallTask() {
  552. if (this.aiSipCallTaskList.length === 0) {
  553. listAiSipCallTask({taskType: 1,status: 0,pageNum: 1,pageSize: 100}).then(response => {
  554. this.aiSipCallTaskList = response.rows || response.data || [];
  555. }).catch(error => {
  556. console.error('加载sip模板失败:', error);
  557. this.$message.error('加载sip模板失败');
  558. });
  559. }
  560. },
  561. getLuckyBagStatus(content) {
  562. const selectedLuckyBag = this.luckyBagList.find(item => item.id === content.luckyBagId);
  563. if (selectedLuckyBag) {
  564. content.luckyBagDataStatus = selectedLuckyBag.dataStatus; // 自动填充标题
  565. } else {
  566. // 若未找到对应直播间,清空标题和封面(可选)
  567. content.luckyBagDataStatus = null;
  568. }
  569. },
  570. liveChange(content) {
  571. // content.liveId 是选中的直播间 ID(liveId)
  572. const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
  573. if (selectedLive) {
  574. // 从选中的直播间对象中提取标题和封面,赋值给当前内容的对应字段
  575. // 假设直播间对象中标题字段为 liveTitle,封面字段为 coverImg(根据实际接口字段调整)
  576. content.miniprogramTitle = selectedLive.liveName || ''; // 自动填充标题
  577. content.miniprogramPicUrl = selectedLive.liveImgUrl || ''; // 自动填充封面
  578. } else {
  579. // 若未找到对应直播间,清空标题和封面(可选)
  580. content.miniprogramTitle = '';
  581. content.miniprogramPicUrl = '';
  582. }
  583. },
  584. qwUserVideoResult(val) {
  585. // 根据选中的内容,将返回的数据更新到相应的表单项
  586. const content = this.videoNumOptions.content;
  587. const setList = content[this.videoNumOptions.contentIndex];
  588. setList.nickname = val.nickname;
  589. setList.avatar = val.avatar;
  590. setList.coverUrl = val.coverUrl;
  591. setList.thumbUrl = val.thumbUrl;
  592. setList.desc = val.desc;
  593. setList.url = val.url;
  594. setList.extras = val.extras;
  595. setList.videoId = val.id;
  596. console.info(setList)
  597. this.videoNumOptions.open = false;
  598. },
  599. oneClickGroupSending(val,type,corpId,isMine){
  600. this.sendMsgOpen.open= true;
  601. this.msgForm.sopIds = val;
  602. this.msgForm.type = type;
  603. this.msgForm.corpId = corpId;
  604. this.msgForm.isMine = isMine;
  605. },
  606. courseChange() {
  607. if (this.msgForm.courseId != null ) {
  608. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  609. for (let i = 0; i < this.setting.length; i++) {
  610. //响应式直接给链接的标题/封面上值
  611. if (selectedCourse && this.msgForm.courseId != null) {
  612. if ( this.setting[i].contentType == 3 || this.setting[i].contentType == 9 ){
  613. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  614. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  615. }
  616. if ( this.setting[i].contentType == 4 || this.setting[i].contentType == 10 || this.setting[i].contentType == 17
  617. || this.setting[i].contentType == 23){//新增APP 看课 跳转短链回填封面
  618. this.$set(this.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  619. }
  620. }
  621. }
  622. }
  623. videoList(this.msgForm.courseId).then(response => {
  624. this.videoList=response.list;
  625. });
  626. this.msgForm.videoId = null
  627. },
  628. videoIdChange() {
  629. if (this.msgForm.videoId != null ) {
  630. // 查找选中的课节对应的 label
  631. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  632. for (let i = 0; i < this.setting.length; i++) {
  633. //响应式直接给链接的描述上值
  634. if (selectedVideo && this.msgForm.videoId != null) {
  635. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9 ){
  636. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  637. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  638. this.$set(this.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
  639. }
  640. }
  641. if (this.setting[i].contentType == 4 || this.setting[i].contentType == 10 || this.setting[i].contentType == 17
  642. || this.setting[i].contentType == 23){//新增APP 看课 跳转短链回填标题
  643. this.$set(this.setting[i], 'miniprogramTitle', selectedVideo.dictLabel);
  644. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  645. this.$set(this.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
  646. }
  647. }
  648. }
  649. }
  650. }
  651. },
  652. handleAvatarSuccessFile(res, file, item) {
  653. if (res.code === 200) {
  654. // 使用 $set 确保响应式更新
  655. this.$set(item, 'fileUrl', res.url);
  656. } else {
  657. this.msgError(res.msg);
  658. }
  659. },
  660. beforeAvatarUploadFile(file){
  661. const isLt1M = file.size / 1024 / 1024 < 10;
  662. if (!isLt1M) {
  663. this.$message.error('上传大小不能超过 10MB!');
  664. }
  665. return isLt1M;
  666. },
  667. //下载文件
  668. downloadUrl(materialUrl) {
  669. // 直接返回文件 URL
  670. return materialUrl;
  671. },
  672. handleAvatarSuccessVideo(res, file, item) {
  673. if(res.code==200){
  674. // 使用 $set 确保响应式更新
  675. this.$set(item, 'videoUrl', res.url);
  676. }
  677. else{
  678. this.msgError(res.msg);
  679. }
  680. },
  681. beforeAvatarUploadVideo(file){
  682. const isLt30M = file.size / 1024 / 1024 < 10;
  683. const isMP4 = file.type === 'video/mp4';
  684. if (!isMP4) {
  685. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  686. return false;
  687. }
  688. if (!isLt30M) {
  689. this.$message.error('上传大小不能超过 10MB!');
  690. return false;
  691. }
  692. return true;
  693. },
  694. handleInputVideoText(value,content){
  695. // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
  696. const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
  697. // 删除不符合条件的字符
  698. const filteredValue = value.split('').filter(char => regex.test(char)).join('');
  699. this.$set(content, 'value', filteredValue);
  700. },
  701. delSetList(index){
  702. this.setting.splice(index,1)
  703. },
  704. addSetList(){
  705. const newSetting = {
  706. contentType:'1',
  707. value: '',
  708. };
  709. // 将新设置项添加到 content.setting 数组中
  710. this.setting.push(newSetting);
  711. },
  712. //选择视频号
  713. hanldeSelectVideoNum(content, index) {
  714. this.videoNumOptions.content = content;
  715. this.videoNumOptions.contentIndex = index;
  716. this.videoNumOptions.open = true;
  717. },
  718. handleKeydown(event, index) {
  719. const item = this.setting[index];
  720. const textarea = this.$refs[`textarea-${index}`][0].$refs.textarea;
  721. const cursorPosition = textarea.selectionStart;
  722. // 检查是否按下了 Backspace 或 Delete 键
  723. if (event.key === 'Backspace' || event.key === 'Delete') {
  724. const tags = ['#销售称呼#', '#客户称呼#']; // 需要检查的标签
  725. const value = item.value;
  726. // 遍历标签,检查是否需要删除
  727. for (const tag of tags) {
  728. let start, end;
  729. if (event.key === 'Backspace') {
  730. // 检查光标前是否是当前标签的一部分
  731. start = cursorPosition - tag.length;
  732. if (start >= 0 && value.slice(start, cursorPosition) === tag) {
  733. // 删除整个标签
  734. item.value = value.slice(0, start) + value.slice(cursorPosition);
  735. // 更新光标位置
  736. this.$nextTick(() => {
  737. textarea.setSelectionRange(start, start);
  738. });
  739. // 更新状态
  740. if (tag === '#销售称呼#') item.isSalesCallAdded = false;
  741. if (tag === '#客户称呼#') item.isSalesCallCustomerAdded = false;
  742. event.preventDefault(); // 阻止默认删除行为
  743. break; // 找到匹配的标签后退出循环
  744. }
  745. } else if (event.key === 'Delete') {
  746. // 检查光标后是否是当前标签的一部分
  747. end = cursorPosition + tag.length;
  748. if (end <= value.length && value.slice(cursorPosition, end) === tag) {
  749. // 删除整个标签
  750. item.value = value.slice(0, cursorPosition) + value.slice(end);
  751. // 更新状态
  752. if (tag === '#销售称呼#') item.isSalesCallAdded = false;
  753. if (tag === '#客户称呼#') item.isSalesCallCustomerAdded = false;
  754. event.preventDefault(); // 阻止默认删除行为
  755. break; // 找到匹配的标签后退出循环
  756. }
  757. }
  758. // 检查光标是否位于标签的中间
  759. for (let i = 0; i <= tag.length; i++) {
  760. const tagStart = cursorPosition - i;
  761. const tagEnd = tagStart + tag.length;
  762. if (
  763. tagStart >= 0 &&
  764. tagEnd <= value.length &&
  765. value.slice(tagStart, tagEnd) === tag
  766. ) {
  767. // 删除整个标签
  768. item.value = value.slice(0, tagStart) + value.slice(tagEnd);
  769. // 更新光标位置
  770. this.$nextTick(() => {
  771. textarea.setSelectionRange(tagStart, tagStart);
  772. });
  773. // 更新状态
  774. if (tag === '#销售称呼#') item.isSalesCallAdded = false;
  775. if (tag === '#客户称呼#') item.isSalesCallCustomerAdded = false;
  776. event.preventDefault(); // 阻止默认删除行为
  777. break; // 找到匹配的标签后退出循环
  778. }
  779. }
  780. }
  781. }
  782. },
  783. // 切换添加销售称呼按钮点击事件
  784. toggleSalesCall(index) {
  785. const item = this.setting[index];
  786. const salesCall = '#销售称呼#';
  787. const textarea = this.$refs[`textarea-${index}`][0].$refs.textarea;
  788. // 获取当前光标位置
  789. const cursorPosition = textarea.selectionStart;
  790. if (item.isSalesCallAdded) {
  791. // 移除所有的 #销售称呼#
  792. item.value = item.value.replace(new RegExp(salesCall, 'g'), '');
  793. } else {
  794. // 添加 #销售称呼#
  795. item.value = item.value.slice(0, cursorPosition) + salesCall + item.value.slice(cursorPosition);
  796. }
  797. // 切换状态
  798. item.isSalesCallAdded = !item.isSalesCallAdded;
  799. // 保持光标位置
  800. this.$nextTick(() => {
  801. textarea.setSelectionRange(cursorPosition, cursorPosition);
  802. });
  803. },
  804. toggleSalesCallCustomer(index) {
  805. const item = this.setting[index];
  806. const salesCall = '#客户称呼#';
  807. const textarea = this.$refs[`textarea-${index}`][0].$refs.textarea;
  808. // 获取当前光标位置
  809. const cursorPosition = textarea.selectionStart;
  810. if (item.isSalesCallCustomerAdded) {
  811. // 移除所有的 #销售称呼#
  812. item.value = item.value.replace(new RegExp(salesCall, 'g'), '');
  813. } else {
  814. // 添加 #客户称呼#
  815. item.value = item.value.slice(0, cursorPosition) + salesCall + item.value.slice(cursorPosition);
  816. }
  817. // 切换状态
  818. item.isSalesCallCustomerAdded = !item.isSalesCallCustomerAdded;
  819. // 保持光标位置
  820. this.$nextTick(() => {
  821. textarea.setSelectionRange(cursorPosition, cursorPosition);
  822. });
  823. },
  824. handleContentTypeChange() {
  825. //如果是链接的才上
  826. if (this.msgForm.courseId != null ) {
  827. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === this.msgForm.courseId);
  828. for (let i = 0; i < this.setting.length; i++) {
  829. //响应式直接给链接的标题/封面上值
  830. if (selectedCourse && this.msgForm.courseId != null) {
  831. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9){
  832. this.$set(this.setting[i], 'linkTitle', selectedCourse.dictLabel);
  833. this.$set(this.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  834. }
  835. if (this.setting[i].contentType == 4 || this.setting[i].contentType == 10 || this.setting[i].contentType == 17
  836. || this.setting[i].contentType == 23){
  837. this.$set(this.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  838. }
  839. }
  840. }
  841. }
  842. if (this.msgForm.videoId != null ) {
  843. // 查找选中的课节对应的 label
  844. const selectedVideo = this.videoList.find(course => parseInt(course.dictValue) === this.msgForm.videoId);
  845. for (let i = 0; i < this.setting.length; i++) {
  846. //响应式直接给链接的描述上值
  847. if (selectedVideo && this.msgForm.videoId != null) {
  848. if (this.setting[i].contentType == 3 || this.setting[i].contentType == 9){
  849. this.$set(this.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  850. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  851. this.$set(this.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
  852. }
  853. }
  854. if (this.setting[i].contentType == 4 || this.setting[i].contentType == 10 || this.setting[i].contentType == 17
  855. || this.setting[i].contentType == 23){
  856. this.$set(this.setting[i], 'miniprogramTitle', selectedVideo.dictLabel);
  857. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  858. this.$set(this.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
  859. }
  860. }
  861. }
  862. }
  863. }
  864. },
  865. resetSendMsgSop() {
  866. this.msgForm = {
  867. videoId:null,
  868. courseId:null,
  869. courseType:null,
  870. setting:null,
  871. sendTime:null,
  872. draftStrategy:1,
  873. };
  874. this.resetForm("msgForm");
  875. },
  876. // 多选框选中数据
  877. handleSelectionChange(selection) {
  878. this.ids = selection.map(item => item.id)
  879. this.single = selection.length!==1
  880. this.multiple = !selection.length
  881. },
  882. submitMsgForm(){
  883. this.$refs["msgForm"].validate(valid => {
  884. if (valid) {
  885. if (this.msgForm.draftStrategy==1 || this.msgForm.draftStrategy == 4 ){
  886. this.msgForm.setting = JSON.stringify(this.setting);
  887. let jsonSetting = JSON.parse(this.msgForm.setting);
  888. let hasLiveSetting = false;
  889. let count = 0;
  890. for (let index = 0; index < jsonSetting.length; index++) {
  891. if (jsonSetting[index] && [12, 18, 19, 24].includes(Number(jsonSetting[index].contentType))) {
  892. hasLiveSetting = true;
  893. count++;
  894. }
  895. }
  896. if (hasLiveSetting) {
  897. if (this.msgForm.courseId) {
  898. return this.$message.error("直播间不能选取课程");
  899. }
  900. if (this.msgForm.videoId) {
  901. return this.$message.error("直播间不能选取课节");
  902. }
  903. if (count > 1) {
  904. return this.$message.error("直播间一次只能发送一条");
  905. }
  906. }
  907. if (this.setting.length <= 0) {
  908. return this.$message.error("请添加规则")
  909. }
  910. if (!hasLiveSetting && !this.msgForm.courseId){
  911. return this.$message.error("课程不能为空")
  912. }
  913. if (!hasLiveSetting && !this.msgForm.videoId){
  914. return this.$message.error("课节不能为空")
  915. }
  916. if (this.msgForm.courseType===null || this.msgForm.courseType===''){
  917. return this.$message.error("消息类型不能为空")
  918. }
  919. if(this.msgForm.draftStrategy == 4){
  920. if (this.msgForm.aiCustomerRoleId == null || this.msgForm.aiCustomerRoleId == '') {
  921. return this.$message.error("请选择外呼任务")
  922. }
  923. }
  924. if(this.msgForm.draftStrategy != 4) {
  925. for (let i = 0; i < this.setting.length; i++) {
  926. if (this.setting[i].contentType == 1 && (this.setting[i].value == null || this.setting[i].value == "")) {
  927. return this.$message.error("内容不能为空")
  928. }
  929. if (this.setting[i].contentType == 2 && (this.setting[i].imgUrl == null || this.setting[i].imgUrl == "")) {
  930. return this.$message.error("图片不能为空")
  931. }
  932. if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkTitle == null || this.setting[i].linkTitle == "")) {
  933. return this.$message.error("链接标题不能为空")
  934. }
  935. if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkDescribe == null || this.setting[i].linkDescribe == "")) {
  936. return this.$message.error("链接描述不能为空")
  937. }
  938. if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && (this.setting[i].linkImageUrl == null || this.setting[i].linkImageUrl == "")) {
  939. return this.$message.error("链接图片不能为空")
  940. }
  941. if ((this.setting[i].contentType == 3 || this.setting[i].contentType == 9) && this.setting[i].type == 1 && (this.setting[i].linkUrl == null || this.setting[i].linkUrl == "")) {
  942. return this.$message.error("链接地址不能为空")
  943. }
  944. if ([4, 10, 17, 23, 24].includes(Number(this.setting[i].contentType)) && (this.setting[i].miniprogramTitle == null || this.setting[i].miniprogramTitle == "")) {
  945. return this.$message.error("小程序消息标题不能为空")
  946. }
  947. if ([4, 10, 17, 23, 24].includes(Number(this.setting[i].contentType)) && (this.setting[i].miniprogramPicUrl == null || this.setting[i].miniprogramPicUrl == "")) {
  948. return this.$message.error("小程序封面地址不能为空")
  949. }
  950. if (this.setting[i].contentType == 10 && (this.setting[i].miniprogramPage == null || this.setting[i].miniprogramPage == "")) {
  951. return this.$message.error("小程序page地址不能为空")
  952. }
  953. if (this.setting[i].contentType == 5 && (this.setting[i].fileUrl == null || this.setting[i].fileUrl == "")) {
  954. return this.$message.error("文件不能为空")
  955. }
  956. if (this.setting[i].contentType == 6 && (this.setting[i].videoUrl == null || this.setting[i].videoUrl == "")) {
  957. return this.$message.error("视频不能为空")
  958. }
  959. if (this.setting[i].contentType == 7 && (this.setting[i].value == null || this.setting[i].value == "")) {
  960. return this.$message.error("语音不能为空")
  961. }
  962. // 添加对福袋的验证
  963. if (this.setting[i].contentType == 14 && (this.setting[i].luckyBagId == null || this.setting[i].luckyBagId === "")) {
  964. return this.$message.error("福袋不能为空")
  965. }
  966. if ((this.setting[i].contentType == 12 || this.setting[i].contentType == 24) && (this.setting[i].liveId == null || this.setting[i].liveId == "")) {
  967. return this.$message.error("直播间不能为空");
  968. }
  969. }
  970. }
  971. }
  972. this.sendMsgOpen.open = false;
  973. const loading = this.$loading({
  974. lock: true,
  975. text: '正在执行中请稍后~~请不要刷新页面!!',
  976. spinner: 'el-icon-loading',
  977. background: 'rgba(0, 0, 0, 0.7)'
  978. });
  979. sendMsg(this.msgForm).then(response => {
  980. this.msgSuccess("一键群发成功");
  981. loading.close();
  982. this.setting=[];
  983. this.resetSendMsgSop();
  984. }).finally(()=>{
  985. loading.close();
  986. });
  987. }
  988. });
  989. },
  990. cancelMsgForm(){
  991. this.sendMsgOpen.open = false;
  992. this.resetSendMsgSop();
  993. },
  994. openVoiceDialog(item) {
  995. this.voiceOptions.open = true;
  996. this.voiceOptions.currentItem = item;
  997. this.voiceOptions.keyword = '';
  998. this.voiceOptions.pageNum = 1;
  999. this.searchVoice();
  1000. },
  1001. searchVoice() {
  1002. this.voiceOptions.loading = true;
  1003. getQwSopTempVoiceCompanyUser({
  1004. pageNum: this.voiceOptions.pageNum,
  1005. pageSize: this.voiceOptions.pageSize,
  1006. keyword: this.voiceOptions.keyword || undefined,
  1007. }).then(response => {
  1008. this.voiceOptions.list = response.rows || response.list || [];
  1009. this.voiceOptions.total = response.total || 0;
  1010. }).finally(() => {
  1011. this.voiceOptions.loading = false;
  1012. });
  1013. },
  1014. selectVoice(row) {
  1015. if (this.voiceOptions.currentItem) {
  1016. this.$set(this.voiceOptions.currentItem, 'value', row.voiceTxt || '');
  1017. }
  1018. this.voiceOptions.open = false;
  1019. },
  1020. handleVoiceSelect(row) {
  1021. // 预留行选中事件
  1022. },
  1023. }
  1024. };
  1025. </script>