updateSopTemp.vue 101 KB

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