| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567 |
- <template>
- <div class="app-container">
- <el-container>
- <!-- 左侧区域 -->
- <el-aside width="360px" class="left-aside">
- <!-- 顶部区域 -->
- <div class="left-header">
- <div class="left-header-top">
- <el-button type="primary" class="search-btn" @click="handleLeftQuery" v-hasPermi="['course:trainingCamp:list']">搜索</el-button>
- <el-button type="primary" style="width: 50%" icon="el-icon-plus" @click="handleAddTrainingCamp" v-hasPermi="['course:trainingCamp:add']">新建训练营</el-button>
- </div>
- <div class="search-input-wrapper">
- <el-input
- v-model="leftQueryParams.trainingCampName"
- placeholder="请输入训练营名称"
- prefix-icon="el-icon-search"
- clearable
- size="small"
- @keyup.enter.native="handleLeftQuery"
- />
- </div>
- <div class="sort-wrapper">
- <span class="sort-label">排序方式</span>
- <el-select v-model="leftQueryParams.scs"
- placeholder="按序号倒序"
- size="small"
- class="sort-select"
- @change="handleSortChange"
- >
- <el-option label="按序号倒序" value="order_number(desc),training_camp_id(desc)" />
- <el-option label="按序号顺序" value="order_number(asc),training_camp_id(desc)" />
- </el-select>
- </div>
- </div>
- <!-- 训练营列表 -->
- <div class="camp-list" ref="campList" @scroll="handleScroll" v-loading="leftLoading">
- <div
- v-for="(item, index) in campList"
- :key="index"
- class="camp-item"
- :class="{ 'active': activeCampIndex === index }"
- @click="selectCamp(index)"
- >
- <div class="camp-content">
- <div class="camp-title">
- <i class="el-icon-s-flag camp-icon"></i>
- {{ item.trainingCampName }}
- </div>
- <div class="camp-info">
- <span>序号:{{ item.orderNumber }}</span>
- <span>最新营期开课:{{ item.recentDate || '-' }}</span>
- </div>
- <div class="camp-stats">
- <span class="stat-item">
- <i class="el-icon-s-data"></i>
- 营期数:{{ item.periodCount || 0 }}
- </span>
- <span class="stat-item">
- <i class="el-icon-user"></i>
- 会员总数:{{ item.vipCount || 0 }}
- </span>
- </div>
- </div>
- <div class="camp-actions">
- <el-button type="text" class="action-btn delete-btn" @click.stop="handleDeleteCamp(item)" v-hasPermi="['course:trainingCamp:remove']">删除</el-button>
- <!-- <el-button type="text" class="action-btn copy-btn" @click.stop="handleCopyCamp(item)" v-hasPermi="['course:trainingCamp:copy']">复制</el-button>-->
- <el-button type="text" class="action-btn copy-btn" @click.stop="handleEditCamp(item)" v-hasPermi="['course:trainingCamp:edit']">编辑</el-button>
- </div>
- </div>
- <!-- 底部加载更多提示 -->
- <div v-if="loadingMore" class="loading-more">
- <i class="el-icon-loading"></i>
- <span>加载中...</span>
- </div>
- <!-- 所有数据加载完毕提示 -->
- <div v-if="campList.length > 0 && !leftQueryParams.hasNextPage && !loadingMore" class="no-more-data">
- <span>—— 已加载全部训练营 ——</span>
- </div>
- </div>
- </el-aside>
- <!-- 右侧区域 -->
- <el-main>
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
- <el-form-item label="营期名称" prop="periodName">
- <el-input
- v-model="queryParams.periodName"
- placeholder="请输入营期名称"
- clearable
- size="small"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="公司" prop="companyIdList">
- <div style="display: flex; gap: 10px; align-items: center;">
- <el-select v-model="queryParams.companyIdList" placeholder="请选择公司" clearable size="small" multiple style="flex: 1;">
- <el-option
- v-for="item in companyOptions"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- <el-button
- type="primary"
- size="small"
- @click="handleSelectAllCompanies('query')"
- :disabled="!companyOptions || companyOptions.length === 0"
- >
- {{ isAllCompaniesSelected('query') ? '取消全选' : '全选' }}
- </el-button>
- </div>
- </el-form-item>
- <el-form-item label="开营日期开始" prop="periodStartingTime" label-width="120px">
- <el-date-picker clearable size="small" style="width: 200px"
- v-model="queryParams.periodStartingTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="请选择开营日期开始时间">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="开营日期结束" prop="periodEndTime" label-width="120px">
- <el-date-picker clearable size="small" style="width: 300px"
- v-model="queryParams.periodEndTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="请选择开营日期结束时间">
- </el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['course:period:list']">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['course:period:add']"
- >新增</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="handleExport"
- v-hasPermi="['course:period:export']"
- >导出</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-edit"
- size="mini"
- @click="handleBatchSetRedPacket"
- v-hasPermi="['course:period:setRedPacket']"
- :disabled="batchSetRedPacketDisabled"
- >批量设置红包
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAddExistCampPeriod"
- v-hasPermi="['course:period:add']"
- >复制现有营期</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table v-loading="loading" :data="periodList" @selection-change="handleSelectionChange" border>
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="营期名称" align="center" prop="periodName" />
- <el-table-column label="公司名称" align="center" prop="companyName" />
- <el-table-column label="营期状态" align="center" prop="periodStatus" width="100" :formatter="periodStatusFormatter" />
- <el-table-column label="自由模式" align="center" prop="freeMode" width="100">
- <template slot-scope="scope">
- <el-tag :type="scope.row.freeMode === 1 ? 'success' : 'info'">
- {{ scope.row.freeMode === 1 ? '开启' : '关闭' }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column label="营期线" align="center" prop="periodLine" width="180" />
- <el-table-column label="开营开始时间" align="center" prop="periodStartingTime" width="180" />
- <el-table-column label="开营结束时间" align="center" prop="periodEndTime" width="180" />
- <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdate(scope.row)"
- v-hasPermi="['course:period:edit']"
- >修改</el-button>
- <!-- <el-button-->
- <!-- size="mini"-->
- <!-- type="text"-->
- <!-- icon="el-icon-edit"-->
- <!-- @click="handleCourse(scope.row)"-->
- <!-- v-hasPermi="['course:period:edit']"-->
- <!-- >课程管理</el-button>-->
- <!-- <el-button-->
- <!-- size="mini"-->
- <!-- type="text"-->
- <!-- icon="el-icon-money"-->
- <!-- @click="setRedPacket(scope.row)"-->
- <!-- >设置红包</el-button>-->
- <el-button
- size="mini"
- type="text"
- icon="el-icon-setting"
- @click="handlePeriodSettings(scope.row)"
- >营期相关设置</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-circle-close"
- @click="handleClosePeriod(scope.row)"
- v-hasPermi="['course:period:close']"
- >结束营期</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- v-hasPermi="['course:period:remove']"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </el-main>
- </el-container>
- <!-- 添加或修改会员营期对话框-->
- <el-drawer :title="title" :visible.sync="open" size="700px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="120px">
- <el-form-item label="营期名称" prop="periodName">
- <el-input v-model="form.periodName" placeholder="请输入营期名称" />
- </el-form-item>
- <el-form-item label="公司" prop="companyId">
- <div style="display: flex; gap: 10px; align-items: flex-start;">
- <el-select v-model="form.companyId" placeholder="请选择公司" multiple style="flex: 1;">
- <el-option
- v-for="item in companyOptions"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- <el-button
- type="primary"
- size="small"
- @click="handleSelectAllCompanies('form')"
- :disabled="!companyOptions || companyOptions.length === 0"
- >
- {{ isAllCompaniesSelected('form') ? '取消全选' : '全选' }}
- </el-button>
- </div>
- </el-form-item>
- <el-form-item label="课程风格" prop="courseStyle">
- <image-upload v-model="form.courseStyle" :limit="1" />
- </el-form-item>
- <el-form-item label="直播间风格" prop="liveRoomStyle">
- <image-upload v-model="form.liveRoomStyle" :limit="1" />
- </el-form-item>
- <el-form-item label="课程LOGO" prop="courseLogo">
- <image-upload v-model="form.courseLogo" :limit="1" />
- </el-form-item>
- <!-- <el-form-item label="红包发放方式" prop="redPacketGrantMethod">-->
- <!-- <el-radio-group v-model="form.redPacketGrantMethod">-->
- <!-- <el-radio :label="1" >按课程</el-radio>-->
- <!-- <el-radio :label="2" >按营期</el-radio>-->
- <!-- </el-radio-group>-->
- <!-- </el-form-item>-->
- <el-form-item label="营期类型" prop="periodType">
- <el-radio-group v-model="form.periodType">
- <el-radio :label="1" >多课程</el-radio>
- <el-radio :label="2" >单课程</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="销售提前查看天数" prop="maxViewNum">
- <el-input-number :min="0" v-model="form.maxViewNum" style="width: 200px" />
- </el-form-item>
- <el-form-item prop="freeMode">
- <span slot="label">
- 是否开启自由模式
- <el-tooltip content="开启后,学员可以自由安排学习进度,不受营期时间限制" placement="top">
- <i class="el-icon-question" style="margin-left: 5px; color: #909399; cursor: help;"></i>
- </el-tooltip>
- </span>
- <el-radio-group v-model="form.freeMode">
- <el-radio :label="1">开启</el-radio>
- <el-radio :label="0">关闭</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="开营日期" prop="periodStartingTime">
- <div style="display: flex; flex-direction: column; gap: 10px; width: 100%;">
- <div style="display: flex; align-items: center; gap: 10px;">
- <el-date-picker
- :style="{display: form.periodType == 1 ? '' : 'none !important', flex: 1}"
- v-model="form.dateRange"
- @change="timeChange(1)"
- type="daterange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- value-format="yyyy-MM-dd"
- :picker-options="{}"
- :clearable="false"
- >
- </el-date-picker>
- <el-date-picker
- :disabled = "isDisabledDateRange"
- :style="{display: form.periodType == 2 ? '' : 'none !important', flex: 1}"
- @change="timeChange(2)"
- v-model="form.date"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="选择日期"
- :picker-options="{}"
- :clearable="false"
- >
- </el-date-picker>
- <el-button
- v-if="form.periodType == 1"
- type="warning"
- size="small"
- icon="el-icon-setting"
- @click="setEndDateTo2099"
- title="一键将结束日期设置为2099-12-31"
- >
- 永久营期
- </el-button>
- </div>
- <div v-if="form.periodType == 1" style="color: #909399; font-size: 12px;">
- <i class="el-icon-info"></i> 点击"永久营期"可将结束日期设置为2099-12-31
- </div>
- </div>
- </el-form-item>
- <el-form-item prop="periodLine">
- <span slot="label">
- 营期线
- <el-tooltip content="营期首次播放课程的日期" placement="top">
- <i class="el-icon-question" style="margin-left: 5px; color: #909399; cursor: help;"></i>
- </el-tooltip>
- </span>
- <el-date-picker
- v-model="form.periodLine"
- type="date"
- placeholder="请选择营期线"
- value-format="yyyy-MM-dd"
- :clearable="true">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="课程选择" prop="courseId" v-if="courseSelectionIsAdd">
- <el-select v-model="form.courseId" placeholder="请选课程" filterable clearable size="small" >
- <el-option
- v-for="dict in courseSelection"
- :key="dict.courseId"
- :label="dict.courseName"
- :value="dict.courseId"
- />
- </el-select>
- </el-form-item>
- </el-form>
- <div class="drawer-footer">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-drawer>
- <!-- 添加训练营对话框 -->
- <el-dialog :title="campForm.trainingCampId ? '修改训练营' : '新建训练营'" :visible.sync="campDialogVisible" width="500px" append-to-body>
- <el-form ref="campForm" :model="campForm" :rules="campRules" label-width="100px">
- <el-form-item label="训练营名称" prop="trainingCampName">
- <el-input v-model="campForm.trainingCampName" placeholder="请输入训练营名称" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitCampForm">确 定</el-button>
- <el-button @click="cancelCampForm">取 消</el-button>
- </div>
- </el-dialog>
- <!-- <!– 添加或修改会员营期对话框–>-->
- <!-- <el-dialog title="课程管理" :visible.sync="course.open" width="75%" top="10px" append-to-body style="padding-bottom: 10px">-->
- <!-- <el-row :gutter="10" class="mb8">-->
- <!-- <el-col :span="1.5">-->
- <!-- <el-button-->
- <!-- v-if="(getDiff(course.row.periodStartingTime, course.row.periodEndTime) - course.total) > 0"-->
- <!-- type="primary"-->
- <!-- icon="el-icon-plus"-->
- <!-- size="mini"-->
- <!-- @click="handleAddCourse"-->
- <!-- v-hasPermi="['course:period:add']"-->
- <!-- >添加课程</el-button>-->
- <!-- </el-col>-->
- <!-- </el-row>-->
- <!-- <el-table v-loading="course.loading" :data="course.list">-->
- <!-- <el-table-column label="课程" align="center" prop="courseName" width="180" />-->
- <!-- <el-table-column label="小节" align="center" prop="videoName" />-->
- <!-- <el-table-column label="营期时间" align="center" prop="dayDate" width="150" />-->
- <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="150" />-->
- <!-- </el-table>-->
- <!-- <div slot="footer" class="dialog-footer">-->
- <!--<!– <el-button type="primary" @click="saveCourseData">保存</el-button>–>-->
- <!-- </div>-->
- <!-- </el-dialog>-->
- <!-- 添加课程对话框-->
- <el-dialog title="添加课程" :visible.sync="course.addOpen" width="500px" append-to-body>
- <el-form ref="courseAddForm" :model="course.form" :rules="courseAddRules" label-width="100px">
- <el-form-item label="课程" prop="courseId">
- <el-select filterable v-model="course.form.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(course.form.courseId)" style="width: 100%" :value-key="'dictValue'">
- <el-option
- v-for="dict in courseList"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="小节" prop="videoIds">
- <div style="display: flex; align-items: center; gap: 10px; width: 100%;">
- <el-select
- filterable
- v-model="course.form.videoIds"
- placeholder="请选择小节"
- :multiple-limit="getDiff(periodSettingsData.periodStartingTime, periodSettingsData.periodEndTime) - course.total"
- multiple
- clearable
- size="small"
- style="flex: 1"
- :value-key="'dictValue'"
- >
- <el-option
- v-for="dict in videoList"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="parseInt(dict.dictValue)"
- />
- </el-select>
- <el-button
- type="primary"
- size="small"
- @click="handleBatchSelectSections"
- :disabled="!course.form.courseId || !videoList || videoList.length === 0"
- title="一键选择所有可用小节"
- >
- 批量选择
- </el-button>
- </div>
- </el-form-item>
- <el-form-item label="看课时间" prop="timeRange">
- <el-time-picker
- is-range
- v-model="course.form.timeRange"
- :picker-options="{
- selectableRange: '00:00:00 - 23:59:59'
- }"
- range-separator="至"
- start-placeholder="开始时间"
- value-format="HH:mm:ss"
- end-placeholder="结束时间">
- </el-time-picker>
- </el-form-item>
- <el-form-item v-if="joinTimeSwitch" label="领取红包时间" prop="lastJoinTime">
- <el-time-picker
- v-model="course.form.joinTime"
- value-format="HH:mm:ss"
- placeholder="选择时间范围">
- </el-time-picker>
- <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitCourseForm">确 定</el-button>
- <el-button @click="closeAddCourse">取 消</el-button>
- </div>
- </el-dialog>
- <el-dialog title="修改看课时间" :visible.sync="updateCourse.open" width="600px" append-to-body>
- <el-form ref="courseUpdateForm" :model="updateCourse.form" :rules="courseUpdateRules" label-width="100px">
- <el-form-item label="看课时间" prop="timeRange" label-width="110px">
- <el-date-picker
- v-model="updateCourse.form.timeRange"
- type="datetimerange"
- range-separator="至"
- start-placeholder="开始时间"
- end-placeholder="结束时间"
- value-format="yyyy-MM-dd HH:mm:ss"
- :default-time="['00:00:00', '23:59:59']"
- :picker-options="{
- shortcuts: [{
- text: '今天',
- onClick(picker) {
- const end = new Date();
- const start = new Date();
- picker.$emit('pick', [start, end]);
- }
- }]
- }"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item v-if="joinTimeSwitch" label="领取红包时间" prop="joinTime" label-width="110px">
- <el-date-picker
- v-model="updateCourse.form.joinTime"
- type="datetime"
- placeholder="选择时间"
- value-format="yyyy-MM-dd HH:mm:ss"
- :default-time="'23:59:59'"
- >
- </el-date-picker>
- <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitUpdateCourseForm">确 定</el-button>
- <el-button @click="closeUpdateCourse">取 消</el-button>
- </div>
- </el-dialog>
- <el-dialog title="修改营期时间" :visible.sync="updatePeriodDate.open" width="500px" append-to-body>
- <el-form ref="courseUpdateForm" :model="updatePeriodDate.form" label-width="100px">
- <el-form-item label="营期时间" prop="dayDate">
- <el-date-picker
- v-model="updatePeriodDate.form.dayDate"
- :selectableRange="updatePeriodDate.form.dayDate"
- value-format="yyyy-MM-dd"
- type="date"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="updatePeriodDateSubmit">确 定</el-button>
- <el-button @click="updatePeriodDate.open = false">取 消</el-button>
- </div>
- </el-dialog>
- <!-- <red-packet-->
- <!-- :visible.sync="redPacketVisible"-->
- <!-- :periodId="currentRedPacketData.periodId"-->
- <!-- :videoId="currentRedPacketData.videoId"-->
- <!-- @success="handleRedPacketSuccess"-->
- <!-- />-->
- <!-- 营期相关设置抽屉 -->
- <el-drawer
- title="营期相关设置"
- :visible.sync="periodSettingsVisible"
- direction="rtl"
- size="74%"
- :destroy-on-close="true"
- append-to-body
- custom-class="period-settings-drawer"
- >
- <div class="drawer-content" style="margin-left: 25px">
- <el-tabs v-model="activeTab" @tab-click="handleTabClick">
- <el-tab-pane label="课程管理" name="course">
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- v-if="(getDiff(periodSettingsData.periodStartingTime, periodSettingsData.periodEndTime) - course.total) > 0"
- type="primary"
- icon="el-icon-plus"
- size="mini"
- @click="handleAddCourse"
- v-hasPermi="['course:period:addCourse']"
- >添加课程</el-button>
- </el-col>
- <!-- <el-col :span="1.5">-->
- <!-- <el-button-->
- <!-- type="primary"-->
- <!-- size="mini"-->
- <!-- :disabled="updateCourse.ids.length <= 0"-->
- <!-- @click="handleUpdatePeriodDate"-->
- <!-- >修改营期时间</el-button>-->
- <!-- </el-col>-->
- <el-col :span="1.5">
- <el-button
- type="primary"
- size="mini"
- :disabled="updateCourse.ids.length <= 0"
- @click="handleUpdateCourse"
- v-hasPermi="['course:period:updateCourseTime']"
- >修改看课时间</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- size="mini"
- icon="el-icon-delete"
- :disabled="updateCourse.ids.length <= 0"
- @click="handleDeleteCourse"
- v-hasPermi="['course:period:dayRemove']"
- >删除课程</el-button>
- </el-col>
- </el-row>
- <el-table ref="courseTable" v-loading="course.loading" :data="course.list" @selection-change="handleSelectionCourseChange" border>
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="课程" align="center" prop="courseName" width="180" />
- <el-table-column label="小节" align="center" prop="videoName" />
- <el-table-column label="开课状态" align="center" prop="status" width="100">
- <template slot-scope="scope">
- <span v-if="periodSettingsData.freeMode === 1">
- <el-tag type="success">进行中</el-tag>
- </span>
- <span v-else>{{ courseStatusFormatter(scope.row) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="营期时间" align="center" prop="dayDate" width="100"/>
- <el-table-column label="开始时间" align="center" prop="startDateTime" width="100">
- <!-- <template slot-scope="scope">-->
- <!-- <el-tag>{{scope.row.startDateTime}}</el-tag>-->
- <!-- </template>-->
- </el-table-column>
- <el-table-column label="结束时间" align="center" prop="endDateTime" width="120">
- <template slot-scope="scope">
- <span v-if="periodSettingsData.freeMode === 1">
- <el-tag type="warning">永不过期</el-tag>
- </span>
- <span v-else>{{ scope.row.endDateTime }}</span>
- </template>
- </el-table-column>
- <el-table-column label="领取红包时间" align="center" prop="lastJoinTime" width="160">
- <template slot-scope="scope">
- <el-tag type="danger">{{scope.row.lastJoinTime}}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-top"
- @click="handleTop(scope.row)"
- v-hasPermi="['course:period:courseMove']"
- >上移</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-bottom"
- @click="handleBottom(scope.row)"
- v-hasPermi="['course:period:courseMove']"
- >下移</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdateDate(scope.row)"
- >修改营期时间</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDeleteCourse(scope.row)"
- v-hasPermi="['course:period:dayRemove']"
- >删除课程</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="course.total > 0"
- :total="course.total"
- :page.sync="course.queryParams.pageNum"
- :limit.sync="course.queryParams.pageSize"
- @pagination="getCourseList"
- style="height: 40px"
- />
- </el-tab-pane>
- <el-tab-pane label="公司列表" name="company">
- <red-packet
- :visible.sync="redPacketVisible"
- :activeTab="activeTab"
- :periodId="periodSettingsData.periodId"
- @success="handleRedPacketSuccess"
- />
- </el-tab-pane>
- <el-tab-pane label="课程统计" name="statistics">
- <course-statistics
- :periodId="periodSettingsData.periodId"
- :active="activeTab === 'statistics'"
- />
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-drawer>
- <batch-red-packet
- :visible.sync="batchRedPacketVisible"
- :selected-data="selectedPeriods"
- @success="handleBatchRedPacketSuccess"
- />
- <el-dialog
- :title="addExistCampPeriodName"
- :visible.sync="addExistCampPeriod"
- width="1000px"
- append-to-body
- @close="handleDialogClose"
- >
- <el-form ref="createCampPeriodForm" :model="createCampPeriodForm" :rules="campRules" label-width="500px">
- <el-form-item label="营期创建方式" prop="campPeriodType">
- <el-radio-group v-model="createCampPeriodForm.campPeriodType" @change="handlePeriodTypeChange">
- <el-radio :label="1">从当前训练营复制</el-radio>
- <el-radio :label="2">从其他训练营复制</el-radio>
- <el-radio :label="3">我要新建一个训练营</el-radio>
- </el-radio-group>
- </el-form-item>
- <!-- 从当前训练营复制 -->
- <el-form-item
- v-if="createCampPeriodForm.campPeriodType === 1"
- label="选择当前营期"
- prop="periodId"
- >
- <el-select
- v-model="createCampPeriodForm.periodId"
- placeholder="请选择当前营期"
- clearable
- >
- <el-option
- v-for="item in currentCampPeriods"
- :key="item.periodId"
- :label="item.periodName"
- :value="item.periodId"
- />
- </el-select>
- </el-form-item>
- <!-- 从其他训练营复制 -->
- <el-form-item
- v-if="createCampPeriodForm.campPeriodType === 2"
- label="选择其他营期"
- prop="periodId"
- >
- <el-select
- v-model="createCampPeriodForm.trainingCampId"
- placeholder="请选择训练营"
- :loading="loadingNew"
- clearable
- filterable
- @change="handleTrainingCampChange"
- >
- <el-option
- v-for="item in trainingCampList"
- :key="item.trainingCampId"
- :label="item.trainingCampName"
- :value="item.trainingCampId"
- />
- </el-select>
- <el-select
- v-model="createCampPeriodForm.periodId"
- placeholder="请选择营期"
- :loading="loadingNew"
- clearable
- filterable
- >
- <el-option
- v-for="item in otherCampPeriods"
- :key="item.periodId"
- :label="item.periodName"
- :value="item.periodId"
- />
- </el-select>
- <div v-if="loadingNew" class="loading-text">
- <i class="el-icon-loading"></i> 加载中...
- </div>
- </el-form-item>
- <!-- 新建营期 -->
- <el-form-item
- v-if="createCampPeriodForm.campPeriodType === 3"
- label="新建营期名称"
- prop="trainingCampName"
- >
- <el-input
- v-model="createCampPeriodForm.trainingCampName"
- placeholder="请输入新训练营名称"
- style="width: 300px"
- maxlength="50"
- show-word-limit
- />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="copySubmitCampForm" :loading="submitLoading">确 定</el-button>
- <el-button @click="cancelExistCampPeriod" :disabled="submitLoading">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod, batchAddCourseSections,copyExistCampPeriod} from "@/api/course/userCoursePeriod";
- import {getCompanyList} from "@/api/company/company";
- import {listCamp, addCamp, editCamp, delCamp, copyCamp, getScreeningCampPeriod} from "@/api/course/userCourseCamp";
- import { courseList,videoList } from '@/api/course/courseRedPacketLog'
- import RedPacket from './redPacket.vue'
- import BatchRedPacket from './batchRedPacket.vue'
- import CourseStatistics from './statistics.vue'
- import Da from "element-ui/src/locale/lang/da";
- import { getConfigByKey } from '@/api/system/config'
- import {listUserCourse} from "@/api/course/userCourse";
- export default {
- name: "Period",
- components: {
- RedPacket,
- BatchRedPacket,
- CourseStatistics
- },
- data() {
- return {
- // 遮罩层
- loading: true,
- updateDateOpen: false,
- // 左侧遮罩层
- leftLoading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 左侧总条数
- leftTotal: 0,
- // 会员营期表格数据
- periodList: [],
- // 左侧列表数据
- leftList: [],
- videoList: [],
- // 弹出层标题
- title: "",
- isDisabledDateRange: false, //是否禁用开营日期
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- periodName: null,
- periodStartingTime: null,
- periodEndTime: null,
- companyIdList: []
- },
- // 左侧查询参数
- leftQueryParams: {
- pageNum: 1,
- pageSize: 10,
- hasNextPage: false,
- scs: 'order_number(desc),training_camp_id(desc)',
- trainingCampName: null
- },
- // 表单参数
- form: {},
- // 课程相关数据
- course: {
- open: false,
- row:{},
- list:[],
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- },
- loading: true,
- total: 0,
- addOpen: false,
- form: {},
- },
- //修改营期时间参数
- updatePeriodDate: {
- open: false,
- loading: true,
- ids: [],
- form: {},
- },
- joinTimeSwitch:true,
- updateCourse: {
- open: false,
- loading: true,
- ids: [],
- form: {
- timeRange: null,
- joinTime: null
- },
- },
- // 表单校验
- rules: {
- periodName: [
- { required: true, message: '营期名称不能为空', trigger: 'blur' }
- ],
- companyId: [
- { required: true, message: '公司不能为空', trigger: 'change' }
- ],
- courseStyle: [
- { required: true, message: '课程风格不能为空', trigger: 'change' }
- ],
- // redPacketGrantMethod: [
- // { required: true, message: '红包发放方式不能为空', trigger: 'change' }
- // ],
- periodType: [
- { required: true, message: '营期类型不能为空', trigger: 'change' }
- ],
- maxViewNum: [
- { required: true, message: '销售可查看天数不能为空', trigger: 'blur' }
- ],
- periodStartingTime: [
- { required: true, message: '开营日期不能为空', trigger: 'change' }
- ]
- },
- // 公司选项
- companyOptions: [],
- // 训练营列表
- campList: [],
- // 激活的训练营索引
- activeCampIndex: null,
- // 训练营对话框是否显示
- campDialogVisible: false,
- courseList: false,
- // 训练营表单
- campForm: {
- trainingCampId: null,
- trainingCampName: ''
- },
- // 训练营表单校验
- campRules: {
- trainingCampName: [
- { required: true, message: '训练营名称不能为空', trigger: 'blur' },
- { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
- ]
- },
- // 添加课程表单校验
- courseAddRules: {
- courseId: [
- { required: true, message: '请选择课程', trigger: 'change' }
- ],
- videoIds: [
- { required: true, message: '请选择小节', trigger: 'change' },
- { type: 'array', min: 1, message: '请至少选择一个小节', trigger: 'change' }
- ]
- },
- // 修改看课时间表单校验
- courseUpdateRules: {
- timeRange: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (!value || !Array.isArray(value) || value.length !== 2) {
- callback(new Error('请选择完整的看课时间范围'));
- } else {
- // 检查时间格式是否正确(yyyy-MM-dd HH:mm:ss)
- const timeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
- if (!timeRegex.test(value[0]) || !timeRegex.test(value[1])) {
- callback(new Error('时间格式不正确'));
- } else if (value[0] >= value[1]) {
- callback(new Error('结束时间必须大于开始时间'));
- } else {
- callback();
- }
- }
- },
- trigger: 'change'
- }
- ],
- joinTime: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (!value) {
- callback(new Error('请选择领取红包时间'));
- } else {
- // 检查时间格式是否正确(yyyy-MM-dd HH:mm:ss)
- const timeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
- if (!timeRegex.test(value)) {
- callback(new Error('时间格式不正确'));
- } else {
- // 检查领取红包时间是否在看课时间范围内
- const timeRange = this.updateCourse.form.timeRange;
- if (timeRange && Array.isArray(timeRange) && timeRange.length === 2) {
- if (value < timeRange[0] || value > timeRange[1]) {
- callback(new Error('领取红包时间必须在看课时间范围内'));
- } else {
- callback();
- }
- } else {
- callback();
- }
- }
- }
- },
- trigger: 'change'
- }
- ]
- },
- // 滚动节流标志
- scrollThrottle: false,
- // 加载更多状态
- loadingMore: false,
- // 设置红包对话框
- redPacketVisible: false,
- periodCompanyList: [],
- currentRedPacketData: {
- periodId: '',
- videoId: ''
- },
- // 营期相关设置抽屉
- periodSettingsVisible: false,
- activeTab: 'course',
- periodSettingsData: {},
- companyList: [],
- courseDialogVisible: false,
- redPacketList: [],
- currentCompany: null,
- // 选中的营期数据
- selectedPeriods: [],
- // 批量设置红包按钮是否禁用
- batchSetRedPacketDisabled: true,
- // 批量设置红包弹出框
- batchRedPacketVisible: false,
- //课程选择
- courseSelection: [],
- courseSelectionIsAdd: true, // 默认新增状态,编辑时会设为false
- // 训练营对话框是否显示
- addExistCampPeriod: false,
- addExistCampPeriodName: "新增已存在营期",
- loadingNew: false,
- submitLoading: false,
- // 表单数据
- createCampPeriodForm: {
- campPeriodType: 1,
- periodId: null,
- trainingCampName: null,
- },
- // 数据列表
- currentCampPeriods: [], // 当前训练营的期数列表
- otherCampPeriods: [], // 其他训练营的期数列表
- // 缓存数据避免重复请求
- periodDataCache: new Map(),
- trainingCampList:[],
- };
- },
- created() {
- courseList().then(response => {
- this.courseList = response.list;
- });
- // this.getList();
- this.getLeftList();
- this.getCompanyList();
- /** 获取课程下拉框*/
- listUserCourse().then(response => {
- this.courseSelection = response.rows;
- });
- },
- methods: {
- /** 删除按钮操作 */
- async handleDeleteCourse(row) {
- const periodDayIds = row.id || this.updateCourse.ids;
- try {
- await this.$confirm('是否确认删除该课程?', "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- });
- const res = await delPeriodDay(periodDayIds);
- if (res && res.code === 200) {
- this.getCourseList();// 刷新列表
- this.$message.success('删除成功');
- } else {
- this.$message.error(res.msg);
- }
- } catch (error) {
- }
- },
- /** 查询会员营期列表 */
- getList() {
- this.loading = true;
- const params = { ...this.queryParams };
- pagePeriod(params).then(response => {
- this.periodList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- /** 查询左侧列表 */
- getLeftList() {
- this.leftLoading = true;
- // 重置页码和加载更多状态
- this.leftQueryParams.pageNum = 1;
- this.loadingMore = false;
- // 训练营数据
- listCamp(this.leftQueryParams).then(response => {
- if (response && response.code === 200) {
- this.campList = response.data.list || [];
- this.leftQueryParams.hasNextPage = response.data.hasNextPage;
- this.activeCampIndex = this.campList.length > 0 ? 0 : null;
- this.selectCamp(this.activeCampIndex);
- // 如果当前显示的列表高度不足以触发滚动,但还有更多数据,自动加载下一页
- this.$nextTick(() => {
- const scrollEl = this.$refs.campList;
- if (scrollEl && this.leftQueryParams.hasNextPage && scrollEl.scrollHeight <= scrollEl.clientHeight) {
- this.loadMoreCamps();
- }
- });
- } else {
- this.$message.error(response.msg || '获取训练营列表失败');
- this.campList = [];
- this.leftQueryParams.hasNextPage = false;
- }
- this.leftLoading = false;
- }).catch(error => {
- console.error('获取训练营列表失败:', error);
- this.$message.error('获取训练营列表失败');
- this.campList = [];
- this.leftQueryParams.hasNextPage = false;
- this.leftLoading = false;
- });
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 左侧搜索按钮操作 */
- handleLeftQuery() {
- // 重置页码和列表
- this.leftQueryParams.pageNum = 1;
- this.campList = [];
- this.getLeftList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.queryParams.companyIdList = [];
- this.handleQuery();
- },
- /** 多选框选中数据 */
- handleSelectionChange(selection) {
- this.ids = selection.map(item => item.periodId)
- this.single = selection.length!==1
- this.multiple = !selection.length
- // 更新批量设置红包相关数据
- this.selectedPeriods = selection;
- this.batchSetRedPacketDisabled = selection.length === 0;
- },
- handleSelectionCourseChange(selection) {
- this.updateCourse.ids = selection.map(item => item.id)
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.courseSelectionIsAdd = true;
- this.reset();
- this.open = true;
- this.title = "添加会员营期";
- this.isDisabledDateRange = false;
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.courseSelectionIsAdd = false;
- this.reset();
- const periodId = row.periodId || this.ids
- getPeriod(periodId).then(response => {
- this.form = response.data;
- if (this.form.companyId) {
- this.form.companyId = this.form.companyId.split(',').map(id => Number(id));
- }
- // 设置看课时间范围(回显)
- if (this.form.viewStartTime && this.form.viewEndTime) {
- this.form.timeRange = [this.form.viewStartTime, this.form.viewEndTime];
- }
- if(this.form.periodType == 1){
- this.$set(this.form,'dateRange',[this.form.periodStartingTime, this.form.periodEndTime])
- }
- if(this.form.periodType == 2){
- this.$set(this.form,'date',this.form.periodStartingTime)
- }
- this.open = true;
- this.title = "修改会员营期";
- this.isDisabledDateRange = true;
- });
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- // 显示加载提示(全屏遮罩+转圈)
- const loading = this.$loading({
- lock: true, // 锁定屏幕滚动
- text: '提交中,请稍候...', // 提示文本
- spinner: 'el-icon-loading', // 加载图标
- background: 'rgba(0, 0, 0, 0.7)' // 背景遮罩
- });
- let data = JSON.parse(JSON.stringify(this.form));
- // 处理看课时间范围
- if (data.timeRange && data.timeRange.length === 2) {
- data.viewStartTime = data.timeRange[0];
- data.viewEndTime = data.timeRange[1];
- }
- data.companyId = data.companyId.join();
- data.trainingCampId = this.queryParams.trainingCampId;
- const request = data.periodId != null ? updatePeriod(data) : addPeriod(data);
- request.then(response => {
- if (response.code === 200) {
- this.msgSuccess(data.periodId != null ? "修改成功" : "新增成功");
- this.open = false;
- this.getList();
- }
- }).finally(() => {
- // 无论成功失败,都关闭加载提示
- loading.close();
- });
- }
- });
- },
- /** 删除按钮操作 */
- async handleDelete(row) {
- const periodIds = row.periodId || this.ids;
- try {
- await this.$confirm('是否确认删除该营期?', "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- });
- const res = await delPeriod(periodIds);
- if (res && res.code === 200) {
- this.getList(); // 刷新列表
- this.$message.success('删除成功');
- } else {
- this.$message.error(res.msg);
- }
- } catch (error) {
- }
- },
- /** 导出按钮操作 */
- handleExport() {
- const queryParams = this.queryParams;
- this.$confirm('是否确认导出所有会员营期数据项?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function() {
- return exportPeriod(queryParams);
- }).then(response => {
- this.download(response.msg);
- }).catch(function() {});
- },
- /** 批量设置红包 */
- handleBatchSetRedPacket() {
- if (this.selectedPeriods.length === 0) {
- this.$message.warning('请至少选择一个营期');
- return;
- }
- this.batchRedPacketVisible = true;
- },
- /** 处理批量设置红包保存 */
- // handleBatchRedPacketSave(data) {
- // // 这里等待接口提供后补充具体实现
- // // 示例代码:
- // // batchSetRedPacket(data).then(response => {
- // // if (response.code === 200) {
- // // this.$message.success('批量设置成功');
- // // this.getList();
- // // }
- // // });
- // this.batchRedPacketVisible = false;
- // },
- /** 获取公司下拉列表*/
- getCompanyList() {
- this.loading = true;
- getCompanyList().then(response => {
- this.companyOptions = response.data;
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- periodId: null,
- periodName: null,
- companyId: null,
- courseId: null,
- videoId: null,
- trainingCampId: null,
- createTime: null,
- updateTime: null,
- courseStyle: null,
- liveRoomStyle: null,
- redPacketGrantMethod: 1,
- periodType: 1,
- periodStartingTime: null,
- dateRange: [],
- date: null,
- days: [],
- maxViewNum: 0,
- periodEndTime: null,
- timeRange: [], // 看课时间范围
- viewStartTime: null, // 看课开始时间
- viewEndTime: null, // 看课结束时间
- lastJoinTime: null, // 领取红包时间
- freeMode: 0 // 是否开启自由模式,默认关闭
- };
- this.resetForm("form");
- },
- // 处理训练营列表的逻辑
- handleDeleteCamp(item) {
- this.$confirm(`确定要删除训练营"${item.trainingCampName}"吗?`, '提示', {
- confirmButtonText: '删除',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- // 调用删除训练营API
- const trainingCampId = item.trainingCampId;
- this.leftLoading = true;
- delCamp(trainingCampId).then(response => {
- if (response.code === 200) {
- this.$message.success('删除成功');
- // 从列表中移除
- const index = this.campList.findIndex(camp => camp.trainingCampId === trainingCampId);
- if (index !== -1) {
- this.campList.splice(index, 1);
- }
- // 如果删除的是当前选中的训练营,则重置选中状态
- if (this.activeCampIndex === index) {
- this.activeCampIndex = this.campList.length > 0 ? 0 : null;
- if (this.activeCampIndex !== null) {
- // 更新右侧列表
- this.selectCamp(this.activeCampIndex);
- } else {
- // 没有训练营了,清空右侧列表
- this.periodList = [];
- }
- }
- } else {
- this.$message.error(response.msg || '删除失败');
- }
- this.leftLoading = false;
- }).catch(error => {
- // this.$message.error('删除失败: ' + error.message);
- this.leftLoading = false;
- });
- }).catch(() => {
- this.$message.info('已取消删除');
- });
- },
- /** 复制训练营 */
- handleCopyCamp(item) {
- // 调用添加训练营API
- copyCamp(item.trainingCampId).then(response => {
- if (response.code === 200) {
- this.$message.success('复制成功');
- // 重新加载训练营列表
- this.getLeftList();
- } else {
- this.$message.error(response.msg || '复制训练营失败');
- }
- }).catch(error => {
- this.$message.error('复制训练营失败: ' + error.message);
- });
- },
- /** 修改训练营按钮操作 */
- handleEditCamp(item) {
- this.resetCampForm();
- this.leftLoading = true;
- // 获取最新的训练营数据
- const trainingCampId = item.trainingCampId;
- // 应该调用获取训练营详情的API
- setTimeout(() => {
- // 填充表单数据
- this.campForm = {
- trainingCampId: item.trainingCampId,
- trainingCampName: item.trainingCampName,
- orderNumber: item.orderNumber || 1,
- status: item.status !== undefined ? item.status : 1
- };
- this.campDialogVisible = true;
- this.leftLoading = false;
- }, 300);
- },
- /** 新建训练营按钮操作 */
- handleAddTrainingCamp() {
- this.resetCampForm();
- this.campDialogVisible = true;
- },
- /** 重置训练营表单 */
- resetCampForm() {
- this.campForm = {
- trainingCampId: null,
- trainingCampName: ''
- };
- // 如果表单已经创建,则重置校验结果
- if (this.$refs.campForm) {
- this.$refs.campForm.resetFields();
- }
- },
- /** 取消训练营表单 */
- cancelCampForm() {
- this.campDialogVisible = false;
- this.resetCampForm();
- },
- /** 提交训练营表单 */
- submitCampForm() {
- this.$refs.campForm.validate(valid => {
- if (valid) {
- // 显示加载中
- this.leftLoading = true;
- // 准备提交的数据
- const submitData = JSON.parse(JSON.stringify(this.campForm));
- // 判断是新增还是修改
- if (submitData.trainingCampId) {
- // 修改训练营
- editCamp(submitData).then(response => {
- if (response.code === 200) {
- this.$message.success('修改训练营成功');
- this.campDialogVisible = false;
- // 更新列表中的数据
- const index = this.campList.findIndex(camp => camp.trainingCampId === submitData.trainingCampId);
- if (index !== -1) {
- this.campList[index] = { ...this.campList[index], ...submitData };
- // 如果修改的是当前选中的训练营,更新右侧列表
- if (this.activeCampIndex === index) {
- this.selectCamp(index);
- }
- }
- // 重新加载训练营列表
- this.getLeftList();
- } else {
- this.$message.error(response.msg || '修改训练营失败');
- this.leftLoading = false;
- }
- }).catch(error => {
- this.$message.error('修改训练营失败: ' + (error.message || '未知错误'));
- this.leftLoading = false;
- });
- } else {
- // 新增训练营
- addCamp(submitData).then(response => {
- if (response.code === 200) {
- this.$message.success('新建训练营成功');
- this.campDialogVisible = false;
- // 重新加载训练营列表
- this.getLeftList();
- } else {
- this.$message.error(response.msg || '新建训练营失败');
- this.leftLoading = false;
- }
- }).catch(error => {
- this.$message.error('新建训练营失败: ' + (error.message || '未知错误'));
- this.leftLoading = false;
- });
- }
- }
- });
- },
- /** 排序方式改变 */
- handleSortChange(value) {
- this.leftQueryParams.scs = value;
- // 重置页码和列表
- this.leftQueryParams.pageNum = 1;
- this.campList = [];
- this.getLeftList();
- },
- /** 选中训练营 */
- selectCamp(index) {
- if(index == null || index == undefined) return;
- this.activeCampIndex = index;
- // 加载对应的训练营营期数据
- const selectedCamp = this.campList[index];
- this.queryParams.trainingCampId = selectedCamp.trainingCampId;
- this.trainingCampIdValue=selectedCamp.trainingCampId;
- this.getList();
- },
- /** 处理滚动事件,实现滚动到底部加载更多 */
- handleScroll() {
- // 如果正在节流中或者正在加载中,则不处理
- if (this.scrollThrottle || this.loadingMore) return;
- // 设置节流,200ms内不再处理滚动事件
- this.scrollThrottle = true;
- setTimeout(() => {
- this.scrollThrottle = false;
- }, 200);
- const scrollEl = this.$refs.campList;
- if (!scrollEl) return;
- // 判断是否滚动到底部:滚动高度 + 可视高度 >= 总高度 - 30(添加30px的容差,提前触发加载)
- const isBottom = scrollEl.scrollTop + scrollEl.clientHeight >= scrollEl.scrollHeight - 30;
- // 如果滚动到底部,且有下一页数据,且当前不在加载中,则加载更多
- if (isBottom && this.leftQueryParams.hasNextPage && !this.leftLoading && !this.loadingMore) {
- this.loadMoreCamps();
- }
- },
- /** 加载更多训练营数据 */
- loadMoreCamps() {
- // 已在加载中,防止重复加载
- if (this.leftLoading || this.loadingMore) return;
- // 设置加载状态
- this.loadingMore = true;
- // 页码加1
- this.leftQueryParams.pageNum += 1;
- // 加载下一页数据
- listCamp(this.leftQueryParams).then(response => {
- if (response && response.code === 200) {
- // 将新数据追加到列表中
- const newList = response.data.list || [];
- if (newList.length > 0) {
- this.campList = [...this.campList, ...newList];
- }
- // 更新是否有下一页的标志
- this.leftQueryParams.hasNextPage = response.data.hasNextPage;
- // 如果当前显示的列表高度不足以触发滚动,但还有更多数据,自动加载下一页
- this.$nextTick(() => {
- const scrollEl = this.$refs.campList;
- if (scrollEl && this.leftQueryParams.hasNextPage && scrollEl.scrollHeight <= scrollEl.clientHeight) {
- // 延迟一点再加载下一页,避免过快加载
- setTimeout(() => {
- this.loadMoreCamps();
- }, 300);
- }
- });
- } else {
- this.$message.error(response.msg || '加载更多训练营失败');
- }
- this.loadingMore = false;
- }).catch(error => {
- console.error('加载更多训练营失败:', error);
- this.$message.error('加载更多训练营失败');
- this.loadingMore = false;
- });
- },
- timeChange(type) {
- if (type == 1) {
- this.form.periodStartingTime = this.form.dateRange[0];
- this.form.periodEndTime = this.form.dateRange[1];
- if (!Array.isArray(this.form.days)) {
- this.form.days = [];
- }
- this.form.days = [];
- let days = this.getDiff(this.form.periodStartingTime, this.form.periodEndTime);
- for (let i = 0; i < days; i++) {
- this.form.days.push({ lesson: i + 1 });
- }
- }
- if (type == 2) {
- this.form.periodStartingTime = this.form.date;
- this.form.periodEndTime = this.form.date;
- this.form.days = [];
- }
- },
- /** 一键设置结束日期为2099-12-31 */
- setEndDateTo2099() {
- // 检查是否有开始日期
- if (!this.form.dateRange || !this.form.dateRange[0]) {
- this.$message.warning('请先选择开始日期');
- return;
- }
- this.$confirm('是否将结束日期设置为 2099-12-31?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'info'
- }).then(() => {
- // 保持开始日期,修改结束日期
- this.form.dateRange = [this.form.dateRange[0], '2099-12-31'];
- // 触发时间变更事件
- this.timeChange(1);
- this.$message.success('已将结束日期设置为 2099-12-31');
- }).catch(() => {
- this.$message.info('已取消操作');
- });
- },
- getDiff(start, end) {
- if(start == null || start == undefined || start == '') return 0;
- if(end == null || end == undefined || end == '') return 0;
- if(start == end) 1;
- const startDate = this.getUTCDate(start);
- const endDate = this.getUTCDate(end);
- const timeDiff = endDate - startDate;
- return (Math.floor(timeDiff / (1000 * 3600 * 24))) + 1; // 直接取整
- },
- getUTCDate(dateStr) {
- const [year, month, day] = dateStr.split('-').map(Number);
- return new Date(Date.UTC(year, month - 1, day)); // 月份从0开始
- },
- // handleCourse(row){
- // this.course = {
- // open: false,
- // row:{},
- // list:[],
- // queryParams: {
- // pageNum: 1,
- // pageSize: 3, // 修改为每页显示3条
- // },
- // loading: true,
- // total: 0,
- // addOpen: false,
- // form: {},
- // };
- // this.course.open = true;
- // this.course.row = row;
- // this.course.queryParams.periodId = row.periodId;
- // this.getCourseList();
- // },
- getCourseList(){
- this.course.loading = true;
- getDays(this.course.queryParams).then(e => {
- this.course.list = e.rows;
- this.course.total = e.total;
- this.course.loading = false;
- });
- },
- handleAddCourse() {
- const key = "joinTime.switch.config"
- getConfigByKey(key).then(response => {
- const {code,data} = response
- if (code === 200) {
- let value = data?.configValue
- console.log(value)
- if (value) {
- this.joinTimeSwitch = value=='0'?true:false;
- }
- }
- });
- this.course.addOpen = true;
- this.course.form = {
- periodId: this.course.queryParams.periodId,
- courseId: null,
- timeRange: ['00:00:00', '23:59:59'],
- joinTime: '23:59:59',
- videoIds: []
- };
- // 重置表单
- this.$nextTick(() => {
- if (this.$refs.courseAddForm) {
- this.$refs.courseAddForm.resetFields();
- }
- });
- },
- handleUpdateCourse() {
- const key = "joinTime.switch.config"
- getConfigByKey(key).then(response => {
- const {code,data} = response
- if (code === 200) {
- let value = data?.configValue
- console.log(value)
- if (value) {
- this.joinTimeSwitch = value=='0'?true:false;
- }
- }
- })
- this.updateCourse.open = true;
- this.updateCourse.form = {
- ids: this.updateCourse.ids,
- timeRange: null,
- joinTime: null
- };
- // 重置表单校验状态(但不清空选中状态)
- this.$nextTick(() => {
- if (this.$refs.courseUpdateForm) {
- this.$refs.courseUpdateForm.resetFields();
- }
- });
- },
- closeAddCourse() {
- this.course.addOpen = false;
- this.course.form = {
- periodId: null,
- courseId: null,
- timeRange: null,
- joinTime: null,
- videoIds: []
- };
- // 重置表单
- if (this.$refs.courseAddForm) {
- this.$refs.courseAddForm.resetFields();
- }
- },
- closeUpdateCourse() {
- this.updateCourse.open = false;
- // 清空选中的课程id,使【修改看课时间】按钮变为禁用状态
- this.updateCourse.ids = [];
- // 清空课程列表的选中状态
- this.$nextTick(() => {
- if (this.$refs.courseTable) {
- this.$refs.courseTable.clearSelection();
- }
- });
- // 重置表单数据
- this.updateCourse.form = {
- ids: [],
- timeRange: null,
- joinTime: null
- };
- // 重置表单校验
- this.$nextTick(() => {
- if (this.$refs.courseUpdateForm) {
- this.$refs.courseUpdateForm.resetFields();
- }
- });
- },
- courseChange(row){
- this.course.form.videoIds = [];
- videoList(row).then(response => {
- this.videoList=response.list
- });
- },
- submitCourseForm(){
- this.$refs.courseAddForm.validate(valid => {
- if (valid) {
- if(this.course.form.timeRange != null && this.course.form.timeRange.length === 2){
- this.course.form.startTime = this.course.form.timeRange[0];
- this.course.form.endTime1 = this.course.form.timeRange[1];
- }
- // 检查是否有选择的小节
- if (!this.course.form.videoIds || this.course.form.videoIds.length === 0) {
- this.$message.warning('请选择至少一个小节');
- return;
- }
- // 如果选择了多个小节,使用批量添加接口
- if (this.course.form.videoIds.length > 1) {
- const batchData = {
- periodId: this.course.form.periodId,
- courseId: this.course.form.courseId,
- videoIds: this.course.form.videoIds,
- startTime: this.course.form.startTime,
- endTime1: this.course.form.endTime1,
- endDateTime: this.course.form.endTime1, // 添加endDateTime参数
- joinTime: this.course.form.joinTime
- };
- // 调用批量添加小节接口
- batchAddCourseSections(batchData).then(response => {
- if (response.code === 200) {
- this.$message.success('批量添加课程成功');
- this.course.addOpen = false;
- this.getCourseList();
- } else {
- this.$message.error(response.msg || '批量添加课程失败');
- }
- }).catch(error => {
- this.$message.error('批量添加课程失败:' + (error.message || '未知错误'));
- });
- } else {
- // 单个小节,使用原来的接口
- addCourse(this.course.form).then(response => {
- this.$message.success('添加成功');
- this.course.addOpen = false;
- this.getCourseList();
- }).catch(error => {
- this.$message.error('添加失败:' + (error.message || '未知错误'));
- });
- }
- }
- });
- },
- /** 批量选择小节 */
- handleBatchSelectSections() {
- if (!this.course.form.courseId) {
- this.$message.warning('请先选择课程');
- return;
- }
- if (!this.videoList || this.videoList.length === 0) {
- this.$message.warning('该课程下暂无可选择的小节');
- return;
- }
- this.$confirm('确认要批量选择所有小节吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'info'
- }).then(() => {
- // 获取所有可用的小节ID
- const allVideoIds = this.videoList.map(video => parseInt(video.dictValue));
- // 获取剩余可选择数量
- const remainingLimit = this.getDiff(this.periodSettingsData.periodStartingTime, this.periodSettingsData.periodEndTime) - this.course.total;
- // 调试信息
- console.log('批量选择调试信息:', {
- 营期开始时间: this.periodSettingsData.periodStartingTime,
- 营期结束时间: this.periodSettingsData.periodEndTime,
- 营期总天数: this.getDiff(this.periodSettingsData.periodStartingTime, this.periodSettingsData.periodEndTime),
- 已有课程数: this.course.total,
- 剩余可选择数量: remainingLimit,
- 可用小节总数: allVideoIds.length
- });
- // 只选择剩余数量内的小节
- const selectedVideoIds = allVideoIds.slice(0, remainingLimit);
- if (selectedVideoIds.length === 0) {
- this.$message.warning('已达到营期天数限制,无法添加更多小节');
- return;
- }
- // 将选中的小节ID设置到表单中(只是选择,不调用API)
- this.course.form.videoIds = selectedVideoIds;
- this.$message.success(`批量选择成功,已选择 ${selectedVideoIds.length} 个小节`);
- }).catch(() => {
- this.$message.info('已取消批量选择');
- });
- },
- submitUpdateCourseForm(){
- this.$refs.courseUpdateForm.validate(valid => {
- if (valid) {
- // 检查时间范围是否正确
- if (this.updateCourse.form.timeRange &&
- Array.isArray(this.updateCourse.form.timeRange) &&
- this.updateCourse.form.timeRange.length === 2) {
- this.updateCourse.form.startTime = this.updateCourse.form.timeRange[0];
- this.updateCourse.form.endTime1 = this.updateCourse.form.timeRange[1];
- } else {
- this.$message.error('请先选择正确的看课时间范围');
- return;
- }
- // 检查领取红包时间是否正确
- if (!this.updateCourse.form.joinTime&&this.joinTimeSwitch) {
- this.$message.error('请选择领取红包时间');
- return;
- }
- // 提交数据
- updateCourseTime(this.updateCourse.form).then(response => {
- this.$message.success('修改成功');
- this.updateCourse.open = false;
- // 清空选中的课程ID,使【修改看课时间】按钮变为禁用状态
- this.updateCourse.ids = [];
- // 清空课程列表的选中状态
- this.$nextTick(() => {
- if (this.$refs.courseTable) {
- this.$refs.courseTable.clearSelection();
- }
- });
- // 重新加载训练营列表
- this.getCourseList();
- }).catch(error => {
- this.$message.error('修改失败:' + (error.message || '未知错误'));
- });
- }
- });
- },
- updatePeriodDateSubmit(){
- updateCourseDate(this.updatePeriodDate.form).then(response => {
- this.$message.success('修改成功');
- this.updatePeriodDate.open = false;
- // 重新加载课程列表
- this.getCourseList();
- });
- },
- // saveCourseData(){
- // updateListCourseData(this.course.list).then(response => {
- // this.$message.success('保存成功');
- // this.getCourseList();
- // });
- // },
- // setRedPacket(row) {
- // this.currentRedPacketData = {
- // periodId: row.periodId
- // // videoId: row.videoId
- // };
- // this.redPacketVisible = true;
- // },
- handleRedPacketSuccess() {
- this.getCourseList();
- },
- handlePeriodSettings(row) {
- this.periodSettingsData = row;
- this.periodSettingsVisible = true;
- // 初始化课程列表
- this.course.queryParams.periodId = row.periodId;
- // 根据当前激活的tab加载对应数据
- this.handleTabClick({ name: this.activeTab });
- },
- // 结束营期
- handleClosePeriod(row) {
- const msg = `注: 1.确认结束营期,该营期的开营结束时间改为当天24点。2.当天正在播放中的课程不变。3.第二天如有未开始的课程,统一改为已结束。是否确认结束 ${row.periodName} 营期吗?`
- this.$confirm(msg, "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- closePeriod({id: row.periodId}).then(response => {
- if (response.code === 200) {
- this.getList()
- } else {
- this.$message.error(response.msg)
- }
- })
- }).catch(() => {})
- },
- handleBatchRedPacketSuccess() {
- this.batchRedPacketVisible = false;
- this.getCourseList();
- },
- /** 处理tab切换 */
- handleTabClick(tab) {
- if (tab.name === 'course') {
- this.getCourseList();
- } else if (tab.name === 'company') {
- this.redPacketVisible = true;
- }
- },
- /** 上移课程 */
- handleTop(row) {
- const currentIndex = this.course.list.findIndex(item => item.id === row.id);
- if (currentIndex <= 0) {
- this.$message.warning('已经是第一条数据');
- return;
- }
- // 获取上一条数据
- const prevRow = this.course.list[currentIndex - 1];
- console.log({
- id: row.id,
- targetId: prevRow.id,
- type: 1 //上移
- })
- periodCourseMove({
- id: row.id,
- targetId: prevRow.id,
- type: 1 //上移
- }).then(response => {
- if (response.code === 200) {
- this.$message.success('上移成功');
- this.getCourseList();
- } else {
- this.$message.error(response.msg || '上移失败');
- }
- }).catch(() => {
- this.$message.error('上移失败');
- });
- },
- /** 下移课程 */
- handleBottom(row) {
- const currentIndex = this.course.list.findIndex(item => item.id === row.id);
- if (currentIndex === -1 || currentIndex >= this.course.list.length - 1) {
- this.$message.warning('已经是最后一条数据');
- return;
- }
- // 获取下一条数据
- const nextRow = this.course.list[currentIndex + 1];
- periodCourseMove({
- id: row.id,
- targetId: nextRow.id,
- type: 2 //下移
- }).then(response => {
- if (response.code === 200) {
- this.$message.success('下移成功');
- this.getCourseList(); // 重新加载列表
- } else {
- this.$message.error(response.msg || '下移失败');
- }
- }).catch(() => {
- this.$message.error('下移失败');
- });
- },
- /** 营期状态格式化 */
- periodStatusFormatter(row) {
- const statusMap = {
- 1: '未开始',
- 2: '进行中',
- 3: '已结束'
- };
- return statusMap[row.periodStatus] || '未知状态';
- },
- /** 开课状态格式化 */
- courseStatusFormatter(row) {
- const statusMap = {
- 0: '未开始',
- 1: '进行中',
- 2: '已结束'
- };
- return statusMap[row.status] || '未知状态';
- },
- /** 营期状态格式化 */
- handleUpdateDate(row) {
- this.updatePeriodDate.form = {id: row.id, dayDate: row.dayDate};
- this.updatePeriodDate.open = true;
- },
- // disabledDate(time) {
- // return time.getTime() < new Date(new Date().setHours(0,0,0,0));
- // },
- getPickerOptions() {
- // 如果已选择看课时间范围,则领取红包时间应在看课时间范围内
- if (this.updateCourse.form.timeRange &&
- Array.isArray(this.updateCourse.form.timeRange) &&
- this.updateCourse.form.timeRange.length === 2) {
- return {
- selectableRange: `${this.updateCourse.form.timeRange[0]} - ${this.updateCourse.form.timeRange[1]}`
- };
- }
- // 默认全天可选
- return {
- selectableRange: '00:00:00 - 23:59:59'
- };
- },
- onTimeRangeChange() {
- // 当看课时间范围改变时,清空领取红包时间
- this.updateCourse.form.joinTime = null;
- // 强制更新组件以刷新领取红包时间的可选范围
- this.$forceUpdate();
- },
- /** 新建存在训练营按钮操作 */
- handleAddExistCampPeriod() {
- this.resetForm();
- this.addExistCampPeriod = true;
- // 初始化当前训练营的期数列表
- this.initCurrentCampPeriods();
- },
- /** 初始化当前训练营期数列表 */
- initCurrentCampPeriods() {
- this.currentCampPeriods = [...(this.periodList || [])];
- },
- /** 处理创建方式变更 */
- async handlePeriodTypeChange(value) {
- this.createCampPeriodForm.periodId = null;
- this.createCampPeriodForm.trainingCampName = null;
- if (value === 1) {
- // 从当前训练营复制 - 使用本地数据
- this.initCurrentCampPeriods();
- } else if (value === 2) {
- // 从其他训练营复制 - 需要请求接口
- await this.loadOtherCampPeriods();
- }
- },
- /** 加载其他训练营期数列表 */
- async loadOtherCampPeriods() {
- // 清空营期数据和选中项,避免显示旧数据
- this.otherCampPeriods = [];
- this.createCampPeriodForm.periodId = ''; // 清空已选营期
- this.createCampPeriodForm.trainingCampId = ''; // 清空已选训练营
- // 检查缓存 - 使用固定键名,因为训练营列表不依赖当前训练营ID
- // const cacheKey = 'trainingCampList';
- // if (this.periodDataCache.has(cacheKey)) {
- // this.trainingCampList = this.periodDataCache.get(cacheKey);
- // return;
- // }
- this.loadingNew = true;
- try {
- const requestParams = {
- periodId: this.trainingCampIdValue,
- campPeriodType: this.createCampPeriodForm.campPeriodType
- };
- const response = await getScreeningCampPeriod(requestParams);
- if (response && Array.isArray(response.resultList)) {
- this.trainingCampList = response.resultList;
- // 缓存数据 - 使用固定键名
- //this.periodDataCache.set(cacheKey, response.resultList);
- } else {
- console.warn('接口返回格式异常:', response);
- this.trainingCampList = [];
- }
- } catch (error) {
- console.error('接口请求失败:', error);
- this.$message.error('查询失败,请重试');
- this.trainingCampList = [];
- } finally {
- this.loadingNew = false;
- }
- },
- /** 提交表单 */
- copySubmitCampForm() {
- try {
- // 表单验证
- const valid = this.$refs.createCampPeriodForm.validate();
- if (!valid) return ;
- this.submitLoading = true;
- const submitData = this.buildSubmitData();
- if (submitData.campPeriodType===3){
- // 新增训练营
- addCamp(submitData).then(response => {
- if (response.code === 200) {
- this.$message.success('新建训练营成功');
- this.addExistCampPeriod = false;
- // 重新加载训练营列表
- this.getLeftList();
- } else {
- this.$message.error(response.msg || '新建训练营失败');
- }
- }).catch(error => {
- this.$message.error('新建训练营失败: ' + (error.message || '未知错误'));
- });
- }else {
- // 显示全屏加载圈和遮蔽层
- const loadingInstance = this.$loading({
- lock: true,
- text: '复制营期中,请耐心等待...',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- // 调用批量添加小节接口
- copyExistCampPeriod(submitData).then(response => {
- if (response.code === 200) {
- this.$message.success('复制营期成功');
- this.course.addOpen = false;
- this.addExistCampPeriod = false;
- // 重新加载训练营列表
- this.getList();
- } else {
- this.$message.error(response.msg || '复制营期失败');
- }
- }).catch(error => {
- this.$message.error('复制营期失败:' + (error.message || '未知错误'));
- }).finally(() => {
- loadingInstance.close(); // 关闭加载圈
- });
- }
- } catch (error) {
- this.$message.error('提交失败:' + (error.message || '未知错误'));
- } finally {
- this.submitLoading = false;
- }
- },
- /** 组装提交数据 */
- buildSubmitData() {
- const { campPeriodType, periodId, trainingCampName } = this.createCampPeriodForm;
- const baseData = {
- campPeriodType,
- trainingCampId: this.trainingCampIdValue // 这里已经正确添加了 trainingCampId
- };
- switch (campPeriodType) {
- case 1: // 从当前训练营复制
- case 2: // 从其他训练营复制
- if (!periodId) {
- throw new Error('请选择要复制的营期');
- }
- return { ...baseData, periodId };
- case 3: // 新建营期
- if (!trainingCampName?.trim()) {
- throw new Error('请输入营期名称');
- }
- return { ...baseData, trainingCampName: trainingCampName.trim() };
- default:
- throw new Error('未知的创建方式');
- }
- },
- /** 取消新建存在训练营 */
- cancelExistCampPeriod() {
- this.addExistCampPeriod = false;
- this.resetForm();
- },
- /** 对话框关闭事件 */
- handleDialogClose() {
- this.resetForm();
- },
- /** 重置表单 */
- resetForm() {
- this.createCampPeriodForm = {
- campPeriodType: 1,
- periodId: null,
- trainingCampName: null,
- };
- this.currentCampPeriods = [];
- this.otherCampPeriods = [];
- this.trainingCampList=[]
- this.loading = false;
- this.submitLoading = false;
- // 清除表单验证
- if (this.$refs.createCampPeriodForm) {
- this.$refs.createCampPeriodForm.clearValidate();
- }
- },
- /** 全选/取消全选公司 */
- handleSelectAllCompanies(type) {
- if (!this.companyOptions || this.companyOptions.length === 0) {
- this.$message.warning('暂无可选公司');
- return;
- }
- if (type === 'form') {
- // 营期表单中的公司选择
- if (this.isAllCompaniesSelected('form')) {
- // 当前已全选,则取消全选
- this.form.companyId = [];
- } else {
- // 当前未全选,则全选
- this.form.companyId = this.companyOptions.map(item => item.companyId);
- }
- } else if (type === 'query') {
- // 查询条件中的公司选择
- if (this.isAllCompaniesSelected('query')) {
- // 当前已全选,则取消全选
- this.queryParams.companyIdList = [];
- } else {
- // 当前未全选,则全选
- this.queryParams.companyIdList = this.companyOptions.map(item => item.companyId);
- }
- }
- },
- /** 判断是否已全选公司 */
- isAllCompaniesSelected(type) {
- if (!this.companyOptions || this.companyOptions.length === 0) {
- return false;
- }
- let selectedCompanies = [];
- if (type === 'form') {
- selectedCompanies = this.form.companyId || [];
- } else if (type === 'query') {
- selectedCompanies = this.queryParams.companyIdList || [];
- }
- return selectedCompanies.length === this.companyOptions.length;
- },
- handleTrainingCampChange(trainingCampId){
- this.otherCampPeriods = [];
- this.createCampPeriodForm.periodId = '';
- const params = {
- ...this.queryParams,
- trainingCampId: trainingCampId // 更新训练营ID
- };
- pagePeriod(params).then(response => {
- if (response.code === 200) {
- this.otherCampPeriods = response.rows;
- } else {
- this.$message.error(response.msg || '查询营期失败');
- }
- }).catch(error => {
- this.$message.error('查询营期失败: ' + (error.message || '查询营期失败'));
- });
- },
- },
- };
- </script>
- <style scoped>
- .left-aside {
- background-color: #fff;
- border-right: 1px solid #EBEEF5;
- padding: 0;
- display: flex;
- flex-direction: column;
- height: 800px;
- }
- .left-header {
- padding: 10px;
- border-bottom: 1px solid #EBEEF5;
- }
- .left-header-top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10px;
- }
- .search-btn {
- width: 50%;
- height: 36px;
- background-color: #409EFF;
- color: white;
- border: none;
- }
- .search-input-wrapper {
- margin-bottom: 10px;
- }
- .sort-wrapper {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- }
- .sort-label {
- width: 70px;
- font-size: 14px;
- font-weight: 600;
- color: #909399;
- }
- .sort-select {
- margin-left: 10px;
- width: 280px;
- }
- .color-wrapper {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- }
- .color-label {
- width: 70px;
- color: #606266;
- }
- .color-hint {
- margin-left: 10px;
- color: #606266;
- font-size: 12px;
- }
- .color-help {
- margin-left: 5px;
- color: #909399;
- cursor: pointer;
- }
- .hint-text {
- color: #606266;
- font-size: 12px;
- margin-top: 5px;
- }
- .camp-list {
- flex: 1;
- overflow-y: auto;
- padding: 3px;
- }
- .camp-item {
- margin-bottom: 5px;
- padding: 15px;
- background-color: #ffffff;
- position: relative;
- cursor: pointer;
- display: flex;
- justify-content: space-between;
- border: 1px solid #eaedf2;
- }
- .camp-item:last-child {
- margin-bottom: 0;
- }
- .camp-item:hover {
- background-color: #f5f9ff;
- }
- .camp-item.active {
- background-color: #eaf4ff;
- border-left: 1px solid #75b8fc;
- }
- .camp-content {
- flex: 1;
- padding-right: 10px;
- }
- .camp-title {
- font-weight: bold;
- font-size: 16px;
- margin-bottom: 8px;
- color: #333;
- display: flex;
- align-items: center;
- }
- .camp-icon {
- font-size: 16px;
- margin-right: 6px;
- color: #409EFF;
- }
- .camp-info {
- display: flex;
- justify-content: space-between;
- margin-bottom: 8px;
- font-size: 12px;
- color: #c4c1c1;
- line-height: 1.5;
- }
- .camp-stats {
- display: flex;
- justify-content: space-between;
- font-size: 12px;
- color: #666;
- background-color: #f5f9ff;
- padding: 6px 10px;
- border-radius: 4px;
- line-height: 1.5;
- }
- .stat-item {
- display: flex;
- align-items: center;
- }
- .stat-item i {
- margin-right: 4px;
- font-size: 14px;
- color: #409EFF;
- }
- .camp-actions {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: flex-end;
- gap: 8px;
- border-left: 1px dashed #eaedf2;
- padding-left: 12px;
- min-width: 50px;
- }
- .action-btn {
- padding: 2px 5px;
- font-size: 12px;
- border-radius: 4px;
- transition: all 0.2s;
- }
- .action-btn:hover {
- background-color: rgba(255, 255, 255, 0.8);
- }
- .delete-btn {
- color: #f56c6c;
- }
- .delete-btn:hover {
- background-color: rgba(245, 108, 108, 0.1);
- }
- .copy-btn {
- color: #409EFF;
- }
- .copy-btn:hover {
- background-color: rgba(64, 158, 255, 0.1);
- }
- .warning-icon {
- color: #E6A23C;
- font-size: 16px;
- margin-left: 5px;
- }
- .el-main {
- padding: 10px;
- }
- /* 添加训练营表单样式 */
- .drawer-footer {
- /* position: absolute; */
- bottom: 0;
- left: 0;
- right: 0;
- padding: 20px;
- background: #fff;
- text-align: right;
- border-top: 1px solid #e8e8e8;
- }
- .el-input-number {
- width: 100%;
- }
- /* 加载更多样式 */
- .loading-more {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 12px 0;
- color: #909399;
- font-size: 14px;
- }
- .loading-more i {
- margin-right: 5px;
- font-size: 16px;
- }
- /* 无更多数据提示 */
- .no-more-data {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 12px 0;
- color: #c0c4cc;
- font-size: 13px;
- }
- .no-more-data span {
- position: relative;
- display: flex;
- align-items: center;
- }
- </style>
|