deptIndex.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="模板编号" prop="id">
  5. <el-input
  6. v-model="queryParams.id"
  7. placeholder="请输入模板编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="名称" prop="name">
  14. <el-input
  15. v-model="queryParams.name"
  16. placeholder="请输入名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="课程" prop="courseId">
  23. <el-select v-model="queryParams.courseId" clearable placeholder="请选择课程" style=" margin-right: 10px;" size="mini">
  24. <el-option
  25. v-for="dict in courseList"
  26. :key="dict.dictValue"
  27. :label="dict.dictLabel"
  28. :value="parseInt(dict.dictValue)"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button
  40. type="primary"
  41. plain
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['course:courseFinishTempParent:deptAdd']"
  46. >新增</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['course:courseFinishTempParent:deptEdit']"
  57. >修改</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button
  61. type="danger"
  62. plain
  63. icon="el-icon-delete"
  64. size="mini"
  65. :disabled="multiple"
  66. @click="handleDelete"
  67. v-hasPermi="['course:courseFinishTempParent:deptRemove']"
  68. >删除</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. plain
  74. icon="el-icon-download"
  75. size="mini"
  76. :loading="exportLoading"
  77. @click="handleExport"
  78. v-hasPermi="['course:courseFinishTempParent:deptExport']"
  79. >导出</el-button>
  80. </el-col>
  81. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  82. </el-row>
  83. <el-table border v-loading="loading" :data="courseFinishTempParentList" @selection-change="handleSelectionChange">
  84. <el-table-column type="selection" width="55" align="center" />
  85. <el-table-column label="模板编号" align="center" prop="id" />
  86. <el-table-column label="名称" align="center" prop="name" />
  87. <el-table-column label="课程" align="center" prop="courseId">
  88. <template slot-scope="scope">
  89. <el-tag v-for="dict in courseList" v-if="dict.dictValue == scope.row.courseId">{{dict.dictLabel}}</el-tag>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  93. <template slot-scope="scope">
  94. <el-button
  95. size="mini"
  96. type="text"
  97. icon="el-icon-edit"
  98. @click="handleUpdate(scope.row)"
  99. v-hasPermi="['course:courseFinishTempParent:deptEdit']"
  100. >修改</el-button>
  101. <el-button
  102. size="mini"
  103. type="text"
  104. @click="jump(scope.row.id)"
  105. >模板列表</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. @click="handleDelete(scope.row)"
  111. v-hasPermi="['course:courseFinishTempParent:deptRemove']"
  112. >删除</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改完课模板对话框 -->
  124. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  125. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  126. <el-form-item label="名称" prop="name">
  127. <el-input v-model="form.name" placeholder="请输入名称" />
  128. </el-form-item>
  129. <el-form-item label="状态" v-if="!form.id">
  130. <el-radio-group v-model="form.status">
  131. <el-radio
  132. v-for="dict in statusOptions"
  133. :key="dict.dictValue"
  134. :label="parseInt(dict.dictValue)"
  135. >{{ dict.dictLabel }}
  136. </el-radio>
  137. </el-radio-group>
  138. </el-form-item>
  139. <el-form-item label="课程" prop="courseId">
  140. <el-select v-model="form.courseId" :disabled="form.id != null" placeholder="请选择课程" style=" margin-right: 10px;" size="mini">
  141. <el-option
  142. v-for="dict in courseList"
  143. :key="dict.dictValue"
  144. :label="dict.dictLabel"
  145. :value="parseInt(dict.dictValue)"
  146. />
  147. </el-select>
  148. </el-form-item>
  149. <el-form-item prop="setting">
  150. <span slot="label" class="finish-rule-label finish-rule-label--watch">
  151. <el-tag type="primary" size="mini" effect="dark">私聊</el-tag>
  152. <span>看课规则</span>
  153. </span>
  154. <div class="finish-rule-panel finish-rule-panel--watch">
  155. <div class="finish-rule-panel__tip">发给客户本人(私聊),与下方「群聊恭喜」完全独立,请勿混用</div>
  156. <div v-for="(item, index) in setting" :key="index"
  157. class="finish-rule-item finish-rule-item--watch">
  158. <el-row>
  159. <el-col :span="22">
  160. <el-form :model="item" label-width="70px">
  161. <el-form-item label="内容类别" style="margin: 2%">
  162. <el-radio-group v-model="item.contentType">
  163. <el-radio :label="item.dictValue" v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
  164. </el-radio>
  165. </el-radio-group>
  166. </el-form-item>
  167. <el-form-item label="内容" style="margin-bottom: 2%">
  168. <el-input v-if="item.contentType == 1 || item.contentType == 15" v-model="item.value" type="textarea" :rows="3"
  169. placeholder="内容" style="width: 90%;margin-top: 10px;"/>
  170. <ImageUpload v-if="item.contentType == 2 " v-model="item.imgUrl" type="image" :num="1" :width="150"
  171. :height="150"/>
  172. <div v-if="item.contentType == 3 || item.contentType ==9">
  173. <el-card class="box-card">
  174. <el-form-item label="链接标题:" label-width="100px">
  175. <el-input v-model="item.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  176. </el-form-item>
  177. <el-form-item label="链接描述:" label-width="100px">
  178. <el-input type="textarea" :rows="3" v-model="item.linkDescribe" placeholder="请输入链接描述"
  179. style="width: 90%;margin-top: 1%;"/>
  180. </el-form-item>
  181. <el-form-item label="链接封面:" label-width="100px">
  182. <ImageUpload v-model="item.linkImageUrl" type="image" :num="1" :file-size="2" :width="150"
  183. :height="150" style="margin-top: 1%;"/>
  184. </el-form-item>
  185. <el-form-item label="链接地址:" label-width="100px">
  186. <el-input v-model="item.linkUrl" placeholder="请输入链接地址" style="width: 90%;"/>
  187. </el-form-item>
  188. </el-card>
  189. </div>
  190. <div v-if="item.contentType == 4">
  191. <el-card class="box-card">
  192. <el-form-item label="选择课程">
  193. <el-select
  194. v-model="item.courseId"
  195. placeholder="请选择课程"
  196. style="margin-right: 10px"
  197. size="mini"
  198. @change="handleRuleCourseChange(item)"
  199. >
  200. <el-option
  201. v-for="dict in courseList"
  202. :key="dict.dictValue"
  203. :label="dict.dictLabel"
  204. :value="parseInt(dict.dictValue)"
  205. />
  206. </el-select>
  207. <el-select
  208. v-model="item.videoId"
  209. placeholder="请选择小节"
  210. size="mini"
  211. style="margin-right: 10px"
  212. filterable
  213. remote
  214. :remote-method="(query) => remoteMethodRuleVideo(query, item)"
  215. :loading="videoOptionsLoading"
  216. @change="handleRuleVideoChange(item)"
  217. >
  218. <el-option
  219. v-for="dict in videoOptions || []"
  220. :key="dict.dictValue"
  221. :label="dict.dictLabel"
  222. :value="parseInt(dict.dictValue)"
  223. />
  224. </el-select>
  225. </el-form-item>
  226. <el-card class="box-card" style="margin-top: 10px">
  227. <el-form-item label="标题" prop="miniprogramTitle">
  228. <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字" />
  229. </el-form-item>
  230. <el-form-item label="封面" prop="miniprogramPicUrl">
  231. <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
  232. </el-form-item>
  233. </el-card>
  234. </el-card>
  235. </div>
  236. <div v-if="item.contentType == 5 ">
  237. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  238. <el-upload
  239. v-model="item.fileUrl"
  240. class="avatar-uploader"
  241. :action="uploadUrl"
  242. :show-file-list="false"
  243. :on-success="(res, file) => handleAvatarSuccessFile(res, file, item)"
  244. :before-upload="beforeAvatarUploadFile">
  245. <i class="el-icon-plus avatar-uploader-icon"></i>
  246. </el-upload>
  247. <el-link v-if="item.fileUrl" type="primary" :href="downloadUrl(item.fileUrl)" download>
  248. {{ item.fileUrl }}
  249. </el-link>
  250. </el-form-item>
  251. </div>
  252. <div v-if="item.contentType == 6 ">
  253. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  254. <el-upload
  255. v-model="item.videoUrl"
  256. class="avatar-uploader"
  257. :action="uploadUrl"
  258. :show-file-list="false"
  259. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, item)"
  260. :before-upload="beforeAvatarUploadVideo">
  261. <i class="el-icon-plus avatar-uploader-icon"></i>
  262. </el-upload>
  263. <video v-if="item.videoUrl"
  264. :src="item.videoUrl"
  265. controls style="width: 200px;height: 100px">
  266. </video>
  267. </el-form-item>
  268. </div>
  269. <div v-if="item.contentType == 7 ">
  270. <el-input
  271. v-model="item.value"
  272. type="textarea" :rows="3" maxlength="66" show-word-limit
  273. placeholder="输入要转为语音的内容" style="width: 90%;margin-top: 10px;"
  274. @input="handleInputVideoText(item.value,item)"/>
  275. </div>
  276. <div v-if="item.contentType == 8">
  277. <el-button type="primary"
  278. style="margin-bottom: 1%"
  279. @click="hanldeSelectVideoNum(setting,index)">
  280. 选择视频号
  281. </el-button>
  282. <el-card class="box-card" v-if="item.coverUrl">
  283. <el-form-item label="封面标题:" label-width="100px">
  284. <el-input v-model="item.nickname"
  285. style="width: 90%;margin-bottom: 1%" disabled/>
  286. </el-form-item>
  287. <el-form-item label="头像:" label-width="100px">
  288. <el-image
  289. v-if="item.avatar != null"
  290. :src="item.avatar"
  291. :preview-src-list="[item.avatar]"
  292. :style="{ width: '50px', height: '50px' }"
  293. ></el-image>
  294. </el-form-item>
  295. <el-form-item label="封面:" label-width="100px">
  296. <el-image
  297. v-if="item.coverUrl != null"
  298. :src="item.coverUrl"
  299. :preview-src-list="[item.coverUrl]"
  300. :style="{ width: '200px', height: '200px' }"
  301. ></el-image>
  302. </el-form-item>
  303. <el-form-item label="简介:" label-width="100px">
  304. <el-input type="textarea" :rows="3"
  305. v-model="item.desc"
  306. style="width: 90%;margin-top: 1%;" disabled/>
  307. </el-form-item>
  308. <el-form-item label="视频地址:" label-width="100px"
  309. style="margin-top: 1%">
  310. <el-input v-model="item.url"
  311. style="width: 90%;" disabled/>
  312. </el-form-item>
  313. </el-card>
  314. </div>
  315. </el-form-item>
  316. </el-form>
  317. </el-col>
  318. <el-col :span="1" :offset="1">
  319. <i class="el-icon-delete" @click="delSetList(index, 0)" style="margin-top: 20px;"
  320. v-if="setting.length>1"></i>
  321. </el-col>
  322. </el-row>
  323. </div>
  324. <el-link type="primary" class="el-icon-plus" :underline="false" @click='addSetList(0)'>
  325. 添加私聊内容
  326. </el-link>
  327. </div>
  328. </el-form-item>
  329. <el-form-item prop="chatSetting">
  330. <span slot="label" class="finish-rule-label finish-rule-label--chat">
  331. <el-tag type="warning" size="mini" effect="dark">群聊</el-tag>
  332. <span>群聊恭喜规则</span>
  333. </span>
  334. <div class="finish-rule-panel finish-rule-panel--chat">
  335. <div class="finish-rule-panel__tip">发到客户群(群聊恭喜),与上方「看课私聊」完全独立,请勿混用</div>
  336. <div v-for="(item, index) in chatSetting" :key="index"
  337. class="finish-rule-item finish-rule-item--chat">
  338. <el-row>
  339. <el-col :span="22">
  340. <el-form :model="item" label-width="70px">
  341. <el-form-item label="内容类别" style="margin: 2%">
  342. <el-radio-group v-model="item.contentType">
  343. <el-radio :label="item.dictValue" v-for="item in sysQwSopAiContentType">{{ item.dictLabel }}
  344. </el-radio>
  345. </el-radio-group>
  346. </el-form-item>
  347. <el-form-item label="内容" style="margin-bottom: 2%">
  348. <el-input v-if="item.contentType == 1 || item.contentType == 15" v-model="item.value" type="textarea" :rows="3"
  349. placeholder="内容" style="width: 90%;margin-top: 10px;"/>
  350. <ImageUpload v-if="item.contentType == 2 " v-model="item.imgUrl" type="image" :num="1" :width="150"
  351. :height="150"/>
  352. <div v-if="item.contentType == 3 || item.contentType ==9">
  353. <el-card class="box-card">
  354. <el-form-item label="链接标题:" label-width="100px">
  355. <el-input v-model="item.linkTitle" placeholder="请输入链接标题" style="width: 90%;"/>
  356. </el-form-item>
  357. <el-form-item label="链接描述:" label-width="100px">
  358. <el-input type="textarea" :rows="3" v-model="item.linkDescribe" placeholder="请输入链接描述"
  359. style="width: 90%;margin-top: 1%;"/>
  360. </el-form-item>
  361. <el-form-item label="链接封面:" label-width="100px">
  362. <ImageUpload v-model="item.linkImageUrl" type="image" :num="1" :file-size="2" :width="150"
  363. :height="150" style="margin-top: 1%;"/>
  364. </el-form-item>
  365. <el-form-item label="链接地址:" label-width="100px">
  366. <el-input v-model="item.linkUrl" placeholder="请输入链接地址" style="width: 90%;"/>
  367. </el-form-item>
  368. </el-card>
  369. </div>
  370. <div v-if="item.contentType == 4">
  371. <el-card class="box-card">
  372. <el-form-item label="选择课程">
  373. <el-select
  374. v-model="item.courseId"
  375. placeholder="请选择课程"
  376. style="margin-right: 10px"
  377. size="mini"
  378. @change="handleRuleCourseChange(item)"
  379. >
  380. <el-option
  381. v-for="dict in courseList"
  382. :key="dict.dictValue"
  383. :label="dict.dictLabel"
  384. :value="parseInt(dict.dictValue)"
  385. />
  386. </el-select>
  387. <el-select
  388. v-model="item.videoId"
  389. placeholder="请选择小节"
  390. size="mini"
  391. style="margin-right: 10px"
  392. filterable
  393. remote
  394. :remote-method="(query) => remoteMethodRuleVideo(query, item)"
  395. :loading="videoOptionsLoading"
  396. @change="handleRuleVideoChange(item)"
  397. >
  398. <el-option
  399. v-for="dict in videoOptions || []"
  400. :key="dict.dictValue"
  401. :label="dict.dictLabel"
  402. :value="parseInt(dict.dictValue)"
  403. />
  404. </el-select>
  405. </el-form-item>
  406. <el-card class="box-card" style="margin-top: 10px">
  407. <el-form-item label="标题" prop="miniprogramTitle">
  408. <el-input v-model="item.miniprogramTitle" placeholder="请输入小程序消息标题,最长为64字" />
  409. </el-form-item>
  410. <el-form-item label="封面" prop="miniprogramPicUrl">
  411. <ImageUpload v-model="item.miniprogramPicUrl" type="image" :num="10" :width="150" :height="150" />
  412. </el-form-item>
  413. </el-card>
  414. </el-card>
  415. </div>
  416. <div v-if="item.contentType == 5 ">
  417. <el-form-item label="上传文件:" prop="fileUrl" label-width="100px">
  418. <el-upload
  419. v-model="item.fileUrl"
  420. class="avatar-uploader"
  421. :action="uploadUrl"
  422. :show-file-list="false"
  423. :on-success="(res, file) => handleAvatarSuccessFile(res, file, item)"
  424. :before-upload="beforeAvatarUploadFile">
  425. <i class="el-icon-plus avatar-uploader-icon"></i>
  426. </el-upload>
  427. <el-link v-if="item.fileUrl" type="primary" :href="downloadUrl(item.fileUrl)" download>
  428. {{ item.fileUrl }}
  429. </el-link>
  430. </el-form-item>
  431. </div>
  432. <div v-if="item.contentType == 6 ">
  433. <el-form-item label="上传视频:" prop="videoUrl" label-width="100px">
  434. <el-upload
  435. v-model="item.videoUrl"
  436. class="avatar-uploader"
  437. :action="uploadUrl"
  438. :show-file-list="false"
  439. :on-success="(res, file) => handleAvatarSuccessVideo(res, file, item)"
  440. :before-upload="beforeAvatarUploadVideo">
  441. <i class="el-icon-plus avatar-uploader-icon"></i>
  442. </el-upload>
  443. <video v-if="item.videoUrl"
  444. :src="item.videoUrl"
  445. controls style="width: 200px;height: 100px">
  446. </video>
  447. </el-form-item>
  448. </div>
  449. <div v-if="item.contentType == 7 || item.contentType == 16">
  450. <el-input
  451. v-model="item.value"
  452. type="textarea" :rows="3" maxlength="66" show-word-limit
  453. placeholder="输入要转为语音的内容" style="width: 90%;margin-top: 10px;"
  454. @input="handleInputVideoText(item.value,item)"/>
  455. </div>
  456. <div v-if="item.contentType == 8">
  457. <el-button type="primary"
  458. style="margin-bottom: 1%"
  459. @click="hanldeSelectVideoNum(setting,index)">
  460. 选择视频号
  461. </el-button>
  462. <el-card class="box-card" v-if="item.coverUrl">
  463. <el-form-item label="封面标题:" label-width="100px">
  464. <el-input v-model="item.nickname"
  465. style="width: 90%;margin-bottom: 1%" disabled/>
  466. </el-form-item>
  467. <el-form-item label="头像:" label-width="100px">
  468. <el-image
  469. v-if="item.avatar != null"
  470. :src="item.avatar"
  471. :preview-src-list="[item.avatar]"
  472. :style="{ width: '50px', height: '50px' }"
  473. ></el-image>
  474. </el-form-item>
  475. <el-form-item label="封面:" label-width="100px">
  476. <el-image
  477. v-if="item.coverUrl != null"
  478. :src="item.coverUrl"
  479. :preview-src-list="[item.coverUrl]"
  480. :style="{ width: '200px', height: '200px' }"
  481. ></el-image>
  482. </el-form-item>
  483. <el-form-item label="简介:" label-width="100px">
  484. <el-input type="textarea" :rows="3"
  485. v-model="item.desc"
  486. style="width: 90%;margin-top: 1%;" disabled/>
  487. </el-form-item>
  488. <el-form-item label="视频地址:" label-width="100px"
  489. style="margin-top: 1%">
  490. <el-input v-model="item.url"
  491. style="width: 90%;" disabled/>
  492. </el-form-item>
  493. </el-card>
  494. </div>
  495. </el-form-item>
  496. </el-form>
  497. </el-col>
  498. <el-col :span="1" :offset="1">
  499. <i class="el-icon-delete" @click="delSetList(index,1)" style="margin-top: 20px;"
  500. v-if="setting.length>1"></i>
  501. </el-col>
  502. </el-row>
  503. </div>
  504. <el-link type="warning" class="el-icon-plus" :underline="false" @click='addSetList(1)'>
  505. 添加群聊内容
  506. </el-link>
  507. </div>
  508. </el-form-item>
  509. <el-form-item label="全选销售" prop="isAllCompanyUser" v-if="!form.id">
  510. <el-switch
  511. v-model="form.isAllCompanyUser"
  512. active-color="#13ce66"
  513. inactive-color="#ff4949"
  514. :active-value="1"
  515. :inactive-value="2">
  516. </el-switch>
  517. <span v-if="form.isAllCompanyUser == '1'" style="margin-left: 10px;color: #13ce66">是</span>
  518. <span v-else style="margin-left: 10px;color: #ff4949">否</span>
  519. </el-form-item>
  520. <el-form-item label="所属销售" prop="companyUserIds" v-if="!form.id && form.isAllCompanyUser == '2'">
  521. <el-select v-model="companyUserIds" remote multiple placeholder="请选择" filterable style="width: 100%;">
  522. <el-option
  523. v-for="dict in userList"
  524. :key="dict.userId"
  525. :label="dict.nickName"
  526. :value="dict.userId.toString()">
  527. </el-option>
  528. </el-select>
  529. </el-form-item>
  530. </el-form>
  531. <div slot="footer" class="dialog-footer">
  532. <el-button type="primary" @click="submitForm">确 定</el-button>
  533. <el-button @click="cancel">取 消</el-button>
  534. </div>
  535. </el-dialog>
  536. <el-dialog :title="videoNumOptions.title" :visible.sync="videoNumOptions.open" width="1500px" append-to-body>
  537. <userVideo ref="QwUserVideo" @videoResult="qwUserVideoResult"></userVideo>
  538. </el-dialog>
  539. </div>
  540. </template>
  541. <script>
  542. import { listCourseFinishTempParent, getCourseFinishTempParent, delCourseFinishTempParent, addCourseFinishTempParent, updateCourseFinishTempParent, exportCourseFinishTempParent } from "@/api/course/courseFinishTempParent";
  543. import {courseList, videoList} from '@/api/qw/sop'
  544. import ImageUpload from '@/views/qw/sop/ImageUpload.vue'
  545. import { getUserList } from '@/api/company/companyUser'
  546. import userVideo from "@/views/qw/userVideo/userVideo.vue";
  547. import {
  548. deptExportCourseFinishTempParent,
  549. deptListCourseFinishTempParent
  550. } from "../../../api/course/courseFinishTempParent";
  551. export default {
  552. name: "CourseFinishTempParent",
  553. components: { ImageUpload ,userVideo},
  554. data() {
  555. return {
  556. videoOptionsLoading: false,
  557. videoOptions: [],
  558. videoLoading: false,
  559. videoNumOptions: {
  560. title: '选择视频号',
  561. open: false,
  562. content: null,
  563. contentIndex: null,
  564. },
  565. voiceLoading: false,
  566. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS2",
  567. uploadUrlByVoice: process.env.VUE_APP_BASE_API + "/common/uploadOSSByHOOKVoice",
  568. // 遮罩层
  569. loading: true,
  570. // 导出遮罩层
  571. exportLoading: false,
  572. // 选中数组
  573. ids: [],
  574. // 非单个禁用
  575. single: true,
  576. // 非多个禁用
  577. multiple: true,
  578. // 显示搜索条件
  579. showSearch: true,
  580. // 总条数
  581. total: 0,
  582. // 完课模板表格数据
  583. courseFinishTempParentList: [],
  584. companyUserIds: [],
  585. courseList: [],
  586. userList: [],
  587. // 状态字典
  588. statusOptions: [],
  589. allowSelect: [],
  590. sysFsSopWatchStatus: [],
  591. sysQwSopAiContentType: [],
  592. // 弹出层标题
  593. title: "",
  594. // 是否显示弹出层
  595. open: false,
  596. // 模板表格数据
  597. setting: [],
  598. chatSetting: [],
  599. // 查询参数
  600. queryParams: {
  601. pageNum: 1,
  602. pageSize: 10,
  603. id: null,
  604. name: null,
  605. courseId: null,
  606. },
  607. // 表单参数
  608. form: {companyUserIds: [],},
  609. // 表单校验
  610. rules: {
  611. name:[
  612. { required: true, message: "名称不能为空", trigger: "blur" }
  613. ],
  614. courseId:[
  615. { required: true, message: "课程不能为空", trigger: "blur" }
  616. ],
  617. }
  618. };
  619. },
  620. created() {
  621. this.getDicts("sys_company_status").then(response => {
  622. this.statusOptions = response.data;
  623. });//复用一下
  624. this.getDicts("sys_qw_allow_select").then(response => {
  625. this.allowSelect = response.data;
  626. });
  627. this.getDicts("sys_fs_sop_watch_status").then(response => {
  628. this.sysFsSopWatchStatus = response.data;
  629. });
  630. this.getDicts("sys_qwSopAi_contentType").then(response => {
  631. this.sysQwSopAiContentType = response.data;
  632. });
  633. getUserList().then(response => {
  634. this.userList = response.data;
  635. });
  636. courseList().then(response => {
  637. this.courseList = response.list;
  638. });
  639. this.getList();
  640. },
  641. methods: {
  642. // 处理规则中课程变化
  643. handleRuleCourseChange(item) {
  644. // 为当前规则项单独加载视频列表
  645. videoList(item.courseId).then((response) => {
  646. // 只保存视频列表,不保存整个响应对象
  647. this.videoOptions = response.list;
  648. this.$set(item, 'videoId', null); // Reset video selection when course changes
  649. // 自动设置封面为课程封面
  650. const selectedCourse = this.courseList.find(
  651. course => parseInt(course.dictValue) === item.courseId
  652. );
  653. if (selectedCourse) {
  654. this.$set(item, 'miniprogramPicUrl', selectedCourse.dictImgUrl);
  655. }
  656. });
  657. },
  658. // 处理规则中视频变化
  659. handleRuleVideoChange(item) {
  660. if (!item.videoId) return;
  661. // 自动设置标题为视频标题
  662. const selectedVideo = (this.videoOptions || []).find(
  663. video => parseInt(video.dictValue) === item.videoId
  664. );
  665. if (selectedVideo) {
  666. this.$set(item, 'miniprogramTitle', selectedVideo.dictLabel);
  667. }
  668. },
  669. // 远程搜索规则中的视频
  670. remoteMethodRuleVideo(query, item) {
  671. if (!item.courseId) {
  672. this.$message.warning('请先选择课程');
  673. this.videoOptions = [];
  674. reject();
  675. return;
  676. }
  677. this.videoOptionsLoading = true;
  678. const data = query ? { title: query } : {};
  679. videoList(item.courseId, data).then((response) => {
  680. this.videoOptions = response.list;
  681. this.videoOptionsLoading = false;
  682. resolve(response);
  683. }).catch((error) => {
  684. this.videoOptionsLoading = false;
  685. reject(error);
  686. });
  687. },
  688. remoteMethodVideo(query) {
  689. if (!this.form.courseId) {
  690. this.$message.warning('请先选择课程');
  691. this.videoList = []; // 清空小节列表
  692. return;
  693. }
  694. if (query !== '') {
  695. this.videoLoading = true;
  696. // 这里调用接口搜索小节,假设 videoList 方法支持搜索参数
  697. var data = {
  698. title:query
  699. }
  700. videoList(this.form.courseId, data).then((response) => {
  701. this.videoList = response.list;
  702. this.videoLoading = false;
  703. });
  704. } else {
  705. // 如果查询为空,则加载全部
  706. videoList(this.form.courseId).then((response) => {
  707. this.videoList = response.list;
  708. });
  709. }
  710. },
  711. /** 查询完课模板列表 */
  712. getList() {
  713. this.loading = true;
  714. deptListCourseFinishTempParent(this.queryParams).then(response => {
  715. this.courseFinishTempParentList = response.rows;
  716. this.total = response.total;
  717. this.loading = false;
  718. });
  719. },
  720. // 取消按钮
  721. cancel() {
  722. this.open = false;
  723. this.reset();
  724. },
  725. // 表单重置
  726. reset() {
  727. this.form = {
  728. id: null,
  729. status: 1,
  730. name: null,
  731. setting: [],
  732. chatSetting: [],
  733. courseId: null,
  734. createTime: null,
  735. createBy: null,
  736. updateBy: null,
  737. updateTime: null,
  738. companyUserIds: null,
  739. remark: null,
  740. isAllCompanyUser: 2
  741. };
  742. this.resetForm("form");
  743. },
  744. /** 搜索按钮操作 */
  745. handleQuery() {
  746. this.queryParams.pageNum = 1;
  747. this.getList();
  748. },
  749. /** 重置按钮操作 */
  750. resetQuery() {
  751. this.resetForm("queryForm");
  752. this.handleQuery();
  753. },
  754. // 多选框选中数据
  755. handleSelectionChange(selection) {
  756. this.ids = selection.map(item => item.id)
  757. this.single = selection.length!==1
  758. this.multiple = !selection.length
  759. },
  760. /** 新增按钮操作 */
  761. handleAdd() {
  762. this.reset();
  763. this.open = true;
  764. this.title = "添加完课模板";
  765. },
  766. //选择视频号
  767. hanldeSelectVideoNum(content, index) {
  768. this.videoNumOptions.content = content;
  769. this.videoNumOptions.contentIndex = index;
  770. this.videoNumOptions.open = true;
  771. },
  772. qwUserVideoResult(val) {
  773. // 根据选中的内容,将返回的数据更新到相应的表单项
  774. const content = this.videoNumOptions.content;
  775. const setList = content[this.videoNumOptions.contentIndex];
  776. setList.nickname = val.nickname;
  777. setList.avatar = val.avatar;
  778. setList.coverUrl = val.coverUrl;
  779. setList.thumbUrl = val.thumbUrl;
  780. setList.desc = val.desc;
  781. setList.url = val.url;
  782. setList.extras = val.extras;
  783. setList.videoId = val.id;
  784. console.info(setList)
  785. this.videoNumOptions.open = false;
  786. },
  787. /** 修改按钮操作 */
  788. handleUpdate(row) {
  789. this.reset();
  790. const id = row.id || this.ids
  791. getCourseFinishTempParent(id).then(response => {
  792. this.form = response.data;
  793. try {
  794. this.setting = response.data.setting ? JSON.parse(response.data.setting) : [];
  795. } catch (e) {
  796. this.setting = [];
  797. }
  798. try {
  799. this.chatSetting = response.data.chatSetting ? JSON.parse(response.data.chatSetting) : [];
  800. } catch (e) {
  801. this.chatSetting = [];
  802. }
  803. if (response.data.companyUserIds != null && response.data.companyUserIds !== '') {
  804. this.companyUserIds = String(this.form.companyUserIds).split(",");
  805. } else {
  806. this.companyUserIds = [];
  807. }
  808. const allRuleItems = [].concat(this.setting || [], this.chatSetting || []);
  809. allRuleItems.forEach(item => {
  810. if (item && (item.contentType == 4 || item.contentType == '4') && item.courseId) {
  811. this.videoOptions = [];
  812. this.videoOptionsLoading = false;
  813. videoList(item.courseId).then((videoResponse) => {
  814. this.videoOptions = videoResponse.list;
  815. });
  816. }
  817. });
  818. this.open = true;
  819. this.title = "修改完课模板";
  820. });
  821. },
  822. /** 提交按钮 */
  823. submitForm() {
  824. this.$refs["form"].validate(valid => {
  825. if (valid) {
  826. if (this.form.isAllCompanyUser == null) {
  827. this.form.isAllCompanyUser = 2;
  828. }
  829. if (this.companyUserIds != null) {
  830. this.form.companyUserIds = this.companyUserIds.toString();
  831. }
  832. const processedSetting = this.setting.map(item => {
  833. const newItem = {...item};
  834. if (newItem.videoOptions) {
  835. delete newItem.videoOptions;
  836. }
  837. if (newItem.videoLoading !== undefined) {
  838. delete newItem.videoLoading;
  839. }
  840. return newItem;
  841. });
  842. this.form.setting = JSON.stringify(processedSetting);
  843. this.form.chatSetting = JSON.stringify(this.chatSetting);
  844. if (this.setting.length <= 0) {
  845. return this.$message("请添加看课规则")
  846. }
  847. for (let i = 0; i < this.setting.length; i++) {
  848. if (this.setting[i].contentType == 1 && (this.setting[i].value == null || this.setting[i].value == "")) {
  849. return this.$message.error("看课规则:内容不能为空")
  850. }
  851. if (this.setting[i].contentType == 2 && (this.setting[i].imgUrl == null || this.setting[i].imgUrl == "")) {
  852. return this.$message.error("看课规则:图片不能为空")
  853. }
  854. if (this.setting[i].contentType == 3 && (this.setting[i].linkTitle == null || this.setting[i].linkTitle == "")) {
  855. return this.$message.error("看课规则:链接标题不能为空")
  856. }
  857. if (this.setting[i].contentType == 3 && (this.setting[i].linkDescribe == null || this.setting[i].linkDescribe == "")) {
  858. return this.$message.error("看课规则:链接描述不能为空")
  859. }
  860. if (this.setting[i].contentType == 3 && (this.setting[i].linkImageUrl == null || this.setting[i].linkImageUrl == "")) {
  861. return this.$message.error("看课规则:链接图片不能为空")
  862. }
  863. if (this.setting[i].contentType == 3 && this.setting[i].type == 1 && (this.setting[i].linkUrl == null || this.setting[i].linkUrl == "")) {
  864. return this.$message.error("看课规则:链接地址不能为空")
  865. }
  866. if (this.setting[i].contentType == 5 && (this.setting[i].fileUrl == null || this.setting[i].fileUrl == "")) {
  867. return this.$message.error("看课规则:文件不能为空")
  868. }
  869. if (this.setting[i].contentType == 6 && (this.setting[i].videoUrl == null || this.setting[i].videoUrl == "")) {
  870. return this.$message.error("看课规则:视频不能为空")
  871. }
  872. if (this.setting[i].contentType == 7 && (this.setting[i].value == null || this.setting[i].value == "")) {
  873. return this.$message.error("看课规则:语音不能为空")
  874. }
  875. }
  876. for (let i = 0; i < this.chatSetting.length; i++) {
  877. if (this.chatSetting[i].contentType == 1 && (this.chatSetting[i].value == null || this.chatSetting[i].value == "")) {
  878. return this.$message.error("群聊恭喜规则:内容不能为空")
  879. }
  880. if (this.chatSetting[i].contentType == 2 && (this.chatSetting[i].imgUrl == null || this.chatSetting[i].imgUrl == "")) {
  881. return this.$message.error("群聊恭喜规则:图片不能为空")
  882. }
  883. if (this.chatSetting[i].contentType == 3 && (this.chatSetting[i].linkTitle == null || this.chatSetting[i].linkTitle == "")) {
  884. return this.$message.error("群聊恭喜规则:链接标题不能为空")
  885. }
  886. if (this.chatSetting[i].contentType == 3 && (this.chatSetting[i].linkDescribe == null || this.chatSetting[i].linkDescribe == "")) {
  887. return this.$message.error("群聊恭喜规则:链接描述不能为空")
  888. }
  889. if (this.chatSetting[i].contentType == 3 && (this.chatSetting[i].linkImageUrl == null || this.chatSetting[i].linkImageUrl == "")) {
  890. return this.$message.error("群聊恭喜规则:链接图片不能为空")
  891. }
  892. if (this.chatSetting[i].contentType == 3 && this.chatSetting[i].type == 1 && (this.chatSetting[i].linkUrl == null || this.chatSetting[i].linkUrl == "")) {
  893. return this.$message.error("群聊恭喜规则:链接地址不能为空")
  894. }
  895. if (this.chatSetting[i].contentType == 5 && (this.chatSetting[i].fileUrl == null || this.chatSetting[i].fileUrl == "")) {
  896. return this.$message.error("群聊恭喜规则:文件不能为空")
  897. }
  898. if (this.chatSetting[i].contentType == 6 && (this.chatSetting[i].videoUrl == null || this.chatSetting[i].videoUrl == "")) {
  899. return this.$message.error("群聊恭喜规则:视频不能为空")
  900. }
  901. if (this.chatSetting[i].contentType == 7 && (this.chatSetting[i].value == null || this.chatSetting[i].value == "")) {
  902. return this.$message.error("群聊恭喜规则:语音不能为空")
  903. }
  904. }
  905. if (this.form.id != null) {
  906. updateCourseFinishTempParent(this.form).then(response => {
  907. this.msgSuccess("修改成功");
  908. this.open = false;
  909. this.getList();
  910. });
  911. } else {
  912. addCourseFinishTempParent(this.form).then(response => {
  913. this.msgSuccess("新增成功");
  914. this.open = false;
  915. this.getList();
  916. });
  917. }
  918. }
  919. });
  920. },
  921. /** 删除按钮操作 */
  922. handleDelete(row) {
  923. const ids = row.id || this.ids;
  924. this.$confirm('是否确认删除完课模板编号为"' + ids + '"的数据项?', "警告", {
  925. confirmButtonText: "确定",
  926. cancelButtonText: "取消",
  927. type: "warning"
  928. }).then(function() {
  929. return delCourseFinishTempParent(ids);
  930. }).then(() => {
  931. this.getList();
  932. this.msgSuccess("删除成功");
  933. }).catch(() => {});
  934. },
  935. /** 导出按钮操作 */
  936. handleExport() {
  937. const queryParams = this.queryParams;
  938. this.$confirm('是否确认导出所有完课模板数据项?', "警告", {
  939. confirmButtonText: "确定",
  940. cancelButtonText: "取消",
  941. type: "warning"
  942. }).then(() => {
  943. this.exportLoading = true;
  944. return deptExportCourseFinishTempParent(queryParams);
  945. }).then(response => {
  946. this.download(response.msg);
  947. this.exportLoading = false;
  948. }).catch(() => {});
  949. },
  950. handleAvatarSuccessFile(res, file, item) {
  951. if (res.code === 200) {
  952. // 使用 $set 确保响应式更新
  953. this.$set(item, 'fileUrl', res.url);
  954. } else {
  955. this.msgError(res.msg);
  956. }
  957. },
  958. beforeAvatarUploadFile(file) {
  959. const isLt1M = file.size / 1024 / 1024 < 10;
  960. if (!isLt1M) {
  961. this.$message.error('上传大小不能超过 10MB!');
  962. }
  963. return isLt1M;
  964. },
  965. //下载文件
  966. downloadUrl(materialUrl) {
  967. // 直接返回文件 URL
  968. return materialUrl;
  969. },
  970. handleInputVideoText(value, content) {
  971. // 允许的字符:中文、英文(大小写)、数字和指定标点符号(,。!?)
  972. const regex = /^[\u4e00-\u9fa5,。!?,!?]+$/;
  973. // 删除不符合条件的字符
  974. const filteredValue = value.split('').filter(char => regex.test(char)).join('');
  975. this.$set(content, 'value', filteredValue);
  976. },
  977. handleAvatarSuccessVideo(res, file, item) {
  978. if (res.code == 200) {
  979. // 使用 $set 确保响应式更新
  980. this.$set(item, 'videoUrl', res.url);
  981. } else {
  982. this.msgError(res.msg);
  983. }
  984. },
  985. beforeAvatarUploadVideo(file) {
  986. const isLt30M = file.size / 1024 / 1024 < 10;
  987. const isMP4 = file.type === 'video/mp4';
  988. if (!isMP4) {
  989. this.$message.error('仅支持上传 MP4 格式的视频文件!');
  990. return false;
  991. }
  992. if (!isLt30M) {
  993. this.$message.error('上传大小不能超过 10MB!');
  994. return false;
  995. }
  996. return true;
  997. },
  998. delSetList(index, type) {
  999. if (type == 0) {
  1000. this.setting.splice(index, 1)
  1001. } else {
  1002. this.chatSetting.splice(index, 1)
  1003. }
  1004. },
  1005. addSetList(type) {
  1006. const newSetting = {
  1007. contentType: '1',
  1008. value: '',
  1009. };
  1010. // 将新设置项添加到 content.setting 数组中
  1011. if (type == 0) {
  1012. this.setting.push(newSetting);
  1013. } else {
  1014. this.chatSetting.push(newSetting);
  1015. }
  1016. },
  1017. jump(id){
  1018. this.$router.push('/qw/conversion/courseFinishTemp/' + id)
  1019. },
  1020. },
  1021. };
  1022. </script>
  1023. <style scoped>
  1024. .finish-rule-label {
  1025. display: inline-flex;
  1026. flex-direction: column;
  1027. align-items: flex-start;
  1028. line-height: 1.4;
  1029. gap: 4px;
  1030. }
  1031. .finish-rule-label span:last-child {
  1032. font-weight: 600;
  1033. }
  1034. .finish-rule-panel {
  1035. width: 100%;
  1036. box-sizing: border-box;
  1037. border-radius: 4px;
  1038. padding: 12px;
  1039. }
  1040. .finish-rule-panel--watch {
  1041. background: #ecf5ff;
  1042. border: 1px solid #b3d8ff;
  1043. border-left: 4px solid #409eff;
  1044. }
  1045. .finish-rule-panel--chat {
  1046. background: #fdf6ec;
  1047. border: 1px solid #f5dab1;
  1048. border-left: 4px solid #e6a23c;
  1049. }
  1050. .finish-rule-panel__tip {
  1051. font-size: 12px;
  1052. margin-bottom: 10px;
  1053. line-height: 1.5;
  1054. }
  1055. .finish-rule-panel--watch .finish-rule-panel__tip {
  1056. color: #337ecc;
  1057. }
  1058. .finish-rule-panel--chat .finish-rule-panel__tip {
  1059. color: #b88230;
  1060. }
  1061. .finish-rule-item {
  1062. margin-bottom: 16px;
  1063. border-radius: 4px;
  1064. background: #fff;
  1065. }
  1066. .finish-rule-item--watch {
  1067. border: 1px solid #b3d8ff;
  1068. }
  1069. .finish-rule-item--chat {
  1070. border: 1px solid #f5dab1;
  1071. }
  1072. </style>