updateSopTemp.vue 99 KB

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