updateSopTemp.vue 84 KB

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