sendMsgOpenTool.vue 52 KB

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