updateSopTemp.vue 71 KB

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