updateSopTemp.vue 89 KB

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