sendMsgSopOpenTool.vue 44 KB

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