sendMsgOpenTool.vue 43 KB

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