sendMsgOpenTool.vue 57 KB

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