updateSopTemp.vue 90 KB

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