updateSopTemp.vue 107 KB

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