updateSopTemp.vue 90 KB

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