userCourseCatalogDetails.vue 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. <template>
  2. <div class="app-container">
  3. <div style="padding-bottom: 20px">
  4. <span v-if="courseName != null">{{ courseName }}</span>
  5. </div>
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
  7. <el-form-item label="小节名称" prop="title">
  8. <el-input v-model="queryParams.title" placeholder="请输入小节名称" clearable size="small"
  9. @keyup.enter.native="handleQuery"/>
  10. </el-form-item>
  11. <el-form-item label="小节id" prop="videoId">
  12. <el-input v-model="queryParams.videoId" placeholder="请输入小节id" clearable size="small"
  13. @keyup.enter.native="handleQuery"/>
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  17. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  23. v-hasPermi="['course:userCourseVideo:add']">新增目录
  24. </el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button type="primary" plain :disabled="!ids || ids.length <= 0" size="mini" @click="openUpdates"
  28. v-hasPermi="['course:userCourseVideo:updateTime']">修改时间
  29. </el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button type="primary" plain size="mini" @click="openAdds"
  33. v-hasPermi="['course:userCourseVideo:batchAdd']">批量添加
  34. </el-button>
  35. </el-col>
  36. <el-col v-if="usePublicVideoLibrary" :span="1.5">
  37. <el-button
  38. type="primary"
  39. plain
  40. size="mini"
  41. :disabled="!ids || ids.length <= 0"
  42. v-hasPermi="['course:userCourseVideo:edit']"
  43. @click="openBatchWatchIntegralDialog"
  44. >批量修改</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button type="primary" plain size="mini" @click="updateRedPageckeOpen"
  48. v-hasPermi="['course:userCourseVideo:updateRed']">修改红包
  49. </el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  53. v-hasPermi="['course:userCourseVideo:remove']">删除
  54. </el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button type="warning" plain icon="el-icon-edit" size="mini" @click="handleCourseSort"
  58. v-hasPermi="['course:userCourseVideo:sort']">修改课节排序
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button type="primary" plain icon="el-icon-delete" size="mini" @click="handleSync"
  63. v-hasPermi="['course:userCourseVideo:sync']">同步模板数据
  64. </el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleDown"
  68. v-hasPermi="['course:userCourseVideo:batchDown']">批量下架
  69. </el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleUp"
  73. v-hasPermi="['course:userCourseVideo:batchUp']">批量上架</el-button>
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleEditCover"
  77. v-hasPermi="['course:userCourseVideo:batchEditCover']">批量修改封面图
  78. </el-button>
  79. </el-col>
  80. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  81. </el-row>
  82. <el-table border v-loading="loading" :data="userCourseVideoList" @selection-change="handleSelectionChange">
  83. <el-table-column type="selection" width="55" align="center"/>
  84. <el-table-column label="视频ID" align="center" prop="videoId"/>
  85. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title"/>
  86. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName">
  87. </el-table-column>
  88. <el-table-column label="视频时长" align="center" prop="duration">
  89. <template slot-scope="{ row }">
  90. {{ formatDuration(row.duration) }}
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="看课开始时间" align="center" prop="duration">
  94. <template slot-scope="{ row }">
  95. <el-tag v-if="row.viewStartTime">{{ row.viewStartTime }}</el-tag>
  96. <el-tag type="danger" v-if="!row.viewStartTime">无</el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="看课结束时间" align="center" prop="duration">
  100. <template slot-scope="{ row }">
  101. <el-tag v-if="row.viewEndTime">{{ row.viewEndTime }}</el-tag>
  102. <el-tag type="danger" v-if="!row.viewEndTime">无</el-tag>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="领取红包时间" align="center" prop="duration">
  106. <template slot-scope="{ row }">
  107. <el-tag v-if="row.lastJoinTime">{{ row.lastJoinTime }}</el-tag>
  108. <el-tag type="danger" v-if="!row.lastJoinTime">无</el-tag>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="红包金额" align="center" prop="redPacketMoney"/>
  112. <el-table-column label="排序" align="center" prop="courseSort"/>
  113. <el-table-column v-if="usePublicVideoLibrary" label="观看时长(分钟)" align="center" width="120" prop="watchDurationMinutes"/>
  114. <el-table-column v-if="usePublicVideoLibrary" label="积分奖励" align="center" width="100" prop="integralReward"/>
  115. <el-table-column label="上传时间" align="center" prop="createTime"/>
  116. <el-table-column label="是否上架" align="center" prop="isOnPut">
  117. <template slot-scope="{ row }">
  118. <el-tag v-if="row.isOnPut == 0">是</el-tag>
  119. <el-tag type="danger" v-if="row.isOnPut == 1">否</el-tag>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  123. <template slot-scope="scope">
  124. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  125. v-hasPermi="['course:userCourseVideo:edit']">修改
  126. </el-button>
  127. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleComment(scope.row)"
  128. v-hasPermi="['course:courseWatchComment:list']">查看评论
  129. </el-button>
  130. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  131. v-hasPermi="['course:userCourseVideo:remove']">删除
  132. </el-button>
  133. <el-button size="mini"
  134. type="text" v-if="projectFrom === 'myhk'" @click="openXsyDialog(scope.row)">
  135. 复制参数
  136. </el-button>
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  141. @pagination="getList"/>
  142. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  143. <el-form ref="form" :model="form" :rules="rules" label-width="110px" v-loading="uploadLoading">
  144. <el-form-item label="视频标题" prop="title">
  145. <el-input v-model="form.title" placeholder="请输入内容"/>
  146. </el-form-item>
  147. <el-form-item label="视频描述" prop="description">
  148. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入内容"/>
  149. </el-form-item>
  150. <el-form-item label="课程排序" prop="courseSort">
  151. <el-input-number v-model="form.courseSort" :min="1"></el-input-number>
  152. </el-form-item>
  153. <el-form-item label="视频缩略图" prop="thumbnail">
  154. <ImageUpload v-model="form.thumbnail" :limit="1" :width="300" :height="168" />
  155. </el-form-item>
  156. <video-upload :type="1" :isPrivate="isPrivate" :use-public-video-library="usePublicVideoLibrary" :fileKey.sync="form.fileKey" :fileSize.sync="form.fileSize"
  157. :videoUrl.sync="videoUrl" :fileName.sync="form.fileName" :line_1.sync="form.lineOne"
  158. :line_2.sync="form.lineTwo" :line_3.sync="form.lineThree" :thumbnail.sync="form.thumbnail"
  159. :uploadType.sync="form.uploadType" :isTranscode.sync="form.isTranscode"
  160. :transcodeFileKey.sync="form.transcodeFileKey" @video-duration="handleVideoDuration"
  161. @change="handleVideoChange" @selectProjects="handleSelectProjects" ref="videoUpload"
  162. append-to-body/>
  163. <!-- <el-form-item label="关联疗法" >-->
  164. <!--&lt;!&ndash; <el-button size="small" type="primary" @click="choosePackage">选取疗法</el-button>&ndash;&gt;-->
  165. <!-- <el-table border width="100%" style="margin-top:5px;" :data="packageList">-->
  166. <!-- <el-table-column label="疗法名称" align="center" prop="packageName"/>-->
  167. <!-- <el-table-column label="疗法图片" align="center" prop="imgUrl">-->
  168. <!-- <template slot-scope="scope">-->
  169. <!-- <img :src="scope.row.imgUrl" style="height: 80px;">-->
  170. <!-- </template>-->
  171. <!-- </el-table-column>-->
  172. <!-- <el-table-column label="疗法别名" align="center" prop="secondName"/>-->
  173. <!-- <el-table-column label="总金额" align="center" prop="totalPrice"/>-->
  174. <!-- &lt;!&ndash; 根据课程类型控制是否显示弹出时间列:0是公域(显示),1是私域(不显示) &ndash;&gt;-->
  175. <!-- <el-table-column label="弹出时间" align="center" width="250px" v-if="isPrivate == 0">-->
  176. <!-- <template slot-scope="scope">-->
  177. <!-- <div>-->
  178. <!-- <el-time-select-->
  179. <!-- v-model="scope.row.duration"-->
  180. <!-- size="mini"-->
  181. <!-- placeholder="选择时间"-->
  182. <!-- :picker-options="getPickerOptions()"-->
  183. <!-- @change="handleTimeChange(scope.$index, scope.row)"-->
  184. <!-- ></el-time-select>-->
  185. <!-- </div>-->
  186. <!-- </template>-->
  187. <!-- </el-table-column>-->
  188. <!-- <el-table-column label="操作" align="center" width="100px" fixed="right">-->
  189. <!-- <template slot-scope="scope">-->
  190. <!-- <el-button-->
  191. <!-- size="mini"-->
  192. <!-- type="text"-->
  193. <!-- icon="el-icon-delete"-->
  194. <!-- @click="handlePackageDelete(scope.row)"-->
  195. <!-- >删除</el-button>-->
  196. <!-- </template>-->
  197. <!-- </el-table-column>-->
  198. <!-- </el-table>-->
  199. <!-- </el-form-item >-->
  200. <el-form-item label="课题选择" prop="questionBankId">
  201. <el-button size="small" type="primary" @click="chooseQuestionBank">选取课题</el-button>
  202. <el-table border width="100%" style="margin-top:5px;" :data="form.questionBankList">
  203. <el-table-column label="问题" align="center" prop="title">
  204. <template slot-scope="scope">
  205. <el-tooltip class="item" effect="dark" :content="scope.row.title" placement="top">
  206. <div
  207. style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
  208. <span>{{ scope.row.title }}</span>
  209. </div>
  210. </el-tooltip>
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="类别" align="center" prop="type">
  214. <template slot-scope="scope">
  215. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  216. </template>
  217. </el-table-column>
  218. <el-table-column label="答案" align="center" prop="answer"/>
  219. <el-table-column label="操作" align="center" width="100px" fixed="right">
  220. <template slot-scope="scope">
  221. <el-button size="mini" type="text" icon="el-icon-delete"
  222. @click="handleQuestionBankDelete(scope.row)">删除
  223. </el-button>
  224. </template>
  225. </el-table-column>
  226. </el-table>
  227. </el-form-item>
  228. <el-form-item label="红包金额" prop="redPacketMoney">
  229. <el-input-number v-model="form.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
  230. </el-form-item>
  231. <!-- v-if="!!form.randomRedPacketRulesArr" -->
  232. <el-form-item v-if="!!enableRandomRedPacket" label="随机红包金额" >
  233. <template >
  234. <div v-for="(rule, index) in form.randomRedPacketRulesArr" :key="index" class="form-row">
  235. <el-form-item
  236. label="随机红包金额区间"
  237. :prop="`randomRedPacketRulesArr.${index}.minAmount`"
  238. :rules="[
  239. { required: true, message: '请输入最小金额', trigger: 'blur' },
  240. { validator: validateMinAmount, trigger: 'blur', index: index }
  241. ]"
  242. class="form-item-amount"
  243. >
  244. <el-input
  245. v-model.number="rule.minAmount"
  246. type="number"
  247. :min="0.01"
  248. :precision="2"
  249. :step="0.01"
  250. placeholder="最小金额"
  251. size="small"
  252. class="amount-input"
  253. @input="handleAmountInput(rule, 'minAmount')"
  254. ></el-input>
  255. <span class="separator">-</span>
  256. <el-input
  257. v-model.number="rule.maxAmount"
  258. type="number"
  259. :min="rule.minAmount || 0.01"
  260. :precision="2"
  261. :step="0.01"
  262. placeholder="最大金额"
  263. size="small"
  264. class="amount-input"
  265. @input="handleAmountInput(rule, 'maxAmount')"
  266. ></el-input>
  267. <span class="suffix">元</span>
  268. </el-form-item>
  269. <el-form-item
  270. label="随机权重"
  271. :prop="`randomRedPacketRulesArr.${index}.weight`"
  272. :rules="[
  273. { required: true, message: '请输入权重', trigger: 'blur' },
  274. { type: 'integer', message: '权重必须为整数', trigger: 'blur' },
  275. ]"
  276. class="form-item-weight"
  277. >
  278. <el-input
  279. v-model.number="rule.weight"
  280. type="number"
  281. :min="1"
  282. placeholder="权重"
  283. size="small"
  284. ></el-input>
  285. </el-form-item>
  286. <el-tooltip class="item" effect="dark" content="权重越高,被随机到的概率越大" placement="top">
  287. <i class="el-icon-question"></i>
  288. </el-tooltip>
  289. <div class="action-buttons">
  290. <el-button
  291. icon="el-icon-plus"
  292. size="mini"
  293. type="text"
  294. @click="addRule(index)"
  295. class="add-btn"
  296. >
  297. 新增
  298. </el-button>
  299. <el-button
  300. icon="el-icon-delete"
  301. size="mini"
  302. type="text"
  303. @click="deleteRule(index)"
  304. :disabled="form.randomRedPacketRulesArr.length <= 1"
  305. class="delete-btn"
  306. >
  307. 删除
  308. </el-button>
  309. </div>
  310. </div>
  311. </template>
  312. </el-form-item>
  313. <el-form-item label="是否关联商品" prop="isProduct">
  314. <el-radio-group v-model="form.isProduct">
  315. <el-radio :label="1">是</el-radio>
  316. <el-radio :label="0">否</el-radio>
  317. </el-radio-group>
  318. </el-form-item>
  319. <el-form-item label="是否先导课" prop="isFirst">
  320. <el-radio-group v-model="form.isFirst">
  321. <el-radio :label="1">是</el-radio>
  322. <el-radio :label="0">否</el-radio>
  323. </el-radio-group>
  324. </el-form-item>
  325. <el-form-item label="是否启用倍速" prop="isSpeed">
  326. <el-radio-group v-model="form.isSpeed">
  327. <el-radio :label="1">是</el-radio>
  328. <el-radio :label="0">否</el-radio>
  329. </el-radio-group>
  330. </el-form-item>
  331. <el-form-item label="是否上架" prop="isOnPut">
  332. <el-radio-group v-model="form.isOnPut">
  333. <el-radio :label="0">上架</el-radio>
  334. <el-radio :label="1">下架</el-radio>
  335. </el-radio-group>
  336. </el-form-item>
  337. <el-form-item label="课程优惠券" prop="courseCouponId">
  338. <el-select v-model="form.courseCouponId" clearable placeholder="请选择课程优惠券">
  339. <el-option
  340. v-for="item in courseCouponList"
  341. :key="item.id"
  342. :label="item.title"
  343. :value="item.id">
  344. </el-option>
  345. </el-select>
  346. </el-form-item>
  347. <el-form-item label="商品选择" v-if="form.isProduct === 1">
  348. <el-button size="small" type="primary" @click="chooseCourseProduct">选取商品</el-button>
  349. <el-table border width="100%" style="margin-top:5px;" :data="form.courseProducts">
  350. <el-table-column label="商品名称" align="center" prop="productName"/>
  351. <el-table-column label="产品条码" align="center" prop="barCode"/>
  352. <el-table-column label="商品价格" align="center" prop="productPrice"/>
  353. <el-table-column label="库存" align="center" prop="stock"/>
  354. <el-table-column label="操作" align="center" width="100px" fixed="right">
  355. <template slot-scope="scope">
  356. <el-button size="mini" type="text" icon="el-icon-delete"
  357. @click="handleCourseProductDelete(scope.row)">删除
  358. </el-button>
  359. </template>
  360. </el-table-column>
  361. </el-table>
  362. </el-form-item>
  363. <el-row>
  364. <el-col :span="12">
  365. <el-form-item v-if="form.isProduct === 1" label="商品售卖时间" prop="listingStartTime">
  366. <el-input-number v-model="form.listingStartTime" :min="0" label="商品售卖时间"></el-input-number>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="12">
  370. <el-form-item v-if="form.isProduct === 1" label="结束售卖时间" prop="listingStartTime">
  371. <el-input-number v-model="form.listingEndTime" :min="0" label="结束售卖时间"></el-input-number>
  372. </el-form-item>
  373. </el-col>
  374. </el-row>
  375. <el-form-item v-if="usePublicVideoLibrary" label="观看时长" prop="watchDurationMinutes">
  376. <el-input-number
  377. v-model="form.watchDurationMinutes"
  378. :min="0"
  379. :precision="0"
  380. :step="1"
  381. controls-position="right"
  382. placeholder="请输入"
  383. class="input-num-fixed"
  384. style="width: 200px"
  385. />
  386. <span class="form-unit">分钟</span>
  387. <span class="form-hint">注释:用户在页面的停留时间</span>
  388. </el-form-item>
  389. <el-form-item v-if="usePublicVideoLibrary" label="积分奖励" prop="integralReward">
  390. <el-input-number
  391. v-model="form.integralReward"
  392. :min="0"
  393. :precision="0"
  394. :step="1"
  395. controls-position="right"
  396. placeholder="请输入"
  397. class="input-num-fixed"
  398. style="width: 200px"
  399. />
  400. </el-form-item>
  401. <el-form-item label="课程介绍图" prop="courseIntroImg">
  402. <ImageUpload v-model="form.courseIntroImg" :limit="1" :width="300" :height="200" />
  403. </el-form-item>
  404. <!-- <el-form-item label="精选留言">-->
  405. <!-- <el-button size="small" type="primary" @click="openCommentImportDialog">导入留言</el-button>-->
  406. <!-- <el-button size="small" style="margin-left: 8px;" @click="openUserCommentDialog">用户留言</el-button>-->
  407. <!-- </el-form-item>-->
  408. </el-form>
  409. <div slot="footer" class="dialog-footer">
  410. <el-button type="primary" @click="submitForm">确 定</el-button>
  411. <el-button @click="cancel">取 消</el-button>
  412. </div>
  413. </el-dialog>
  414. <el-dialog title="导入精选留言" :visible.sync="commentImportDialog.visible" width="600px" append-to-body>
  415. <el-upload
  416. drag
  417. :auto-upload="false"
  418. :limit="1"
  419. accept=".xls,.xlsx"
  420. :on-change="handleCommentFileChange"
  421. :file-list="commentImportDialog.fileList">
  422. <i class="el-icon-upload"></i>
  423. <div class="el-upload__text">将Excel文件拖到此处,或<em>点击上传</em></div>
  424. <div class="el-upload__tip" slot="tip">仅支持.xls/.xlsx格式</div>
  425. </el-upload>
  426. <div style="margin-top: 10px;">
  427. <el-button size="small" type="text" @click="handleDownloadTemplate">下载Excel导入模板</el-button>
  428. </div>
  429. <div v-if="commentImportDialog.historyList.length > 0" style="margin-top: 15px;">
  430. <el-divider content-position="left">历史上传留言</el-divider>
  431. <el-table :data="commentImportDialog.historyList" border size="small" max-height="300">
  432. <el-table-column label="昵称" prop="nickName" width="100"/>
  433. <el-table-column label="评论内容" prop="content" show-overflow-tooltip/>
  434. <el-table-column label="上传时间" prop="createTime" width="160"/>
  435. <el-table-column label="操作" width="70" align="center">
  436. <template slot-scope="scope">
  437. <el-button type="text" size="mini" style="color:#F56C6C" @click="handleDeleteComment(scope.row)">删除</el-button>
  438. </template>
  439. </el-table-column>
  440. </el-table>
  441. </div>
  442. <div slot="footer" class="dialog-footer">
  443. <el-button type="primary" :loading="commentImportDialog.loading" @click="handleImportComments">确认导入</el-button>
  444. <el-button @click="commentImportDialog.visible = false">取 消</el-button>
  445. </div>
  446. </el-dialog>
  447. <el-dialog :title="title" :visible.sync="updateBatchData.open" width="1000px" append-to-body>
  448. <el-form ref="form" :model="updateBatchData.form" label-width="110px">
  449. <el-form-item label="看课时间" prop="timeRange">
  450. <el-time-picker is-range v-model="updateBatchData.form.timeRange" range-separator="至"
  451. start-placeholder="开始时间"
  452. value-format="HH:mm:ss" end-placeholder="结束时间" placeholder="选择时间范围">
  453. </el-time-picker>
  454. </el-form-item>
  455. <el-form-item label="领取红包时间" prop="lastJoinTime">
  456. <el-time-picker v-model="updateBatchData.form.lastJoinTime" :selectableRange="updateBatchData.form.timeRange"
  457. value-format="HH:mm:ss" placeholder="选择时间范围">
  458. </el-time-picker>
  459. <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
  460. </el-form-item>
  461. </el-form>
  462. <div slot="footer" class="dialog-footer">
  463. <el-button type="primary" @click="updateBatch">确 定</el-button>
  464. <el-button @click="updateBatchData.open = false">取 消</el-button>
  465. </div>
  466. </el-dialog>
  467. <el-dialog title="批量修改观看时长与积分" :visible.sync="batchWatchIntegral.open" width="520px" append-to-body>
  468. <p class="batch-watch-tip">已选 <strong>{{ ids.length }}</strong> 条课节,将统一更新为下方数值(仅本课程下已选中的记录)。</p>
  469. <el-form label-width="120px">
  470. <el-form-item label="观看时长">
  471. <el-input-number
  472. v-model="batchWatchIntegral.form.watchDurationMinutes"
  473. :min="0"
  474. :precision="0"
  475. :step="1"
  476. controls-position="right"
  477. style="width: 200px"
  478. />
  479. <span class="form-unit">分钟</span>
  480. </el-form-item>
  481. <el-form-item label="积分奖励">
  482. <el-input-number
  483. v-model="batchWatchIntegral.form.integralReward"
  484. :min="0"
  485. :precision="0"
  486. :step="1"
  487. controls-position="right"
  488. style="width: 200px"
  489. />
  490. </el-form-item>
  491. </el-form>
  492. <div slot="footer" class="dialog-footer">
  493. <el-button @click="batchWatchIntegral.open = false">取 消</el-button>
  494. <el-button type="primary" @click="submitBatchWatchIntegral">确 定</el-button>
  495. </div>
  496. </el-dialog>
  497. <el-dialog :title="questionBank.title" :visible.sync="questionBank.open" width="1000px" append-to-body>
  498. <question-bank ref="questionBank" @questionBankResult="questionBankResult"></question-bank>
  499. </el-dialog>
  500. <el-dialog :title="courseProduct.title" :visible.sync="courseProduct.open" width="1000px" append-to-body>
  501. <course-product ref="courseProduct" @courseProductResult="courseProductResult"></course-product>
  502. </el-dialog>
  503. <el-dialog title="视频库选择" :visible.sync="addBatchData.open" width="900px" append-to-body>
  504. <!-- 搜索条件 -->
  505. <el-form :inline="true" :model="addBatchData.queryParams" class="library-search">
  506. <el-form-item label="素材名称">
  507. <el-input v-model="addBatchData.queryParams.resourceName" placeholder="请输入素材名称" clearable size="small"
  508. @keyup.enter.native="resourceList"/>
  509. </el-form-item>
  510. <el-form-item label="类型">
  511. <el-select v-model="addBatchData.queryParams.typeId" @change="changeCateType" placeholder="请选择素材类型"
  512. clearable
  513. size="small">
  514. <el-option v-for="item in addBatchData.typeOptions" :key="item.dictValue" :label="item.dictLabel"
  515. :value="item.dictValue"/>
  516. </el-select>
  517. </el-form-item>
  518. <el-form-item label="子类型">
  519. <el-select v-model="addBatchData.queryParams.typeSubId" placeholder="请选择素材子类型" clearable size="small">
  520. <el-option v-for="item in addBatchData.typeSubOptions" :key="item.dictValue" :label="item.dictLabel"
  521. :value="item.dictValue"/>
  522. </el-select>
  523. </el-form-item>
  524. <el-form-item>
  525. <el-button type="primary" icon="el-icon-search" size="mini" @click="resourceList">搜索</el-button>
  526. </el-form-item>
  527. </el-form>
  528. <!-- 视频列表 -->
  529. <el-table v-loading="addBatchData.loading" :data="addBatchData.list"
  530. @selection-change="handVideoleSelectionChange" height="400px">
  531. <el-table-column type="selection" width="55" align="center"/>
  532. <el-table-column label="素材名称" align="center" prop="resourceName"/>
  533. <el-table-column label="文件名称" align="center" prop="fileName"/>
  534. <el-table-column label="排序" align="center" prop="sort"/>
  535. <el-table-column label="缩略图" align="center">
  536. <template slot-scope="scope">
  537. <el-popover placement="right" title="" trigger="hover">
  538. <img alt="" slot="reference" :src="scope.row.thumbnail" style="width: 80px; height: 50px"/>
  539. <img alt="" :src="scope.row.thumbnail" style="max-width: 150px;"/>
  540. </el-popover>
  541. </template>
  542. </el-table-column>
  543. <el-table-column label="视频时长" align="center">
  544. <template slot-scope="scope">
  545. <span>{{ formatDuration(scope.row.duration) }}</span>
  546. </template>
  547. </el-table-column>
  548. </el-table>
  549. <!-- 分页 -->
  550. <pagination v-show="addBatchData.total > 0" :total="addBatchData.total"
  551. :page.sync="addBatchData.queryParams.pageNum" :limit.sync="addBatchData.queryParams.pageSize"
  552. @pagination="resourceList"/>
  553. <div slot="footer" class="dialog-footer">
  554. <el-button type="primary" @click="batchVideoSave">确 定</el-button>
  555. </div>
  556. </el-dialog>
  557. <el-dialog title="章节红包" :visible.sync="redData.open" :close-on-click-modal="false" width="900px" append-to-body>
  558. <el-table border v-loading="redData.loading" :data="redData.list" height="600px">
  559. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title">
  560. <template slot-scope="scope">
  561. <el-input class="el-input" v-model="scope.row.title"/>
  562. </template>
  563. </el-table-column>
  564. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName">
  565. </el-table-column>
  566. <el-table-column label="视频时长" align="center" prop="duration">
  567. <template slot-scope="{ row }">
  568. {{ formatDuration(row.duration) }}
  569. </template>
  570. </el-table-column>
  571. <el-table-column label="红包金额" align="center" prop="redPacketMoney">
  572. <template slot-scope="scope">
  573. <el-input class="el-input" v-model="scope.row.redPacketMoney"/>
  574. </template>
  575. </el-table-column>
  576. <el-table-column label="排序" align="center" prop="courseSort"/>
  577. <el-table-column label="上传时间" align="center" prop="createTime"/>
  578. </el-table>
  579. <div slot="footer" class="dialog-footer">
  580. <el-button type="primary" @click="batchRedSave">确 定</el-button>
  581. </div>
  582. </el-dialog>
  583. <el-dialog :title="commentDialog.title" :visible.sync="commentDialog.open" width="1000px" append-to-body
  584. :close-on-click-modal="false">
  585. <course-watch-comment ref="courseWatchComment" :courseId="commentDialog.courseId" :videoId="commentDialog.videoId"
  586. v-if="commentDialog.open">
  587. </course-watch-comment>
  588. </el-dialog>
  589. <el-dialog :title="userCommentDialog.title" :visible.sync="userCommentDialog.open" width="1000px" append-to-body
  590. :close-on-click-modal="false" @opened="onUserCommentDialogOpened">
  591. <user-course-section-comment
  592. v-if="userCommentDialog.open"
  593. ref="userCourseSectionComment"
  594. :course-id="userCommentDialog.courseId"
  595. :video-id="userCommentDialog.videoId"
  596. />
  597. </el-dialog>
  598. <el-dialog title="修改课节排序" :visible.sync="openVideoSort" style="width: 1600px;" append-to-body>
  599. <draggable v-model="userCourseVideoSortList" @end="onDragEndDay" style="padding: 10px">
  600. <el-button style="margin: 8px 4px;" v-for="(item, index) in userCourseVideoSortList"
  601. :class="item.newCourseSort != item.courseSort ? 'red':''">第{{
  602. item.newCourseSort
  603. }}序(原排序第{{ item.courseSort }})
  604. </el-button>
  605. </draggable>
  606. <div style="float: right;margin-top: -20px">
  607. <el-button type="primary" @click="saveSorts">保存</el-button>
  608. </div>
  609. </el-dialog>
  610. <!-- 批量修改封面 -->
  611. <el-dialog :title="batchEditCoverDialog.title" :visible.sync="batchEditCoverDialog.visible" width="500px" append-to-body>
  612. <el-form ref="batchEditCoverDialogForm"
  613. :model="batchEditCoverDialog.form"
  614. :rules="batchEditCoverDialog.rules"
  615. v-loading="batchEditCoverDialog.uploadLoading">
  616. <el-form-item label="视频封面" prop="thumbnail">
  617. <ImageUpload v-model="batchEditCoverDialog.form.thumbnail" :limit="1" :width="300" :height="168" />
  618. </el-form-item>
  619. </el-form>
  620. <div slot="footer" class="dialog-footer">
  621. <el-button type="primary" @click="submitEditCoverForm">确 定</el-button>
  622. <el-button @click="cancelEditCoverForm">取 消</el-button>
  623. </div>
  624. </el-dialog>
  625. <!-- 销售易参数弹窗 -->
  626. <el-dialog
  627. title="复制销售易参数"
  628. :visible.sync="xsyDialogVisible"
  629. width="500px"
  630. append-to-body
  631. >
  632. <div style="margin-bottom: 20px;">
  633. <el-input
  634. v-model="xsyParams"
  635. type="textarea"
  636. :rows="3"
  637. readonly
  638. placeholder="参数将显示在这里"
  639. class="xsy-textarea"
  640. />
  641. </div>
  642. <div slot="footer" class="dialog-footer">
  643. <el-button @click="xsyDialogVisible = false">取消</el-button>
  644. <el-button type="primary" @click="copyXsyParams">复制参数</el-button>
  645. </div>
  646. </el-dialog>
  647. </div>
  648. </template>
  649. <script>
  650. import {
  651. addUserCourseVideo,
  652. batchSaveVideo,
  653. batchUpdateRed,
  654. delUserCourseVideo,
  655. getSort,
  656. getUserCourseVideo,
  657. getVideoListByCourseId,
  658. getPublicVideoListByCourseId,
  659. getVideoListByCourseIdAll,
  660. sortCourseVideo,
  661. updates,
  662. updateUserCourseVideo,
  663. batchUpdateWatchIntegral,
  664. syncTemplate, batchDownUserCourseVideo, batchEditCover, batchUpUserCourseVideo, getPublicUserCourseVideo
  665. } from '@/api/course/userCourseVideo'
  666. // import {syncTemplate} from '@/api/course/userCourse'
  667. import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
  668. import CourseProduct from "@/views/course/fsCourseProduct/CourseProduct.vue";
  669. import VideoUpload from "@/components/VideoUpload/index.vue";
  670. import {listVideoResource, listPublicVideoResource} from '@/api/course/videoResource';
  671. import {getByIds} from '@/api/course/courseQuestionBank'
  672. import CourseWatchComment from "./courseWatchComment.vue";
  673. import UserCourseSectionComment from "./userCourseSectionComment.vue";
  674. import {getCateListByPid, getCatePidList, getPublicCateListByPid, getPublicCatePidList} from '@/api/course/userCourseCategory'
  675. import {downloadCommentImportTemplate, importComments, listFeaturedComments, delUserCourseComment} from '@/api/course/userCourseComment'
  676. import draggable from 'vuedraggable'
  677. import { getConfigByKey } from '@/api/system/config'
  678. import { options as courserCouponOptions} from "@/api/his/courserCoupon";
  679. export default {
  680. name: "userCourseCatalog",
  681. components: {VideoUpload, QuestionBank, CourseWatchComment, UserCourseSectionComment, CourseProduct, draggable},
  682. props: {
  683. /** 为 true 时「视频库选择」使用公域分类 + 公域素材接口;默认 false 走原 list / 原分类下拉 */
  684. usePublicVideoLibrary: {
  685. type: Boolean,
  686. default: false
  687. }
  688. },
  689. watch:{
  690. // 深度监听 rules 数组的变化,以更新总权重
  691. "form.randomRedPacketRulesArr": {
  692. handler(val) {
  693. // this.calculateTotalWeight();
  694. this.validateRules();
  695. },
  696. deep: true,
  697. },
  698. },
  699. data() {
  700. return {
  701. courseCouponList: [],
  702. duration: null,
  703. packageList: [],
  704. //课题
  705. package: {
  706. title: '',
  707. open: false,
  708. },
  709. //课题
  710. questionBank: {
  711. title: '',
  712. open: false,
  713. },
  714. //拍商品
  715. courseProduct: {
  716. title: '',
  717. open: false,
  718. },
  719. isPrivate: null,
  720. videoUrl: "",
  721. uploadTypeOptions: [
  722. {dictLabel: "线路一", dictValue: 2},
  723. {dictLabel: "线路二", dictValue: 3},
  724. ],
  725. uploadLoading: false,
  726. courseId: null,
  727. videoName: '',
  728. title: "",
  729. // 是否显示弹出层
  730. open: false,
  731. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS",
  732. baseUrl: process.env.VUE_APP_BASE_API,
  733. projectFrom:process.env.VUE_APP_PROJECT,
  734. typeOptions: [],
  735. files: [],
  736. fileList: [],
  737. // 上传成功后的地址
  738. videoURL: '',
  739. // 进度条百分比
  740. progress: 0,
  741. // 上传视频获取成功后拿到的fileID【备用】
  742. fileId: '',
  743. courseName: null,
  744. userCourseVideoList: [],
  745. userCourseVideoSortList: [],
  746. total: 0,
  747. redData: {
  748. queryParams: {
  749. pageNum: 1,
  750. pageSize: 99999,
  751. courseId: null,
  752. },
  753. list: [],
  754. open: false,
  755. loading: true,
  756. form: {}
  757. },
  758. queryParams: {
  759. pageNum: 1,
  760. pageSize: 10,
  761. courseId: null,
  762. videoId: null,
  763. title: null
  764. },
  765. addBatchData: {
  766. open: false,
  767. loading: true,
  768. form: {},
  769. select: [], // 按用户选择顺序存储视频ID
  770. total: 0,
  771. queryParams: {
  772. pageNum: 1,
  773. pageSize: 10,
  774. resourceName: null,
  775. typeId: null,
  776. typeSubId: null
  777. },
  778. typeOptions: [],
  779. typeSubOptions: []
  780. },
  781. // 显示搜索条件
  782. showSearch: true,
  783. // 遮罩层
  784. loading: true,
  785. // 导出遮罩层
  786. exportLoading: false,
  787. // 选中数组
  788. ids: [],
  789. // 非单个禁用
  790. single: true,
  791. // 非多个禁用
  792. multiple: true,
  793. loading3: false,
  794. openVideoSort: false,
  795. // 表单参数
  796. form: {
  797. isOnPut: 0,
  798. courseProducts: [],
  799. courseIntroImg: null,
  800. randomRedPacketRules:null,
  801. randomRedPacketRulesArr:[
  802. {
  803. minAmount: 0.01,
  804. maxAmount: 0.01,
  805. weight: 100,
  806. }
  807. ]
  808. },
  809. updateBatchData: {
  810. open: false,
  811. form: {}
  812. },
  813. batchWatchIntegral: {
  814. open: false,
  815. form: {
  816. watchDurationMinutes: 0,
  817. integralReward: 0
  818. }
  819. },
  820. // 表单校验
  821. rules: {
  822. title: [
  823. {required: true, message: "小节名称不能为空", trigger: "change"}
  824. ],
  825. courseSort: [
  826. {required: true, message: "排序不能为空", trigger: "change"}
  827. ],
  828. },
  829. // 评论弹窗数据
  830. commentDialog: {
  831. open: false,
  832. courseId: null,
  833. videoId: null,
  834. title: ""
  835. },
  836. userCommentDialog: {
  837. open: false,
  838. courseId: null,
  839. videoId: null,
  840. title: ""
  841. },
  842. enableRandomRedPacket:false,
  843. // 批量修改封面
  844. batchEditCoverDialog: {
  845. title: '修改视频封面',
  846. visible: false,
  847. uploadLoading: false,
  848. form: {
  849. thumbnail: null,
  850. },
  851. rules: {
  852. thumbnail: [
  853. {required: true, message: "视频封面不能为空", trigger: "change"}
  854. ],
  855. }
  856. },
  857. // 销售易弹窗
  858. xsyDialogVisible: false,
  859. xsyParams: '',
  860. // 精选留言导入弹窗
  861. commentImportDialog: {
  862. visible: false,
  863. loading: false,
  864. fileList: [],
  865. file: null,
  866. historyList: [],
  867. courseId: null,
  868. videoId: null
  869. },
  870. }
  871. },
  872. created() {
  873. this.getDicts("sys_course_temp_type").then(response => {
  874. this.typeOptions = response.data;
  875. });
  876. getConfigByKey('randomRedpacket:config').then(res=>{
  877. let configData = res.data;
  878. if(!!configData && !!configData.configValue){
  879. let configValue = JSON.parse(configData.configValue);
  880. if(!!configValue.enableRandomRedpacket){
  881. this.enableRandomRedPacket = configValue.enableRandomRedpacket;
  882. console.log("this.enableRandomRedPacket ::" + this.enableRandomRedPacket)
  883. }
  884. }
  885. }).catch(res=>{
  886. });
  887. courserCouponOptions().then(res=>{
  888. this.courseCouponList = res.data;
  889. }).catch(res=>{
  890. });
  891. },
  892. methods: {
  893. getPickerOptions() {
  894. const durationInMinutes = Math.floor(this.form.duration / 60); // 将秒转换为分钟
  895. const endHour = Math.floor(durationInMinutes / 60); // 起始小时
  896. const endMinute = durationInMinutes % 60; // 起始分钟
  897. return {
  898. start: "00:00", // 固定开始时间
  899. step: "00:01", // 时间间隔
  900. end: `${endHour.toString().padStart(2, "0")}:${endMinute
  901. .toString()
  902. .padStart(2, "0")}`, // 动态结束时间
  903. };
  904. },
  905. // 处理时间选择框值变化
  906. handleTimeChange(index, row) {
  907. // 确保 packageList 中的数据被正确更新
  908. this.$set(this.packageList, index, row);
  909. // 同步更新 form.packageJson 字段
  910. this.$nextTick(() => {
  911. // 确保每个疗法包都有 duration 字段
  912. this.packageList.forEach(item => {
  913. if (item.duration === undefined || item.duration === null) {
  914. item.duration = ''; // 空值应初始化为空字符串而不是null,避免显示"null"
  915. }
  916. });
  917. this.form.packageJson = JSON.stringify(this.packageList);
  918. });
  919. },
  920. handlePackageDelete(row) {
  921. this.packageList.splice(this.packageList.findIndex(item => item.packageId === row.packageId), 1)
  922. },
  923. choosePackage() {
  924. this.package.open = true;
  925. this.package.title = '疗法选择';
  926. },
  927. /**
  928. * 选择课题
  929. */
  930. chooseQuestionBank() {
  931. this.questionBank.open = true;
  932. this.questionBank.title = '课题选择';
  933. },
  934. /**
  935. * 选择拍商品
  936. */
  937. chooseCourseProduct() {
  938. this.courseProduct.open = true;
  939. this.courseProduct.title = '拍商品选择';
  940. },
  941. //选择疗法
  942. selectPackage(row) {
  943. const drug = {};
  944. for (var i = 0; i < this.packageList.length; i++) {
  945. if (this.packageList[i].packageId == row.packageId) {
  946. this.$message.warning("疗法已存在!")
  947. return;
  948. }
  949. }
  950. drug.packageId = row.packageId;
  951. drug.packageName = row.packageName;
  952. drug.secondName = row.secondName;
  953. drug.totalPrice = row.totalPrice;
  954. drug.imgUrl = row.imgUrl;
  955. this.packageList.push(drug);
  956. this.$message({
  957. message: '添加成功',
  958. type: 'success'
  959. });
  960. },
  961. courseProductResult(val) {
  962. this.form.courseProducts = this.form.courseProducts || [];
  963. for (var i = 0; i < this.form.courseProducts.length; i++) {
  964. if (this.form.courseProducts[i].id == val.id) {
  965. return this.$message.error("当前商品已选择")
  966. }
  967. }
  968. //先置空 只选择一件商品
  969. this.form.courseProducts = [];
  970. this.form.courseProducts.push(val);
  971. this.$message({
  972. message: '添加成功',
  973. type: 'success'
  974. });
  975. },
  976. //选择结果
  977. questionBankResult(val) {
  978. // 确保 questionBankList 是数组
  979. this.form.questionBankList = this.form.questionBankList || [];
  980. for (var i = 0; i < this.form.questionBankList.length; i++) {
  981. if (this.form.questionBankList[i].id == val.id) {
  982. return this.$message.error("当前课题已选择")
  983. }
  984. }
  985. this.form.questionBankList.push(val);
  986. this.$message({
  987. message: '添加成功',
  988. type: 'success'
  989. });
  990. },
  991. //删除课题
  992. handleQuestionBankDelete(row) {
  993. this.form.questionBankList.splice(this.form.questionBankList.findIndex(item => item.id === row.id), 1)
  994. },
  995. //删除商品
  996. handleCourseProductDelete(row) {
  997. this.form.courseProducts.splice(this.form.courseProducts.findIndex(item => item.id === row.id), 1)
  998. },
  999. handleVideoChange() {
  1000. if (this.form.uploadType == 1) {
  1001. this.videoUrl = this.form.lineOne;
  1002. } else if (this.form.uploadType == 2) {
  1003. this.videoUrl = this.form.lineTwo;
  1004. } else if (this.form.uploadType == 3) {
  1005. this.videoUrl = this.form.lineThree;
  1006. }
  1007. },
  1008. // 视频库课题
  1009. handleSelectProjects(projectIds) {
  1010. this.form.questionBankList = []
  1011. if (!projectIds || projectIds.length === 0 || this.isPrivate === 0) {
  1012. return
  1013. }
  1014. const params = {ids: projectIds}
  1015. getByIds(params).then(response => {
  1016. if (response.code === 200) {
  1017. response.data.forEach(item => {
  1018. let isExist = this.form.questionBankList.some(q => q.id === item.id)
  1019. if (!isExist) {
  1020. this.form.questionBankList.push(item)
  1021. }
  1022. });
  1023. }
  1024. })
  1025. },
  1026. handleVideoDuration(duration) {
  1027. this.form.duration = duration;
  1028. },
  1029. formatDuration(seconds) {
  1030. if (seconds === null || seconds === undefined) {
  1031. return '未上传视频';
  1032. }
  1033. const hours = Math.floor(seconds / 3600);
  1034. const minutes = Math.floor((seconds % 3600) / 60);
  1035. const remainingSeconds = seconds % 60;
  1036. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  1037. const formattedMinutes = minutes.toString().padStart(2, '0');
  1038. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  1039. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  1040. },
  1041. getDetails(courseId, courseName, isPrivate) {
  1042. this.isPrivate = isPrivate
  1043. this.courseName = courseName
  1044. this.courseId = courseId;
  1045. this.queryParams.courseId = courseId;
  1046. this.getList();
  1047. },
  1048. getList() {
  1049. this.loading = true;
  1050. const api = this.usePublicVideoLibrary ? getPublicVideoListByCourseId : getVideoListByCourseId;
  1051. api(this.queryParams).then(response => {
  1052. this.userCourseVideoList = response.rows;
  1053. this.total = response.total;
  1054. this.loading = false;
  1055. });
  1056. },
  1057. // 取消按钮
  1058. cancel() {
  1059. this.open = false;
  1060. this.reset();
  1061. },
  1062. // 表单重置
  1063. reset() {
  1064. this.form = {
  1065. videoId: null,
  1066. title: null,
  1067. description: null,
  1068. url: null,
  1069. thumbnail: null,
  1070. duration: null,
  1071. createTime: null,
  1072. uploadType: null,
  1073. lineOne: null,
  1074. lineTwo: null,
  1075. lineThree: null,
  1076. fileName: null,
  1077. userId: null,
  1078. cateId: null,
  1079. courseId: null,
  1080. likes: null,
  1081. views: null,
  1082. comments: null,
  1083. status: 0,
  1084. courseSort: 1,
  1085. isHot: null,
  1086. isShow: null,
  1087. isAudit: null,
  1088. auditBy: null,
  1089. auditTime: null,
  1090. updateTime: null,
  1091. source: null,
  1092. isDel: null,
  1093. shares: null,
  1094. tags: null,
  1095. productId: null,
  1096. productJson: null,
  1097. questionBankId: null,
  1098. questionBankList: [],
  1099. redPacketMoney: 0,
  1100. isTranscode: 0,
  1101. transcodeFileKey: null,
  1102. isProduct: 0,
  1103. isFirst: 0,
  1104. isSpeed: 0,
  1105. isOnPut: 0,
  1106. listingStartTime: null,
  1107. listingEndTime: null,
  1108. watchDurationMinutes: null,
  1109. integralReward: null,
  1110. randomRedPacketRules:null,
  1111. randomRedPacketRulesArr:[
  1112. {
  1113. minAmount: 0.01,
  1114. maxAmount: 0.01,
  1115. weight: 100,
  1116. }
  1117. ],
  1118. courseIntroImg: null
  1119. };
  1120. this.videoURL = '';
  1121. this.progress = 0;
  1122. this.resetForm("form");
  1123. },
  1124. /** 搜索按钮操作 */
  1125. handleQuery() {
  1126. this.queryParams.pageNum = 1;
  1127. this.getList();
  1128. },
  1129. /** 重置按钮操作 */
  1130. resetQuery() {
  1131. this.resetForm("queryForm");
  1132. this.handleQuery();
  1133. },
  1134. // 多选框选中数据
  1135. handleSelectionChange(selection) {
  1136. this.ids = selection.map(item => item.videoId)
  1137. this.single = selection.length !== 1
  1138. this.multiple = !selection.length
  1139. },
  1140. // 视频库多选框选中数据(按用户点击顺序记录)
  1141. handVideoleSelectionChange(selection) {
  1142. // 提取当前选中的所有ID
  1143. const selectedIds = selection.map(item => item.id);
  1144. // 处理新增选中项:保留用户点击顺序
  1145. selectedIds.forEach(id => {
  1146. if (!this.addBatchData.select.includes(id)) {
  1147. this.addBatchData.select.push(id);
  1148. }
  1149. });
  1150. // 处理取消选中项:移除已取消的ID
  1151. this.addBatchData.select = this.addBatchData.select.filter(id => selectedIds.includes(id));
  1152. },
  1153. handleAdd() {
  1154. this.reset();
  1155. this.form.uploadType = 1; // 默认播放线路:线路一
  1156. this.form.courseId = this.courseId;
  1157. this.open = true;
  1158. this.title = "添加课堂视频";
  1159. this.videoUrl = '';
  1160. this.packageList = [];
  1161. getSort(this.courseId).then(response => {
  1162. this.form.courseSort = Number(response.data);
  1163. })
  1164. setTimeout(() => {
  1165. this.$refs.videoUpload.resetUpload();
  1166. }, 500);
  1167. },
  1168. /** 修改按钮操作 */
  1169. handleUpdate(row) {
  1170. this.reset();
  1171. this.form.isOnPut=row.isOnPut
  1172. this.packageList = [];
  1173. const videoId = row.videoId || this.ids
  1174. const api = this.usePublicVideoLibrary ? getPublicUserCourseVideo : getUserCourseVideo;
  1175. api(videoId).then(response => {
  1176. console.log(response);
  1177. this.form = response.data;
  1178. this.$set(this.form, 'courseIntroImg', response.data.courseIntroImg || null);
  1179. this.$set(this.form, 'isOnPut', response.data.isOnPut !== undefined ? Number(response.data.isOnPut) : 0);
  1180. // 后端字段需为数字;null 时 el-radio 会误选中「是」(1)
  1181. this.$set(this.form, 'isProduct', response.data.isProduct != null ? Number(response.data.isProduct) : 0);
  1182. this.$set(this.form, 'isFirst', response.data.isFirst != null ? Number(response.data.isFirst) : 0);
  1183. this.$set(this.form, 'isSpeed', response.data.isSpeed != null ? Number(response.data.isSpeed) : 0);
  1184. if (this.form.isProduct !== 1) {
  1185. this.$set(this.form, 'courseProducts', []);
  1186. this.form.productId = null;
  1187. }
  1188. if(!!this.form.randomRedPacketRules){
  1189. this.$set(this.form, 'randomRedPacketRulesArr', JSON.parse(this.form.randomRedPacketRules)) ;
  1190. // this.form.randomRedPacketRulesArr = JSON.parse(this.form.randomRedPacketRules);
  1191. }else{
  1192. //处理初始值
  1193. this.form.randomRedPacketRulesArr = [{
  1194. minAmount: 0.01,
  1195. maxAmount: 0.01,
  1196. weight: 100,
  1197. }]
  1198. }
  1199. if (response.data.videoUrl != null && response.data.videoUrl !== '') {
  1200. this.videoUrl = response.data.videoUrl;
  1201. }
  1202. if (this.form.packageJson != null) {
  1203. this.packageList = JSON.parse(this.form.packageJson);
  1204. }
  1205. if (response.data.viewStartTime != null && response.data.viewEndTime != null) {
  1206. this.form.timeRange = [response.data.viewStartTime, response.data.viewEndTime]
  1207. }
  1208. setTimeout(() => {
  1209. this.$refs.videoUpload.resetUpload();
  1210. }, 500);
  1211. this.open = true;
  1212. this.title = "修改课堂视频";
  1213. });
  1214. },
  1215. /** 提交按钮 */
  1216. submitForm() {
  1217. this.$refs["form"].validate(valid => {
  1218. if (valid) {
  1219. this.form.videoUrl = this.videoUrl;
  1220. if (this.form.videoUrl == null || this.form.videoUrl === '') {
  1221. this.$message({
  1222. message: '请上传视频!',
  1223. type: 'warning'
  1224. });
  1225. return
  1226. }
  1227. if (this.form.timeRange && this.form.timeRange.length === 2) {
  1228. this.form.viewStartTime = this.form.timeRange[0];
  1229. this.form.viewEndTime = this.form.timeRange[1];
  1230. }
  1231. if (this.form.duration == null) {
  1232. this.$message({
  1233. message: '未识别到视频时长请稍等。。。',
  1234. type: 'warning'
  1235. });
  1236. return
  1237. }
  1238. if (this.form.isProduct != null && this.form.isProduct == 1 && (this.form.courseProducts == null || this.form.courseProducts.length < 1)) {
  1239. this.$message({
  1240. message: '请选择关联商品',
  1241. type: 'warning'
  1242. });
  1243. return
  1244. }
  1245. if (this.form.questionBankList !== null) {
  1246. this.form.questionBankId = this.form.questionBankList.map(item => item.id).join(',');
  1247. }
  1248. if (this.packageList.length > 0) {
  1249. this.form.packageJson = JSON.stringify(this.packageList);
  1250. }
  1251. if (this.form.isProduct === 1 && this.form.courseProducts != null && this.form.courseProducts.length > 0) {
  1252. this.form.productId = this.form.courseProducts.map(item => item.id).join(',');
  1253. } else {
  1254. this.form.productId = null;
  1255. this.form.courseProducts = [];
  1256. }
  1257. if(!!this.form.randomRedPacketRulesArr){
  1258. let rulesJson = JSON.stringify(this.form.randomRedPacketRulesArr);
  1259. this.form.randomRedPacketRules = rulesJson;
  1260. }
  1261. if (this.form.videoId != null) {
  1262. updateUserCourseVideo(this.form).then(response => {
  1263. this.msgSuccess("修改成功");
  1264. this.open = false;
  1265. this.getList();
  1266. });
  1267. } else {
  1268. addUserCourseVideo(this.form).then(response => {
  1269. this.msgSuccess("新增成功");
  1270. this.open = false;
  1271. this.getList();
  1272. });
  1273. }
  1274. }
  1275. });
  1276. },
  1277. openUpdates() {
  1278. this.updateBatchData.form = {};
  1279. this.updateBatchData.open = true;
  1280. },
  1281. /** 提交按钮 */
  1282. updateBatch() {
  1283. this.updateBatchData.form.ids = this.ids;
  1284. if (this.updateBatchData.form.timeRange != null && this.updateBatchData.form.timeRange.length === 2) {
  1285. this.updateBatchData.form.viewStartTime = this.updateBatchData.form.timeRange[0];
  1286. this.updateBatchData.form.viewEndTime = this.updateBatchData.form.timeRange[1];
  1287. }
  1288. updates(this.updateBatchData.form).then(response => {
  1289. this.msgSuccess("修改成功");
  1290. this.updateBatchData.open = false;
  1291. this.getList();
  1292. });
  1293. },
  1294. /** 删除按钮操作 */
  1295. handleDelete(row) {
  1296. const videoIds = row.videoId || this.ids;
  1297. this.$confirm('是否确认删除视频编号为"' + videoIds + '"的数据项?', "警告", {
  1298. confirmButtonText: "确定",
  1299. cancelButtonText: "取消",
  1300. type: "warning"
  1301. }).then(function () {
  1302. return delUserCourseVideo(videoIds);
  1303. }).then(() => {
  1304. this.getList();
  1305. this.msgSuccess("删除成功");
  1306. }).catch(() => {
  1307. });
  1308. },
  1309. /** 同步模板数据*/
  1310. handleSync() {
  1311. const courseId = this.courseId;
  1312. this.$confirm('是否同步课程数据至模板', "确认", {
  1313. confirmButtonText: "确定",
  1314. cancelButtonText: "取消",
  1315. type: "warning"
  1316. }).then(function () {
  1317. return syncTemplate(courseId);
  1318. }).then(() => {
  1319. this.getList();
  1320. this.msgSuccess("正在同步模板中!!请稍后!");
  1321. }).catch(() => {
  1322. });
  1323. },
  1324. handleCourseSort() {
  1325. getVideoListByCourseIdAll(this.queryParams.courseId).then(response => {
  1326. response.rows.forEach((item) => item.newCourseSort = item.courseSort);
  1327. this.userCourseVideoSortList = response.rows.sort((a, b) => a.courseSort - b.courseSort);
  1328. if (this.userCourseVideoSortList == null || this.userCourseVideoSortList.length == 0) {
  1329. this.$message.error("暂无课节天数")
  1330. } else {
  1331. this.openVideoSort = true;
  1332. }
  1333. })
  1334. },
  1335. onDragEndDay() {
  1336. this.userCourseVideoSortList.forEach((item, index) => {
  1337. item.newCourseSort = index + 1;
  1338. })
  1339. this.$forceUpdate()
  1340. },
  1341. saveSorts() {
  1342. let list = this.userCourseVideoSortList.filter(e => e.courseSort != e.newCourseSort).map(e => {
  1343. return {courseSort: e.newCourseSort, videoId: e.videoId}
  1344. })
  1345. this.loading3 = true;
  1346. sortCourseVideo(list).then(e => {
  1347. this.getList();
  1348. }).finally(() => {
  1349. this.userCourseVideoSortList = [];
  1350. this.openVideoSort = false;
  1351. })
  1352. },
  1353. openAdds() {
  1354. this.addBatchData.open = true;
  1355. this.getRootTypeList();
  1356. this.addBatchData.form = {
  1357. courseId: this.courseId,
  1358. };
  1359. // 重置选择顺序数组
  1360. this.addBatchData.select = [];
  1361. this.resourceList();
  1362. },
  1363. openBatchWatchIntegralDialog() {
  1364. if (!this.ids || this.ids.length === 0) {
  1365. this.$message.warning('请先勾选要修改的课节');
  1366. return;
  1367. }
  1368. this.batchWatchIntegral.form = {
  1369. watchDurationMinutes: 0,
  1370. integralReward: 0
  1371. };
  1372. this.batchWatchIntegral.open = true;
  1373. },
  1374. submitBatchWatchIntegral() {
  1375. const w = this.batchWatchIntegral.form.watchDurationMinutes;
  1376. const i = this.batchWatchIntegral.form.integralReward;
  1377. if (w === null || w === undefined || i === null || i === undefined) {
  1378. this.$message.warning('请填写观看时长与积分奖励');
  1379. return;
  1380. }
  1381. const videoIds = (this.ids || []).map(id => (typeof id === 'string' ? parseInt(id, 10) : id));
  1382. batchUpdateWatchIntegral({
  1383. courseId: this.courseId,
  1384. videoIds: videoIds,
  1385. watchDurationMinutes: w,
  1386. integralReward: i
  1387. }).then(response => {
  1388. if (response.code === 200) {
  1389. this.msgSuccess('修改成功');
  1390. this.batchWatchIntegral.open = false;
  1391. this.getList();
  1392. } else {
  1393. this.$message.error(response.msg || '修改失败');
  1394. }
  1395. });
  1396. },
  1397. getRootTypeList() {
  1398. const req = this.usePublicVideoLibrary ? getPublicCatePidList() : getCatePidList()
  1399. req.then(response => {
  1400. this.addBatchData.typeOptions = response.data
  1401. });
  1402. },
  1403. async changeCateType(val) {
  1404. this.addBatchData.queryParams.typeSubId = null
  1405. this.addBatchData.typeSubOptions = []
  1406. if (!val) {
  1407. return
  1408. }
  1409. const subReq = this.usePublicVideoLibrary ? getPublicCateListByPid(val) : getCateListByPid(val)
  1410. await subReq.then(response => {
  1411. this.addBatchData.typeSubOptions = response.data
  1412. })
  1413. },
  1414. resourceList() {
  1415. this.addBatchData.loading = true;
  1416. const api = this.usePublicVideoLibrary ? listPublicVideoResource : listVideoResource
  1417. api(this.addBatchData.queryParams).then(response => {
  1418. this.addBatchData.loading = false;
  1419. this.addBatchData.list = response.rows;
  1420. this.addBatchData.total = response.total;
  1421. });
  1422. },
  1423. batchVideoSave() {
  1424. if (this.addBatchData.select.length === 0) {
  1425. this.$message({
  1426. message: '请选择视频!!',
  1427. type: 'warning'
  1428. });
  1429. return
  1430. }
  1431. this.addBatchData.form.ids = this.addBatchData.select; // 按用户选择顺序提交
  1432. batchSaveVideo(this.addBatchData.form).then(response => {
  1433. this.addBatchData.open = false;
  1434. this.getList();
  1435. })
  1436. },
  1437. updateRedPageckeOpen() {
  1438. this.redData.open = true;
  1439. this.redData.loading = true;
  1440. this.redData.queryParams.courseId = this.courseId;
  1441. getVideoListByCourseId(this.redData.queryParams).then(response => {
  1442. if(!!response.rows && response.rows.length >0){
  1443. for(let i = 0; i < response.rows.length; i++){
  1444. if(!!response.rows[i].randomRedPacketRules){
  1445. this.$set(response.rows[i], 'randomRedPacketRulesArr', JSON.parse(response.rows[i].randomRedPacketRules)) ;
  1446. }
  1447. }
  1448. }
  1449. this.redData.list = response.rows;
  1450. console.log(this.redData.list);
  1451. this.redData.loading = false;
  1452. });
  1453. },
  1454. batchRedSave() {
  1455. batchUpdateRed(this.redData.list).then(response => {
  1456. this.redData.open = false;
  1457. this.getList();
  1458. })
  1459. },
  1460. /** 查看评论按钮操作 */
  1461. handleComment(row) {
  1462. this.commentDialog.courseId = row.courseId || this.courseId;
  1463. this.commentDialog.videoId = row.videoId;
  1464. this.commentDialog.title = `查看评论 - ${row.title}`;
  1465. this.commentDialog.open = true;
  1466. },
  1467. // 实时过滤金额输入,只允许两位小数
  1468. handleAmountInput(rule, field) {
  1469. let value = rule[field];
  1470. if (value === null || value === undefined) return;
  1471. // 转换为字符串处理
  1472. let str = value.toString();
  1473. // 移除除数字和小数点外的所有字符
  1474. str = str.replace(/[^0-9.]/g, '');
  1475. // 只保留一个小数点
  1476. const dotIndex = str.indexOf('.');
  1477. if (dotIndex !== -1) {
  1478. str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
  1479. }
  1480. // 限制小数点后最多两位
  1481. if (dotIndex !== -1 && str.length > dotIndex + 3) {
  1482. str = str.substring(0, dotIndex + 3);
  1483. }
  1484. // 转换回数字并更新
  1485. rule[field] = parseFloat(str) || 0;
  1486. },
  1487. deleteRule(index) {
  1488. this.$confirm("确定要删除这个区间吗?", "提示", {
  1489. confirmButtonText: "确定",
  1490. cancelButtonText: "取消",
  1491. type: "warning",
  1492. }).then(() => {
  1493. this.form.randomRedPacketRulesArr.splice(index, 1);
  1494. this.$message({
  1495. type: "success",
  1496. message: "删除成功!",
  1497. });
  1498. });
  1499. },
  1500. addRule(index) {
  1501. // 在当前行的后面插入一个新行
  1502. this.form.randomRedPacketRulesArr.splice(index + 1, 0, {
  1503. minAmount: 0.01,
  1504. maxAmount: 0.01,
  1505. weight: 100,
  1506. });
  1507. },
  1508. // 自定义校验规则:确保最大金额大于最小金额
  1509. validateMinAmount(rule, value, callback) {
  1510. // debugger;
  1511. // const maxAmount = this.form29.rules[].maxAmount
  1512. const index = rule.index;
  1513. const maxAmount = this.form.randomRedPacketRulesArr[index].maxAmount;
  1514. if (value > maxAmount) {
  1515. callback(new Error("最小金额不能大于最大金额"));
  1516. } else {
  1517. callback();
  1518. }
  1519. },
  1520. validateRules() {
  1521. this.form.randomRedPacketRulesArr.forEach((rule) => {
  1522. if (rule.minAmount === undefined || rule.minAmount < 0.01) {
  1523. rule.minAmount = 0.01;
  1524. }
  1525. if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
  1526. rule.maxAmount = rule.minAmount;
  1527. }
  1528. if (rule.weight === undefined || rule.weight < 1) {
  1529. rule.weight = 1;
  1530. }
  1531. });
  1532. },
  1533. /** 下架 **/
  1534. handleDown() {
  1535. const videoIds = this.ids;
  1536. this.$confirm('是否确认下架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1537. confirmButtonText: "确定",
  1538. cancelButtonText: "取消",
  1539. type: "warning"
  1540. }).then(function () {
  1541. return batchDownUserCourseVideo(videoIds);
  1542. }).then(() => {
  1543. this.getList();
  1544. this.msgSuccess("下架成功");
  1545. }).catch(() => {
  1546. });
  1547. },
  1548. /** 上架按钮操作 */
  1549. handleUp() {
  1550. const videoIds = this.ids;
  1551. this.$confirm('是否确认上架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1552. confirmButtonText: "确定",
  1553. cancelButtonText: "取消",
  1554. type: "warning"
  1555. }).then(function () {
  1556. return batchUpUserCourseVideo(videoIds);
  1557. }).then(() => {
  1558. this.getList();
  1559. this.msgSuccess("上架成功");
  1560. }).catch(function () {
  1561. });
  1562. },
  1563. /** 修改封面 **/
  1564. handleEditCover() {
  1565. this.batchEditCoverDialog.form = {
  1566. thumbnail: null
  1567. }
  1568. this.batchEditCoverDialog.visible = true
  1569. },
  1570. submitEditCoverForm() {
  1571. this.$refs["batchEditCoverDialogForm"].validate(valid => {
  1572. if (!valid) {
  1573. return;
  1574. }
  1575. const thumbnail = this.batchEditCoverDialog.form.thumbnail
  1576. const videoIds = this.ids
  1577. if (!thumbnail || thumbnail === '') {
  1578. this.$message({
  1579. message: '请上传封面!',
  1580. type: 'warning'
  1581. });
  1582. return
  1583. }
  1584. if (!videoIds || videoIds.length === 0) {
  1585. this.$message({
  1586. message: '请选择小节!',
  1587. type: 'warning'
  1588. });
  1589. return
  1590. }
  1591. const params = {
  1592. thumbnail: thumbnail,
  1593. videoIds: videoIds
  1594. }
  1595. batchEditCover(params).then(response => {
  1596. this.msgSuccess("修改成功")
  1597. this.batchEditCoverDialog.visible = false
  1598. this.getList();
  1599. });
  1600. });
  1601. },
  1602. cancelEditCoverForm() {
  1603. this.batchEditCoverDialog.visible = false
  1604. this.batchEditCoverDialog.form = {
  1605. thumbnail: null,
  1606. }
  1607. },
  1608. // 复制销售易链接
  1609. openXsyDialog(row) {
  1610. // 构建JSON字符串
  1611. const courseData = {
  1612. videoId: row.videoId,
  1613. courseId: row.courseId,
  1614. companyId: 0
  1615. };
  1616. this.xsyParams = `pages_course/videoxsy?course=${JSON.stringify(courseData)}`;
  1617. this.xsyDialogVisible = true;
  1618. },
  1619. // 复制销售易参数
  1620. copyXsyParams() {
  1621. this.copyLink(this.xsyParams);
  1622. },
  1623. copyLink(url) {
  1624. const link = url;
  1625. // navigator clipboard 需要https等安全上下文
  1626. if (navigator.clipboard && window.isSecureContext) {
  1627. // navigator clipboard 向剪贴板写文本
  1628. navigator.clipboard.writeText(link).then(() => {
  1629. this.$message.success('链接已复制到剪贴板');
  1630. });
  1631. } else {
  1632. // document.execCommand('copy') 向剪贴板写文本
  1633. let input = document.createElement('input')
  1634. input.style.position = 'fixed'
  1635. input.style.top = '-10000px'
  1636. input.style.zIndex = '-999'
  1637. document.body.appendChild(input)
  1638. input.value = link
  1639. input.focus()
  1640. input.select()
  1641. try {
  1642. let result = document.execCommand('copy')
  1643. document.body.removeChild(input)
  1644. if (!result || result === 'unsuccessful') {
  1645. this.$message.error('复制失败');
  1646. console.log('复制失败')
  1647. } else {
  1648. this.$message.success('链接已复制到剪贴板');
  1649. console.log('复制成功')
  1650. }
  1651. } catch (e) {
  1652. document.body.removeChild(input)
  1653. alert('当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作')
  1654. }
  1655. }
  1656. },
  1657. // 打开精选留言导入弹窗
  1658. openUserCommentDialog() {
  1659. if (!this.form.courseId || !this.form.videoId) {
  1660. this.$message.warning('请先保存课节后再查看用户留言')
  1661. return
  1662. }
  1663. this.userCommentDialog.courseId = this.form.courseId
  1664. this.userCommentDialog.videoId = this.form.videoId
  1665. this.userCommentDialog.title = `用户留言 - ${this.form.title || ''}`
  1666. this.userCommentDialog.open = true
  1667. },
  1668. onUserCommentDialogOpened() {
  1669. this.$nextTick(() => {
  1670. if (this.$refs.userCourseSectionComment) {
  1671. this.$refs.userCourseSectionComment.handleQuery()
  1672. }
  1673. })
  1674. },
  1675. openCommentImportDialog() {
  1676. this.commentImportDialog.visible = true;
  1677. this.commentImportDialog.file = null;
  1678. this.commentImportDialog.fileList = [];
  1679. this.commentImportDialog.courseId = this.form.courseId;
  1680. this.commentImportDialog.videoId = this.form.videoId;
  1681. // 加载历史留言
  1682. listFeaturedComments(this.form.courseId, this.form.videoId).then(res => {
  1683. this.commentImportDialog.historyList = res.rows || [];
  1684. });
  1685. },
  1686. // 选择导入文件
  1687. handleCommentFileChange(file) {
  1688. this.commentImportDialog.file = file.raw;
  1689. },
  1690. // 删除精选留言
  1691. handleDeleteComment(row) {
  1692. this.$confirm('确认删除该条精选留言?', '提示', {type: 'warning'}).then(() => {
  1693. delUserCourseComment(row.commentId).then(res => {
  1694. if (res.code === 200) {
  1695. this.$message.success('删除成功');
  1696. // 刷新历史列表
  1697. listFeaturedComments(this.commentImportDialog.courseId, this.commentImportDialog.videoId).then(res2 => {
  1698. this.commentImportDialog.historyList = res2.rows || [];
  1699. });
  1700. } else {
  1701. this.$message.error(res.msg || '删除失败');
  1702. }
  1703. });
  1704. }).catch(() => {});
  1705. },
  1706. // 下载Word导入模板
  1707. handleDownloadTemplate() {
  1708. downloadCommentImportTemplate().then(res => {
  1709. const blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
  1710. const url = window.URL.createObjectURL(blob);
  1711. const link = document.createElement('a');
  1712. link.href = url;
  1713. link.download = '精选留言导入模板.xlsx';
  1714. link.click();
  1715. window.URL.revokeObjectURL(url);
  1716. });
  1717. },
  1718. // 确认导入精选留言
  1719. handleImportComments() {
  1720. if (!this.commentImportDialog.file) {
  1721. this.$message.warning('请先选择要导入的Excel文件');
  1722. return;
  1723. }
  1724. this.commentImportDialog.loading = true;
  1725. importComments(this.commentImportDialog.courseId, this.commentImportDialog.videoId, this.commentImportDialog.file).then(res => {
  1726. if (res.code === 200) {
  1727. this.$message.success(res.msg);
  1728. // 刷新历史列表
  1729. listFeaturedComments(this.commentImportDialog.courseId, this.commentImportDialog.videoId).then(res2 => {
  1730. this.commentImportDialog.historyList = res2.rows || [];
  1731. });
  1732. } else {
  1733. this.$message.error(res.msg);
  1734. }
  1735. }).finally(() => {
  1736. this.commentImportDialog.loading = false;
  1737. });
  1738. },
  1739. }
  1740. }
  1741. </script>
  1742. <style scoped>
  1743. .form-unit {
  1744. margin-left: 8px;
  1745. color: #606266;
  1746. }
  1747. .form-hint {
  1748. margin-left: 12px;
  1749. color: #909399;
  1750. font-size: 12px;
  1751. }
  1752. .batch-watch-tip {
  1753. margin: 0 0 16px 0;
  1754. color: #606266;
  1755. font-size: 13px;
  1756. }
  1757. .avatar-uploader-icon {
  1758. display: flex;
  1759. align-items: center;
  1760. justify-content: center;
  1761. }
  1762. .xsy-textarea >>> .el-textarea__inner {
  1763. background-color: #f5f5f5 !important;
  1764. resize: none !important;
  1765. }
  1766. </style>
  1767. <style>
  1768. .avatar-uploader .el-upload {
  1769. border: 1px dashed #d9d9d9;
  1770. border-radius: 6px;
  1771. cursor: pointer;
  1772. position: relative;
  1773. overflow: hidden;
  1774. }
  1775. .avatar-uploader .el-upload:hover {
  1776. border-color: #409EFF;
  1777. }
  1778. .avatar-uploader-icon {
  1779. font-size: 28px;
  1780. color: #8c939d;
  1781. width: 150px;
  1782. height: 150px;
  1783. line-height: 150px;
  1784. text-align: center;
  1785. }
  1786. .red:hover {
  1787. color: #dbdbdb !important;
  1788. }
  1789. .red {
  1790. background-color: #F56C6C !important;
  1791. color: #fff !important;
  1792. }
  1793. </style>