index.vue 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075
  1. <template>
  2. <div class="app-container">
  3. <el-container>
  4. <!-- 左侧区域 -->
  5. <el-aside width="360px" class="left-aside">
  6. <!-- 顶部区域 -->
  7. <div class="left-header">
  8. <div class="left-header-top">
  9. <el-button type="primary" class="search-btn" @click="handleLeftQuery" v-hasPermi="['course:trainingCamp:list']">搜索</el-button>
  10. <el-button type="primary" style="width: 50%" icon="el-icon-plus" @click="handleAddTrainingCamp" v-hasPermi="['course:trainingCamp:add']">新建训练营</el-button>
  11. </div>
  12. <div class="search-input-wrapper">
  13. <el-input
  14. v-model="leftQueryParams.trainingCampName"
  15. placeholder="请输入训练营名称"
  16. prefix-icon="el-icon-search"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleLeftQuery"
  20. />
  21. </div>
  22. <div class="sort-wrapper">
  23. <span class="sort-label">排序方式</span>
  24. <el-select v-model="leftQueryParams.scs"
  25. placeholder="按序号倒序"
  26. size="small"
  27. class="sort-select"
  28. @change="handleSortChange"
  29. >
  30. <el-option label="按序号倒序" value="order_number(desc),training_camp_id(desc)" />
  31. <el-option label="按序号顺序" value="order_number(asc),training_camp_id(desc)" />
  32. </el-select>
  33. </div>
  34. </div>
  35. <!-- 训练营列表 -->
  36. <div class="camp-list" ref="campList" @scroll="handleScroll" v-loading="leftLoading">
  37. <div
  38. v-for="(item, index) in campList"
  39. :key="index"
  40. class="camp-item"
  41. :class="{ 'active': activeCampIndex === index }"
  42. @click="selectCamp(index)"
  43. >
  44. <div class="camp-content">
  45. <div class="camp-title">
  46. <i class="el-icon-s-flag camp-icon"></i>
  47. {{ item.trainingCampName }}
  48. </div>
  49. <div class="camp-info">
  50. <span>序号:{{ item.orderNumber }}</span>
  51. <span>最新营期开课:{{ item.recentDate || '-' }}</span>
  52. </div>
  53. <div class="camp-stats">
  54. <span class="stat-item">
  55. <i class="el-icon-s-data"></i>
  56. 营期数:{{ item.periodCount || 0 }}
  57. </span>
  58. <span class="stat-item">
  59. <i class="el-icon-user"></i>
  60. 会员总数:{{ item.vipCount || 0 }}
  61. </span>
  62. </div>
  63. </div>
  64. <div class="camp-actions">
  65. <el-button type="text" class="action-btn delete-btn" @click.stop="handleDeleteCamp(item)" v-hasPermi="['course:trainingCamp:remove']">删除</el-button>
  66. <!-- <el-button type="text" class="action-btn copy-btn" @click.stop="handleCopyCamp(item)" v-hasPermi="['course:trainingCamp:copy']">复制</el-button>-->
  67. <el-button type="text" class="action-btn copy-btn" @click.stop="handleEditCamp(item)" v-hasPermi="['course:trainingCamp:edit']">编辑</el-button>
  68. </div>
  69. </div>
  70. <!-- 底部加载更多提示 -->
  71. <div v-if="loadingMore" class="loading-more">
  72. <i class="el-icon-loading"></i>
  73. <span>加载中...</span>
  74. </div>
  75. <!-- 所有数据加载完毕提示 -->
  76. <div v-if="campList.length > 0 && !leftQueryParams.hasNextPage && !loadingMore" class="no-more-data">
  77. <span>—— 已加载全部训练营 ——</span>
  78. </div>
  79. </div>
  80. </el-aside>
  81. <!-- 右侧区域 -->
  82. <el-main>
  83. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  84. <el-form-item label="营期名称" prop="periodName">
  85. <el-input
  86. v-model="queryParams.periodName"
  87. placeholder="请输入营期名称"
  88. clearable
  89. size="small"
  90. @keyup.enter.native="handleQuery"
  91. />
  92. </el-form-item>
  93. <el-form-item label="公司" prop="companyIdList">
  94. <el-select v-model="queryParams.companyIdList" placeholder="请选择公司" clearable size="small" multiple>
  95. <el-option
  96. v-for="item in companyOptions"
  97. :key="item.companyId"
  98. :label="item.companyName"
  99. :value="item.companyId"
  100. />
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label="开营日期开始" prop="periodStartingTime" label-width="120px">
  104. <el-date-picker clearable size="small" style="width: 200px"
  105. v-model="queryParams.periodStartingTime"
  106. type="date"
  107. value-format="yyyy-MM-dd"
  108. placeholder="请选择开营日期开始时间">
  109. </el-date-picker>
  110. </el-form-item>
  111. <el-form-item label="开营日期结束" prop="periodEndTime" label-width="120px">
  112. <el-date-picker clearable size="small" style="width: 300px"
  113. v-model="queryParams.periodEndTime"
  114. type="date"
  115. value-format="yyyy-MM-dd"
  116. placeholder="请选择开营日期结束时间">
  117. </el-date-picker>
  118. </el-form-item>
  119. <el-form-item>
  120. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['course:period:list']">搜索</el-button>
  121. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  122. </el-form-item>
  123. </el-form>
  124. <el-row :gutter="10" class="mb8">
  125. <el-col :span="1.5">
  126. <el-button
  127. type="primary"
  128. plain
  129. icon="el-icon-plus"
  130. size="mini"
  131. @click="handleAdd"
  132. v-hasPermi="['course:period:add']"
  133. >新增</el-button>
  134. </el-col>
  135. <el-col :span="1.5">
  136. <el-button
  137. type="warning"
  138. plain
  139. icon="el-icon-download"
  140. size="mini"
  141. @click="handleExport"
  142. v-hasPermi="['course:period:export']"
  143. >导出</el-button>
  144. </el-col>
  145. <el-col :span="1.5">
  146. <el-button
  147. type="primary"
  148. plain
  149. icon="el-icon-edit"
  150. size="mini"
  151. @click="handleBatchSetRedPacket"
  152. v-hasPermi="['course:period:setRedPacket']"
  153. :disabled="batchSetRedPacketDisabled"
  154. >批量设置红包</el-button>
  155. </el-col>
  156. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  157. </el-row>
  158. <el-table v-loading="loading" :data="periodList" @selection-change="handleSelectionChange" border>
  159. <el-table-column type="selection" width="55" align="center" />
  160. <el-table-column label="营期名称" align="center" prop="periodName" />
  161. <el-table-column label="公司名称" align="center" prop="companyName" />
  162. <el-table-column label="营期状态" align="center" prop="periodStatus" width="100" :formatter="periodStatusFormatter" />
  163. <el-table-column label="营期线" align="center" prop="periodLine" width="180" />
  164. <el-table-column label="开营开始时间" align="center" prop="periodStartingTime" width="180" />
  165. <el-table-column label="开营结束时间" align="center" prop="periodEndTime" width="180" />
  166. <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
  167. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  168. <template slot-scope="scope">
  169. <el-button
  170. size="mini"
  171. type="text"
  172. icon="el-icon-edit"
  173. @click="handleUpdate(scope.row)"
  174. v-hasPermi="['course:period:edit']"
  175. >修改</el-button>
  176. <!-- <el-button-->
  177. <!-- size="mini"-->
  178. <!-- type="text"-->
  179. <!-- icon="el-icon-edit"-->
  180. <!-- @click="handleCourse(scope.row)"-->
  181. <!-- v-hasPermi="['course:period:edit']"-->
  182. <!-- >课程管理</el-button>-->
  183. <!-- <el-button-->
  184. <!-- size="mini"-->
  185. <!-- type="text"-->
  186. <!-- icon="el-icon-money"-->
  187. <!-- @click="setRedPacket(scope.row)"-->
  188. <!-- >设置红包</el-button>-->
  189. <el-button
  190. size="mini"
  191. type="text"
  192. icon="el-icon-setting"
  193. @click="handlePeriodSettings(scope.row)"
  194. >营期相关设置</el-button>
  195. <el-button
  196. size="mini"
  197. type="text"
  198. icon="el-icon-circle-close"
  199. @click="handleClosePeriod(scope.row)"
  200. v-hasPermi="['course:period:close']"
  201. >结束营期</el-button>
  202. <el-button
  203. size="mini"
  204. type="text"
  205. icon="el-icon-delete"
  206. @click="handleDelete(scope.row)"
  207. v-hasPermi="['course:period:remove']"
  208. >删除</el-button>
  209. </template>
  210. </el-table-column>
  211. </el-table>
  212. <pagination
  213. v-show="total>0"
  214. :total="total"
  215. :page.sync="queryParams.pageNum"
  216. :limit.sync="queryParams.pageSize"
  217. @pagination="getList"
  218. />
  219. </el-main>
  220. </el-container>
  221. <!-- 添加或修改会员营期对话框-->
  222. <el-drawer :title="title" :visible.sync="open" size="700px" append-to-body>
  223. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  224. <el-form-item label="营期名称" prop="periodName">
  225. <el-input v-model="form.periodName" placeholder="请输入营期名称" />
  226. </el-form-item>
  227. <el-form-item label="公司" prop="companyId">
  228. <el-select v-model="form.companyId" placeholder="请选择公司" multiple>
  229. <el-option
  230. v-for="item in companyOptions"
  231. :key="item.companyId"
  232. :label="item.companyName"
  233. :value="item.companyId"
  234. />
  235. </el-select>
  236. </el-form-item>
  237. <el-form-item label="课程风格" prop="courseStyle">
  238. <image-upload v-model="form.courseStyle" :limit="1" />
  239. </el-form-item>
  240. <el-form-item label="直播间风格" prop="liveRoomStyle">
  241. <image-upload v-model="form.liveRoomStyle" :limit="1" />
  242. </el-form-item>
  243. <el-form-item label="课程LOGO" prop="courseLogo">
  244. <image-upload v-model="form.courseLogo" :limit="1" />
  245. </el-form-item>
  246. <!-- <el-form-item label="红包发放方式" prop="redPacketGrantMethod">-->
  247. <!-- <el-radio-group v-model="form.redPacketGrantMethod">-->
  248. <!-- <el-radio :label="1" >按课程</el-radio>-->
  249. <!-- <el-radio :label="2" >按营期</el-radio>-->
  250. <!-- </el-radio-group>-->
  251. <!-- </el-form-item>-->
  252. <el-form-item label="营期类型" prop="periodType">
  253. <el-radio-group v-model="form.periodType">
  254. <el-radio :label="1" >多课程</el-radio>
  255. <el-radio :label="2" >单课程</el-radio>
  256. </el-radio-group>
  257. </el-form-item>
  258. <el-form-item label="APP端看课">
  259. <el-switch
  260. v-model="form.appViewEnabled"
  261. :active-value="1"
  262. :inactive-value="0"
  263. active-text="开启"
  264. inactive-text="关闭"
  265. ></el-switch>
  266. </el-form-item>
  267. <el-form-item label="小程序端看课">
  268. <el-switch
  269. v-model="form.miniProgramViewEnabled"
  270. :active-value="1"
  271. :inactive-value="0"
  272. active-text="开启"
  273. inactive-text="关闭"
  274. ></el-switch>
  275. </el-form-item>
  276. <el-form-item label="H5端看课">
  277. <el-switch
  278. v-model="form.h5ViewEnabled"
  279. :active-value="1"
  280. :inactive-value="0"
  281. active-text="开启"
  282. inactive-text="关闭"
  283. ></el-switch>
  284. </el-form-item>
  285. <el-form-item label="销售提前查看天数" prop="maxViewNum">
  286. <el-input-number :min="0" v-model="form.maxViewNum" style="width: 200px" />
  287. </el-form-item>
  288. <el-form-item label="开营日期" prop="periodStartingTime">
  289. <el-date-picker
  290. :style="{display: form.periodType == 1 ? '' : 'none !important'}"
  291. v-model="form.dateRange"
  292. @change="timeChange(1)"
  293. type="daterange"
  294. range-separator="至"
  295. start-placeholder="开始日期"
  296. end-placeholder="结束日期"
  297. value-format="yyyy-MM-dd"
  298. :picker-options="{}"
  299. :clearable="false"
  300. >
  301. </el-date-picker>
  302. <el-date-picker
  303. :disabled = "isDisabledDateRange"
  304. :style="{display: form.periodType == 2 ? '' : 'none !important'}"
  305. @change="timeChange(2)"
  306. v-model="form.date"
  307. type="date"
  308. value-format="yyyy-MM-dd"
  309. placeholder="选择日期"
  310. :picker-options="{}"
  311. :clearable="false"
  312. >
  313. </el-date-picker>
  314. </el-form-item>
  315. <el-form-item prop="periodLine">
  316. <span slot="label">
  317. 营期线
  318. <el-tooltip content="营期首次播放课程的日期" placement="top">
  319. <i class="el-icon-question" style="margin-left: 5px; color: #909399; cursor: help;"></i>
  320. </el-tooltip>
  321. </span>
  322. <el-date-picker
  323. v-model="form.periodLine"
  324. type="date"
  325. placeholder="请选择营期线"
  326. value-format="yyyy-MM-dd"
  327. :clearable="true">
  328. </el-date-picker>
  329. </el-form-item>
  330. </el-form>
  331. <div class="drawer-footer">
  332. <el-button type="primary" @click="submitForm">确 定</el-button>
  333. <el-button @click="cancel">取 消</el-button>
  334. </div>
  335. </el-drawer>
  336. <!-- 添加训练营对话框 -->
  337. <el-dialog :title="campForm.trainingCampId ? '修改训练营' : '新建训练营'" :visible.sync="campDialogVisible" width="500px" append-to-body>
  338. <el-form ref="campForm" :model="campForm" :rules="campRules" label-width="100px">
  339. <el-form-item label="训练营名称" prop="trainingCampName">
  340. <el-input v-model="campForm.trainingCampName" placeholder="请输入训练营名称" />
  341. </el-form-item>
  342. </el-form>
  343. <div slot="footer" class="dialog-footer">
  344. <el-button type="primary" @click="submitCampForm">确 定</el-button>
  345. <el-button @click="cancelCampForm">取 消</el-button>
  346. </div>
  347. </el-dialog>
  348. <!-- &lt;!&ndash; 添加或修改会员营期对话框&ndash;&gt;-->
  349. <!-- <el-dialog title="课程管理" :visible.sync="course.open" width="75%" top="10px" append-to-body style="padding-bottom: 10px">-->
  350. <!-- <el-row :gutter="10" class="mb8">-->
  351. <!-- <el-col :span="1.5">-->
  352. <!-- <el-button-->
  353. <!-- v-if="(getDiff(course.row.periodStartingTime, course.row.periodEndTime) - course.total) > 0"-->
  354. <!-- type="primary"-->
  355. <!-- icon="el-icon-plus"-->
  356. <!-- size="mini"-->
  357. <!-- @click="handleAddCourse"-->
  358. <!-- v-hasPermi="['course:period:add']"-->
  359. <!-- >添加课程</el-button>-->
  360. <!-- </el-col>-->
  361. <!-- </el-row>-->
  362. <!-- <el-table v-loading="course.loading" :data="course.list">-->
  363. <!-- <el-table-column label="课程" align="center" prop="courseName" width="180" />-->
  364. <!-- <el-table-column label="小节" align="center" prop="videoName" />-->
  365. <!-- <el-table-column label="营期时间" align="center" prop="dayDate" width="150" />-->
  366. <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="150" />-->
  367. <!-- </el-table>-->
  368. <!-- <div slot="footer" class="dialog-footer">-->
  369. <!--&lt;!&ndash; <el-button type="primary" @click="saveCourseData">保存</el-button>&ndash;&gt;-->
  370. <!-- </div>-->
  371. <!-- </el-dialog>-->
  372. <!-- 添加课程对话框-->
  373. <el-dialog title="添加课程" :visible.sync="course.addOpen" width="500px" append-to-body>
  374. <el-form ref="courseAddForm" :model="course.form" :rules="courseAddRules" label-width="100px">
  375. <el-form-item label="课程" prop="courseId">
  376. <el-select filterable v-model="course.form.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(course.form.courseId)" style="width: 100%" :value-key="'dictValue'">
  377. <el-option
  378. v-for="dict in courseList"
  379. :key="dict.dictValue"
  380. :label="dict.dictLabel"
  381. :value="parseInt(dict.dictValue)"
  382. />
  383. </el-select>
  384. </el-form-item>
  385. <el-form-item label="小节" prop="videoIds">
  386. <el-select filterable v-model="course.form.videoIds" placeholder="请选择小节" :multiple-limit="getDiff(course.row.periodStartingTime, course.row.periodEndTime) - course.total" multiple clearable size="small" style="width: 100%" :value-key="'dictValue'">
  387. <el-option
  388. v-for="dict in videoList"
  389. :key="dict.dictValue"
  390. :label="dict.dictLabel"
  391. :value="parseInt(dict.dictValue)"
  392. />
  393. </el-select>
  394. </el-form-item>
  395. <el-form-item label="无需注册小节" prop="noRegisterVideoIds">
  396. <el-select
  397. filterable
  398. v-model="course.form.noRegisterVideoIds"
  399. placeholder="请选择无需注册的小节"
  400. multiple
  401. clearable
  402. size="small"
  403. style="width: 100%"
  404. :value-key="'dictValue'"
  405. :disabled="!course.form.videoIds || course.form.videoIds.length === 0">
  406. <el-option
  407. v-for="dict in filteredVideoList"
  408. :key="dict.dictValue"
  409. :label="dict.dictLabel"
  410. :value="parseInt(dict.dictValue)"
  411. />
  412. </el-select>
  413. <p v-if="!course.form.videoIds || course.form.videoIds.length === 0" style="color: #909399; font-size: 12px; margin: 5px 0 0;">请先选择小节</p>
  414. </el-form-item>
  415. <el-form-item label="看课时间" prop="timeRange">
  416. <el-time-picker
  417. is-range
  418. v-model="course.form.timeRange"
  419. :picker-options="{
  420. selectableRange: '00:00:00 - 23:59:59'
  421. }"
  422. range-separator="至"
  423. start-placeholder="开始时间"
  424. value-format="HH:mm:ss"
  425. end-placeholder="结束时间">
  426. </el-time-picker>
  427. </el-form-item>
  428. <el-form-item v-if="joinTimeSwitch" label="领取红包时间" prop="lastJoinTime">
  429. <el-time-picker
  430. v-model="course.form.joinTime"
  431. value-format="HH:mm:ss"
  432. placeholder="选择时间范围">
  433. </el-time-picker>
  434. <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
  435. </el-form-item>
  436. </el-form>
  437. <div slot="footer" class="dialog-footer">
  438. <el-button type="primary" @click="submitCourseForm">确 定</el-button>
  439. <el-button @click="closeAddCourse">取 消</el-button>
  440. </div>
  441. </el-dialog>
  442. <el-dialog title="修改看课时间" :visible.sync="updateCourse.open" width="600px" append-to-body>
  443. <el-form ref="courseUpdateForm" :model="updateCourse.form" :rules="courseUpdateRules" label-width="100px">
  444. <el-form-item label="看课时间" prop="timeRange" label-width="110px">
  445. <el-date-picker
  446. v-model="updateCourse.form.timeRange"
  447. type="datetimerange"
  448. range-separator="至"
  449. start-placeholder="开始时间"
  450. end-placeholder="结束时间"
  451. value-format="yyyy-MM-dd HH:mm:ss"
  452. :default-time="['00:00:00', '23:59:59']"
  453. :picker-options="{
  454. shortcuts: [{
  455. text: '今天',
  456. onClick(picker) {
  457. const end = new Date();
  458. const start = new Date();
  459. picker.$emit('pick', [start, end]);
  460. }
  461. }]
  462. }"
  463. >
  464. </el-date-picker>
  465. </el-form-item>
  466. <el-form-item v-if="joinTimeSwitch" label="领取红包时间" prop="joinTime" label-width="110px">
  467. <el-date-picker
  468. v-model="updateCourse.form.joinTime"
  469. type="datetime"
  470. placeholder="选择时间"
  471. value-format="yyyy-MM-dd HH:mm:ss"
  472. :default-time="'23:59:59'"
  473. >
  474. </el-date-picker>
  475. <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
  476. </el-form-item>
  477. </el-form>
  478. <div slot="footer" class="dialog-footer">
  479. <el-button type="primary" @click="submitUpdateCourseForm">确 定</el-button>
  480. <el-button @click="closeUpdateCourse">取 消</el-button>
  481. </div>
  482. </el-dialog>
  483. <el-dialog title="修改营期时间" :visible.sync="updatePeriodDate.open" width="500px" append-to-body>
  484. <el-form ref="courseUpdateForm" :model="updatePeriodDate.form" label-width="100px">
  485. <el-form-item label="营期时间" prop="dayDate">
  486. <el-date-picker
  487. v-model="updatePeriodDate.form.dayDate"
  488. :selectableRange="updatePeriodDate.form.dayDate"
  489. value-format="yyyy-MM-dd"
  490. type="date"
  491. placeholder="选择日期">
  492. </el-date-picker>
  493. </el-form-item>
  494. </el-form>
  495. <div slot="footer" class="dialog-footer">
  496. <el-button type="primary" @click="updatePeriodDateSubmit">确 定</el-button>
  497. <el-button @click="updatePeriodDate.open = false">取 消</el-button>
  498. </div>
  499. </el-dialog>
  500. <!-- <red-packet-->
  501. <!-- :visible.sync="redPacketVisible"-->
  502. <!-- :periodId="currentRedPacketData.periodId"-->
  503. <!-- :videoId="currentRedPacketData.videoId"-->
  504. <!-- @success="handleRedPacketSuccess"-->
  505. <!-- />-->
  506. <!-- 营期相关设置抽屉 -->
  507. <el-drawer
  508. title="营期相关设置"
  509. :visible.sync="periodSettingsVisible"
  510. direction="rtl"
  511. size="74%"
  512. :destroy-on-close="true"
  513. append-to-body
  514. custom-class="period-settings-drawer"
  515. >
  516. <div class="drawer-content" style="margin-left: 25px">
  517. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  518. <el-tab-pane label="课程管理" name="course">
  519. <el-row :gutter="10" class="mb8">
  520. <el-col :span="1.5">
  521. <el-button
  522. v-if="(getDiff(periodSettingsData.periodStartingTime, periodSettingsData.periodEndTime) - course.total) > 0"
  523. type="primary"
  524. icon="el-icon-plus"
  525. size="mini"
  526. @click="handleAddCourse"
  527. v-hasPermi="['course:period:addCourse']"
  528. >添加课程</el-button>
  529. </el-col>
  530. <!-- <el-col :span="1.5">-->
  531. <!-- <el-button-->
  532. <!-- type="primary"-->
  533. <!-- size="mini"-->
  534. <!-- :disabled="updateCourse.ids.length <= 0"-->
  535. <!-- @click="handleUpdatePeriodDate"-->
  536. <!-- >修改营期时间</el-button>-->
  537. <!-- </el-col>-->
  538. <el-col :span="1.5">
  539. <el-button
  540. type="primary"
  541. size="mini"
  542. :disabled="updateCourse.ids.length <= 0"
  543. @click="handleUpdateCourse"
  544. v-hasPermi="['course:period:updateCourseTime']"
  545. >修改看课时间</el-button>
  546. </el-col>
  547. <el-col :span="1.5">
  548. <el-button
  549. type="warning"
  550. size="mini"
  551. icon="el-icon-delete"
  552. :disabled="updateCourse.ids.length <= 0"
  553. @click="handleDeleteCourse"
  554. v-hasPermi="['course:period:dayRemove']"
  555. >删除课程</el-button>
  556. </el-col>
  557. </el-row>
  558. <el-table ref="courseTable" v-loading="course.loading" :data="course.list" @selection-change="handleSelectionCourseChange" border>
  559. <el-table-column type="selection" width="55" align="center" />
  560. <el-table-column label="课程" align="center" prop="courseName" width="180" />
  561. <el-table-column label="小节" align="center" prop="videoName" />
  562. <el-table-column label="开课状态" align="center" prop="status" width="100" :formatter="courseStatusFormatter" />
  563. <el-table-column label="是否开启注册链接" align="center" prop="registrationSwitch" width="180" :formatter="registrationSwitchFormatter" />
  564. <el-table-column label="营期时间" align="center" prop="dayDate" width="100"/>
  565. <el-table-column label="开始时间" align="center" prop="startDateTime" width="100">
  566. <!-- <template slot-scope="scope">-->
  567. <!-- <el-tag>{{scope.row.startDateTime}}</el-tag>-->
  568. <!-- </template>-->
  569. </el-table-column>
  570. <el-table-column label="结束时间" align="center" prop="endDateTime" width="100">
  571. <!-- <template slot-scope="scope">-->
  572. <!-- <el-tag type="success">{{parseTime(scope.row.endDateTime, '{h}:{i}:{s}')}}</el-tag>-->
  573. <!-- </template>-->
  574. </el-table-column>
  575. <el-table-column label="领取红包时间" align="center" prop="lastJoinTime" width="160">
  576. <template slot-scope="scope">
  577. <el-tag type="danger">{{scope.row.lastJoinTime}}</el-tag>
  578. </template>
  579. </el-table-column>
  580. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  581. <template slot-scope="scope">
  582. <el-button
  583. size="mini"
  584. type="text"
  585. icon="el-icon-top"
  586. @click="handleTop(scope.row)"
  587. v-hasPermi="['course:period:courseMove']"
  588. >上移</el-button>
  589. <el-button
  590. size="mini"
  591. type="text"
  592. icon="el-icon-bottom"
  593. @click="handleBottom(scope.row)"
  594. v-hasPermi="['course:period:courseMove']"
  595. >下移</el-button>
  596. <el-button
  597. size="mini"
  598. type="text"
  599. icon="el-icon-edit"
  600. @click="handleUpdateDate(scope.row)"
  601. >修改营期时间</el-button>
  602. <el-button
  603. size="mini"
  604. type="text"
  605. icon="el-icon-delete"
  606. @click="handleDeleteCourse(scope.row)"
  607. v-hasPermi="['course:period:dayRemove']"
  608. >删除课程</el-button>
  609. </template>
  610. </el-table-column>
  611. </el-table>
  612. <pagination
  613. v-show="course.total > 0"
  614. :total="course.total"
  615. :page.sync="course.queryParams.pageNum"
  616. :limit.sync="course.queryParams.pageSize"
  617. @pagination="getCourseList"
  618. style="height: 40px"
  619. />
  620. </el-tab-pane>
  621. <el-tab-pane label="公司列表" name="company">
  622. <red-packet
  623. :visible.sync="redPacketVisible"
  624. :activeTab="activeTab"
  625. :periodId="periodSettingsData.periodId"
  626. @success="handleRedPacketSuccess"
  627. />
  628. </el-tab-pane>
  629. <el-tab-pane label="课程统计" name="statistics">
  630. <course-statistics
  631. :periodId="periodSettingsData.periodId"
  632. :active="activeTab === 'statistics'"
  633. />
  634. </el-tab-pane>
  635. </el-tabs>
  636. </div>
  637. </el-drawer>
  638. <batch-red-packet
  639. :visible.sync="batchRedPacketVisible"
  640. :selected-data="selectedPeriods"
  641. @success="handleBatchRedPacketSuccess"
  642. />
  643. </div>
  644. </template>
  645. <script>
  646. import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod} from "@/api/course/userCoursePeriod";
  647. import {getCompanyList} from "@/api/company/company";
  648. import { listCamp, addCamp, editCamp, delCamp, copyCamp } from "@/api/course/userCourseCamp";
  649. import { courseList,videoList } from '@/api/course/courseRedPacketLog'
  650. import RedPacket from './redPacket.vue'
  651. import BatchRedPacket from './batchRedPacket.vue'
  652. import CourseStatistics from './statistics.vue'
  653. import Da from "element-ui/src/locale/lang/da";
  654. import { getConfigByKey } from '@/api/system/config'
  655. export default {
  656. name: "Period",
  657. components: {
  658. RedPacket,
  659. BatchRedPacket,
  660. CourseStatistics
  661. },
  662. data() {
  663. return {
  664. // 遮罩层
  665. loading: true,
  666. updateDateOpen: false,
  667. // 左侧遮罩层
  668. leftLoading: true,
  669. // 选中数组
  670. ids: [],
  671. // 非单个禁用
  672. single: true,
  673. // 非多个禁用
  674. multiple: true,
  675. // 显示搜索条件
  676. showSearch: true,
  677. // 总条数
  678. total: 0,
  679. // 左侧总条数
  680. leftTotal: 0,
  681. // 会员营期表格数据
  682. periodList: [],
  683. // 左侧列表数据
  684. leftList: [],
  685. videoList: [],
  686. // 弹出层标题
  687. title: "",
  688. isDisabledDateRange: false, //是否禁用开营日期
  689. // 是否显示弹出层
  690. open: false,
  691. // 查询参数
  692. queryParams: {
  693. pageNum: 1,
  694. pageSize: 10,
  695. periodName: null,
  696. periodStartingTime: null,
  697. periodEndTime: null,
  698. companyIdList: []
  699. },
  700. // 左侧查询参数
  701. leftQueryParams: {
  702. pageNum: 1,
  703. pageSize: 10,
  704. hasNextPage: false,
  705. scs: 'order_number(desc),training_camp_id(desc)',
  706. trainingCampName: null
  707. },
  708. // 表单参数
  709. form: {},
  710. // 课程相关数据
  711. course: {
  712. open: false,
  713. row:{},
  714. list:[],
  715. queryParams: {
  716. pageNum: 1,
  717. pageSize: 10,
  718. },
  719. loading: true,
  720. total: 0,
  721. addOpen: false,
  722. form: {
  723. videoIds: [],
  724. noRegisterVideoIds: []
  725. },
  726. },
  727. //修改营期时间参数
  728. updatePeriodDate: {
  729. open: false,
  730. loading: true,
  731. ids: [],
  732. form: {},
  733. },
  734. joinTimeSwitch:true,
  735. updateCourse: {
  736. open: false,
  737. loading: true,
  738. ids: [],
  739. form: {
  740. timeRange: null,
  741. joinTime: null
  742. },
  743. },
  744. // 表单校验
  745. rules: {
  746. periodName: [
  747. { required: true, message: '营期名称不能为空', trigger: 'blur' }
  748. ],
  749. companyId: [
  750. { required: true, message: '公司不能为空', trigger: 'change' }
  751. ],
  752. courseStyle: [
  753. { required: true, message: '课程风格不能为空', trigger: 'change' }
  754. ],
  755. // redPacketGrantMethod: [
  756. // { required: true, message: '红包发放方式不能为空', trigger: 'change' }
  757. // ],
  758. periodType: [
  759. { required: true, message: '营期类型不能为空', trigger: 'change' }
  760. ],
  761. maxViewNum: [
  762. { required: true, message: '销售可查看天数不能为空', trigger: 'blur' }
  763. ],
  764. periodStartingTime: [
  765. { required: true, message: '开营日期不能为空', trigger: 'change' }
  766. ]
  767. },
  768. // 公司选项
  769. companyOptions: [],
  770. // 训练营列表
  771. campList: [],
  772. // 激活的训练营索引
  773. activeCampIndex: null,
  774. // 训练营对话框是否显示
  775. campDialogVisible: false,
  776. courseList: false,
  777. // 训练营表单
  778. campForm: {
  779. trainingCampId: null,
  780. trainingCampName: ''
  781. },
  782. // 训练营表单校验
  783. campRules: {
  784. trainingCampName: [
  785. { required: true, message: '训练营名称不能为空', trigger: 'blur' },
  786. { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
  787. ]
  788. },
  789. // 添加课程表单校验
  790. courseAddRules: {
  791. courseId: [
  792. { required: true, message: '请选择课程', trigger: 'change' }
  793. ],
  794. videoIds: [
  795. { required: true, message: '请选择小节', trigger: 'change' },
  796. { type: 'array', min: 1, message: '请至少选择一个小节', trigger: 'change' }
  797. ]
  798. },
  799. // 修改看课时间表单校验
  800. courseUpdateRules: {
  801. timeRange: [
  802. {
  803. required: true,
  804. validator: (rule, value, callback) => {
  805. if (!value || !Array.isArray(value) || value.length !== 2) {
  806. callback(new Error('请选择完整的看课时间范围'));
  807. } else {
  808. // 检查时间格式是否正确(yyyy-MM-dd HH:mm:ss)
  809. const timeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
  810. if (!timeRegex.test(value[0]) || !timeRegex.test(value[1])) {
  811. callback(new Error('时间格式不正确'));
  812. } else if (value[0] >= value[1]) {
  813. callback(new Error('结束时间必须大于开始时间'));
  814. } else {
  815. callback();
  816. }
  817. }
  818. },
  819. trigger: 'change'
  820. }
  821. ],
  822. joinTime: [
  823. {
  824. required: true,
  825. validator: (rule, value, callback) => {
  826. if (!value) {
  827. callback(new Error('请选择领取红包时间'));
  828. } else {
  829. // 检查时间格式是否正确(yyyy-MM-dd HH:mm:ss)
  830. const timeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
  831. if (!timeRegex.test(value)) {
  832. callback(new Error('时间格式不正确'));
  833. } else {
  834. // 检查领取红包时间是否在看课时间范围内
  835. const timeRange = this.updateCourse.form.timeRange;
  836. if (timeRange && Array.isArray(timeRange) && timeRange.length === 2) {
  837. if (value < timeRange[0] || value > timeRange[1]) {
  838. callback(new Error('领取红包时间必须在看课时间范围内'));
  839. } else {
  840. callback();
  841. }
  842. } else {
  843. callback();
  844. }
  845. }
  846. }
  847. },
  848. trigger: 'change'
  849. }
  850. ]
  851. },
  852. // 滚动节流标志
  853. scrollThrottle: false,
  854. // 加载更多状态
  855. loadingMore: false,
  856. // 设置红包对话框
  857. redPacketVisible: false,
  858. periodCompanyList: [],
  859. currentRedPacketData: {
  860. periodId: '',
  861. videoId: ''
  862. },
  863. // 营期相关设置抽屉
  864. periodSettingsVisible: false,
  865. activeTab: 'course',
  866. periodSettingsData: {},
  867. companyList: [],
  868. courseDialogVisible: false,
  869. redPacketList: [],
  870. currentCompany: null,
  871. // 选中的营期数据
  872. selectedPeriods: [],
  873. // 批量设置红包按钮是否禁用
  874. batchSetRedPacketDisabled: true,
  875. // 批量设置红包弹出框
  876. batchRedPacketVisible: false,
  877. };
  878. },
  879. computed: {
  880. filteredVideoList() {
  881. if (!this.course.form.videoIds || this.course.form.videoIds.length === 0) {
  882. return [];
  883. }
  884. // 只显示已选择的 videoIds 中的选项
  885. return this.videoList.filter(video =>
  886. this.course.form.videoIds.includes(parseInt(video.dictValue))
  887. );
  888. }
  889. },
  890. created() {
  891. courseList().then(response => {
  892. this.courseList = response.list;
  893. });
  894. // this.getList();
  895. this.getLeftList();
  896. this.getCompanyList();
  897. },
  898. methods: {
  899. /** 删除按钮操作 */
  900. async handleDeleteCourse(row) {
  901. const periodDayIds = row.id || this.updateCourse.ids;
  902. try {
  903. await this.$confirm('是否确认删除该课程?', "提示", {
  904. confirmButtonText: "确定",
  905. cancelButtonText: "取消",
  906. type: "warning"
  907. });
  908. const res = await delPeriodDay(periodDayIds);
  909. if (res && res.code === 200) {
  910. this.getCourseList();// 刷新列表
  911. this.$message.success('删除成功');
  912. } else {
  913. this.$message.error(res.msg);
  914. }
  915. } catch (error) {
  916. }
  917. },
  918. /** 查询会员营期列表 */
  919. getList() {
  920. this.loading = true;
  921. const params = { ...this.queryParams };
  922. pagePeriod(params).then(response => {
  923. this.periodList = response.rows;
  924. this.total = response.total;
  925. this.loading = false;
  926. });
  927. },
  928. /** 查询左侧列表 */
  929. getLeftList() {
  930. this.leftLoading = true;
  931. // 重置页码和加载更多状态
  932. this.leftQueryParams.pageNum = 1;
  933. this.loadingMore = false;
  934. // 训练营数据
  935. listCamp(this.leftQueryParams).then(response => {
  936. if (response && response.code === 200) {
  937. this.campList = response.data.list || [];
  938. this.leftQueryParams.hasNextPage = response.data.hasNextPage;
  939. this.activeCampIndex = this.campList.length > 0 ? 0 : null;
  940. this.selectCamp(this.activeCampIndex);
  941. // 如果当前显示的列表高度不足以触发滚动,但还有更多数据,自动加载下一页
  942. this.$nextTick(() => {
  943. const scrollEl = this.$refs.campList;
  944. if (scrollEl && this.leftQueryParams.hasNextPage && scrollEl.scrollHeight <= scrollEl.clientHeight) {
  945. this.loadMoreCamps();
  946. }
  947. });
  948. } else {
  949. this.$message.error(response.msg || '获取训练营列表失败');
  950. this.campList = [];
  951. this.leftQueryParams.hasNextPage = false;
  952. }
  953. this.leftLoading = false;
  954. }).catch(error => {
  955. console.error('获取训练营列表失败:', error);
  956. this.$message.error('获取训练营列表失败');
  957. this.campList = [];
  958. this.leftQueryParams.hasNextPage = false;
  959. this.leftLoading = false;
  960. });
  961. },
  962. /** 搜索按钮操作 */
  963. handleQuery() {
  964. this.queryParams.pageNum = 1;
  965. this.getList();
  966. },
  967. /** 左侧搜索按钮操作 */
  968. handleLeftQuery() {
  969. // 重置页码和列表
  970. this.leftQueryParams.pageNum = 1;
  971. this.campList = [];
  972. this.getLeftList();
  973. },
  974. /** 重置按钮操作 */
  975. resetQuery() {
  976. this.resetForm("queryForm");
  977. this.queryParams.companyIdList = [];
  978. this.handleQuery();
  979. },
  980. /** 多选框选中数据 */
  981. handleSelectionChange(selection) {
  982. this.ids = selection.map(item => item.periodId)
  983. this.single = selection.length!==1
  984. this.multiple = !selection.length
  985. // 更新批量设置红包相关数据
  986. this.selectedPeriods = selection;
  987. this.batchSetRedPacketDisabled = selection.length === 0;
  988. },
  989. handleSelectionCourseChange(selection) {
  990. this.updateCourse.ids = selection.map(item => item.id)
  991. },
  992. /** 新增按钮操作 */
  993. handleAdd() {
  994. this.reset();
  995. this.open = true;
  996. this.title = "添加会员营期";
  997. this.isDisabledDateRange = false;
  998. },
  999. /** 修改按钮操作 */
  1000. handleUpdate(row) {
  1001. this.reset();
  1002. const periodId = row.periodId || this.ids
  1003. getPeriod(periodId).then(response => {
  1004. this.form = response.data;
  1005. if (this.form.companyId) {
  1006. this.form.companyId = this.form.companyId.split(',').map(id => Number(id));
  1007. }
  1008. // 设置看课时间范围(回显)
  1009. if (this.form.viewStartTime && this.form.viewEndTime) {
  1010. this.form.timeRange = [this.form.viewStartTime, this.form.viewEndTime];
  1011. }
  1012. if(this.form.periodType == 1){
  1013. this.$set(this.form,'dateRange',[this.form.periodStartingTime, this.form.periodEndTime])
  1014. }
  1015. if(this.form.periodType == 2){
  1016. this.$set(this.form,'date',this.form.periodStartingTime)
  1017. }
  1018. this.open = true;
  1019. this.title = "修改会员营期";
  1020. this.isDisabledDateRange = true;
  1021. });
  1022. },
  1023. /** 提交按钮 */
  1024. submitForm() {
  1025. this.$refs["form"].validate(valid => {
  1026. if (valid) {
  1027. let data = JSON.parse(JSON.stringify(this.form));
  1028. // 处理看课时间范围
  1029. if (data.timeRange && data.timeRange.length === 2) {
  1030. data.viewStartTime = data.timeRange[0];
  1031. data.viewEndTime = data.timeRange[1];
  1032. }
  1033. data.companyId = data.companyId.join()
  1034. data.trainingCampId = this.queryParams.trainingCampId
  1035. if (data.periodId != null) {
  1036. updatePeriod(data).then(response => {
  1037. if (response.code === 200) {
  1038. this.msgSuccess("修改成功");
  1039. this.open = false;
  1040. this.getList();
  1041. }
  1042. });
  1043. } else {
  1044. addPeriod(data).then(response => {
  1045. if (response.code === 200) {
  1046. this.msgSuccess("新增成功");
  1047. this.open = false;
  1048. this.getList();
  1049. }
  1050. });
  1051. }
  1052. }
  1053. });
  1054. },
  1055. /** 删除按钮操作 */
  1056. async handleDelete(row) {
  1057. const periodIds = row.periodId || this.ids;
  1058. try {
  1059. await this.$confirm('是否确认删除该营期?', "提示", {
  1060. confirmButtonText: "确定",
  1061. cancelButtonText: "取消",
  1062. type: "warning"
  1063. });
  1064. const res = await delPeriod(periodIds);
  1065. if (res && res.code === 200) {
  1066. this.getList(); // 刷新列表
  1067. this.$message.success('删除成功');
  1068. } else {
  1069. this.$message.error(res.msg);
  1070. }
  1071. } catch (error) {
  1072. }
  1073. },
  1074. /** 导出按钮操作 */
  1075. handleExport() {
  1076. const queryParams = this.queryParams;
  1077. this.$confirm('是否确认导出所有会员营期数据项?', "警告", {
  1078. confirmButtonText: "确定",
  1079. cancelButtonText: "取消",
  1080. type: "warning"
  1081. }).then(function() {
  1082. return exportPeriod(queryParams);
  1083. }).then(response => {
  1084. this.download(response.msg);
  1085. }).catch(function() {});
  1086. },
  1087. /** 批量设置红包 */
  1088. handleBatchSetRedPacket() {
  1089. if (this.selectedPeriods.length === 0) {
  1090. this.$message.warning('请至少选择一个营期');
  1091. return;
  1092. }
  1093. this.batchRedPacketVisible = true;
  1094. },
  1095. /** 处理批量设置红包保存 */
  1096. // handleBatchRedPacketSave(data) {
  1097. // // 这里等待接口提供后补充具体实现
  1098. // // 示例代码:
  1099. // // batchSetRedPacket(data).then(response => {
  1100. // // if (response.code === 200) {
  1101. // // this.$message.success('批量设置成功');
  1102. // // this.getList();
  1103. // // }
  1104. // // });
  1105. // this.batchRedPacketVisible = false;
  1106. // },
  1107. /** 获取公司下拉列表*/
  1108. getCompanyList() {
  1109. this.loading = true;
  1110. getCompanyList().then(response => {
  1111. this.companyOptions = response.data;
  1112. this.loading = false;
  1113. });
  1114. },
  1115. // 取消按钮
  1116. cancel() {
  1117. this.open = false;
  1118. this.reset();
  1119. },
  1120. // 表单重置
  1121. reset() {
  1122. this.form = {
  1123. periodId: null,
  1124. periodName: null,
  1125. companyId: null,
  1126. courseId: null,
  1127. videoId: null,
  1128. trainingCampId: null,
  1129. createTime: null,
  1130. updateTime: null,
  1131. courseStyle: null,
  1132. liveRoomStyle: null,
  1133. redPacketGrantMethod: 1,
  1134. periodType: 1,
  1135. periodStartingTime: null,
  1136. dateRange: [],
  1137. date: null,
  1138. days: [],
  1139. maxViewNum: 0,
  1140. periodEndTime: null,
  1141. timeRange: [], // 看课时间范围
  1142. viewStartTime: null, // 看课开始时间
  1143. viewEndTime: null, // 看课结束时间
  1144. lastJoinTime: null, // 领取红包时间
  1145. appViewEnabled: 1,
  1146. miniProgramViewEnabled: 1,
  1147. h5ViewEnabled: 1
  1148. };
  1149. this.resetForm("form");
  1150. },
  1151. // 处理训练营列表的逻辑
  1152. handleDeleteCamp(item) {
  1153. this.$confirm(`确定要删除训练营"${item.trainingCampName}"吗?`, '提示', {
  1154. confirmButtonText: '删除',
  1155. cancelButtonText: '取消',
  1156. type: 'warning'
  1157. }).then(() => {
  1158. // 调用删除训练营API
  1159. const trainingCampId = item.trainingCampId;
  1160. this.leftLoading = true;
  1161. delCamp(trainingCampId).then(response => {
  1162. if (response.code === 200) {
  1163. this.$message.success('删除成功');
  1164. // 从列表中移除
  1165. const index = this.campList.findIndex(camp => camp.trainingCampId === trainingCampId);
  1166. if (index !== -1) {
  1167. this.campList.splice(index, 1);
  1168. }
  1169. // 如果删除的是当前选中的训练营,则重置选中状态
  1170. if (this.activeCampIndex === index) {
  1171. this.activeCampIndex = this.campList.length > 0 ? 0 : null;
  1172. if (this.activeCampIndex !== null) {
  1173. // 更新右侧列表
  1174. this.selectCamp(this.activeCampIndex);
  1175. } else {
  1176. // 没有训练营了,清空右侧列表
  1177. this.periodList = [];
  1178. }
  1179. }
  1180. } else {
  1181. this.$message.error(response.msg || '删除失败');
  1182. }
  1183. this.leftLoading = false;
  1184. }).catch(error => {
  1185. // this.$message.error('删除失败: ' + error.message);
  1186. this.leftLoading = false;
  1187. });
  1188. }).catch(() => {
  1189. this.$message.info('已取消删除');
  1190. });
  1191. },
  1192. /** 复制训练营 */
  1193. handleCopyCamp(item) {
  1194. // 调用添加训练营API
  1195. copyCamp(item.trainingCampId).then(response => {
  1196. if (response.code === 200) {
  1197. this.$message.success('复制成功');
  1198. // 重新加载训练营列表
  1199. this.getLeftList();
  1200. } else {
  1201. this.$message.error(response.msg || '复制训练营失败');
  1202. }
  1203. }).catch(error => {
  1204. this.$message.error('复制训练营失败: ' + error.message);
  1205. });
  1206. },
  1207. /** 修改训练营按钮操作 */
  1208. handleEditCamp(item) {
  1209. this.resetCampForm();
  1210. this.leftLoading = true;
  1211. // 获取最新的训练营数据
  1212. const trainingCampId = item.trainingCampId;
  1213. // 应该调用获取训练营详情的API
  1214. setTimeout(() => {
  1215. // 填充表单数据
  1216. this.campForm = {
  1217. trainingCampId: item.trainingCampId,
  1218. trainingCampName: item.trainingCampName,
  1219. orderNumber: item.orderNumber || 1,
  1220. status: item.status !== undefined ? item.status : 1
  1221. };
  1222. this.campDialogVisible = true;
  1223. this.leftLoading = false;
  1224. }, 300);
  1225. },
  1226. /** 新建训练营按钮操作 */
  1227. handleAddTrainingCamp() {
  1228. this.resetCampForm();
  1229. this.campDialogVisible = true;
  1230. },
  1231. /** 重置训练营表单 */
  1232. resetCampForm() {
  1233. this.campForm = {
  1234. trainingCampId: null,
  1235. trainingCampName: ''
  1236. };
  1237. // 如果表单已经创建,则重置校验结果
  1238. if (this.$refs.campForm) {
  1239. this.$refs.campForm.resetFields();
  1240. }
  1241. },
  1242. /** 取消训练营表单 */
  1243. cancelCampForm() {
  1244. this.campDialogVisible = false;
  1245. this.resetCampForm();
  1246. },
  1247. /** 提交训练营表单 */
  1248. submitCampForm() {
  1249. this.$refs.campForm.validate(valid => {
  1250. if (valid) {
  1251. // 显示加载中
  1252. this.leftLoading = true;
  1253. // 准备提交的数据
  1254. const submitData = JSON.parse(JSON.stringify(this.campForm));
  1255. // 判断是新增还是修改
  1256. if (submitData.trainingCampId) {
  1257. // 修改训练营
  1258. editCamp(submitData).then(response => {
  1259. if (response.code === 200) {
  1260. this.$message.success('修改训练营成功');
  1261. this.campDialogVisible = false;
  1262. // 更新列表中的数据
  1263. const index = this.campList.findIndex(camp => camp.trainingCampId === submitData.trainingCampId);
  1264. if (index !== -1) {
  1265. this.campList[index] = { ...this.campList[index], ...submitData };
  1266. // 如果修改的是当前选中的训练营,更新右侧列表
  1267. if (this.activeCampIndex === index) {
  1268. this.selectCamp(index);
  1269. }
  1270. }
  1271. // 重新加载训练营列表
  1272. this.getLeftList();
  1273. } else {
  1274. this.$message.error(response.msg || '修改训练营失败');
  1275. this.leftLoading = false;
  1276. }
  1277. }).catch(error => {
  1278. this.$message.error('修改训练营失败: ' + (error.message || '未知错误'));
  1279. this.leftLoading = false;
  1280. });
  1281. } else {
  1282. // 新增训练营
  1283. addCamp(submitData).then(response => {
  1284. if (response.code === 200) {
  1285. this.$message.success('新建训练营成功');
  1286. this.campDialogVisible = false;
  1287. // 重新加载训练营列表
  1288. this.getLeftList();
  1289. } else {
  1290. this.$message.error(response.msg || '新建训练营失败');
  1291. this.leftLoading = false;
  1292. }
  1293. }).catch(error => {
  1294. this.$message.error('新建训练营失败: ' + (error.message || '未知错误'));
  1295. this.leftLoading = false;
  1296. });
  1297. }
  1298. }
  1299. });
  1300. },
  1301. /** 排序方式改变 */
  1302. handleSortChange(value) {
  1303. this.leftQueryParams.scs = value;
  1304. // 重置页码和列表
  1305. this.leftQueryParams.pageNum = 1;
  1306. this.campList = [];
  1307. this.getLeftList();
  1308. },
  1309. /** 选中训练营 */
  1310. selectCamp(index) {
  1311. if(index == null || index == undefined) return;
  1312. this.activeCampIndex = index;
  1313. // 加载对应的训练营营期数据
  1314. const selectedCamp = this.campList[index];
  1315. this.queryParams.trainingCampId = selectedCamp.trainingCampId;
  1316. this.getList();
  1317. },
  1318. /** 处理滚动事件,实现滚动到底部加载更多 */
  1319. handleScroll() {
  1320. // 如果正在节流中或者正在加载中,则不处理
  1321. if (this.scrollThrottle || this.loadingMore) return;
  1322. // 设置节流,200ms内不再处理滚动事件
  1323. this.scrollThrottle = true;
  1324. setTimeout(() => {
  1325. this.scrollThrottle = false;
  1326. }, 200);
  1327. const scrollEl = this.$refs.campList;
  1328. if (!scrollEl) return;
  1329. // 判断是否滚动到底部:滚动高度 + 可视高度 >= 总高度 - 30(添加30px的容差,提前触发加载)
  1330. const isBottom = scrollEl.scrollTop + scrollEl.clientHeight >= scrollEl.scrollHeight - 30;
  1331. // 如果滚动到底部,且有下一页数据,且当前不在加载中,则加载更多
  1332. if (isBottom && this.leftQueryParams.hasNextPage && !this.leftLoading && !this.loadingMore) {
  1333. this.loadMoreCamps();
  1334. }
  1335. },
  1336. /** 加载更多训练营数据 */
  1337. loadMoreCamps() {
  1338. // 已在加载中,防止重复加载
  1339. if (this.leftLoading || this.loadingMore) return;
  1340. // 设置加载状态
  1341. this.loadingMore = true;
  1342. // 页码加1
  1343. this.leftQueryParams.pageNum += 1;
  1344. // 加载下一页数据
  1345. listCamp(this.leftQueryParams).then(response => {
  1346. if (response && response.code === 200) {
  1347. // 将新数据追加到列表中
  1348. const newList = response.data.list || [];
  1349. if (newList.length > 0) {
  1350. this.campList = [...this.campList, ...newList];
  1351. }
  1352. // 更新是否有下一页的标志
  1353. this.leftQueryParams.hasNextPage = response.data.hasNextPage;
  1354. // 如果当前显示的列表高度不足以触发滚动,但还有更多数据,自动加载下一页
  1355. this.$nextTick(() => {
  1356. const scrollEl = this.$refs.campList;
  1357. if (scrollEl && this.leftQueryParams.hasNextPage && scrollEl.scrollHeight <= scrollEl.clientHeight) {
  1358. // 延迟一点再加载下一页,避免过快加载
  1359. setTimeout(() => {
  1360. this.loadMoreCamps();
  1361. }, 300);
  1362. }
  1363. });
  1364. } else {
  1365. this.$message.error(response.msg || '加载更多训练营失败');
  1366. }
  1367. this.loadingMore = false;
  1368. }).catch(error => {
  1369. console.error('加载更多训练营失败:', error);
  1370. this.$message.error('加载更多训练营失败');
  1371. this.loadingMore = false;
  1372. });
  1373. },
  1374. timeChange(type) {
  1375. if (type == 1) {
  1376. this.form.periodStartingTime = this.form.dateRange[0];
  1377. this.form.periodEndTime = this.form.dateRange[1];
  1378. if (!Array.isArray(this.form.days)) {
  1379. this.form.days = [];
  1380. }
  1381. this.form.days = [];
  1382. let days = this.getDiff(this.form.periodStartingTime, this.form.periodEndTime);
  1383. for (let i = 0; i < days; i++) {
  1384. this.form.days.push({ lesson: i + 1 });
  1385. }
  1386. }
  1387. if (type == 2) {
  1388. this.form.periodStartingTime = this.form.date;
  1389. this.form.periodEndTime = this.form.date;
  1390. this.form.days = [];
  1391. }
  1392. },
  1393. getDiff(start, end) {
  1394. if(start == null || start == undefined || start == '') return 0;
  1395. if(end == null || end == undefined || end == '') return 0;
  1396. if(start == end) 1;
  1397. const startDate = this.getUTCDate(start);
  1398. const endDate = this.getUTCDate(end);
  1399. const timeDiff = endDate - startDate;
  1400. return (Math.floor(timeDiff / (1000 * 3600 * 24))) + 1; // 直接取整
  1401. },
  1402. getUTCDate(dateStr) {
  1403. const [year, month, day] = dateStr.split('-').map(Number);
  1404. return new Date(Date.UTC(year, month - 1, day)); // 月份从0开始
  1405. },
  1406. // handleCourse(row){
  1407. // this.course = {
  1408. // open: false,
  1409. // row:{},
  1410. // list:[],
  1411. // queryParams: {
  1412. // pageNum: 1,
  1413. // pageSize: 3, // 修改为每页显示3条
  1414. // },
  1415. // loading: true,
  1416. // total: 0,
  1417. // addOpen: false,
  1418. // form: {},
  1419. // };
  1420. // this.course.open = true;
  1421. // this.course.row = row;
  1422. // this.course.queryParams.periodId = row.periodId;
  1423. // this.getCourseList();
  1424. // },
  1425. getCourseList(){
  1426. this.course.loading = true;
  1427. getDays(this.course.queryParams).then(e => {
  1428. this.course.list = e.rows;
  1429. this.course.total = e.total;
  1430. this.course.loading = false;
  1431. });
  1432. },
  1433. handleAddCourse() {
  1434. const key = "joinTime.switch.config"
  1435. getConfigByKey(key).then(response => {
  1436. const {code,data} = response
  1437. if (code === 200) {
  1438. let value = data?.configValue
  1439. console.log(value)
  1440. if (value) {
  1441. this.joinTimeSwitch = value=='0'?true:false;
  1442. }
  1443. }
  1444. });
  1445. this.course.addOpen = true;
  1446. this.course.form = {
  1447. periodId: this.course.queryParams.periodId,
  1448. courseId: null,
  1449. timeRange: ['00:00:00', '23:59:59'],
  1450. joinTime: '23:59:59',
  1451. videoIds: [],
  1452. noRegisterVideoIds: []
  1453. };
  1454. // 重置表单
  1455. this.$nextTick(() => {
  1456. if (this.$refs.courseAddForm) {
  1457. this.$refs.courseAddForm.resetFields();
  1458. }
  1459. });
  1460. },
  1461. handleUpdateCourse() {
  1462. const key = "joinTime.switch.config"
  1463. getConfigByKey(key).then(response => {
  1464. const {code,data} = response
  1465. if (code === 200) {
  1466. let value = data?.configValue
  1467. console.log(value)
  1468. if (value) {
  1469. this.joinTimeSwitch = value=='0'?true:false;
  1470. }
  1471. }
  1472. })
  1473. this.updateCourse.open = true;
  1474. this.updateCourse.form = {
  1475. ids: this.updateCourse.ids,
  1476. timeRange: null,
  1477. joinTime: null
  1478. };
  1479. // 重置表单校验状态(但不清空选中状态)
  1480. this.$nextTick(() => {
  1481. if (this.$refs.courseUpdateForm) {
  1482. this.$refs.courseUpdateForm.resetFields();
  1483. }
  1484. });
  1485. },
  1486. closeAddCourse() {
  1487. this.course.addOpen = false;
  1488. this.course.form = {
  1489. periodId: null,
  1490. courseId: null,
  1491. timeRange: null,
  1492. joinTime: null,
  1493. videoIds: [],
  1494. noRegisterVideoIds: []
  1495. };
  1496. // 重置表单
  1497. if (this.$refs.courseAddForm) {
  1498. this.$refs.courseAddForm.resetFields();
  1499. }
  1500. },
  1501. closeUpdateCourse() {
  1502. this.updateCourse.open = false;
  1503. // 清空选中的课程id,使【修改看课时间】按钮变为禁用状态
  1504. this.updateCourse.ids = [];
  1505. // 清空课程列表的选中状态
  1506. this.$nextTick(() => {
  1507. if (this.$refs.courseTable) {
  1508. this.$refs.courseTable.clearSelection();
  1509. }
  1510. });
  1511. // 重置表单数据
  1512. this.updateCourse.form = {
  1513. ids: [],
  1514. timeRange: null,
  1515. joinTime: null
  1516. };
  1517. // 重置表单校验
  1518. this.$nextTick(() => {
  1519. if (this.$refs.courseUpdateForm) {
  1520. this.$refs.courseUpdateForm.resetFields();
  1521. }
  1522. });
  1523. },
  1524. courseChange(row){
  1525. this.course.form.videoIds = [];
  1526. this.course.form.noRegisterVideoIds = [];
  1527. videoList(row).then(response => {
  1528. this.videoList=response.list
  1529. });
  1530. },
  1531. submitCourseForm(){
  1532. this.$refs.courseAddForm.validate(valid => {
  1533. if (valid) {
  1534. if(this.course.form.timeRange != null && this.course.form.timeRange.length === 2){
  1535. this.course.form.startTime = this.course.form.timeRange[0];
  1536. this.course.form.endTime1 = this.course.form.timeRange[1];
  1537. }
  1538. // 提交数据
  1539. addCourse(this.course.form).then(response => {
  1540. this.$message.success('添加成功');
  1541. this.course.addOpen = false;
  1542. // 重新加载训练营列表
  1543. this.getCourseList();
  1544. });
  1545. }
  1546. });
  1547. },
  1548. submitUpdateCourseForm(){
  1549. this.$refs.courseUpdateForm.validate(valid => {
  1550. if (valid) {
  1551. // 检查时间范围是否正确
  1552. if (this.updateCourse.form.timeRange &&
  1553. Array.isArray(this.updateCourse.form.timeRange) &&
  1554. this.updateCourse.form.timeRange.length === 2) {
  1555. this.updateCourse.form.startTime = this.updateCourse.form.timeRange[0];
  1556. this.updateCourse.form.endTime1 = this.updateCourse.form.timeRange[1];
  1557. } else {
  1558. this.$message.error('请先选择正确的看课时间范围');
  1559. return;
  1560. }
  1561. // 检查领取红包时间是否正确
  1562. if (!this.updateCourse.form.joinTime&&this.joinTimeSwitch) {
  1563. this.$message.error('请选择领取红包时间');
  1564. return;
  1565. }
  1566. // 提交数据
  1567. updateCourseTime(this.updateCourse.form).then(response => {
  1568. this.$message.success('修改成功');
  1569. this.updateCourse.open = false;
  1570. // 清空选中的课程ID,使【修改看课时间】按钮变为禁用状态
  1571. this.updateCourse.ids = [];
  1572. // 清空课程列表的选中状态
  1573. this.$nextTick(() => {
  1574. if (this.$refs.courseTable) {
  1575. this.$refs.courseTable.clearSelection();
  1576. }
  1577. });
  1578. // 重新加载训练营列表
  1579. this.getCourseList();
  1580. }).catch(error => {
  1581. this.$message.error('修改失败:' + (error.message || '未知错误'));
  1582. });
  1583. }
  1584. });
  1585. },
  1586. updatePeriodDateSubmit(){
  1587. updateCourseDate(this.updatePeriodDate.form).then(response => {
  1588. this.$message.success('修改成功');
  1589. this.updatePeriodDate.open = false;
  1590. // 重新加载课程列表
  1591. this.getCourseList();
  1592. });
  1593. },
  1594. // saveCourseData(){
  1595. // updateListCourseData(this.course.list).then(response => {
  1596. // this.$message.success('保存成功');
  1597. // this.getCourseList();
  1598. // });
  1599. // },
  1600. // setRedPacket(row) {
  1601. // this.currentRedPacketData = {
  1602. // periodId: row.periodId
  1603. // // videoId: row.videoId
  1604. // };
  1605. // this.redPacketVisible = true;
  1606. // },
  1607. handleRedPacketSuccess() {
  1608. this.getCourseList();
  1609. },
  1610. handlePeriodSettings(row) {
  1611. this.periodSettingsData = row;
  1612. this.periodSettingsVisible = true;
  1613. // 初始化课程列表
  1614. this.course.queryParams.periodId = row.periodId;
  1615. // 根据当前激活的tab加载对应数据
  1616. this.handleTabClick({ name: this.activeTab });
  1617. },
  1618. // 结束营期
  1619. handleClosePeriod(row) {
  1620. const msg = `注: 1.确认结束营期,该营期的开营结束时间改为当天24点。2.当天正在播放中的课程不变。3.第二天如有未开始的课程,统一改为已结束。是否确认结束 ${row.periodName} 营期吗?`
  1621. this.$confirm(msg, "警告", {
  1622. confirmButtonText: "确定",
  1623. cancelButtonText: "取消",
  1624. type: "warning"
  1625. }).then(() => {
  1626. closePeriod({id: row.periodId}).then(response => {
  1627. if (response.code === 200) {
  1628. this.getList()
  1629. } else {
  1630. this.$message.error(response.msg)
  1631. }
  1632. })
  1633. }).catch(() => {})
  1634. },
  1635. handleBatchRedPacketSuccess() {
  1636. this.batchRedPacketVisible = false;
  1637. this.getCourseList();
  1638. },
  1639. /** 处理tab切换 */
  1640. handleTabClick(tab) {
  1641. if (tab.name === 'course') {
  1642. this.getCourseList();
  1643. } else if (tab.name === 'company') {
  1644. this.redPacketVisible = true;
  1645. }
  1646. },
  1647. /** 上移课程 */
  1648. handleTop(row) {
  1649. const currentIndex = this.course.list.findIndex(item => item.id === row.id);
  1650. if (currentIndex <= 0) {
  1651. this.$message.warning('已经是第一条数据');
  1652. return;
  1653. }
  1654. // 获取上一条数据
  1655. const prevRow = this.course.list[currentIndex - 1];
  1656. console.log({
  1657. id: row.id,
  1658. targetId: prevRow.id,
  1659. type: 1 //上移
  1660. })
  1661. periodCourseMove({
  1662. id: row.id,
  1663. targetId: prevRow.id,
  1664. type: 1 //上移
  1665. }).then(response => {
  1666. if (response.code === 200) {
  1667. this.$message.success('上移成功');
  1668. this.getCourseList();
  1669. } else {
  1670. this.$message.error(response.msg || '上移失败');
  1671. }
  1672. }).catch(() => {
  1673. this.$message.error('上移失败');
  1674. });
  1675. },
  1676. /** 下移课程 */
  1677. handleBottom(row) {
  1678. const currentIndex = this.course.list.findIndex(item => item.id === row.id);
  1679. if (currentIndex === -1 || currentIndex >= this.course.list.length - 1) {
  1680. this.$message.warning('已经是最后一条数据');
  1681. return;
  1682. }
  1683. // 获取下一条数据
  1684. const nextRow = this.course.list[currentIndex + 1];
  1685. periodCourseMove({
  1686. id: row.id,
  1687. targetId: nextRow.id,
  1688. type: 2 //下移
  1689. }).then(response => {
  1690. if (response.code === 200) {
  1691. this.$message.success('下移成功');
  1692. this.getCourseList(); // 重新加载列表
  1693. } else {
  1694. this.$message.error(response.msg || '下移失败');
  1695. }
  1696. }).catch(() => {
  1697. this.$message.error('下移失败');
  1698. });
  1699. },
  1700. /** 营期状态格式化 */
  1701. periodStatusFormatter(row) {
  1702. const statusMap = {
  1703. 1: '未开始',
  1704. 2: '进行中',
  1705. 3: '已结束'
  1706. };
  1707. return statusMap[row.periodStatus] || '未知状态';
  1708. },
  1709. /** 注册开关状态格式化 */
  1710. registrationSwitchFormatter(row) {
  1711. const switchMap = {
  1712. 0: '未开启',
  1713. 1: '已开启'
  1714. };
  1715. return switchMap[row.registrationSwitch] || '未知状态';
  1716. },
  1717. /** 开课状态格式化 */
  1718. courseStatusFormatter(row) {
  1719. const statusMap = {
  1720. 0: '未开始',
  1721. 1: '进行中',
  1722. 2: '已结束'
  1723. };
  1724. return statusMap[row.status] || '未知状态';
  1725. },
  1726. /** 营期状态格式化 */
  1727. handleUpdateDate(row) {
  1728. this.updatePeriodDate.form = {id: row.id, dayDate: row.dayDate};
  1729. this.updatePeriodDate.open = true;
  1730. },
  1731. // disabledDate(time) {
  1732. // return time.getTime() < new Date(new Date().setHours(0,0,0,0));
  1733. // },
  1734. getPickerOptions() {
  1735. // 如果已选择看课时间范围,则领取红包时间应在看课时间范围内
  1736. if (this.updateCourse.form.timeRange &&
  1737. Array.isArray(this.updateCourse.form.timeRange) &&
  1738. this.updateCourse.form.timeRange.length === 2) {
  1739. return {
  1740. selectableRange: `${this.updateCourse.form.timeRange[0]} - ${this.updateCourse.form.timeRange[1]}`
  1741. };
  1742. }
  1743. // 默认全天可选
  1744. return {
  1745. selectableRange: '00:00:00 - 23:59:59'
  1746. };
  1747. },
  1748. onTimeRangeChange() {
  1749. // 当看课时间范围改变时,清空领取红包时间
  1750. this.updateCourse.form.joinTime = null;
  1751. // 强制更新组件以刷新领取红包时间的可选范围
  1752. this.$forceUpdate();
  1753. },
  1754. },
  1755. };
  1756. </script>
  1757. <style scoped>
  1758. .left-aside {
  1759. background-color: #fff;
  1760. border-right: 1px solid #EBEEF5;
  1761. padding: 0;
  1762. display: flex;
  1763. flex-direction: column;
  1764. height: 800px;
  1765. }
  1766. .left-header {
  1767. padding: 10px;
  1768. border-bottom: 1px solid #EBEEF5;
  1769. }
  1770. .left-header-top {
  1771. display: flex;
  1772. justify-content: space-between;
  1773. align-items: center;
  1774. margin-bottom: 10px;
  1775. }
  1776. .search-btn {
  1777. width: 50%;
  1778. height: 36px;
  1779. background-color: #409EFF;
  1780. color: white;
  1781. border: none;
  1782. }
  1783. .search-input-wrapper {
  1784. margin-bottom: 10px;
  1785. }
  1786. .sort-wrapper {
  1787. display: flex;
  1788. align-items: center;
  1789. margin-bottom: 10px;
  1790. }
  1791. .sort-label {
  1792. width: 70px;
  1793. font-size: 14px;
  1794. font-weight: 600;
  1795. color: #909399;
  1796. }
  1797. .sort-select {
  1798. margin-left: 10px;
  1799. width: 280px;
  1800. }
  1801. .color-wrapper {
  1802. display: flex;
  1803. align-items: center;
  1804. margin-bottom: 10px;
  1805. }
  1806. .color-label {
  1807. width: 70px;
  1808. color: #606266;
  1809. }
  1810. .color-hint {
  1811. margin-left: 10px;
  1812. color: #606266;
  1813. font-size: 12px;
  1814. }
  1815. .color-help {
  1816. margin-left: 5px;
  1817. color: #909399;
  1818. cursor: pointer;
  1819. }
  1820. .hint-text {
  1821. color: #606266;
  1822. font-size: 12px;
  1823. margin-top: 5px;
  1824. }
  1825. .camp-list {
  1826. flex: 1;
  1827. overflow-y: auto;
  1828. padding: 3px;
  1829. }
  1830. .camp-item {
  1831. margin-bottom: 5px;
  1832. padding: 15px;
  1833. background-color: #ffffff;
  1834. position: relative;
  1835. cursor: pointer;
  1836. display: flex;
  1837. justify-content: space-between;
  1838. border: 1px solid #eaedf2;
  1839. }
  1840. .camp-item:last-child {
  1841. margin-bottom: 0;
  1842. }
  1843. .camp-item:hover {
  1844. background-color: #f5f9ff;
  1845. }
  1846. .camp-item.active {
  1847. background-color: #eaf4ff;
  1848. border-left: 1px solid #75b8fc;
  1849. }
  1850. .camp-content {
  1851. flex: 1;
  1852. padding-right: 10px;
  1853. }
  1854. .camp-title {
  1855. font-weight: bold;
  1856. font-size: 16px;
  1857. margin-bottom: 8px;
  1858. color: #333;
  1859. display: flex;
  1860. align-items: center;
  1861. }
  1862. .camp-icon {
  1863. font-size: 16px;
  1864. margin-right: 6px;
  1865. color: #409EFF;
  1866. }
  1867. .camp-info {
  1868. display: flex;
  1869. justify-content: space-between;
  1870. margin-bottom: 8px;
  1871. font-size: 12px;
  1872. color: #c4c1c1;
  1873. line-height: 1.5;
  1874. }
  1875. .camp-stats {
  1876. display: flex;
  1877. justify-content: space-between;
  1878. font-size: 12px;
  1879. color: #666;
  1880. background-color: #f5f9ff;
  1881. padding: 6px 10px;
  1882. border-radius: 4px;
  1883. line-height: 1.5;
  1884. }
  1885. .stat-item {
  1886. display: flex;
  1887. align-items: center;
  1888. }
  1889. .stat-item i {
  1890. margin-right: 4px;
  1891. font-size: 14px;
  1892. color: #409EFF;
  1893. }
  1894. .camp-actions {
  1895. display: flex;
  1896. flex-direction: column;
  1897. justify-content: center;
  1898. align-items: flex-end;
  1899. gap: 8px;
  1900. border-left: 1px dashed #eaedf2;
  1901. padding-left: 12px;
  1902. min-width: 50px;
  1903. }
  1904. .action-btn {
  1905. padding: 2px 5px;
  1906. font-size: 12px;
  1907. border-radius: 4px;
  1908. transition: all 0.2s;
  1909. }
  1910. .action-btn:hover {
  1911. background-color: rgba(255, 255, 255, 0.8);
  1912. }
  1913. .delete-btn {
  1914. color: #f56c6c;
  1915. }
  1916. .delete-btn:hover {
  1917. background-color: rgba(245, 108, 108, 0.1);
  1918. }
  1919. .copy-btn {
  1920. color: #409EFF;
  1921. }
  1922. .copy-btn:hover {
  1923. background-color: rgba(64, 158, 255, 0.1);
  1924. }
  1925. .warning-icon {
  1926. color: #E6A23C;
  1927. font-size: 16px;
  1928. margin-left: 5px;
  1929. }
  1930. .el-main {
  1931. padding: 10px;
  1932. }
  1933. /* 添加训练营表单样式 */
  1934. .drawer-footer {
  1935. /* position: absolute; */
  1936. bottom: 0;
  1937. left: 0;
  1938. right: 0;
  1939. padding: 20px;
  1940. background: #fff;
  1941. text-align: right;
  1942. border-top: 1px solid #e8e8e8;
  1943. }
  1944. .el-input-number {
  1945. width: 100%;
  1946. }
  1947. /* 加载更多样式 */
  1948. .loading-more {
  1949. display: flex;
  1950. align-items: center;
  1951. justify-content: center;
  1952. padding: 12px 0;
  1953. color: #909399;
  1954. font-size: 14px;
  1955. }
  1956. .loading-more i {
  1957. margin-right: 5px;
  1958. font-size: 16px;
  1959. }
  1960. /* 无更多数据提示 */
  1961. .no-more-data {
  1962. display: flex;
  1963. align-items: center;
  1964. justify-content: center;
  1965. padding: 12px 0;
  1966. color: #c0c4cc;
  1967. font-size: 13px;
  1968. }
  1969. .no-more-data span {
  1970. position: relative;
  1971. display: flex;
  1972. align-items: center;
  1973. }
  1974. </style>