updateSopTemp.vue 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137
  1. <template>
  2. <div class="app-container">
  3. <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==1 "> sop规则【修改企微接口】模板</div>
  4. <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==2 "> sop规则【复制企微接口】模板</div>
  5. <div style="margin: 30px;" v-if="this.form.sendType == 1 && formType==3 "> sop规则【查看企微接口】模板</div>
  6. <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==1 "> sop规则【修改群发助手】模板</div>
  7. <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==2 "> sop规则【复制群发助手】模板</div>
  8. <div style="margin: 30px;" v-if="this.form.sendType == 2 && formType==3 "> sop规则【查看群发助手】模板</div>
  9. <div style="margin: 30px;">模板编号:【{{ this.form.id }}】</div>
  10. <div style="margin-top: 10px;margin-left: 50px;margin-right: 100px;margin-bottom: 60px;">
  11. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  12. <el-form-item label="名称" prop="name">
  13. {{ form.name }}
  14. </el-form-item>
  15. <el-form-item label="状态">
  16. <el-tag v-for="dict in statusOptions" v-if="dict.dictValue == form.status">{{ dict.dictLabel }}</el-tag>
  17. </el-form-item>
  18. <el-form-item label="间隔天数" prop="gap">
  19. {{ form.gap }}天
  20. </el-form-item>
  21. <el-form-item label="规则" prop="setting">
  22. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetting()'
  23. v-if="form.sendType != 4 && formType != 3 && roles.includes('add_sop_temp_day')">添加天数
  24. </el-link>
  25. <el-link type="primary" class="el-icon-sort" :underline="false" @click='openUpdateDaySorts()'
  26. style="margin-left: 20px"
  27. v-if="form.sendType != 4 && formType != 3">修改天数排序
  28. </el-link>
  29. <el-link type="primary" class="el-icon-sort" :underline="false" @click='openUpdateSorts()'
  30. style="margin-left: 20px"
  31. v-if="form.sendType != 4 && formType != 3">修改规则排序
  32. </el-link>
  33. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetting()'
  34. v-if="form.sendType == 4 && (formType != 3 && setting.length < 1) && roles.includes('add_sop_temp_day')">添加天数
  35. </el-link>
  36. <el-tabs v-model="tabIndex" type="card" @tab-remove="delSetting" v-if="setting && setting.length > 0"
  37. :before-leave="leave" @tab-click="tabClick">
  38. <el-tab-pane v-for="(item, index) in setting" :closable="formType != 3 && roles.includes('del_sop_temp_day')" :key="index" :name="index + ''">
  39. <el-badge slot="label" :is-dot="!item.id" class="item" style="display: inline-block">
  40. <span>{{ '第' + item.dayNum + '天' }}</span>
  41. </el-badge>
  42. <el-row v-loading="loading">
  43. <el-col :span="22">
  44. <div
  45. style="background-color: #fbfbfb;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  46. <el-form :model="item" label-width="80px">
  47. <el-form-item v-if="form.sendType != 4" label="内容名称" style="height: 50px;">
  48. <el-input :disabled="formType == 3" v-model="item.name"
  49. placeholder="内容名称,仅内部可见"/>
  50. </el-form-item>
  51. <el-form-item label="课程" v-if="form.sendType == 11 && item.content && item.content.length > 0" required>
  52. <el-select :disabled="((formType == 3 || form.sendType == 11) && item.id != null) || !roles.includes('update_sop_temp_scourse')" v-model="item.content[0].courseId"
  53. placeholder="请选择课程" style=" margin-right: 10px;" size="mini" remote
  54. filterable
  55. @change="courseChangeUpdate(item.content[0], index, 0)">
  56. <el-option
  57. v-for="dict in courseList"
  58. :key="dict.dictValue"
  59. :label="dict.dictLabel"
  60. :value="parseInt(dict.dictValue)"
  61. />
  62. </el-select>
  63. <el-select :disabled="((formType == 3 || form.sendType == 11) && item.id != null) || !roles.includes('update_sop_temp_scourse')" v-model="item.content[0].videoId"
  64. placeholder="请选择小节" size="mini" style=" margin-right: 10px;" remote
  65. filterable
  66. @change="videoIdChange(item.content[0],index,0)">
  67. <el-option
  68. v-for="dict in videoList[0]"
  69. :key="dict.dictValue"
  70. :label="dict.dictLabel"
  71. :value="parseInt(dict.dictValue)"
  72. />
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item label="规则">
  76. <div v-for="(content, contentIndex) in item.content" :key="contentIndex"
  77. style="background-color: #fdfdfd;padding: 15px; border: 1px solid #e6e6e6; margin-bottom: 20px;">
  78. <el-row>
  79. <el-col el-col :span="22">
  80. <el-form :model="content" label-width="70px">
  81. <div v-if="item.dayNum==1">
  82. <el-form-item label="时间" v-if="form.sendType != 4">
  83. <el-time-picker
  84. :disabled="formType == 3 || !roles.includes('update_sop_temp_time')"
  85. class="custom-input"
  86. v-model="content.time"
  87. value-format="HH:mm"
  88. format="HH:mm"
  89. :picker-options="{ selectableRange: ['01:00:00 - 01:59:00','05:00:00 - 23:59:59'] }"
  90. placeholder="时间"
  91. style="width: 100px;height: 20px;">
  92. </el-time-picker>
  93. </el-form-item>
  94. </div>
  95. <div v-else>
  96. <el-form-item label="时间" v-if="form.sendType != 4">
  97. <el-time-picker
  98. :disabled="formType == 3 || !roles.includes('update_sop_temp_time')"
  99. class="custom-input"
  100. v-model="content.time"
  101. :picker-options="{ selectableRange: ['00:01:00 - 00:59:00','05:00:00 - 23:59:59']}"
  102. value-format="HH:mm"
  103. format="HH:mm"
  104. placeholder="时间"
  105. style="width: 100px;height: 20px;">
  106. </el-time-picker>
  107. </el-form-item>
  108. </div>
  109. <el-form-item label="官方群发" v-if="contentIndex==0 && content.type==2 && form.sendType != 4">
  110. <el-switch
  111. v-model="content.isOfficial"
  112. active-color="#13ce66"
  113. inactive-color="#DCDFE6"
  114. active-value="1"
  115. inactive-value="0">
  116. </el-switch>
  117. <div style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px">
  118. <i class="el-icon-info"></i>
  119. 请注意:官方群发 【第1天】 只能设置1点-1点30 的时间,【其他天数时间】 只能设置0点-0点30。此处仅为生成发送记录时间,实际发送可由 销售在公司规定的 【暂早上8点(前!!)】,在企业微信的【群发助手】处点击发送
  120. </div>
  121. </el-form-item>
  122. <el-form-item label="是否@所有人" v-if="form.sendType != 4">
  123. <el-switch
  124. v-model="content.isAtAll"
  125. active-color="#13ce66"
  126. inactive-color="#DCDFE6"
  127. :active-value="1"
  128. :inactive-value="0">
  129. </el-switch>
  130. <div
  131. style="color: #999;font-size: 14px;display: flex;align-items: center;margin-bottom: 5px">
  132. <i class="el-icon-info"></i>
  133. 开启后将在群发消息时@所有人(默认关闭)
  134. </div>
  135. </el-form-item>
  136. <el-form-item label="消息类型" v-if="form.sendType != 4">
  137. <el-select :disabled="formType == 3" v-model="content.courseType"
  138. placeholder="请选择消息类型" size="mini"
  139. style=" margin-right: 10px;" v-if="content.type != 4 ">
  140. <el-option
  141. v-for="dict in sysFsSopWatchStatus"
  142. :key="dict.dictValue"
  143. :label="dict.dictLabel"
  144. :value="Number(dict.dictValue)"
  145. />
  146. </el-select>
  147. </el-form-item>
  148. <el-form-item label="消息类别" v-if="form.sendType != 4 && form.sendType != 5">
  149. <el-radio-group v-model="content.type"
  150. :disabled="formType == 3 || content.isOfficial === '1'"
  151. @change="updateHtml(() => content.contentType = '1')">
  152. <el-radio :label="1">普通</el-radio>
  153. <el-radio :label="2">课程</el-radio>
  154. <el-radio :label="4">AI触达</el-radio>
  155. <el-radio :label="5">打标签</el-radio>
  156. </el-radio-group>
  157. </el-form-item>
  158. <el-form-item label="课程" v-if="content.type == 2 && form.sendType != 5" required>
  159. <el-select :disabled="formType == 3 || form.sendType == 11 || !roles.includes('edit_sop_temp_content')" v-model="content.courseId"
  160. placeholder="请选择课程" style=" margin-right: 10px;" size="mini" remote
  161. filterable
  162. @change="courseChangeUpdate(content,index,contentIndex)">
  163. <el-option
  164. v-for="dict in courseList"
  165. :key="dict.dictValue"
  166. :label="dict.dictLabel"
  167. :value="parseInt(dict.dictValue)"
  168. />
  169. </el-select>
  170. <el-select :disabled="formType == 3 || form.sendType == 11 || !roles.includes('edit_sop_temp_content')" v-model="content.videoId"
  171. placeholder="请选择小节" size="mini" style=" margin-right: 10px;" remote
  172. filterable
  173. @change="videoIdChange(content,index,contentIndex)">
  174. <el-option
  175. v-for="dict in videoList[contentIndex]"
  176. :key="dict.dictValue"
  177. :label="dict.dictLabel"
  178. :value="parseInt(dict.dictValue)"
  179. />
  180. </el-select>
  181. <el-select :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="content.courseType"
  182. placeholder="请选择消息类型" size="mini"
  183. style=" margin-right: 10px;" v-if="content.type != 4 ">
  184. <el-option
  185. v-for="dict in sysFsSopWatchStatus"
  186. :key="dict.dictValue"
  187. :label="dict.dictLabel"
  188. :value="Number(dict.dictValue)"
  189. />
  190. </el-select>
  191. </el-form-item>
  192. <el-form-item label="Ai触达" v-if="content.type == 4 ">
  193. <el-select :disabled="formType == 3" v-model="content.aiTouch"
  194. placeholder="请选择Ai触达类型" size="mini"
  195. style=" margin-right: 10px;" v-if="content.type == 4 ">
  196. <el-option label="非首次交流" value="非首次交流"></el-option>
  197. <el-option label="首次交流1" value="首次交流1"></el-option>
  198. <el-option label="首次交流2" value="首次交流2"></el-option>
  199. <el-option label="交流状态1" value="交流状态1"></el-option>
  200. <el-option label="交流状态2" value="交流状态2"></el-option>
  201. <el-option label="交流状态3" value="交流状态3"></el-option>
  202. </el-select>
  203. </el-form-item>
  204. <el-form-item label="添加标签" prop="addTag" v-if="content.type == 5 "
  205. v-model="content.addTag">
  206. <el-tag
  207. :key="tag"
  208. v-for="tag in content.addTag"
  209. closable
  210. :disable-transitions="false"
  211. @close="handleClose(contentIndex,tag,content)">
  212. {{ tag }}
  213. </el-tag>
  214. <el-input
  215. style="width:110px"
  216. class="input-new-tag"
  217. v-if="addTag[contentIndex] && addTag[contentIndex].inputVisible"
  218. v-model="addTag[contentIndex].inputValue"
  219. ref="saveTagInput"
  220. size="small"
  221. @keyup.enter.native="handleInputConfirm(contentIndex,content)"
  222. @blur="handleInputConfirm(contentIndex,content)"
  223. >
  224. </el-input>
  225. <el-button v-else class="button-new-tag" size="small" style="width: 110px"
  226. @click="showInput(contentIndex)">新增标签
  227. </el-button>
  228. </el-form-item>
  229. <el-form-item label="移除标签" prop="remarkMobiles" v-if="content.type == 5 ">
  230. <el-tag
  231. :key="tag"
  232. v-for="tag in content.delTag"
  233. closable
  234. :disable-transitions="false"
  235. @close="handleCloseDel(contentIndex,tag,content)">
  236. {{ tag }}
  237. </el-tag>
  238. <el-input
  239. style="width:110px"
  240. class="input-new-tag"
  241. v-if="addTag[contentIndex] && addTag[contentIndex].delTagVisible"
  242. v-model="addTag[contentIndex].delTagValue"
  243. ref="saveTagInputDel"
  244. size="small"
  245. @keyup.enter.native="handleInputConfirmDel(contentIndex,content)"
  246. @blur="handleInputConfirmDel(contentIndex,content)"
  247. >
  248. </el-input>
  249. <el-button v-else class="button-new-tag" size="small" style="width: 110px"
  250. @click="showInputDel(contentIndex)">新增标签
  251. </el-button>
  252. </el-form-item>
  253. <div v-for="(setList, setIndex) in content.setting" :key="setIndex"
  254. style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;"
  255. v-if="content.type != 4 && content.type != 5">
  256. <el-row style="padding-bottom: 20px">
  257. <el-col :span="22">
  258. <el-form :model="setList" label-width="70px">
  259. <el-form-item label="内容类别" style="margin: 2%">
  260. <div v-if="form.sendType == 1 ">
  261. <el-radio-group v-model="setList.contentType" :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')">
  262. <!-- <el-radio :label="item.dictValue" v-for="item in sysQwSopContentType">{{item.dictLabel}}</el-radio>-->
  263. <el-radio
  264. v-for="item in sysQwSopContentType"
  265. :key="item.dictValue"
  266. :label="item.dictValue"
  267. :disabled="item.dictValue === '1' && content.setting.some(s => s.contentType == '1') ">
  268. {{ item.dictLabel }}
  269. </el-radio>
  270. </el-radio-group>
  271. </div>
  272. <div v-if="form.sendType == 2">
  273. <el-radio-group v-model="setList.contentType"
  274. :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  275. @change="handleContentTypeChange(content,index,contentIndex,setIndex, item, 'contentType', $event)">
  276. <el-radio
  277. :key="item.dictValue"
  278. :label="item.dictValue"
  279. :disabled="(content.type!=2 && item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue))"
  280. v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
  281. </el-radio>
  282. </el-radio-group>
  283. </div>
  284. <div v-if=" form.sendType == 4 || form.sendType == 17">
  285. <el-radio-group v-model="setList.contentType"
  286. :disabled="formType == 3"
  287. @change="handleContentTypeChange(content,index,contentIndex,setIndex)">
  288. <el-radio
  289. :key="item.dictValue"
  290. :label="item.dictValue"
  291. :disabled="((content.type!=2 || form.sendType == 4) && (item.dictValue === '8' || item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue)))"
  292. v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
  293. </el-radio>
  294. </el-radio-group>
  295. </div>
  296. <div v-if="form.sendType == 11">
  297. <el-radio-group v-model="setList.contentType"
  298. :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
  299. @change="handleContentTypeChange(content,index,contentIndex,setIndex, item, 'contentType', $event)">
  300. <el-radio
  301. :key="item.dictValue"
  302. :label="item.dictValue"
  303. :disabled="(content.type!=2 && item.dictValue === '9') || (content.isOfficial==1 && ['5','6','7','8','9'].includes(item.dictValue))"
  304. v-for="item in sysQwSopAiContentType"
  305. v-if="courseTypeList.includes(item.dictValue)">{{ item.dictLabel }}
  306. </el-radio>
  307. </el-radio-group>
  308. </div>
  309. </el-form-item>
  310. <el-form-item label="内容">
  311. <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-if="setList.contentType == 1 || setList.contentType == 15"
  312. v-model="setList.value"
  313. type="textarea" :rows="3" placeholder="内容"
  314. style="width: 90%;margin-top: 10px;"
  315. @keydown.native="handleKeydown($event, index, contentIndex, setIndex)"
  316. :ref="`textarea-${index}-${contentIndex}-${setIndex}`"
  317. />
  318. <!-- 修改按钮部分 -->
  319. <el-link
  320. v-if="(setList.contentType == 1 || setList.contentType == 15) && roles.includes('edit_sop_temp_content')"
  321. type="primary"
  322. @click="toggleSalesCall(index, contentIndex, setIndex)"
  323. style="margin-top: 10px;"
  324. >
  325. {{ setList.isSalesCallAdded ? '移除#销售称呼#' : '添加#销售称呼#' }}
  326. </el-link>
  327. <el-link
  328. v-if="(setList.contentType == 1 || setList.contentType == 15) && roles.includes('edit_sop_temp_content')"
  329. type="primary"
  330. @click="toggleUserNameCall(index, contentIndex, setIndex)"
  331. style="margin-top: 10px; margin-left: 20px"
  332. >
  333. {{ setList.isUserNameCallAdded ? '移除#客户称呼#' : '添加#客户称呼#' }}
  334. </el-link>
  335. <ImageUpload :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-if="setList.contentType == 2 "
  336. v-model="setList.imgUrl"
  337. type="image" :num="1" :width="150" :height="150"/>
  338. <div
  339. v-if="(setList.contentType == 3 || item.contentType ==9) || (setList.contentType == 9 && content.type==2 )">
  340. <el-card class="box-card">
  341. <el-form-item label="链接标题:" label-width="100px" required>
  342. <el-input :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" v-model="setList.linkTitle"
  343. @change="updateAll(setIndex, item, 'linkTitle', $event)"
  344. placeholder="请输入链接标题"
  345. style="width: 90%;"/>
  346. </el-form-item>
  347. <el-form-item label="链接描述:" label-width="100px" required>
  348. <el-input :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" type="textarea" :rows="3"
  349. v-model="setList.linkDescribe"
  350. @change="updateAll(setIndex, item, 'linkDescribe', $event)"
  351. placeholder="请输入链接描述"
  352. style="width: 90%;margin-top: 1%;"/>
  353. </el-form-item>
  354. <el-form-item label="链接封面:" label-width="100px" required>
  355. <ImageUpload :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)" v-model="setList.linkImageUrl"
  356. type="image" :num="1"
  357. @input="updateAll(setIndex, item, 'linkImageUrl', $event)"
  358. :file-size="2" :width="150" :height="150"
  359. style="margin-top: 1%;"/>
  360. </el-form-item>
  361. <div v-if="content.type != 2 " style="margin-top: 1%">
  362. <el-form-item label="链接地址:" label-width="100px" required>
  363. <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.linkUrl"
  364. placeholder="请输入链接地址"
  365. style="width: 90%;"/>
  366. </el-form-item>
  367. </div>
  368. <div v-if="content.type == 2 ">
  369. <el-form-item label="链接地址:" label-width="100px">
  370. <el-tag type="warning" v-model="setList.isBindUrl = 1 ">选择的课程小节
  371. 即为卡片链接地址
  372. </el-tag>
  373. </el-form-item>
  374. </div>
  375. </el-card>
  376. </div>
  377. <div v-if="setList.contentType == 4 || setList.contentType == 10 || setList.contentType == 17">
  378. <el-card class="box-card">
  379. <el-form-item label="标题" prop="miniprogramTitle">
  380. <el-input v-model="setList.miniprogramTitle"
  381. :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
  382. @change="updateAll(setIndex, item, 'miniprogramTitle', $event)"
  383. placeholder="请输入小程序消息标题,最长为64字节" :rows="2"
  384. maxlength="64" type="textarea"
  385. @input="checkByteLength(content,setList.contentType,content.isOfficial)"/>
  386. </el-form-item>
  387. <el-form-item label="封面" prop="miniprogramPicUrl">
  388. <ImageUpload v-if="content.isOfficial !== '1'"
  389. @change="updateAll(setIndex, item, 'miniprogramPicUrl', $event)"
  390. :disabled="formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0)"
  391. v-model="setList.miniprogramPicUrl" type="image" :num="10"
  392. :width="150" :height="150"/>
  393. </el-form-item>
  394. <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
  395. <el-input v-model="setList.miniprogramAppid='wx73f85f8d62769119' " :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  396. disabled/>
  397. </el-form-item>
  398. <el-form-item label="page路径" prop="miniprogramPage" v-show="setList.contentType == 10"
  399. label-width="100px" style="margin-left: -30px">
  400. <el-input v-model="setList.miniprogramPage"
  401. :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  402. placeholder="小程序消息打开后的路径" type="textarea" :rows="3" />
  403. </el-form-item>
  404. </el-card>
  405. </div>
  406. <div v-if="setList.contentType == 12">
  407. <!-- <div >-->
  408. <el-card class="box-card">
  409. <el-form-item label="直播间" >
  410. <el-select v-model="setList.liveId"
  411. placeholder="请选择直播间" size="mini"
  412. @change="liveChange(setList)" >
  413. <el-option
  414. v-for="dict in liveList"
  415. :key="dict.liveId"
  416. :label="dict.liveName"
  417. :value="dict.liveId"
  418. />
  419. </el-select>
  420. </el-form-item>
  421. <el-form-item label="标题" prop="miniprogramTitle">
  422. <el-input v-model="setList.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字节" :rows="2" maxlength="64"
  423. type="textarea" @input="checkByteLength(content,setList.contentType,content.isOfficial)" />
  424. </el-form-item>
  425. <el-form-item label="封面" prop="miniprogramPicUrl">
  426. <ImageUpload v-model="setList.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
  427. </el-form-item>
  428. <el-form-item label="appid" prop="miniprogramAppid" v-show="false">
  429. <el-input v-model="setList.miniprogramAppid='wx503cf8ab31f83dd4' " disabled />
  430. </el-form-item>
  431. <el-form-item label="page路径" prop="miniprogramPage" v-show="false" label-width="100px" style="margin-left: -30px">
  432. <el-input v-model="setList.miniprogramPage" placeholder="小程序消息打开后的路径" disabled />
  433. </el-form-item>
  434. </el-card>
  435. </div>
  436. <div v-if="setList.contentType == 5 ">
  437. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  438. <el-upload
  439. :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  440. v-model="setList.fileUrl"
  441. class="avatar-uploader"
  442. :action="uploadUrl"
  443. :show-file-list="false"
  444. :on-success="(res, file) => handleAvatarSuccessFile(res, file, setList)"
  445. :before-upload="beforeAvatarUploadFile">
  446. <i class="el-icon-plus avatar-uploader-icon"></i>
  447. </el-upload>
  448. <el-link v-if="setList.fileUrl" type="primary"
  449. :href="downloadUrl(setList.fileUrl)" download>
  450. {{ setList.fileUrl }}
  451. </el-link>
  452. </el-form-item>
  453. </div>
  454. <div v-if="setList.contentType == 6 ">
  455. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  456. <el-upload
  457. :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  458. v-model="setList.videoUrl"
  459. class="avatar-uploader"
  460. :action="uploadUrl"
  461. :show-file-list="false"
  462. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, setList)"
  463. :before-upload="beforeAvatarUploadVideo">
  464. <i class="el-icon-plus avatar-uploader-icon"></i>
  465. </el-upload>
  466. <video v-if="setList.videoUrl"
  467. :src="setList.videoUrl"
  468. controls style="width: 200px;height: 100px">
  469. </video>
  470. </el-form-item>
  471. </div>
  472. <div v-if="setList.contentType == 7 || setList.contentType == 16">
  473. <el-input
  474. :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')"
  475. v-model="setList.value"
  476. type="textarea" :rows="3" maxlength="66" show-word-limit
  477. placeholder="输入要转为语音的内容"
  478. style="width: 90%;margin-top: 10px;"
  479. @input="handleInputVideoText(setList.value,setList)"/>
  480. </div>
  481. <div v-if="setList.contentType == 8 ">
  482. <el-button :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" type="primary"
  483. style="margin-bottom: 1%"
  484. @click="hanldeSelectVideoNum(content,index,contentIndex,setIndex)">
  485. 选择视频号
  486. </el-button>
  487. <el-card class="box-card" v-if="setList.coverUrl">
  488. <el-form-item label="封面标题:" label-width="100px">
  489. <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.nickname"
  490. style="width: 90%;margin-bottom: 1%" disabled/>
  491. </el-form-item>
  492. <el-form-item label="头像:" label-width="100px">
  493. <el-image
  494. v-if="setList.avatar != null"
  495. :src="setList.avatar"
  496. :preview-src-list="[setList.avatar]"
  497. :style="{ width: '50px', height: '50px' }"
  498. ></el-image>
  499. </el-form-item>
  500. <el-form-item label="封面:" label-width="100px">
  501. <el-image
  502. v-if="setList.coverUrl != null"
  503. :src="setList.coverUrl"
  504. :preview-src-list="[setList.coverUrl]"
  505. :style="{ width: '200px', height: '200px' }"
  506. ></el-image>
  507. </el-form-item>
  508. <el-form-item label="简介:" label-width="100px">
  509. <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" type="textarea" :rows="3"
  510. v-model="setList.desc"
  511. style="width: 90%;margin-top: 1%;" disabled/>
  512. </el-form-item>
  513. <el-form-item label="视频地址:" label-width="100px"
  514. style="margin-top: 1%">
  515. <el-input :disabled="formType == 3 || !roles.includes('edit_sop_temp_content')" v-model="setList.url"
  516. style="width: 90%;" disabled/>
  517. </el-form-item>
  518. </el-card>
  519. </div>
  520. <div v-if="setList.contentType == 14">
  521. <el-card class="box-card">
  522. <el-form-item label="福袋名称" >
  523. <el-select :disabled="formType == 3" v-model="setList.luckyBagId"
  524. placeholder="请选择福袋" size="mini"
  525. @change="getLuckyBagStatus(setList)" >
  526. <el-option
  527. v-for="dict in luckyBagList"
  528. :key="dict.id"
  529. :label="dict.name"
  530. :value="dict.id"
  531. />
  532. </el-select>
  533. </el-form-item>
  534. <el-form-item label="福袋状态" >
  535. <el-tag :disabled="formType == 3" :type="setList.luckyBagDataStatus == 1 ? 'success' : 'danger'">
  536. {{ setList.luckyBagDataStatus == 1 ? '启用' : '禁用' }}
  537. </el-tag>
  538. </el-form-item>
  539. </el-card>
  540. </div>
  541. </el-form-item>
  542. <!-- <el-form-item label="添加短链"-->
  543. <!-- v-if="content.type == 2 && setList.contentType == 1 ">-->
  544. <!-- <el-tooltip content="请先根据课程选定课程小节之后再添加" effect="dark"-->
  545. <!-- :disabled="!content.videoId">-->
  546. <!-- <el-switch-->
  547. <!-- @change="updateHtml"-->
  548. <!-- v-model="setList.isBindUrl"-->
  549. <!-- :disabled="!content.videoId && formType == 3 && !roles.includes('edit_sop_temp_content')"-->
  550. <!-- active-color="#13ce66"-->
  551. <!-- inactive-color="#DCDFE6"-->
  552. <!-- active-value="1"-->
  553. <!-- inactive-value="2">-->
  554. <!-- </el-switch>-->
  555. <!-- </el-tooltip>-->
  556. <!-- <span v-if="setList.isBindUrl == '1'"-->
  557. <!-- style="margin-left: 10px; color: #13ce66">添加URL</span>-->
  558. <!-- <span v-if="setList.isBindUrl == '2'"-->
  559. <!-- style="margin-left: 10px; color: #b1b4ba">不加URL</span>-->
  560. <!-- </el-form-item>-->
  561. <el-form-item label="课节过期时间"
  562. v-if="content.type == 2 && (setList.isBindUrl == '1' || setList.contentType==4) && setList.contentType != 2 && setList.contentType != 5 && setList.contentType != 6 && setList.contentType != 8 && setList.contentType != 9 && setList.contentType != 10 ">
  563. <el-row>
  564. <el-input type="number" v-model="setList.expiresDays"
  565. :disabled="!roles.includes('edit_sop_temp_content') && (formType == 3 || (form.sendType == 11 && contentIndex != 0 && setIndex == 0))"
  566. @change="updateAll(setIndex, item, 'expiresDays', $event)"
  567. style="width: 200px">
  568. <template slot="append">天</template>
  569. </el-input>
  570. </el-row>
  571. <el-row>
  572. <span class="tip">填写0或不填时,默认为系统配置的默认时间</span>
  573. </el-row>
  574. </el-form-item>
  575. </el-form>
  576. <el-form v-if="form.sendType == 4" :model="setList" label-width="70px">
  577. <el-form-item label="添加客服" prop="intervalTime" style="margin: 2%">
  578. <el-input-number
  579. v-model="setList.intervalTime"
  580. :min="1"
  581. :max="1440"
  582. style="width:150px;margin-top: 10px;"
  583. >
  584. </el-input-number>
  585. <span class="tip">单位:分钟,最大1440分钟(24小时)</span>
  586. </el-form-item>
  587. <!-- <el-form-item label="内容" style="margin: 2%">-->
  588. <!-- <el-input-->
  589. <!-- v-model="setList.value"-->
  590. <!-- type="textarea"-->
  591. <!-- :rows="3"-->
  592. <!-- placeholder="内容"-->
  593. <!-- style="width: 90%;margin-top: 10px;"/>-->
  594. <!-- </el-form-item>-->
  595. <!-- <el-form-item label="交流状态" style="margin: 2%">-->
  596. <!-- <el-select v-model="setList.talkType" placeholder="更改交流状态" size="mini"-->
  597. <!-- style=" margin-right: 10px;" clearable>-->
  598. <!-- <el-option label="非首次交流" value="非首次交流"></el-option>-->
  599. <!-- <el-option label="首次交流1" value="首次交流1"></el-option>-->
  600. <!-- <el-option label="首次交流2" value="首次交流2"></el-option>-->
  601. <!-- <el-option label="交流状态1" value="交流状态1"></el-option>-->
  602. <!-- <el-option label="交流状态2" value="交流状态2"></el-option>-->
  603. <!-- <el-option label="交流状态3" value="交流状态3"></el-option>-->
  604. <!-- </el-select>-->
  605. <!-- </el-form-item>-->
  606. </el-form>
  607. </el-col>
  608. <el-col :span="1" :offset="1">
  609. <i class="el-icon-delete" @click="delSetList(index,contentIndex,setIndex)"
  610. style="margin-top: 20px;"
  611. v-if="content.setting.length>1 && (formType != 3) && roles.includes('del_sop_temp_content') && !(form.sendType == 11 && setIndex == 0)"></i>
  612. </el-col>
  613. </el-row>
  614. </div>
  615. <el-link type="primary" class="el-icon-plus" :underline="false"
  616. @click='addSetList(contentIndex,item.content)'
  617. v-if="content.type != 4 && formType != 3 && roles.includes('add_sop_temp_content')">添加内容
  618. </el-link>
  619. </el-form>
  620. </el-col>
  621. <el-col :span="1" :offset="1">
  622. <i class="el-icon-delete" @click="delContent(index,contentIndex)"
  623. style="margin-top: 20px;"
  624. v-if="item.content.length>1 && formType != 3 && roles.includes('del_sop_temp_rule')"></i>
  625. </el-col>
  626. </el-row>
  627. </div>
  628. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addContent(index)'
  629. v-if="formType != 3 && form.sendType != 4 && roles.includes('add_sop_temp_rule')">添加规则
  630. </el-link>
  631. </el-form-item>
  632. </el-form>
  633. </div>
  634. <div style="float: right;" v-if="formType != 3 && roles.includes('update_sop_temp_day')">
  635. <el-button type="primary" @click="save" v-if="!item.voice || item.voice == 0">
  636. 保存({{ '第' + (1 + (form.gap * index)) + '天' }})
  637. </el-button>
  638. <el-button type="primary" disabled v-if="item.voice == 1">语言生成中</el-button>
  639. <el-button type="primary" @click="leave(tabIndex)" v-if="item.voice == 1">刷新状态</el-button>
  640. </div>
  641. </el-col>
  642. </el-row>
  643. </el-tab-pane>
  644. </el-tabs>
  645. </el-form-item>
  646. </el-form>
  647. </div>
  648. <el-dialog :title="videoNumOptions.title" :visible.sync="videoNumOptions.open" style="width: 1500px;height: 100%"
  649. append-to-body>
  650. <userVideo ref="QwUserVideo" @videoResult="qwUserVideoResult"></userVideo>
  651. </el-dialog>
  652. <el-dialog title="修改天数排序" :visible.sync="openSort" style="width: 1500px" append-to-body>
  653. <draggable v-model="dayList" @end="onDragEndDay" style="padding: 20px">
  654. <el-button v-for="(item, index) in dayList" :class="item.newDay != item.dayNum ? 'red':''">第{{
  655. item.newDay
  656. }}天(第{{ item.dayNum }}天)
  657. </el-button>
  658. </draggable>
  659. <div style="float: right;">
  660. <el-button type="primary" @click="saveSorts">保存</el-button>
  661. </div>
  662. </el-dialog>
  663. <el-dialog title="修改规则排序" :visible.sync="openSort2" style="width: 1500px" append-to-body>
  664. <draggable v-model="ruleList" @end="onDragEnd" style="padding: 20px">
  665. <el-button v-for="(item, index) in ruleList">{{ item.time }}</el-button>
  666. </draggable>
  667. <div style="float: right;">
  668. <el-button @click="autoSortsRules">自动排序</el-button>
  669. <el-button type="primary" @click="saveSortsRules">保存</el-button>
  670. </div>
  671. </el-dialog>
  672. </div>
  673. </template>
  674. <style scoped>
  675. .el-button {
  676. margin-left: 10px;
  677. }
  678. .red:hover {
  679. color: #dbdbdb !important;
  680. }
  681. .red {
  682. background-color: #F56C6C !important;
  683. color: #fff !important;
  684. }
  685. .custom-input /deep/ .el-input__inner {
  686. height: 20px;
  687. text-align: center;
  688. }
  689. .custom-input /deep/ .el-input__icon {
  690. line-height: 10px;
  691. }
  692. .el-icon-delete {
  693. cursor: pointer;
  694. }
  695. /deep/ .el-badge__content.is-fixed {
  696. top: 10px !important;
  697. right: 0 !important;
  698. width: 8px;
  699. }
  700. .tip {
  701. color: #909399;
  702. font-size: 12px;
  703. margin-left: 10px;
  704. }
  705. .sortable-ghost {
  706. background: rgb(26, 164, 255) !important;
  707. color: #FFF !important;
  708. }
  709. </style>
  710. <script>
  711. import draggable from 'vuedraggable';
  712. import {
  713. listSopTemp,
  714. getSopTemp,
  715. delSopTemp,
  716. addSopTemp,
  717. sortDay,
  718. dayListFun,
  719. updateSopTemp,
  720. exportSopTemp,
  721. addOrUpdateSetting,
  722. getSelectableRange,
  723. selectRulesInfo,
  724. delRules
  725. } from "@/api/qw/sopTemp";
  726. import {courseList, videoList} from "@/api/qw/sop";
  727. import {listToLiveNoEnd} from "@/api/live/live";
  728. import ImageUpload from "@/views/qw/sop/ImageUpload";
  729. import userVideo from "@/views/qw/userVideo/userVideo.vue";
  730. import {listReward} from "@/api/qw/luckyBag";
  731. import {
  732. getRoles,
  733. } from "@/api/qw/sop";
  734. export default {
  735. name: "updateSopTemp",
  736. components: {ImageUpload, userVideo, draggable},
  737. data() {
  738. return {
  739. queryParams1: {
  740. pageNum: 1,
  741. pageSize: 10,
  742. dataStatus: '1',
  743. name: null,
  744. type: null
  745. },
  746. luckyBagList: [],
  747. projectFrom:process.env.VUE_APP_PROJECT_FROM,
  748. addTag: [{
  749. addTag: [],
  750. inputVisible: false,
  751. inputValue: '',
  752. delTag: [],
  753. delTagVisible: false,
  754. delTagValue: ''
  755. }],
  756. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS2",
  757. uploadUrlByVoice: process.env.VUE_APP_BASE_API + "/common/uploadOSSByHOOKVoice",
  758. //上传语音的遮罩层
  759. voiceLoading: false,
  760. openSort: false,
  761. openSort2: false,
  762. // 遮罩层
  763. loading: false,
  764. loading2: false,
  765. loading3: false,
  766. // 导出遮罩层
  767. exportLoading: false,
  768. roles: [],
  769. // 选中数组
  770. dayList: [],
  771. ruleList: [],
  772. ids: [],
  773. // startTimeRange: [],
  774. courseTypeList: ['1','2', '4','5','6', '7','8','9','10'],
  775. sysFsSopWatchStatus: [],
  776. //消息内容类型 企微版
  777. sysQwSopContentType: [],
  778. //插件版
  779. sysQwSopAiContentType: [],
  780. //类别
  781. sysQwSopSettingType: [],
  782. courseList: [],
  783. videoList: [],
  784. // 非单个禁用
  785. single: true,
  786. // 非多个禁用
  787. multiple: true,
  788. defaultContentType: 1,
  789. // 显示搜索条件
  790. showSearch: true,
  791. // 总条数
  792. id: "",
  793. total: 0,
  794. tabIndex: null,
  795. // sop模板表格数据
  796. setting: [],
  797. data: [],
  798. // 弹出层标题
  799. title: "",
  800. // 是否显示弹出层
  801. open: false,
  802. // 状态字典
  803. statusOptions: [],
  804. videoNumOptions: {
  805. title: '选择视频号',
  806. open: false,
  807. content: null,
  808. contentIndex: null,
  809. setIndex: null,
  810. },
  811. //1 修改 2 复制 3 查看
  812. formType: null,
  813. // 查询参数
  814. form: {
  815. name: null,
  816. setting: null,
  817. status: "1",
  818. sort: 1,
  819. companyId: null,
  820. gap: 1,
  821. },
  822. // 缓存对象用于存储预加载的数据
  823. tabCache: {},
  824. // 标记哪些tab已经被请求过
  825. loadedTabs: new Set(),
  826. // 标记正在加载的tab,避免重复请求
  827. loadingTabs: new Set(),
  828. // 表单校验
  829. rules: {
  830. name: [
  831. {required: true, message: '名称不能为空', trigger: 'blur'}
  832. ],
  833. status: [
  834. {required: true, message: '状态不能为空', trigger: 'blur'}
  835. ],
  836. sort: [
  837. {required: true, message: '排序不能为空', trigger: 'blur'}
  838. ],
  839. gap: [
  840. {required: true, message: '间隔天数不能为空', trigger: 'blur'}
  841. ],
  842. },
  843. liveList: [],
  844. };
  845. },
  846. created() {
  847. getRoles().then(res => {
  848. this.roles = res.data;
  849. })
  850. this.getDicts("sys_qwSopAi_contentType").then(response => {
  851. this.sysQwSopAiContentType = response.data;
  852. });
  853. this.getDicts("sys_fs_sop_watch_status").then(response => {
  854. this.sysFsSopWatchStatus = response.data;
  855. });
  856. // getSelectableRange().then(e => {
  857. // this.startTimeRange = e.data;
  858. // })
  859. this.getDicts("sys_qwSop_contentType").then(response => {
  860. this.sysQwSopContentType = response.data;
  861. });
  862. this.getDicts("sys_company_status").then(response => {
  863. this.statusOptions = response.data;
  864. });
  865. this.getDicts("sys_qwSop_settingType").then(response => {
  866. this.sysQwSopSettingType = response.data;
  867. });
  868. courseList().then(response => {
  869. this.courseList = response.list;
  870. });
  871. listToLiveNoEnd().then(response => {
  872. this.liveList = response.rows;
  873. })
  874. listReward(this.queryParams1).then(response => {
  875. this.luckyBagList = response.rows;
  876. });
  877. const id = this.$route.params && this.$route.params.id;
  878. this.id = id;
  879. this.formType = this.$route.params && this.$route.params.type;
  880. console.info(this.form)
  881. this.handleUpdate(id);
  882. },
  883. methods: {
  884. getLuckyBagStatus(content) {
  885. const selectedLuckyBag = this.luckyBagList.find(item => item.id === content.luckyBagId);
  886. if (selectedLuckyBag) {
  887. content.luckyBagDataStatus = selectedLuckyBag.dataStatus; // 自动填充标题
  888. } else {
  889. // 若未找到对应直播间,清空标题和封面(可选)
  890. content.luckyBagDataStatus = null;
  891. }
  892. },
  893. liveChange(content) {
  894. // content.liveId 是选中的直播间 ID(liveId)
  895. const selectedLive = this.liveList.find(live => live.liveId === content.liveId);
  896. if (selectedLive) {
  897. // 从选中的直播间对象中提取标题和封面,赋值给当前内容的对应字段
  898. // 假设直播间对象中标题字段为 liveTitle,封面字段为 coverImg(根据实际接口字段调整)
  899. content.miniprogramTitle = selectedLive.liveName || ''; // 自动填充标题
  900. content.miniprogramPicUrl = selectedLive.liveImgUrl || ''; // 自动填充封面
  901. } else {
  902. // 若未找到对应直播间,清空标题和封面(可选)
  903. content.miniprogramTitle = '';
  904. content.miniprogramPicUrl = '';
  905. }
  906. },
  907. handleClose(index, tag, content) {
  908. content.addTag.splice(content.addTag.indexOf(tag), 1);
  909. },
  910. showInput(index) {
  911. this.addTag[index].inputVisible = true;
  912. },
  913. handleInputConfirm(index, content) {
  914. let inputValue = this.addTag[index].inputValue;
  915. if (inputValue) {
  916. if (!content.hasOwnProperty('addTag')) {
  917. this.$set(content, 'addTag', []);
  918. }
  919. content.addTag.push(inputValue);
  920. }
  921. this.addTag[index].inputVisible = false;
  922. this.addTag[index].inputValue = '';
  923. },
  924. // 检查字节长度
  925. checkByteLength(content, type, isOfficial) {
  926. if (type == 4 && isOfficial == '1')
  927. for (let i = 0; i < content.setting.length; i++) {
  928. const text = content.setting[i].miniprogramTitle;
  929. const byteLength = this.getByteLength(text); // 获取当前字节数
  930. // 如果字节数超过64,截断输入内容
  931. if (byteLength > 64) {
  932. this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(text, 60));
  933. }
  934. }
  935. },
  936. // 计算字符串的字节数
  937. getByteLength(text) {
  938. return new Blob([text]).size; // 使用 Blob 计算字节数
  939. },
  940. // 根据字节数截断字符串
  941. truncateTextByByteLength(text, maxByteLength) {
  942. let byteLength = 0;
  943. let result = "";
  944. for (let i = 0; i < text.length; i++) {
  945. const char = text[i];
  946. const charByteLength = this.getByteLength(char); // 获取当前字符的字节数
  947. // 如果加上当前字符的字节数后不超过限制,则添加到结果中
  948. if (byteLength + charByteLength <= maxByteLength) {
  949. result += char;
  950. byteLength += charByteLength;
  951. } else {
  952. break; // 超过限制时停止
  953. }
  954. }
  955. return result;
  956. },
  957. handleCloseDel(index, tag, content) {
  958. content.delTag.splice(content.delTag.indexOf(tag), 1);
  959. },
  960. showInputDel(index) {
  961. this.addTag[index].delTagVisible = true;
  962. },
  963. handleInputConfirmDel(index, content) {
  964. let delTagValue = this.addTag[index].delTagValue;
  965. if (delTagValue) {
  966. if (!content.hasOwnProperty('delTag')) {
  967. this.$set(content, 'delTag', []);
  968. }
  969. content.delTag.push(delTagValue);
  970. }
  971. this.addTag[index].delTagVisible = false;
  972. this.addTag[index].delTagValue = '';
  973. },
  974. saveSorts() {
  975. let list = this.dayList.filter(e => e.dayNum != e.newDay).map(e => {
  976. return {dayNum: e.newDay, id: e.id}
  977. })
  978. this.loading3 = true;
  979. sortDay(list).then(e => {
  980. window.location.reload();
  981. })
  982. },
  983. saveSortsRules() {
  984. this.$set(this.setting[this.tabIndex], 'content', this.ruleList);
  985. this.openSort2 = false;
  986. },
  987. autoSortsRules() {
  988. this.ruleList = this.ruleList.sort((a, b) => {
  989. // 将 time 字段转换为 Date 对象进行比较
  990. const timeA = new Date(`1970-01-01T${a.time}Z`);
  991. const timeB = new Date(`1970-01-01T${b.time}Z`);
  992. // 比较时间顺序
  993. return timeA - timeB; // 升序排序
  994. });
  995. },
  996. openUpdateDaySorts() {
  997. dayListFun(this.id).then(response => {
  998. response.data.forEach((item) => item.newDay = item.dayNum);
  999. this.dayList = response.data;
  1000. if (this.dayList == null || this.dayList.length == 0) {
  1001. this.$message.error("暂无天数")
  1002. } else {
  1003. this.openSort = true;
  1004. }
  1005. })
  1006. },
  1007. openUpdateSorts() {
  1008. this.ruleList = JSON.parse(JSON.stringify(this.setting[this.tabIndex].content));
  1009. if (this.ruleList == null || this.ruleList.length == 0) {
  1010. this.$message.error("暂无规则")
  1011. } else {
  1012. this.openSort2 = true;
  1013. }
  1014. },
  1015. onDragEndDay() {
  1016. this.dayList.forEach((item, index) => {
  1017. item.newDay = (this.form.gap * index) + 1;
  1018. })
  1019. this.$forceUpdate()
  1020. },
  1021. onDragEnd() {
  1022. // 更新排序值
  1023. // this.setting[this.tabIndex].content.forEach((item, index) => {
  1024. // item.sorts = index;
  1025. // });
  1026. },
  1027. // 切换标签保存数据
  1028. async leave(index, oldIndex) {
  1029. const newData = this.setting[index]
  1030. if (newData.dayNum && newData.id) {
  1031. // 检查是否已经有缓存数据
  1032. if (this.tabCache[newData.id]) {
  1033. // 使用缓存数据,无需loading
  1034. this.applyCachedData(index, newData);
  1035. } else {
  1036. // 没有缓存,需要请求数据
  1037. this.loading = true;
  1038. try {
  1039. const res = await selectRulesInfo(newData.id);
  1040. // 缓存数据
  1041. this.tabCache[newData.id] = res.data;
  1042. this.loadedTabs.add(index);
  1043. this.applyDataToTab(index, newData, res.data);
  1044. } catch (error) {
  1045. console.error("获取规则信息失败:", error);
  1046. } finally {
  1047. this.loading = false;
  1048. }
  1049. }
  1050. // 预加载下一个tab的数据
  1051. this.preloadNextTab(index);
  1052. }
  1053. },
  1054. // 应用缓存数据到tab
  1055. applyCachedData(index, newData) {
  1056. const cachedData = this.tabCache[newData.id];
  1057. this.$nextTick(() => {
  1058. this.videoList = [];
  1059. this.addTag = [];
  1060. this.$set(this.setting, index, {
  1061. ...newData,
  1062. voice: cachedData.voice,
  1063. content: cachedData.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
  1064. });
  1065. for (let j = 0; j < this.setting[index].content.length; j++) {
  1066. if (this.setting[index].content[j].addTag != null) {
  1067. this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
  1068. }
  1069. if (this.setting[index].content[j].delTag != null) {
  1070. this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
  1071. }
  1072. this.videoList.push([])
  1073. this.addTag.push({
  1074. addTag: [],
  1075. inputVisible: false,
  1076. inputValue: '',
  1077. delTag: [],
  1078. delTagVisible: false,
  1079. delTagValue: ''
  1080. })
  1081. if (this.setting[index].content[j].type == 2) {
  1082. if (this.setting[index].content[j].hasOwnProperty('courseId')) {
  1083. this.courseChange(this.setting[index].content[j], index, j);
  1084. }
  1085. }
  1086. }
  1087. });
  1088. },
  1089. // 应用新获取的数据到tab
  1090. applyDataToTab(index, newData, data) {
  1091. this.$nextTick(() => {
  1092. this.videoList = [];
  1093. this.addTag = [];
  1094. this.$set(this.setting, index, {
  1095. ...newData,
  1096. voice: data.voice,
  1097. content: data.list || [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: ""}]}]
  1098. });
  1099. for (let j = 0; j < this.setting[index].content.length; j++) {
  1100. if (this.setting[index].content[j].addTag != null) {
  1101. this.setting[index].content[j].addTag = JSON.parse(this.setting[index].content[j].addTag)
  1102. }
  1103. if (this.setting[index].content[j].delTag != null) {
  1104. this.setting[index].content[j].delTag = JSON.parse(this.setting[index].content[j].delTag)
  1105. }
  1106. this.videoList.push([])
  1107. this.addTag.push({
  1108. addTag: [],
  1109. inputVisible: false,
  1110. inputValue: '',
  1111. delTag: [],
  1112. delTagVisible: false,
  1113. delTagValue: ''
  1114. })
  1115. if (this.setting[index].content[j].type == 2) {
  1116. if (this.setting[index].content[j].hasOwnProperty('courseId')) {
  1117. this.courseChange(this.setting[index].content[j], index, j);
  1118. }
  1119. }
  1120. }
  1121. });
  1122. },
  1123. // 预加载下一个tab的数据
  1124. async preloadNextTab(currentIndex) {
  1125. const nextIndex = parseInt(currentIndex) + 1;
  1126. // 检查是否有下一个tab
  1127. if (nextIndex >= this.setting.length) {
  1128. return;
  1129. }
  1130. const nextTabData = this.setting[nextIndex];
  1131. // 只预加载已存在的tab(有id的),跳过新建的tab
  1132. if (!nextTabData.id || !nextTabData.dayNum) {
  1133. return;
  1134. }
  1135. // 如果已经加载过或正在加载,则跳过
  1136. if (this.loadedTabs.has(nextIndex) || this.loadingTabs.has(nextIndex) || this.tabCache[nextTabData.id]) {
  1137. return;
  1138. }
  1139. // 标记为正在加载
  1140. this.loadingTabs.add(nextIndex);
  1141. try {
  1142. const res = await selectRulesInfo(nextTabData.id);
  1143. // 缓存数据
  1144. this.tabCache[nextTabData.id] = res.data;
  1145. this.loadedTabs.add(nextIndex);
  1146. } catch (error) {
  1147. console.error("预加载tab数据失败:", error);
  1148. } finally {
  1149. // 移除加载标记
  1150. this.loadingTabs.delete(nextIndex);
  1151. }
  1152. },
  1153. save() {
  1154. let data = this.setting[this.tabIndex];
  1155. let check = this.checkData(data);
  1156. if (!check) {
  1157. return;
  1158. }
  1159. for (let j = 0; j < data.content.length; j++) {
  1160. //如果不是每天第一条,全刷为非官方
  1161. if (j!==0){
  1162. data.content[j].isOfficial=0;
  1163. }
  1164. if (data.content[j].type != 4 && data.content[j].type != 5) {
  1165. for (let k = 0; k < data.content[j].setting.length; k++) {
  1166. if (data.content[j].setting[k].contentType == 4 && (data.content[j].setting[k].miniprogramTitle != null || data.content[j].setting[k].miniprogramTitle != "")) {
  1167. data.content[j].setting[k].miniprogramTitle = this.truncateTextByByteLength(data.content[j].setting[k].miniprogramTitle, 60)
  1168. }
  1169. }
  1170. }
  1171. }
  1172. let index = 0;
  1173. const dataList = data.content.map(e => {
  1174. e.name = data.name;
  1175. e.tempId = this.id;
  1176. e.sorts = Number(this.tabIndex);
  1177. e.dayNum = (this.form.gap * e.sorts) + 1;
  1178. e.sorts = index++;
  1179. data.dayNum = e.dayNum;
  1180. e.contentType = e.type;
  1181. e.settingList = e.setting;
  1182. e.settingList.forEach(e => e.content = JSON.stringify(e));
  1183. if (e.addTag != null) {
  1184. e.addTag = JSON.stringify(e.addTag);
  1185. }
  1186. if (e.delTag != null) {
  1187. e.delTag = JSON.stringify(e.delTag);
  1188. }
  1189. return e;
  1190. })
  1191. data.tempId = this.id;
  1192. data.list = dataList;
  1193. this.loading = true;
  1194. addOrUpdateSetting(data).then(e => {
  1195. this.$message.success(e.msg)
  1196. let content = this.setting[this.tabIndex].content;
  1197. for (let j = 0; j < content.length; j++) {
  1198. if (content[j].addTag != null) {
  1199. content[j].addTag = JSON.parse(content[j].addTag);
  1200. }
  1201. if (content[j].delTag != null) {
  1202. content[j].delTag = JSON.parse(content[j].delTag);
  1203. }
  1204. }
  1205. this.loading = false;
  1206. // 使用Vue.set确保响应式更新
  1207. this.$set(this.setting, this.tabIndex, {
  1208. ...this.setting[this.tabIndex],
  1209. id: e.data.id,
  1210. });
  1211. // 更新缓存中的数据
  1212. const currentTabId = this.setting[this.tabIndex].id;
  1213. if (currentTabId) {
  1214. // 重新获取最新数据并更新缓存
  1215. selectRulesInfo(currentTabId).then(res => {
  1216. this.tabCache[currentTabId] = res.data;
  1217. this.loadedTabs.add(parseInt(this.tabIndex));
  1218. }).catch(error => {
  1219. console.error("更新缓存失败:", error);
  1220. });
  1221. }
  1222. }).catch(() => {
  1223. this.loading = false;
  1224. });
  1225. },
  1226. checkData(data) {
  1227. if (this.form.sendType != 4) {
  1228. for (let j = 0; j < data.content.length; j++) {
  1229. if (data.name == null || data.name == "") {
  1230. this.$message.error("内容名称不能为空")
  1231. return false;
  1232. }
  1233. if (data.content[j].time == null || data.content[j].time == "") {
  1234. this.$message.error("时间不能为空")
  1235. return false;
  1236. }
  1237. if (data.content[j].type == 2) {
  1238. if (data.content[j].courseId == null || data.content[j].courseId == "") {
  1239. this.$message.error("请选择课程")
  1240. return false;
  1241. }
  1242. if (data.content[j].videoId == null || data.content[j].videoId == "") {
  1243. this.$message.error("请选择课节")
  1244. return false;
  1245. }
  1246. if (data.content[j].courseType == null || data.content[j].courseType === "") {
  1247. this.$message.error("请选择消息类型")
  1248. return false;
  1249. }
  1250. }
  1251. if (data.content[j].type != 4 && data.content[j].type != 5) {
  1252. for (let k = 0; k < data.content[j].setting.length; k++) {
  1253. if (data.content[j].setting[k].contentType == 1 && (data.content[j].setting[k].value == null || data.content[j].setting[k].value == "")) {
  1254. this.$message.error("内容不能为空")
  1255. return false;
  1256. }
  1257. if (data.content[j].setting[k].contentType == 2 && (data.content[j].setting[k].imgUrl == null || data.content[j].setting[k].imgUrl == "")) {
  1258. this.$message.error("图片不能为空")
  1259. return false;
  1260. }
  1261. if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkTitle == null || data.content[j].setting[k].linkTitle == "")) {
  1262. this.$message.error("链接标题不能为空")
  1263. return false;
  1264. }
  1265. if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkDescribe == null || data.content[j].setting[k].linkDescribe == "")) {
  1266. this.$message.error("链接描述不能为空")
  1267. return false;
  1268. }
  1269. if ((data.content[j].setting[k].contentType == 3 || data.content[j].setting[k].contentType == 9 || data.content[j].setting[k].contentType == 10) && (data.content[j].setting[k].linkImageUrl == null || data.content[j].setting[k].linkImageUrl == "")) {
  1270. this.$message.error("链接图片不能为空")
  1271. return false;
  1272. }
  1273. if (data.content[j].setting[k].contentType == 3 && data.content[j].setting[k].type == 1 && (data.content[j].setting[k].linkUrl == null || data.content[j].setting[k].linkUrl == "")) {
  1274. this.$message.error("链接地址不能为空")
  1275. return false;
  1276. }
  1277. if ((data.content[j].setting[k].contentType == 4 || data.content[j].setting[k].contentType == 10 || data.content[j].setting[k].contentType == 17) && (data.content[j].setting[k].miniprogramTitle == null || data.content[j].setting[k].miniprogramTitle == "")) {
  1278. this.$message.error("小程序消息标题不能为空")
  1279. return false;
  1280. }
  1281. if ((data.content[j].setting[k].contentType == 4 || data.content[j].setting[k].contentType == 10 || data.content[j].setting[k].contentType == 17) && data.content[j].isOfficial !== '1' && (data.content[j].setting[k].miniprogramPicUrl == null || data.content[j].setting[k].miniprogramPicUrl == "")) {
  1282. this.$message.error("小程序封面地址不能为空")
  1283. return false;
  1284. }
  1285. if (data.content[j].setting[k].contentType == 10 && data.content[j].isOfficial !== '1' && (data.content[j].setting[k].miniprogramPage == null || data.content[j].setting[k].miniprogramPage == "")) {
  1286. this.$message.error("小程序page地址不能为空")
  1287. return false;
  1288. }
  1289. if (data.content[j].setting[k].contentType == 5 && (data.content[j].setting[k].fileUrl == null || data.content[j].setting[k].fileUrl == "")) {
  1290. this.$message.error("文件不能为空")
  1291. return false;
  1292. }
  1293. if (data.content[j].setting[k].contentType == 6 && (data.content[j].setting[k].videoUrl == null || data.content[j].setting[k].videoUrl == "")) {
  1294. this.$message.error("视频不能为空")
  1295. return false;
  1296. }
  1297. if (data.content[j].setting[k].contentType == 7 && (data.content[j].setting[k].value == null || data.content[j].setting[k].value == "")) {
  1298. this.$message.error("语音文本不能为空")
  1299. return false;
  1300. }
  1301. if (data.content[j].setting[k].contentType == 8 && (data.content[j].setting[k].url == null || data.content[j].setting[k].url == "")) {
  1302. this.$message.error("视频号信息不能为空")
  1303. return false;
  1304. }
  1305. }
  1306. } else if (data.content[j].type == 4) {
  1307. if (data.content[j].aiTouch == null || data.content[j].aiTouch == '') {
  1308. this.$message.error("AI触达不能为空")
  1309. return false;
  1310. }
  1311. }
  1312. }
  1313. } else {
  1314. for (let day of this.setting) {
  1315. for (let content of day.content) {
  1316. for (let set of content.setting) {
  1317. if (!set.intervalTime) {
  1318. this.$message.error("客服时间不能为空");
  1319. return false;
  1320. }
  1321. if (set.contentType == 1 && (set.value == null || set.value == "")) {
  1322. this.$message.error("内容不能为空")
  1323. return false;
  1324. }
  1325. if (set.contentType == 2 && (set.imgUrl == null || set.imgUrl == "")) {
  1326. this.$message.error("图片不能为空")
  1327. return false;
  1328. }
  1329. if ((set.contentType == 3 || set.contentType == 9) && (set.linkTitle == null || set.linkTitle == "")) {
  1330. this.$message.error("链接标题不能为空")
  1331. return false;
  1332. }
  1333. if ((set.contentType == 3 || set.contentType == 9) && (set.linkDescribe == null || set.linkDescribe == "")) {
  1334. this.$message.error("链接描述不能为空")
  1335. return false;
  1336. }
  1337. if ((set.contentType == 3 || set.contentType == 9) && (set.linkImageUrl == null || set.linkImageUrl == "")) {
  1338. this.$message.error("链接图片不能为空")
  1339. return false;
  1340. }
  1341. if (set.contentType == 3 && set.type == 1 && (set.linkUrl == null || set.linkUrl == "")) {
  1342. this.$message.error("链接地址不能为空")
  1343. return false;
  1344. }
  1345. if (set.contentType == 4 && (set.miniprogramTitle == null || set.miniprogramTitle == "")) {
  1346. this.$message.error("小程序消息标题不能为空")
  1347. return false;
  1348. }
  1349. if (set.contentType == 4 && (set.miniprogramPicUrl == null || set.miniprogramPicUrl == "")) {
  1350. this.$message.error("小程序封面地址不能为空")
  1351. return false;
  1352. }
  1353. if (set.contentType == 5 && (set.fileUrl == null || set.fileUrl == "")) {
  1354. this.$message.error("文件不能为空")
  1355. return false;
  1356. }
  1357. if (set.contentType == 6 && (set.videoUrl == null || set.videoUrl == "")) {
  1358. this.$message.error("视频不能为空")
  1359. return false;
  1360. }
  1361. if (set.contentType == 7 && (set.value == null || set.value == "")) {
  1362. this.$message.error("语音文本不能为空")
  1363. return false;
  1364. }
  1365. if (set.contentType == 8 && (set.url == null || set.url == "")) {
  1366. this.$message.error("视频号信息不能为空")
  1367. return false;
  1368. }
  1369. }
  1370. }
  1371. }
  1372. }
  1373. return true;
  1374. },
  1375. tabClick(obj) {
  1376. },
  1377. addSetList(contentIndex, content) {
  1378. if (this.form.sendType == 1) {
  1379. for (let i = 0; i < content.length; i++) {
  1380. if (!content[i].setting) {
  1381. content[i].setting = []; // 初始化 setting 数组如果不存在
  1382. }
  1383. if (content[i].setting.length > 9) {
  1384. return this.$message.error("因为企微接口限制,企微模板一条消息只能设置最多~9个内容!!")
  1385. } else {
  1386. // 动态生成新的设置项
  1387. const newSetting = content[i].setting.some(item => item.contentType === '1')
  1388. ? {contentType: '2', imgUrl: ''} // 如果存在 contentType = '1',添加 contentType = '2'
  1389. : {contentType: '1', value: ''}; // 如果不存在 contentType = '1',添加 contentType = '1'
  1390. // 将新设置项添加到 content[i].setting 数组中
  1391. content[i].setting.push(newSetting);
  1392. }
  1393. }
  1394. } else {
  1395. if (!content[contentIndex].setting) {
  1396. content[contentIndex].setting = []; // 初始化 setting 数组如果不存在
  1397. }
  1398. const newSetting = {
  1399. contentType: '1',
  1400. value: '',
  1401. };
  1402. if (this.form.sendType === 4) {
  1403. for (let i = 0; i < content.length; i++) {
  1404. if (content[i].setting.length < 5) {
  1405. // 将新设置项添加到 content.setting 数组中
  1406. content[contentIndex].setting.push(newSetting);
  1407. } else {
  1408. return this.$message.error("因为要求限制,新课对话模板一条消息只能设置最多~5个内容!!")
  1409. }
  1410. }
  1411. } else {
  1412. // 将新设置项添加到 content.setting 数组中
  1413. content[contentIndex].setting.push(newSetting);
  1414. }
  1415. }
  1416. },
  1417. delSetList(index, contentIndex, setIndex) {
  1418. this.setting[index].content[contentIndex].setting.splice(setIndex, 1)
  1419. },
  1420. addContent(index) {
  1421. if (this.setting[index].content.length > 0 && this.form.sendType == 1) {
  1422. return this.$message.error("因为企微接口限制,企微模板一天只能设置一条消息~")
  1423. } else {
  1424. const sourceContent = this.setting[index].content[0];
  1425. const newContent = {
  1426. type: this.defaultContentType,
  1427. contentType: 1,
  1428. setting: [{contentType: '1', value: ""}],
  1429. // 复制课程相关字段,如 courseId、videoId,根据实际数据结构补充
  1430. courseId: sourceContent.courseId,
  1431. videoId: sourceContent.videoId,
  1432. courseType: sourceContent.courseType,
  1433. isAtAll: '0',
  1434. };
  1435. this.setting[index].content.push(newContent);
  1436. this.videoList.push([]);
  1437. this.addTag.push({
  1438. addTag: [],
  1439. inputVisible: false,
  1440. inputValue: '',
  1441. delTag: [],
  1442. delTagVisible: false,
  1443. delTagValue: ''
  1444. });
  1445. // 如果有视频列表关联,也可同步处理 videoList,根据 courseId 重新请求或复制已有视频数据
  1446. if (sourceContent.courseId) {
  1447. this.courseUpdate(newContent, index, this.setting[index].content.length - 1);
  1448. }
  1449. }
  1450. },
  1451. delContent(index, contentIndex) {
  1452. this.setting[index].content.splice(contentIndex, 1)
  1453. this.videoList.splice(contentIndex, 1)
  1454. this.addTag.splice(contentIndex, 1)
  1455. },
  1456. addSetting() {
  1457. let content = [{type: this.defaultContentType, contentType: '1', setting: [{contentType: '1', value: "",}],isAtAll: '0'}];
  1458. if (this.form.sendType == 4) {
  1459. content = [{type: 2, contentType: '1', setting: [{contentType: '1', value: "",}]}];
  1460. content[0].setting[0].intervalTime = 5;
  1461. }
  1462. this.setting.push({
  1463. name: null,
  1464. dayNum: (this.form.gap * this.setting.length) + 1,
  1465. content
  1466. })
  1467. },
  1468. delSetting(index) {
  1469. const newData = this.setting[index]
  1470. if (newData.id && newData.dayNum) {
  1471. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  1472. confirmButtonText: '确定',
  1473. cancelButtonText: '取消',
  1474. type: 'warning'
  1475. }).then(() => {
  1476. delRules(newData.id, newData.name, newData.dayNum).then(res => {
  1477. this.del(index);
  1478. });
  1479. });
  1480. } else {
  1481. this.del(index);
  1482. }
  1483. },
  1484. del(index) {
  1485. if (index == 0) {
  1486. this.tabIndex = "0";
  1487. } else {
  1488. this.tabIndex = (index - 1) + "";
  1489. }
  1490. this.setting.splice(index, 1)
  1491. },
  1492. handleClosegroupUser(list) {
  1493. const index = this.userSelectList.findIndex(t => t === list);
  1494. if (index !== -1) {
  1495. this.userSelectList.splice(index, 1);
  1496. }
  1497. },
  1498. //选择视频号
  1499. hanldeSelectVideoNum(content, index, contentIndex, setIndex) {
  1500. this.videoNumOptions.content = content;
  1501. this.videoNumOptions.contentIndex = contentIndex;
  1502. this.videoNumOptions.setIndex = setIndex;
  1503. this.videoNumOptions.open = true;
  1504. },
  1505. qwUserVideoResult(val) {
  1506. // 根据选中的内容,将返回的数据更新到相应的表单项
  1507. const content = this.videoNumOptions.content;
  1508. const setList = content.setting[this.videoNumOptions.setIndex];
  1509. setList.nickname = val.nickname;
  1510. setList.avatar = val.avatar;
  1511. setList.coverUrl = val.coverUrl;
  1512. setList.thumbUrl = val.thumbUrl;
  1513. setList.desc = val.desc;
  1514. setList.url = val.url;
  1515. setList.extras = val.extras;
  1516. setList.videoId = val.id;
  1517. this.videoNumOptions.open = false;
  1518. },
  1519. //首次刷新
  1520. courseChange(content, index, countIndex) {
  1521. this.courseUpdate(content, index, countIndex);
  1522. },
  1523. //修改
  1524. courseChangeUpdate(content, index, countIndex) {
  1525. this.$set(content, 'videoId', null);
  1526. // 查找选中的课程对应的 label
  1527. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
  1528. for (let i = 0; i < content.setting.length; i++) {
  1529. this.$set(content.setting[i], 'linkTitle', null);
  1530. this.$set(content.setting[i], 'linkDescribe', null);
  1531. this.$set(content.setting[i], 'linkImageUrl', null);
  1532. //如果是链接的才上
  1533. if (selectedCourse && content.type == 2 && content.courseId != null) {
  1534. //响应式直接给链接的标题/封面上值
  1535. if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
  1536. this.$set(content.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1537. this.$set(content.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1538. }
  1539. if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10 || content.setting[i].contentType == 17) {
  1540. this.$set(content.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  1541. }
  1542. }
  1543. }
  1544. this.courseUpdate(content, index, countIndex);
  1545. },
  1546. handleInputVideoText(value, content) {
  1547. // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
  1548. const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
  1549. // 删除不符合条件的字符
  1550. const filteredValue = value.split('').filter(char => regex.test(char)).join('');
  1551. this.$set(content, 'value', filteredValue);
  1552. },
  1553. courseUpdate(content, index, countIndex) {
  1554. videoList(content.courseId).then(response => {
  1555. // this.$set(this.videoList, countIndex, response.list); // 响应式设置videoList
  1556. this.videoList.splice(countIndex, 1, response.list);
  1557. });
  1558. },
  1559. toggleSalesCall(itemIndex, contentIndex, setIndex) {
  1560. // 获取目标对象
  1561. const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
  1562. const salesCall = '#销售称呼#';
  1563. const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
  1564. const textarea = this.$refs[refKey][0]?.$refs?.textarea;
  1565. if (!textarea) return;
  1566. // 获取光标位置
  1567. const cursorPosition = textarea.selectionStart;
  1568. if (setItem.isSalesCallAdded) {
  1569. // 移除所有标签
  1570. setItem.value = setItem.value.replace(new RegExp(salesCall, 'g'), '');
  1571. } else {
  1572. // 插入到光标位置
  1573. setItem.value =
  1574. setItem.value.slice(0, cursorPosition) +
  1575. salesCall +
  1576. setItem.value.slice(cursorPosition);
  1577. }
  1578. // 切换状态
  1579. setItem.isSalesCallAdded = !setItem.isSalesCallAdded;
  1580. // 保持光标位置
  1581. this.$nextTick(() => {
  1582. const newCursorPos = cursorPosition + (setItem.isSalesCallAdded ? salesCall.length : 0);
  1583. textarea.setSelectionRange(newCursorPos, newCursorPos);
  1584. });
  1585. },
  1586. toggleUserNameCall(itemIndex, contentIndex, setIndex) {
  1587. // 获取目标对象
  1588. const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
  1589. const salesCall = '#客户称呼#';
  1590. const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
  1591. const textarea = this.$refs[refKey][0]?.$refs?.textarea;
  1592. if (!textarea) return;
  1593. // 获取光标位置
  1594. const cursorPosition = textarea.selectionStart;
  1595. if (setItem.isUserNameCallAdded) {
  1596. // 移除所有标签
  1597. setItem.value = setItem.value.replace(new RegExp(salesCall, 'g'), '');
  1598. } else {
  1599. // 插入到光标位置
  1600. setItem.value =
  1601. setItem.value.slice(0, cursorPosition) +
  1602. salesCall +
  1603. setItem.value.slice(cursorPosition);
  1604. }
  1605. // 切换状态
  1606. setItem.isUserNameCallAdded = !setItem.isUserNameCallAdded;
  1607. // 保持光标位置
  1608. this.$nextTick(() => {
  1609. const newCursorPos = cursorPosition + (setItem.isUserNameCallAdded ? salesCall.length : 0);
  1610. textarea.setSelectionRange(newCursorPos, newCursorPos);
  1611. });
  1612. },
  1613. handleKeydown(event, itemIndex, contentIndex, setIndex) {
  1614. const setItem = this.setting[itemIndex].content[contentIndex].setting[setIndex];
  1615. const refKey = `textarea-${itemIndex}-${contentIndex}-${setIndex}`;
  1616. const textarea = this.$refs[refKey][0]?.$refs?.textarea;
  1617. if (!textarea) return;
  1618. const tags = ['#销售称呼#', '#客户称呼#'];
  1619. const key = event.key;
  1620. const value = setItem.value;
  1621. const cursorPosition = textarea.selectionStart;
  1622. if (key === 'Backspace' || key === 'Delete') {
  1623. tags.forEach(tag => {
  1624. let start, end;
  1625. // Backspace 处理
  1626. if (key === 'Backspace' && cursorPosition >= tag.length) {
  1627. start = cursorPosition - tag.length;
  1628. if (value.slice(start, cursorPosition) === tag) {
  1629. event.preventDefault();
  1630. setItem.value = value.slice(0, start) + value.slice(cursorPosition);
  1631. if (tag === '#销售称呼#') setItem.isSalesCallAdded = false;
  1632. this.$nextTick(() => textarea.setSelectionRange(start, start));
  1633. }
  1634. }
  1635. // Delete 处理
  1636. if (key === 'Delete') {
  1637. end = cursorPosition + tag.length;
  1638. if (value.slice(cursorPosition, end) === tag) {
  1639. event.preventDefault();
  1640. setItem.value = value.slice(0, cursorPosition) + value.slice(end);
  1641. if (tag === '#销售称呼#') setItem.isSalesCallAdded = false;
  1642. }
  1643. }
  1644. });
  1645. }
  1646. },
  1647. handleContentTypeChange(content, index, countIndex, setIndex, item, fieldName, val) {
  1648. //如果是链接的才上
  1649. if (content.courseId != null && content.type == 2) {
  1650. const selectedCourse = this.courseList.find(course => parseInt(course.dictValue) === content.courseId);
  1651. for (let i = 0; i < content.setting.length; i++) {
  1652. //响应式直接给链接的标题/封面上值
  1653. if (selectedCourse && content.type == 2 && content.courseId != null) {
  1654. if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
  1655. this.$set(content.setting[i], 'linkTitle', selectedCourse.dictLabel);
  1656. this.$set(content.setting[i], 'linkImageUrl', selectedCourse.dictImgUrl);
  1657. }
  1658. if ((content.setting[i].contentType == 4 || content.setting[i].contentType == 10 || content.setting[i].contentType == 17) && (content.isOfficial == '0' || content.isOfficial == null)) {
  1659. this.$set(content.setting[i], 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  1660. }
  1661. }
  1662. }
  1663. }
  1664. if (content.videoId != null && content.type == 2) {
  1665. // 查找选中的课节对应的 label
  1666. const selectedVideo = this.videoList[countIndex].find(course => parseInt(course.dictValue) === content.videoId);
  1667. for (let i = 0; i < content.setting.length; i++) {
  1668. //响应式直接给链接的描述上值
  1669. if (selectedVideo && content.type == 2 && content.videoId != null) {
  1670. if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
  1671. this.$set(content.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1672. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  1673. this.$set(content.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
  1674. }
  1675. }
  1676. if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10 || content.setting[i].contentType == 17) {
  1677. this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel, 60));
  1678. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  1679. this.$set(content.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
  1680. }
  1681. }
  1682. }
  1683. }
  1684. }
  1685. if(countIndex == 0 && setIndex == 0){
  1686. this.updateAll(setIndex, item, fieldName, val);
  1687. for (let index in item.content) {
  1688. if(index != 0){
  1689. this.handleContentTypeChange(item.content[index], 0, index, 0, item, fieldName, val);
  1690. }
  1691. }
  1692. }
  1693. },
  1694. videoIdChange(content, index, countIndex) {
  1695. //选择了课程小节则 默认绑上
  1696. let selectedVideo;
  1697. // 查找选中的课程对应的 label
  1698. if (content.videoId != null) {
  1699. selectedVideo = this.videoList[countIndex].find(course => parseInt(course.dictValue) === content.videoId);
  1700. }
  1701. for (let i = 0; i < content.setting.length; i++) {
  1702. //课程消息-文本内容
  1703. if (content.setting[i].contentType == 1 && content.type == 2) {
  1704. this.$set(content.setting[i], 'isBindUrl', '2');
  1705. }
  1706. //如果是链接的才上
  1707. if (selectedVideo && content.type == 2 && content.videoId != null) {
  1708. if (content.setting[i].contentType == 3 || content.setting[i].contentType == 9) {
  1709. this.$set(content.setting[i], 'linkDescribe', selectedVideo.dictLabel);
  1710. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  1711. this.$set(content.setting[i], 'linkImageUrl', selectedVideo.dictImgUrl);
  1712. }
  1713. }
  1714. if (content.setting[i].contentType == 4 || content.setting[i].contentType == 10 || content.setting[i].contentType == 17) {
  1715. this.$set(content.setting[i], 'miniprogramTitle', this.truncateTextByByteLength(selectedVideo.dictLabel, 60));
  1716. if (this.projectFrom == 'sxjz' && selectedVideo.dictImgUrl) {
  1717. this.$set(content.setting[i], 'miniprogramPicUrl', selectedVideo.dictImgUrl);
  1718. }
  1719. }
  1720. }
  1721. }
  1722. },
  1723. //上传文件
  1724. handleAvatarSuccessFile(res, file, content) {
  1725. if (res.code === 200) {
  1726. // 使用 $set 确保响应式更新
  1727. this.$set(content, 'fileUrl', res.url);
  1728. } else {
  1729. this.msgError(res.msg);
  1730. }
  1731. },
  1732. beforeAvatarUploadFile(file) {
  1733. const isLt1M = file.size / 1024 / 1024 < 10;
  1734. if (!isLt1M) {
  1735. this.$message.error('上传大小不能超过 10MB!');
  1736. }
  1737. return isLt1M;
  1738. },
  1739. //下载文件
  1740. downloadUrl(materialUrl) {
  1741. // 直接返回文件 URL
  1742. return materialUrl;
  1743. },
  1744. handleAvatarSuccessVideo(res, file, content) {
  1745. if (res.code == 200) {
  1746. // 使用 $set 确保响应式更新
  1747. this.$set(content, 'videoUrl', res.url);
  1748. } else {
  1749. this.msgError(res.msg);
  1750. }
  1751. },
  1752. beforeAvatarUploadVideo(file) {
  1753. const isLt30M = file.size / 1024 / 1024 < 10;
  1754. const isMP4 = file.type === 'video/mp4';
  1755. if (!isMP4) {
  1756. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  1757. return false;
  1758. }
  1759. if (!isLt30M) {
  1760. this.$message.error('上传大小不能超过 10MB!');
  1761. return false;
  1762. }
  1763. return true;
  1764. },
  1765. handleAvatarSuccessVoice(res, file, content) {
  1766. if (res.code == 200) {
  1767. // 创建 Audio 对象加载音频
  1768. const audio = new Audio(res.mp3Url);
  1769. audio.addEventListener('loadedmetadata', () => {
  1770. // 获取音频时长
  1771. this.$set(content, 'voiceDuration', Math.ceil(audio.duration));
  1772. });
  1773. // 使用 $set 确保响应式更新
  1774. this.$set(content, 'voiceUrl', res.silkUrl);
  1775. this.$set(content, 'mp3Url', res.mp3Url);
  1776. } else {
  1777. this.msgError(res.msg);
  1778. }
  1779. this.voiceLoading = false;
  1780. },
  1781. beforeAvatarUploadVoice(file) {
  1782. return new Promise((resolve, reject) => {
  1783. const isLt10M = file.size / 1024 / 1024 < 10; // 假设语音文件大小限制为10MB
  1784. const isVoiceType = ['audio/mp3', 'audio/mpeg', 'audio/wav', 'audio/x-wav'].includes(file.type);
  1785. if (!isVoiceType) {
  1786. this.$message.error('仅支持上传 MP3, WAV, X-WAV 格式的语音文件!');
  1787. return reject(false); // 不允许继续上传
  1788. }
  1789. if (!isLt10M) {
  1790. this.$message.error('上传大小不能超过 10MB!');
  1791. return reject(false); // 不允许继续上传
  1792. }
  1793. // 使用 FileReader 读取文件
  1794. const reader = new FileReader();
  1795. reader.onload = (event) => {
  1796. const audio = new Audio(event.target.result);
  1797. audio.addEventListener('loadedmetadata', () => {
  1798. // 获取时长并保存
  1799. if (Math.ceil(audio.duration) > 30) {
  1800. this.$message.error('音频时长不能超过30秒!');
  1801. this.voiceLoading = false;
  1802. return reject(false); // 不允许继续上传
  1803. }
  1804. resolve(true); // 允许上传
  1805. });
  1806. };
  1807. reader.onerror = () => {
  1808. this.$message.error('无法读取音频文件!请上传正确的音频文件');
  1809. reject(false); // 不允许继续上传
  1810. };
  1811. this.voiceLoading = true;
  1812. reader.readAsDataURL(file); // 开始读取文件
  1813. });
  1814. },
  1815. /** 查询sop模板列表 */
  1816. getList() {
  1817. this.loading = true;
  1818. listSopTemp(this.queryParams).then(response => {
  1819. this.sopTempList = response.rows;
  1820. this.total = response.total;
  1821. this.loading = false;
  1822. });
  1823. },
  1824. // 取消按钮
  1825. cancel() {
  1826. this.$store.dispatch("tagsView/delView", this.$route);
  1827. this.$router.replace('/qw/conversion/sopTemp')
  1828. // this.reset();
  1829. },
  1830. // 表单重置
  1831. reset() {
  1832. this.form = {
  1833. id: null,
  1834. name: null,
  1835. setting: null,
  1836. status: "0",
  1837. sort: null,
  1838. createTime: null,
  1839. createBy: null,
  1840. companyId: null
  1841. };
  1842. this.resetForm("form");
  1843. },
  1844. /** 修改按钮操作 */
  1845. handleUpdate(id) {
  1846. getSopTemp(id).then(response => {
  1847. this.videoList = []
  1848. this.form = response.data;
  1849. this.setting = this.form.list || [];
  1850. if (Array.isArray(this.setting)) {
  1851. this.setting.forEach(item => {
  1852. if (item && Array.isArray(item.content)) {
  1853. item.content.forEach(content => {
  1854. if (content.isAtAll === undefined || content.isAtAll === null) {
  1855. this.$set(content, 'isAtAll', '0') // 默认关闭
  1856. }
  1857. // 如果后端返回的是数字,转换为字符串
  1858. if (typeof content.isAtAll === 'number') {
  1859. this.$set(content, 'isAtAll', content.isAtAll.toString())
  1860. }
  1861. if (content && Array.isArray(content.setting)) {
  1862. content.setting.forEach(setList => {
  1863. if (setList && !Object.hasOwn(setList, 'isSalesCallAdded')) {
  1864. this.$set(setList, 'isSalesCallAdded', false);
  1865. }
  1866. if (setList && !Object.hasOwn(setList, 'isUserNameCallAdded')) {
  1867. this.$set(setList, 'isUserNameCallAdded', false);
  1868. }
  1869. });
  1870. }
  1871. });
  1872. }
  1873. });
  1874. }
  1875. this.form.list.forEach(e => e.newDay = e.dayNum)
  1876. this.dayList = JSON.parse(JSON.stringify(this.form.list));
  1877. this.videoList.push([]);
  1878. this.addTag = [];
  1879. this.setting.forEach(item => {
  1880. if (item && Array.isArray(item.content)) {
  1881. item.content.forEach(content => {
  1882. this.addTag.push({
  1883. addTag: content.addTag ? JSON.parse(content.addTag) : [],
  1884. inputVisible: false,
  1885. inputValue: '',
  1886. delTag: content.delTag ? JSON.parse(content.delTag) : [],
  1887. delTagVisible: false,
  1888. delTagValue: ''
  1889. });
  1890. });
  1891. }
  1892. });
  1893. // this.addTag.push({
  1894. // addTag: [],
  1895. // inputVisible: false,
  1896. // inputValue: '',
  1897. // delTag: [],
  1898. // delTagVisible: false,
  1899. // delTagValue: ''
  1900. // })
  1901. });
  1902. },
  1903. /** 提交按钮 */
  1904. submitForm() {
  1905. },
  1906. /** 删除按钮操作 */
  1907. handleDelete(row) {
  1908. const ids = row.id || this.ids;
  1909. this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
  1910. confirmButtonText: "确定",
  1911. cancelButtonText: "取消",
  1912. type: "warning"
  1913. }).then(function () {
  1914. return delSopTemp(ids);
  1915. }).then(() => {
  1916. this.getList();
  1917. this.msgSuccess("删除成功");
  1918. }).catch(() => {
  1919. });
  1920. },
  1921. /** 导出按钮操作 */
  1922. handleExport() {
  1923. const queryParams = this.queryParams;
  1924. this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
  1925. confirmButtonText: "确定",
  1926. cancelButtonText: "取消",
  1927. type: "warning"
  1928. }).then(() => {
  1929. this.exportLoading = true;
  1930. return exportSopTemp(queryParams);
  1931. }).then(response => {
  1932. this.download(response.msg);
  1933. this.exportLoading = false;
  1934. }).catch(() => {
  1935. });
  1936. },
  1937. updateHtml(val) {
  1938. val || val();
  1939. },
  1940. updateAll(setIndex, list, fieldName, newVal) {
  1941. if(this.form.sendType == 11 && setIndex == 0) {
  1942. console.info("更新数据", newVal)
  1943. for (let index in list.content) {
  1944. this.$set(list.content[index].setting[0], fieldName, newVal);
  1945. }
  1946. }
  1947. }
  1948. }
  1949. };
  1950. </script>