updateSopTemp.vue 87 KB

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