sendMsgOpenTool.vue 44 KB

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