updateSopTemp.vue 105 KB

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