updateSopTemp.vue 77 KB

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