updateSopTemp.vue 91 KB

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