index.vue 70 KB

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