index.vue 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="素材名称" prop="resourceName">
  5. <el-input
  6. v-model="queryParams.resourceName"
  7. placeholder="请输入素材名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="文件名称" prop="fileName">
  14. <el-input
  15. v-model="queryParams.fileName"
  16. placeholder="请输入素材名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="分类" prop="typeId">
  23. <el-select v-model="queryParams.typeId" clearable placeholder="请选择分类" @change="val => changeCateType(val, 1)">
  24. <el-option
  25. v-for="item in rootTypeList"
  26. :key="item.dictValue"
  27. :label="item.dictLabel"
  28. :value="item.dictValue">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="子分类" prop="typeSubId">
  33. <el-select v-model="queryParams.typeSubId" clearable placeholder="请选择子分类">
  34. <el-option
  35. v-for="item in subTypeList"
  36. :key="item.dictValue"
  37. :label="item.dictLabel"
  38. :value="item.dictValue">
  39. </el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <el-button
  50. type="primary"
  51. icon="el-icon-plus"
  52. size="mini"
  53. @click="handleAdd"
  54. :disabled="hasMinimizableDialog"
  55. v-hasPermi="['course:videoResource:add']"
  56. >新增</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="primary"
  61. icon="el-icon-plus"
  62. size="mini"
  63. @click="handleBatchAdd"
  64. :disabled="hasMinimizableDialog"
  65. v-hasPermi="['course:videoResource:batchAdd']"
  66. >批量新增</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['course:videoResource:remove']"
  76. >删除</el-button>
  77. </el-col>
  78. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  79. </el-row>
  80. <el-table v-loading="loading" :data="resourceList" @selection-change="handleSelectionChange" border>
  81. <el-table-column type="selection" width="55" align="center" />
  82. <el-table-column label="序号" width="55" align="center">
  83. <template slot-scope="scope">
  84. {{ scope.$index + 1 }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="素材名称" align="center" :show-overflow-tooltip="true" prop="resourceName"/>
  88. <el-table-column label="文件名称" align="center" :show-overflow-tooltip="true" prop="fileName"/>
  89. <el-table-column label="排序" align="center" prop="sort" />
  90. <el-table-column label="分类" align="center">
  91. <template slot-scope="scope">
  92. <span v-if="scope.row.typeId">{{ getTypeName(scope.row.typeId) }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="子分类" align="center">
  96. <template slot-scope="scope">
  97. <span v-if="scope.row.typeSubId">{{ getTypeName(scope.row.typeSubId) }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="视频文件" align="center">
  101. <template slot-scope="scope">
  102. <a
  103. @click="handleVideoPreview(scope.row.videoUrl)"
  104. style="background-color: #409EFF; color: white; border: none; border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 12px; display: inline-block; text-decoration: none;">
  105. 查看文件
  106. </a>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="CDN" align="center">
  110. <template slot-scope="scope">
  111. <a
  112. @click="copy(scope.row.videoUrl)"
  113. style="color: #409EFF; border: none; border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 12px; display: inline-block; text-decoration: none;">
  114. 复制链接
  115. </a>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="关联题目" align="center">
  119. <template slot-scope="scope">
  120. <a
  121. @click="handleViewProject(scope.row, 3)"
  122. :style="scope.row.projectIds ? {
  123. backgroundColor: '#409EFF',
  124. color: 'white',
  125. border: 'none',
  126. borderRadius: '4px',
  127. padding: '4px 12px',
  128. cursor: 'pointer',
  129. fontSize: '12px',
  130. display: 'inline-block',
  131. textDecoration: 'none'
  132. } : {
  133. backgroundColor: 'rgb(154 156 159)',
  134. color: 'white',
  135. border: 'none',
  136. cursor: 'pointer',
  137. borderRadius: '4px',
  138. padding: '4px 12px',
  139. fontSize: '12px',
  140. display: 'inline-block',
  141. textDecoration: 'none'
  142. }">
  143. {{ scope.row.projectIds ? '查看详情' : '未关联题目' }}
  144. </a>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="视频时长" align="center">
  148. <template slot-scope="scope">
  149. <div style="padding: 4px 12px;background: linear-gradient(to right, rgb(196 219 255), #409EFF)">{{ formatDuration(scope.row.duration) }}</div>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  153. <template slot-scope="scope">
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-edit"
  158. @click="handleUpdate(scope.row)"
  159. :disabled="hasMinimizableDialog"
  160. v-hasPermi="['course:videoResource:edit']"
  161. >修改</el-button>
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-delete"
  166. @click="handleDelete(scope.row)"
  167. v-hasPermi="['course:videoResource:remove']"
  168. >删除</el-button>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <pagination
  173. v-show="total>0"
  174. :total="total"
  175. :page.sync="queryParams.pageNum"
  176. :limit.sync="queryParams.pageSize"
  177. @pagination="getList"
  178. />
  179. <!-- 添加或修改视频素材库对话框 -->
  180. <minimizable-dialog :title="title" :visible.sync="open" width="700px" append-to-body :before-close="cancel"
  181. @minimize="hasMinimizableDialog = true" @restore="hasMinimizableDialog = false">
  182. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  183. <el-form-item label="素材名称" prop="resourceName" style="margin-top: 20px">
  184. <el-input v-model="form.resourceName" placeholder="请输入" />
  185. </el-form-item>
  186. <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px;display: none">
  187. <el-input v-model="form.fileName" placeholder="请输入" />
  188. </el-form-item>
  189. <el-form-item label="分类" prop="typeId">
  190. <el-select v-model="form.typeId" placeholder="请选择分类" style="width: 100%" @change="val => changeCateType(val, 2)">
  191. <el-option
  192. v-for="item in rootTypeList"
  193. :key="item.dictValue"
  194. :label="item.dictLabel"
  195. :value="item.dictValue">
  196. </el-option>
  197. </el-select>
  198. </el-form-item>
  199. <el-form-item label="子分类" prop="typeSubId">
  200. <el-select v-model="form.typeSubId" clearable placeholder="请选择子分类" style="width: 100%">
  201. <el-option
  202. v-for="item in subTypeList"
  203. :key="item.dictValue"
  204. :label="item.dictLabel"
  205. :value="item.dictValue">
  206. </el-option>
  207. </el-select>
  208. </el-form-item>
  209. <el-form-item label="排序" prop="sort">
  210. <el-input-number v-model="form.sort" :min="0" label="请输入排序"></el-input-number>
  211. </el-form-item>
  212. <el-form-item label="关联题目" prop="projectIds">
  213. <el-select
  214. ref="customSelect"
  215. class="custom-select-class"
  216. v-model="form.projectIds"
  217. multiple
  218. placeholder="请选择关联题目"
  219. @click.native.stop="openProjectDialog(form.projectIds, 0)"
  220. style="width: 100%;">
  221. <el-option
  222. v-for="item in projectShowList"
  223. :key="item.id"
  224. :label="item.title"
  225. :value="item.id">
  226. </el-option>
  227. </el-select>
  228. </el-form-item>
  229. <el-form-item label="上传视频" prop="videoUrl" required>
  230. <el-upload
  231. ref="videoUpload"
  232. action="#"
  233. list-type="picture-card"
  234. :http-request="videoUpload"
  235. :file-list="fileList"
  236. :on-change="handleFileChange"
  237. accept=".mp4">
  238. <i slot="default" class="el-icon-plus"></i>
  239. <div slot="file" slot-scope="{file}">
  240. <div
  241. class="el-upload-list__item-thumbnail"
  242. style="display: flex; justify-content: center; align-items: center; background-color: #f5f7fa; height: 146px;"
  243. >
  244. <i class="el-icon-video-camera" style="font-size: 48px;" />
  245. </div>
  246. <span v-if="file.status === 'success'" class="el-upload-list__item-status-label">
  247. <i class="el-icon-upload-success el-icon--check"></i>
  248. </span>
  249. <span v-if="file.status === 'fail'" class="el-upload-list__item-status-label">
  250. <i class="el-icon-circle-close"></i>
  251. </span>
  252. <span class="el-upload-list__item-actions">
  253. <span
  254. class="el-upload-list__item-preview"
  255. @click="handleVideoPreview(form.videoUrl)"
  256. >
  257. <i class="el-icon-zoom-in"></i>
  258. </span>
  259. <span
  260. class="el-upload-list__item-delete"
  261. @click="handleRemove(file)"
  262. >
  263. <i class="el-icon-delete"></i>
  264. </span>
  265. </span>
  266. <div v-if="file.status === 'uploading'" class="el-upload-list__item-progress">
  267. <div class="dual-upload-progress">
  268. <div class="total-progress">
  269. <el-progress
  270. :percentage="currentUploadProgress.total"
  271. :show-text="true"
  272. :width="52"
  273. :format="() => `${Math.round(currentUploadProgress.total)}%`"
  274. ></el-progress>
  275. </div>
  276. <div class="line-progress-container">
  277. <div class="line-progress-item">
  278. <span class="line-label">线路1:</span>
  279. <el-progress
  280. :percentage="currentUploadProgress.line1"
  281. :show-text="false"
  282. :width="30"
  283. :status="currentUploadProgress.line1Status === 'success' ? 'success' :
  284. currentUploadProgress.line1Status === 'failed' ? 'exception' : ''"
  285. ></el-progress>
  286. <span class="line-status-text">{{ Math.round(currentUploadProgress.line1) }}%</span>
  287. </div>
  288. <div class="line-progress-item">
  289. <span class="line-label">线路2:</span>
  290. <el-progress
  291. :percentage="currentUploadProgress.line2"
  292. :show-text="false"
  293. :width="30"
  294. :status="currentUploadProgress.line2Status === 'success' ? 'success' :
  295. currentUploadProgress.line2Status === 'failed' ? 'exception' : ''"
  296. ></el-progress>
  297. <span class="line-status-text">{{ Math.round(currentUploadProgress.line2) }}%</span>
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. </el-upload>
  304. </el-form-item>
  305. <el-form-item label="时长">
  306. <span>{{ formatDuration(form.duration) }}</span>
  307. </el-form-item>
  308. </el-form>
  309. <div slot="footer" class="dialog-footer">
  310. <el-button @click="cancel">取消</el-button>
  311. <el-button type="primary" @click="submitForm" :disabled="isUploading">
  312. {{ isUploading ? '上传中...' : '保存' }}
  313. </el-button>
  314. </div>
  315. </minimizable-dialog>
  316. <el-dialog
  317. title="视频预览"
  318. :visible.sync="videoPreviewVisible"
  319. append-to-body
  320. :close-on-click-modal="true"
  321. width="700px"
  322. class="video-preview-dialog"
  323. :modal-append-to-body="false"
  324. :before-close="handleCloseVideoPreview">
  325. <video ref="up-video" id="video" width="100%" height="400px" controls :src="videoPreviewUrl" />
  326. </el-dialog>
  327. <!-- 批量选择视频弹窗 -->
  328. <minimizable-dialog :title="'选择视频'" :visible.sync="batchAddVisible" width="1200px" append-to-body class="batch-dialog" :close-on-click-modal="false" :before-close="cancelBeforeBatch"
  329. @minimize="hasMinimizableDialog = true" @restore="hasMinimizableDialog = false">
  330. <div class="filter-container">
  331. <el-button type="primary" icon="el-icon-plus" size="small" @click="showUploadPanel">上传视频</el-button>
  332. </div>
  333. <el-table
  334. v-loading="batchLoading"
  335. :data="videoList"
  336. height="350"
  337. border>
  338. <el-table-column label="序号" width="60" align="center">
  339. <template slot-scope="scope">
  340. {{ scope.$index + 1 }}
  341. </template>
  342. </el-table-column>
  343. <el-table-column label="素材名称" align="center" prop="resourceName" min-width="120" />
  344. <el-table-column label="文件名称" align="center" prop="fileName" min-width="120" />
  345. <el-table-column label="分类" align="center" min-width="100">
  346. <template slot-scope="scope">
  347. {{ getTypeName(scope.row.typeId) }}
  348. </template>
  349. </el-table-column>
  350. <el-table-column label="关联项目" align="center" min-width="100">
  351. <template slot-scope="scope">
  352. <a
  353. @click="handleViewProject(scope.row, 4)"
  354. :style="scope.row.projectIds.length > 0 ? {
  355. backgroundColor: '#409EFF',
  356. color: 'white',
  357. border: 'none',
  358. borderRadius: '4px',
  359. padding: '4px 12px',
  360. cursor: 'pointer',
  361. fontSize: '12px',
  362. display: 'inline-block',
  363. textDecoration: 'none'
  364. } : {
  365. backgroundColor: 'rgb(154 156 159)',
  366. color: 'white',
  367. border: 'none',
  368. cursor: 'pointer',
  369. borderRadius: '4px',
  370. padding: '4px 12px',
  371. fontSize: '12px',
  372. display: 'inline-block',
  373. textDecoration: 'none'
  374. }">
  375. {{ scope.row.projectIds.length > 0 ? '查看详情' : '未关联题目' }}
  376. </a>
  377. </template>
  378. </el-table-column>
  379. <el-table-column label="视频文件" align="center" prop="fileName" min-width="120">
  380. <template slot-scope="scope">
  381. <a
  382. @click="handleVideoPreview(scope.row.videoUrl)"
  383. style="background-color: #409EFF; color: white; border: none; border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 12px; display: inline-block; text-decoration: none;">
  384. 查看文件
  385. </a>
  386. </template>
  387. </el-table-column>
  388. <el-table-column label="视频时长" align="center" width="80">
  389. <template slot-scope="scope">
  390. {{ formatDuration(scope.row.duration) }}
  391. </template>
  392. </el-table-column>
  393. <el-table-column label="上传进度" align="center" width="200">
  394. <template slot-scope="scope">
  395. <div class="batch-upload-progress">
  396. <div class="total-progress-row">
  397. <span class="progress-label">总进度:</span>
  398. <el-progress
  399. :percentage="scope.row.progress || 0"
  400. :status="getProgressStatus(scope.row)"
  401. :show-text="true"
  402. :format="() => `${Math.round(scope.row.progress || 0)}%`"
  403. ></el-progress>
  404. </div>
  405. <div v-if="scope.row.uploadDetails" class="line-progress-rows">
  406. <div class="line-progress-row">
  407. <span class="line-label">线路1:</span>
  408. <el-progress
  409. :percentage="scope.row.uploadDetails.line1 || 0"
  410. :status="scope.row.uploadDetails.line1Status === 'success' ? 'success' :
  411. scope.row.uploadDetails.line1Status === 'failed' ? 'exception' : 'warning'"
  412. :show-text="false"
  413. style="width: 60px;"
  414. ></el-progress>
  415. <span class="line-percentage">{{ Math.round(scope.row.uploadDetails.line1 || 0) }}%</span>
  416. </div>
  417. <div class="line-progress-row">
  418. <span class="line-label">线路2:</span>
  419. <el-progress
  420. :percentage="scope.row.uploadDetails.line2 || 0"
  421. :status="scope.row.uploadDetails.line2Status === 'success' ? 'success' :
  422. scope.row.uploadDetails.line2Status === 'failed' ? 'exception' : 'warning'"
  423. :show-text="false"
  424. style="width: 60px;"
  425. ></el-progress>
  426. <span class="line-percentage">{{ Math.round(scope.row.uploadDetails.line2 || 0) }}%</span>
  427. </div>
  428. </div>
  429. </div>
  430. </template>
  431. </el-table-column>
  432. <el-table-column label="操作" align="center" width="150">
  433. <template slot-scope="scope">
  434. <el-button
  435. size="mini"
  436. type="text"
  437. icon="el-icon-edit"
  438. @click="handleEditVideo(scope.row)">编辑</el-button>
  439. <el-button
  440. size="mini"
  441. type="text"
  442. icon="el-icon-delete"
  443. @click="handleDeleteVideo(scope.row)">删除</el-button>
  444. <el-button
  445. v-if="scope.row.progress < 100 && scope.row.uploadStatus === 'failed'"
  446. size="mini"
  447. type="text"
  448. icon="el-icon-refresh"
  449. @click="retryBatchUpload(scope.row)"
  450. style="color: #E6A23C;">重试</el-button>
  451. </template>
  452. </el-table-column>
  453. </el-table>
  454. <div class="dialog-footer">
  455. <el-button @click="cancelBatch">取 消</el-button>
  456. <el-button type="primary" @click="submitBatchAdd">保 存</el-button>
  457. </div>
  458. <!-- 批量上传视频弹窗 -->
  459. <el-dialog
  460. title="批量上传视频"
  461. :visible.sync="showUpload"
  462. width="500px"
  463. append-to-body
  464. :close-on-click-modal="false"
  465. class="upload-dialog">
  466. <el-form :model="batchUploadForm" ref="batchUploadForm" label-width="80px">
  467. <el-form-item style="margin-top: 20px" label="分类" prop="typeId" :rules="[{ required: true, message: '请选择分类', trigger: 'blur' }]">
  468. <el-select v-model="batchUploadForm.typeId" placeholder="请选择分类" style="width: 100%" @change="val => changeCateType(val, 3)">
  469. <el-option
  470. v-for="item in rootTypeList"
  471. :key="item.dictValue"
  472. :label="item.dictLabel"
  473. :value="item.dictValue">
  474. </el-option>
  475. </el-select>
  476. </el-form-item>
  477. <el-form-item label="子分类" prop="typeSubId" :rules="[{ required: true, message: '请选择子分类', trigger: 'blur' }]">
  478. <el-select v-model="batchUploadForm.typeSubId" clearable placeholder="请选择子分类" style="width: 100%">
  479. <el-option
  480. v-for="item in subTypeList"
  481. :key="item.dictValue"
  482. :label="item.dictLabel"
  483. :value="item.dictValue">
  484. </el-option>
  485. </el-select>
  486. </el-form-item>
  487. <el-form-item label="关联题目" prop="projectIds" style="display: none">
  488. <el-select
  489. ref="customSelect"
  490. class="custom-select-class"
  491. v-model="batchUploadForm.projectIds"
  492. multiple
  493. placeholder="请选择关联题目"
  494. @click.native.stop="openProjectDialog(batchUploadForm.projectIds, 1)"
  495. style="width: 100%;">
  496. <el-option
  497. v-for="item in projectShowList"
  498. :key="item.id"
  499. :label="item.title"
  500. :value="item.id">
  501. </el-option>
  502. </el-select>
  503. </el-form-item>
  504. <el-form-item label="上传视频" prop="files">
  505. <el-upload
  506. ref="batchVideoUpload"
  507. action="#"
  508. :http-request="batchVideoUpload"
  509. :file-list="batchFileList"
  510. :on-change="handleBatchFileChange"
  511. multiple
  512. accept=".mp4">
  513. <el-button type="primary" :disabled="batchUploadForm.typeSubId === null">选择文件</el-button>
  514. <div slot="tip" class="el-upload__tip">选择分类后才可以上传视频</div>
  515. </el-upload>
  516. </el-form-item>
  517. </el-form>
  518. </el-dialog>
  519. <!-- 添加或修改视频素材库对话框 -->
  520. <el-dialog :title="batchEditDialog.title" :visible.sync="batchEditDialog.open" width="600px" append-to-body :before-close="batchEditCancel">
  521. <el-form ref="batchEditDialogForm" :model="batchEditDialog.form" :rules="batchEditDialog.rules" label-width="80px">
  522. <el-form-item label="素材名称" prop="resourceName" style="margin-top: 20px">
  523. <el-input v-model="batchEditDialog.form.resourceName" placeholder="请输入" />
  524. </el-form-item>
  525. <el-form-item label="文件名称" prop="fileName" style="margin-top: 20px;display: none">
  526. <el-input v-model="batchEditDialog.form.fileName" placeholder="请输入" />
  527. </el-form-item>
  528. <el-form-item label="关联题目" prop="projectIds">
  529. <el-select
  530. ref="customSelect"
  531. class="custom-select-class"
  532. v-model="batchEditDialog.form.projectIds"
  533. multiple
  534. placeholder="请选择关联题目"
  535. @click.native.stop="openProjectDialog(batchEditDialog.form.projectIds, 2)"
  536. style="width: 100%;">
  537. <el-option
  538. v-for="item in projectShowList"
  539. :key="item.id"
  540. :label="item.title"
  541. :value="item.id">
  542. </el-option>
  543. </el-select>
  544. </el-form-item>
  545. </el-form>
  546. <div slot="footer" class="dialog-footer">
  547. <el-button @click="batchEditCancel">取消</el-button>
  548. <el-button type="primary" @click="batchEditSubmitForm">保存</el-button>
  549. </div>
  550. </el-dialog>
  551. </minimizable-dialog>
  552. <!-- 项目选择弹窗 -->
  553. <el-dialog
  554. title="选择题目"
  555. :visible.sync="projectDialogVisible"
  556. width="1000px"
  557. append-to-body
  558. @close="cancelSelectProject"
  559. :close-on-click-modal="false">
  560. <div class="project-container">
  561. <!-- 左侧分类树 -->
  562. <div class="category-tree">
  563. <div class="tree-fixed-header">
  564. <el-input
  565. placeholder="请输入分类名称"
  566. v-model="categoryFilterText"
  567. size="small"
  568. clearable
  569. prefix-icon="el-icon-search">
  570. </el-input>
  571. </div>
  572. <div class="tree-content">
  573. <el-tree
  574. ref="categoryTree"
  575. :data="categoryTreeData"
  576. node-key="cateId"
  577. highlight-current
  578. :filter-node-method="filterNode"
  579. :props="{ label: 'cateName', children: 'children' }"
  580. @node-click="handleCategoryClick"
  581. :expand-on-click-node="false"
  582. default-expand-all>
  583. <span class="custom-tree-node" slot-scope="{ node, data }">
  584. <span>{{ node.label }}</span>
  585. </span>
  586. </el-tree>
  587. </div>
  588. </div>
  589. <!-- 右侧题目列表 -->
  590. <div class="project-list">
  591. <div class="filter-container">
  592. <el-form :inline="true" :model="projectQueryParams" ref="projectForm">
  593. <el-form-item>
  594. <el-input prefix-icon="el-icon-search" @input="searchProjects" v-model="projectQueryParams.title" placeholder="请输入题目标题" clearable size="small" />
  595. </el-form-item>
  596. </el-form>
  597. </div>
  598. <el-table
  599. ref="projectTable"
  600. height="350"
  601. :data="projectList"
  602. row-key="id"
  603. v-loading="projectLoading"
  604. border
  605. @select="handleProjectSelect"
  606. @select-all="handleProjectSelect">
  607. <el-table-column type="selection" reserve-selection width="55" align="center" />
  608. <el-table-column label="序号" width="60" align="center">
  609. <template slot-scope="scope">
  610. {{ scope.row.sort }}
  611. </template>
  612. </el-table-column>
  613. <el-table-column label="题目标题" align="center" prop="title" min-width="200" show-overflow-tooltip />
  614. </el-table>
  615. <div class="table-footer">
  616. <el-pagination
  617. style="text-align: right"
  618. v-show="projectListTotal>0"
  619. :pager-count="5"
  620. background
  621. @size-change="handleProjectPageSizeChange"
  622. @current-change="handleProjectPageChange"
  623. :current-page="projectQueryParams.pageNum"
  624. :page-sizes="[10, 20, 30, 50]"
  625. :page-size="projectQueryParams.pageSize"
  626. layout="total, sizes, prev, pager, next, jumper"
  627. :total="projectListTotal">
  628. </el-pagination>
  629. </div>
  630. </div>
  631. </div>
  632. <div slot="footer" class="dialog-footer">
  633. <span style="float: left; color: #606266; font-size: 13px;">
  634. 共选择 <span style="color: #409EFF; font-weight: bold;">{{ selectedProjectIds.length }}</span> 个题目
  635. </span>
  636. <el-button @click="projectDialogVisible = false">取消</el-button>
  637. <el-button type="primary" @click="confirmSelectProject">确定</el-button>
  638. </div>
  639. </el-dialog>
  640. <!-- 项目列表弹窗 -->
  641. <el-dialog
  642. title="题目列表"
  643. :visible.sync="projectListDialogVisible"
  644. width="600px"
  645. append-to-body
  646. :close-on-click-modal="false">
  647. <div class="project-list-container" style="max-height: 500px; overflow-y: auto; padding: 10px;">
  648. <!-- 题目列表 -->
  649. <div v-for="(item, index) in projectShowList" :key="index" class="question-card">
  650. <!-- 题目标题 -->
  651. <div class="question-header">
  652. <span class="question-index">{{ index + 1 }}</span>
  653. <span class="question-title">{{ item.title }}</span>
  654. </div>
  655. <!-- 题目类型 -->
  656. <div class="question-type">
  657. <el-tag size="small" type="primary">{{ item.type === 1 ? '单选' : '多选' }}</el-tag>
  658. </div>
  659. <!-- 题目内容 -->
  660. <div class="question-content" v-if="item.question && item.question.length > 0">
  661. <div class="content-title">题目内容:</div>
  662. <div v-for="(q, qIndex) in JSON.parse(item.question)" :key="qIndex" class="question-item"
  663. :style=" q.isAnswer === 1 ? 'background-color: rgb(234 245 251)' : ''">
  664. <div class="question-item-header">
  665. <span class="item-index">{{ convertToLetter(qIndex) }}</span>
  666. <span class="item-name">{{ q.name }}</span>
  667. </div>
  668. </div>
  669. </div>
  670. <!-- 答案 -->
  671. <div class="question-answer" v-if="item.answer">
  672. <span class="answer-label">答案:</span>
  673. <span class="answer-content">{{ item.answer }}</span>
  674. </div>
  675. </div>
  676. </div>
  677. </el-dialog>
  678. </div>
  679. </template>
  680. <script>
  681. import {
  682. addVideoResource,
  683. deleteVideoResource,
  684. getVideoResource,
  685. listVideoResource,
  686. updateVideoResource,
  687. batchAddVideoResource
  688. } from '@/api/course/videoResource'
  689. import {listUserCourseCategory,getCatePidList,getCateListByPid} from '@/api/course/userCourseCategory'
  690. import {getByIds, listCourseQuestionBank} from '@/api/course/courseQuestionBank'
  691. import {getThumbnail} from "@/api/course/userVideo";
  692. import {uploadObject} from "@/utils/cos.js";
  693. import {uploadToOBS} from "@/utils/obs.js";
  694. import MinimizableDialog from "@/components/MinimizableDialog"
  695. export default {
  696. name: 'VideoResource',
  697. components: {
  698. MinimizableDialog
  699. },
  700. data() {
  701. return {
  702. // 遮罩层
  703. loading: true,
  704. // 选中数组
  705. ids: [],
  706. // 非单个禁用
  707. single: true,
  708. // 非多个禁用
  709. multiple: true,
  710. // 显示搜索条件
  711. showSearch: true,
  712. // 总条数
  713. total: 0,
  714. // 视频素材库表格数据
  715. resourceList: [],
  716. // 弹出层标题
  717. title: "",
  718. // 是否显示弹出层
  719. open: false,
  720. // 查询参数
  721. queryParams: {
  722. pageNum: 1,
  723. pageSize: 10,
  724. resourceName: null,
  725. fileName: null,
  726. typeId: null,
  727. typeSubId: null
  728. },
  729. // 表单参数
  730. form: {
  731. id: null,
  732. resourceName: null,
  733. fileName: null,
  734. thumbnail: null,
  735. line1: null,
  736. line2: null,
  737. line3: null,
  738. duration: null,
  739. fileSize: null,
  740. fileKey: null,
  741. videoUrl: null,
  742. typeId: null,
  743. typeSubId: null,
  744. projectIds: [],
  745. sort: null,
  746. // 新增上传状态字段
  747. uploadStatus: 'pending', // pending, uploading, success, failed
  748. uploadProgress: {
  749. total: 0,
  750. line1: 0,
  751. line2: 0,
  752. line1Status: 'pending', // pending, uploading, success, failed
  753. line2Status: 'pending'
  754. }
  755. },
  756. // 表单校验
  757. rules: {
  758. resourceName: [
  759. { required: true, message: "素材名称不能为空", trigger: "blur" }
  760. ],
  761. fileName: [
  762. { required: true, message: "文件名称不能为空", trigger: "blur" }
  763. ],
  764. typeId: [
  765. { required: true, message: "请选择分类", trigger: "change" }
  766. ],
  767. typeSubId: [
  768. { required: true, message: "请选择子分类", trigger: "change" }
  769. ],
  770. sort: [
  771. { required: true, message: '排序不能为空', trigger: 'blur' }
  772. ],
  773. videoUrl: [
  774. { required: true, message: "请上传视频", trigger: "change" }
  775. ]
  776. },
  777. // 课程列表数据
  778. projectList: [],
  779. projectShowList: [],
  780. // 分类
  781. typeList: [],
  782. rootTypeList: [],
  783. subTypeList: [],
  784. // 视频上传
  785. videoDisabled: false,
  786. videoPreviewVisible: false,
  787. videoPreviewUrl: '',
  788. fileList: [],
  789. // 批量添加相关
  790. batchAddVisible: false,
  791. batchLoading: false,
  792. videoList: [],
  793. // 批量上传相关
  794. showUpload: false,
  795. batchUploadForm: {
  796. typeId: null,
  797. typeSubId: null,
  798. projectIds: [],
  799. files: []
  800. },
  801. batchFileList: [],
  802. // 弹窗选择项目相关
  803. projectDialogVisible: false,
  804. projectQueryParams: {
  805. pageNum: 1,
  806. pageSize: 10,
  807. questionType: null,
  808. questionSubType: null,
  809. title: null
  810. },
  811. projectLoading: false,
  812. projectListTotal: 0,
  813. selectedProjectIds: [],
  814. selectedType: 0,
  815. currentRow: null,
  816. // 分类树相关数据
  817. categoryFilterText: '',
  818. categoryTreeData: [],
  819. add: false,
  820. // 题目列表
  821. projectListDialogVisible: false,
  822. // 修改视频记录
  823. batchEditDialog: {
  824. title: '修改视频',
  825. open: false,
  826. form: {},
  827. rules: {
  828. resourceName: [
  829. { required: true, message: "素材名称不能为空", trigger: "blur" }
  830. ],
  831. fileName: [
  832. { required: true, message: "文件名称不能为空", trigger: "blur" }
  833. ]
  834. },
  835. },
  836. // 是否存在最小化窗口
  837. hasMinimizableDialog: false,
  838. // 新增上传相关状态
  839. isUploading: false,
  840. currentUploadProgress: {
  841. total: 0,
  842. line1: 0,
  843. line2: 0,
  844. line1Status: 'pending',
  845. line2Status: 'pending'
  846. },
  847. // 上传任务队列
  848. uploadQueue: []
  849. }
  850. },
  851. watch: {
  852. categoryFilterText(val) {
  853. this.$refs.categoryTree.filter(val);
  854. }
  855. },
  856. created() {
  857. this.getTypeList();
  858. this.getRootTypeList()
  859. this.getList();
  860. },
  861. methods: {
  862. /** 将数字索引转换为字母序号 (0->A, 1->B, 等) */
  863. convertToLetter(index) {
  864. // 确保索引是数字
  865. let numIndex = parseInt(index, 10);
  866. // 如果无法转换成数字,返回原始值
  867. if (isNaN(numIndex)) {
  868. return index;
  869. }
  870. // 处理负数情况
  871. if (numIndex < 0) {
  872. return index;
  873. }
  874. // 直接使用索引计算ASCII码(0对应A,1对应B,以此类推)
  875. return String.fromCharCode(65 + numIndex); // 65 是大写字母 A 的ASCII码
  876. },
  877. /** 查询视频素材库列表 */
  878. getList() {
  879. this.loading = true;
  880. listVideoResource(this.queryParams).then(response => {
  881. this.resourceList = response.rows;
  882. this.total = response.total;
  883. this.loading = false;
  884. });
  885. },
  886. // 取消按钮
  887. cancel() {
  888. this.$refs.videoUpload.clearFiles()
  889. this.open = false;
  890. this.reset();
  891. this.changeCateType(this.queryParams.typeId)
  892. },
  893. // 表单重置
  894. reset() {
  895. // 初始化表单对象
  896. this.form = {
  897. id: null,
  898. resourceName: null,
  899. fileName: null,
  900. thumbnail: null,
  901. line1: null,
  902. line2: null,
  903. line3: null,
  904. duration: null,
  905. fileSize: null,
  906. fileKey: null,
  907. videoUrl: null,
  908. typeId: null,
  909. typeSubId: null,
  910. projectIds: []
  911. };
  912. // 重置表单验证状态
  913. this.resetForm("form");
  914. this.add = false
  915. },
  916. /** 搜索按钮操作 */
  917. handleQuery() {
  918. this.queryParams.pageNum = 1;
  919. this.getList();
  920. },
  921. /** 重置按钮操作 */
  922. resetQuery() {
  923. this.resetForm("queryForm");
  924. this.handleQuery();
  925. },
  926. // 多选框选中数据
  927. handleSelectionChange(selection) {
  928. this.ids = selection.map(item => item.id)
  929. this.single = selection.length!==1
  930. this.multiple = !selection.length
  931. },
  932. /** 新增按钮操作 */
  933. handleAdd() {
  934. // 先清空文件列表
  935. this.fileList = [];
  936. this.projectShowList = [];
  937. // 先重置表单
  938. this.reset();
  939. this.subTypeList = []
  940. // 重置上传组件
  941. if (this.$refs.videoUpload) {
  942. this.$refs.videoUpload.clearFiles();
  943. }
  944. // 所有重置完成后再打开弹窗
  945. this.open = true;
  946. this.title = "添加视频素材库";
  947. },
  948. /** 修改按钮操作 */
  949. handleUpdate(row) {
  950. // 先清空文件列表
  951. this.fileList = [];
  952. this.projectShowList = [];
  953. // 先重置表单
  954. this.reset();
  955. this.subTypeList = []
  956. const id = row.id
  957. // 获取数据并设置表单
  958. getVideoResource(id).then(async response => {
  959. this.form = response.data;
  960. await this.changeCateType(this.form.typeId)
  961. // 处理projectIds,确保是数组格式
  962. if (this.form.projectIds && typeof this.form.projectIds === 'string') {
  963. this.form.projectIds = this.form.projectIds.split(',').map(id => parseInt(id));
  964. } else if (!this.form.projectIds) {
  965. this.form.projectIds = [];
  966. }
  967. // 如果存在关联项目,获取项目详情用于回显
  968. if (this.form.projectIds && this.form.projectIds.length > 0) {
  969. // 加载项目列表信息用于回显
  970. await getByIds({ids: this.form.projectIds.join(',')}).then(reponse => {
  971. this.projectShowList = reponse.data
  972. });
  973. }
  974. // 如果存在视频URL,设置fileList
  975. if (this.form.videoUrl) {
  976. this.fileList = [{
  977. name: this.form.fileName || '视频文件',
  978. url: this.form.videoUrl,
  979. thumbnail: this.form.thumbnail,
  980. status: 'success' // 设置为成功状态
  981. }];
  982. }
  983. // 所有设置完成后再打开弹窗
  984. this.open = true;
  985. this.title = "修改视频素材库";
  986. });
  987. },
  988. /** 提交按钮 */
  989. submitForm() {
  990. this.$refs["form"].validate(valid => {
  991. if (valid) {
  992. if (this.add){
  993. this.$message.warning("文件上传中,请稍后再试")
  994. return
  995. }
  996. const params = Object.assign({}, this.form);
  997. params.projectIds = this.form.projectIds.join(',');
  998. if (this.form.id != null) {
  999. updateVideoResource(params).then(response => {
  1000. if (response.code === 200) {
  1001. this.msgSuccess("修改成功");
  1002. this.open = false;
  1003. this.getList();
  1004. }
  1005. });
  1006. } else {
  1007. addVideoResource(params).then(response => {
  1008. if (response.code === 200) {
  1009. this.msgSuccess("新增成功");
  1010. this.open = false;
  1011. this.getList();
  1012. }
  1013. });
  1014. }
  1015. }
  1016. });
  1017. },
  1018. /** 删除按钮操作 */
  1019. handleDelete(row) {
  1020. const ids = row.id || this.ids;
  1021. this.$confirm('是否确认删除视频素材库编号为"' + ids + '"的数据项?', "警告", {
  1022. confirmButtonText: "确定",
  1023. cancelButtonText: "取消",
  1024. type: "warning"
  1025. }).then(function() {
  1026. return deleteVideoResource(ids);
  1027. }).then(() => {
  1028. this.getList();
  1029. this.msgSuccess("删除成功");
  1030. }).catch(function() {});
  1031. },
  1032. /** 查询视频分类列表 */
  1033. getTypeList() {
  1034. listUserCourseCategory().then(response => {
  1035. this.typeList = response.data;
  1036. });
  1037. },
  1038. getRootTypeList() {
  1039. getCatePidList().then(response => {
  1040. this.rootTypeList = response.data
  1041. });
  1042. },
  1043. async changeCateType(val, type) {
  1044. if (type === 1) {
  1045. this.queryParams.typeSubId = null
  1046. }
  1047. if (type === 2) {
  1048. this.form.typeSubId = null
  1049. }
  1050. if (type === 3) {
  1051. this.batchUploadForm.typeSubId = null
  1052. }
  1053. this.subTypeList = []
  1054. if (!val) {
  1055. return
  1056. }
  1057. await getCateListByPid(val).then(response => {
  1058. this.subTypeList = response.data
  1059. })
  1060. },
  1061. /** 预览视频 */
  1062. handleVideoPreview(url) {
  1063. this.videoPreviewVisible = true;
  1064. this.videoPreviewUrl = url || this.form.videoUrl;
  1065. },
  1066. /** 格式化视频时长 */
  1067. formatDuration(seconds) {
  1068. if (!seconds) return '00:00';
  1069. const minutes = Math.floor(seconds / 60);
  1070. const remainingSeconds = seconds % 60;
  1071. return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
  1072. },
  1073. /** 移除视频 */
  1074. handleRemove(file) {
  1075. this.fileList.splice(this.fileList.indexOf(file), 1);
  1076. this.form.videoUrl = '';
  1077. this.form.thumbnail = '';
  1078. this.form.duration = 0;
  1079. this.form.fileSize = 0;
  1080. this.form.fileName = '';
  1081. this.form.line1 = '';
  1082. this.form.line_2 = '';
  1083. this.form.line_3 = '';
  1084. this.uploadType = null
  1085. this.fileSize = null
  1086. this.fileKey = null
  1087. },
  1088. //获取第一帧封面
  1089. async getFirstThumbnail(file, form){
  1090. try {
  1091. //截取小文件
  1092. // 打印原始文件名和大小
  1093. console.log("原始文件名:", file.name);
  1094. console.log("原始文件大小:", file.size, "bytes");
  1095. console.log("原始文件类型:", file.type);
  1096. // 截取小文件
  1097. const clippedBlob = await this.clipVideoFirstTwoSeconds(file);
  1098. console.log("clippedBlob:::::::::", clippedBlob);
  1099. console.log("截取后的Blob大小:", clippedBlob.size, "bytes");
  1100. console.log("截取后的Blob类型:", clippedBlob.type);
  1101. const clippedFile = new File([clippedBlob], 'clipped_video.mp4', {
  1102. type: 'video/mp4',
  1103. lastModified: Date.now()
  1104. });
  1105. // 3. 调用接口获取封面
  1106. const response = await getThumbnail(clippedFile);
  1107. console.log("获取封面请求---------------》",response)
  1108. form.thumbnail = response.url;
  1109. } catch (error) {
  1110. console.error('获取封面失败:', error);
  1111. }
  1112. },
  1113. //截取大文件视频
  1114. async clipVideoFirstTwoSeconds(file) {
  1115. return new Promise((resolve, reject) => {
  1116. const video = document.createElement('video');
  1117. video.src = URL.createObjectURL(file);
  1118. video.muted = true;
  1119. video.playsInline = true;
  1120. video.onloadedmetadata = () => {
  1121. video.currentTime = 0; // 定位到第一帧
  1122. video.onseeked = () => {
  1123. const canvas = document.createElement('canvas');
  1124. canvas.width = video.videoWidth;
  1125. canvas.height = video.videoHeight;
  1126. const ctx = canvas.getContext('2d');
  1127. ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
  1128. canvas.toBlob(
  1129. (blob) => {
  1130. URL.revokeObjectURL(video.src);
  1131. resolve(blob); // 返回 JPEG Blob
  1132. },
  1133. 'image/jpeg',
  1134. 0.8 // 质量
  1135. );
  1136. };
  1137. };
  1138. video.onerror = () => {
  1139. URL.revokeObjectURL(video.src);
  1140. reject(new Error('视频加载失败'));
  1141. };
  1142. });
  1143. },
  1144. //上传腾讯云Pcdn
  1145. async uploadVideoToTxPcdn(file, form, onProgress) {
  1146. try {
  1147. // 更新线路1状态为上传中
  1148. this.updateUploadProgress('line1Status', 'uploading');
  1149. const data = await uploadObject(file, (progress) => {
  1150. const progressPercent = Math.floor(progress.percent * 100);
  1151. this.updateUploadProgress('line1', progressPercent);
  1152. const progressEvent = {
  1153. percent: progressPercent,
  1154. loaded: progress.loaded,
  1155. total: progress.total,
  1156. lengthComputable: true
  1157. };
  1158. onProgress(progressEvent);
  1159. }, 1);
  1160. let line_1 = `${process.env.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
  1161. form.fileKey = data.urlPath.substring(1);
  1162. form.videoUrl = line_1;
  1163. form.line1 = line_1;
  1164. // 更新线路1状态为成功
  1165. this.updateUploadProgress('line1Status', 'success');
  1166. this.updateUploadProgress('line1', 100);
  1167. this.$message.success("线路一上传成功");
  1168. return { success: true, url: line_1 };
  1169. } catch (error) {
  1170. // 更新线路1状态为失败
  1171. this.updateUploadProgress('line1Status', 'failed');
  1172. this.$message.error("线路一上传失败");
  1173. return { success: false, error: error.message };
  1174. }
  1175. },
  1176. //上传华为云Obs
  1177. async uploadVideoToHwObs(file, form, onProgress) {
  1178. try {
  1179. // 更新线路2状态为上传中
  1180. this.updateUploadProgress('line2Status', 'uploading');
  1181. const data = await uploadToOBS(file, (progress) => {
  1182. const progressPercent = Math.floor(progress);
  1183. this.updateUploadProgress('line2', progressPercent);
  1184. const progressEvent = {
  1185. percent: progressPercent,
  1186. loaded: progress,
  1187. total: progress,
  1188. lengthComputable: true
  1189. };
  1190. onProgress(progressEvent);
  1191. }, 1);
  1192. form.line2 = `${process.env.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
  1193. // 更新线路2状态为成功
  1194. this.updateUploadProgress('line2Status', 'success');
  1195. this.updateUploadProgress('line2', 100);
  1196. this.$message.success("线路二上传成功");
  1197. return { success: true, url: form.line2 };
  1198. } catch (error) {
  1199. // 更新线路2状态为失败
  1200. this.updateUploadProgress('line2Status', 'failed');
  1201. this.$message.error("线路二上传失败");
  1202. return { success: false, error: error.message };
  1203. }
  1204. },
  1205. // 更新上传进度的辅助方法
  1206. updateUploadProgress(key, value) {
  1207. this.currentUploadProgress[key] = value;
  1208. // 计算总进度:只有两个线路都成功才算100%
  1209. if (this.currentUploadProgress.line1Status === 'success' &&
  1210. this.currentUploadProgress.line2Status === 'success') {
  1211. this.currentUploadProgress.total = 100;
  1212. } else if (this.currentUploadProgress.line1Status === 'failed' ||
  1213. this.currentUploadProgress.line2Status === 'failed') {
  1214. // 如果任一线路失败,总进度保持当前状态
  1215. this.currentUploadProgress.total = Math.min(
  1216. (this.currentUploadProgress.line1 + this.currentUploadProgress.line2) / 2,
  1217. 99 // 失败时最多99%
  1218. );
  1219. } else {
  1220. // 正常上传中,计算平均进度
  1221. this.currentUploadProgress.total = Math.min(
  1222. (this.currentUploadProgress.line1 + this.currentUploadProgress.line2) / 2,
  1223. 99 // 上传中最多99%,只有都成功才100%
  1224. );
  1225. }
  1226. },
  1227. // 上传视频
  1228. async videoUpload(options) {
  1229. this.isUploading = true;
  1230. this.form.uploadStatus = 'uploading';
  1231. const file = options.file;
  1232. this.getMediaDuration(file);
  1233. // 重置进度
  1234. this.currentUploadProgress = {
  1235. total: 0,
  1236. line1: 0,
  1237. line2: 0,
  1238. line1Status: 'pending',
  1239. line2Status: 'pending'
  1240. };
  1241. try {
  1242. // 获取第一帧图片
  1243. await this.getFirstThumbnail(file, this.form);
  1244. // 并行上传到两个服务器
  1245. const [line1Result, line2Result] = await Promise.allSettled([
  1246. this.uploadVideoToTxPcdn(file, this.form, options.onProgress),
  1247. this.uploadVideoToHwObs(file, this.form, options.onProgress)
  1248. ]);
  1249. // 检查上传结果
  1250. const line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
  1251. const line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
  1252. if (line1Success && line2Success) {
  1253. // 两个都成功
  1254. this.form.uploadStatus = 'success';
  1255. this.form.uploadProgress = {
  1256. total: 100,
  1257. line1: 100,
  1258. line2: 100,
  1259. line1Status: 'success',
  1260. line2Status: 'success'
  1261. };
  1262. this.currentUploadProgress.total = 100;
  1263. this.$message.success("视频上传完成!两个线路都上传成功");
  1264. } else {
  1265. // 至少有一个失败
  1266. this.form.uploadStatus = 'failed';
  1267. this.form.uploadProgress = {
  1268. total: this.currentUploadProgress.total,
  1269. line1: this.currentUploadProgress.line1,
  1270. line2: this.currentUploadProgress.line2,
  1271. line1Status: this.currentUploadProgress.line1Status,
  1272. line2Status: this.currentUploadProgress.line2Status
  1273. };
  1274. const failedLines = [];
  1275. if (!line1Success) failedLines.push('线路1');
  1276. if (!line2Success) failedLines.push('线路2');
  1277. this.$message.error(`视频上传失败!${failedLines.join('、')} 上传失败,请重试`);
  1278. }
  1279. this.form.fileName = file.name;
  1280. this.form.fileSize = file.size;
  1281. } catch (error) {
  1282. this.form.uploadStatus = 'failed';
  1283. this.$message.error("视频上传过程中发生错误,请重试");
  1284. } finally {
  1285. this.isUploading = false;
  1286. }
  1287. },
  1288. // 获取媒体文件时长
  1289. getMediaDuration(file) {
  1290. // 处理视频
  1291. const video = document.createElement('video');
  1292. video.preload = 'metadata';
  1293. video.onloadedmetadata = () => {
  1294. this.form.duration = Math.round(video.duration);
  1295. };
  1296. video.src = URL.createObjectURL(file);
  1297. },
  1298. handleFileChange(file, files) {
  1299. // 保留最后一个文件
  1300. this.fileList = files.slice(-1);
  1301. },
  1302. /** 批量新增 */
  1303. handleBatchAdd() {
  1304. this.batchAddVisible = true;
  1305. this.videoList = []; // 清空之前的视频列表
  1306. },
  1307. cancelBeforeBatch(done, cancel) {
  1308. if (!this.videoList || this.videoList.length === 0) {
  1309. done()
  1310. return
  1311. }
  1312. this.$confirm('关闭窗口视频需要重新上传,确定关闭吗?', '提示', {
  1313. confirmButtonText: '确定',
  1314. cancelButtonText: '取消',
  1315. type: 'warning'
  1316. }).then(() => {
  1317. done()
  1318. }).catch(() => {
  1319. cancel()
  1320. });
  1321. },
  1322. /** 取消批量 */
  1323. cancelBatch() {
  1324. if (!this.videoList || this.videoList.length === 0) {
  1325. this.batchAddVisible = false
  1326. return
  1327. }
  1328. this.$confirm('关闭窗口视频需要重新上传,确定关闭吗?', '提示', {
  1329. confirmButtonText: '确定',
  1330. cancelButtonText: '取消',
  1331. type: 'warning'
  1332. }).then(() => {
  1333. this.batchAddVisible = false
  1334. this.changeCateType(this.queryParams.typeId)
  1335. }).catch(() => {
  1336. });
  1337. },
  1338. /** 提交批量添加 */
  1339. submitBatchAdd() {
  1340. // 检查是否所有选中的视频都已上传完成
  1341. const incompleteVideos = this.videoList.filter(item => (item.progress || 0) < 100);
  1342. if (incompleteVideos.length > 0) {
  1343. this.$message.warning('有未完成上传的视频,请先完成上传');
  1344. return;
  1345. }
  1346. // 调用批量添加API
  1347. const videoList = JSON.parse(JSON.stringify(this.videoList));
  1348. videoList.forEach(item => {
  1349. item.projectIds = item.projectIds.join(",");
  1350. });
  1351. batchAddVideoResource(videoList).then(response => {
  1352. if (response.code === 200) {
  1353. this.$message.success('批量添加成功');
  1354. this.batchAddVisible = false;
  1355. this.getList();
  1356. }
  1357. });
  1358. },
  1359. /** 获取分类名称 */
  1360. getTypeName(typeId) {
  1361. const type = this.typeList.find(item => item.cateId === typeId);
  1362. return type ? type.cateName : '';
  1363. },
  1364. /** 编辑视频信息 */
  1365. handleEditVideo(row) {
  1366. this.batchEditDialog.form = Object.assign({}, row)
  1367. this.changeCateType(row.typeId)
  1368. this.batchEditDialog.open = true
  1369. },
  1370. batchEditCancel() {
  1371. this.resetForm('batchEditDialogForm')
  1372. this.batchEditDialog.open = false
  1373. },
  1374. batchEditSubmitForm() {
  1375. let temp = this.videoList.find(item => item.tempId === this.batchEditDialog.form.tempId)
  1376. Object.assign(temp, this.batchEditDialog.form)
  1377. this.batchEditDialog.open = false
  1378. },
  1379. /** 删除视频 */
  1380. handleDeleteVideo(row) {
  1381. this.$confirm('确认要从列表中删除该视频吗?', '提示', {
  1382. confirmButtonText: '确定',
  1383. cancelButtonText: '取消',
  1384. type: 'warning'
  1385. }).then(() => {
  1386. // 从视频列表中删除该项
  1387. const index = this.videoList.findIndex(item => {
  1388. // 通过文件名和大小确定唯一性,因为临时视频可能没有id
  1389. return item.tempId === row.tempId
  1390. });
  1391. if (index !== -1) {
  1392. this.videoList.splice(index, 1);
  1393. this.$message({
  1394. type: 'success',
  1395. message: '已从列表中移除该视频'
  1396. });
  1397. }
  1398. }).catch(() => {
  1399. // 取消删除
  1400. });
  1401. },
  1402. /** 显示上传面板 */
  1403. showUploadPanel() {
  1404. this.showUpload = true;
  1405. this.batchUploadForm = {
  1406. typeId: null,
  1407. typeSubId: null,
  1408. projectIds: [],
  1409. files: []
  1410. };
  1411. this.batchFileList = [];
  1412. this.subTypeList = []
  1413. if (this.$refs.batchVideoUpload) {
  1414. this.$refs.batchVideoUpload.clearFiles();
  1415. }
  1416. },
  1417. /** 批量文件变更 */
  1418. handleBatchFileChange(file, fileList) {
  1419. this.batchFileList = fileList;
  1420. },
  1421. /** 批量上传视频 */
  1422. async batchVideoUpload(options) {
  1423. const file = options.file;
  1424. // 创建临时视频对象添加到列表中
  1425. const tempVideo = {
  1426. tempId: Math.random().toString(36).substring(2, 15),
  1427. resourceName: file.name.split('.')[0], // 使用文件名作为视频名称
  1428. fileName: file.name,
  1429. thumbnail: null,
  1430. line1: null,
  1431. line2: null,
  1432. line3: null,
  1433. duration: 0, // 先默认为0,后续获取真实时长
  1434. fileSize: file.size,
  1435. fileKey: null,
  1436. videoUrl: null,
  1437. typeId: this.batchUploadForm.typeId, // 使用选择的分类
  1438. typeSubId: this.batchUploadForm.typeSubId, // 使用选择的子分类
  1439. projectIds: this.batchUploadForm.projectIds, // 使用选择的项目
  1440. progress: 0, // 总进度
  1441. uploadStatus: 'uploading',
  1442. uploadDetails: {
  1443. line1: 0,
  1444. line2: 0,
  1445. line1Status: 'pending',
  1446. line2Status: 'pending'
  1447. },
  1448. file: file // 保存文件引用
  1449. };
  1450. // 添加到视频列表
  1451. this.videoList.unshift(tempVideo);
  1452. // 获取视频时长
  1453. const video = document.createElement('video');
  1454. video.preload = 'metadata';
  1455. video.onloadedmetadata = () => {
  1456. const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
  1457. if (index !== -1) {
  1458. tempVideo.duration = Math.round(video.duration);
  1459. }
  1460. };
  1461. video.src = URL.createObjectURL(file);
  1462. // 关闭上传弹窗,返回批量选择视频弹窗
  1463. this.showUpload = false;
  1464. try {
  1465. // 获取封面
  1466. await this.getFirstThumbnail(file, tempVideo);
  1467. // // 上传到第一个服务器
  1468. // await this.uploadVideoToTxPcdn(file, tempVideo, (event) => {
  1469. // tempVideo.progress = event.percent
  1470. // });
  1471. // // 上传到第二个服务器
  1472. // await this.uploadVideoToHwObs(file, tempVideo, (event) => {
  1473. // tempVideo.progress = event.percent
  1474. // });
  1475. // 并行上传到两个服务器
  1476. const [line1Result, line2Result] = await Promise.allSettled([
  1477. this.uploadVideoToTxPcdnBatch(file, tempVideo),
  1478. this.uploadVideoToHwObsBatch(file, tempVideo)
  1479. ]);
  1480. // 检查上传结果
  1481. const line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
  1482. const line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
  1483. if (line1Success && line2Success) {
  1484. // 两个都成功,更新进度为100%
  1485. const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
  1486. if (index !== -1) {
  1487. this.videoList[index].progress = 100;
  1488. this.videoList[index].uploadStatus = 'success';
  1489. this.videoList[index].uploadDetails.line1Status = 'success';
  1490. this.videoList[index].uploadDetails.line2Status = 'success';
  1491. this.videoList[index].uploadDetails.line1 = 100;
  1492. this.videoList[index].uploadDetails.line2 = 100;
  1493. }
  1494. this.$message.success(`文件 ${file.name} 上传成功`);
  1495. } else {
  1496. // 至少有一个失败
  1497. const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
  1498. if (index !== -1) {
  1499. this.videoList[index].uploadStatus = 'failed';
  1500. this.videoList[index].uploadDetails.line1Status = line1Success ? 'success' : 'failed';
  1501. this.videoList[index].uploadDetails.line2Status = line2Success ? 'success' : 'failed';
  1502. // 失败时保持当前进度,不设为100%
  1503. this.updateBatchProgress(index);
  1504. }
  1505. const failedLines = [];
  1506. if (!line1Success) failedLines.push('线路1');
  1507. if (!line2Success) failedLines.push('线路2');
  1508. this.$message.error(`文件 ${file.name} 在 ${failedLines.join('、')} 上传失败`);
  1509. }
  1510. } catch (error) {
  1511. this.$message.error(`文件 ${file.name} 上传失败: ${error.message || '未知错误'}`);
  1512. }
  1513. if (this.$refs.batchVideoUpload) {
  1514. this.$refs.batchVideoUpload.clearFiles();
  1515. }
  1516. },
  1517. /** 复制视频链接到剪贴板 */
  1518. copy(url) {
  1519. // 创建一个临时的input元素
  1520. const input = document.createElement('input');
  1521. // 设置input的值为要复制的视频链接
  1522. input.value = url;
  1523. // 将input添加到DOM中
  1524. document.body.appendChild(input);
  1525. // 选中input的值
  1526. input.select();
  1527. // 执行复制命令
  1528. document.execCommand('copy');
  1529. // 从DOM中移除input元素
  1530. document.body.removeChild(input);
  1531. // 提示用户复制成功
  1532. this.$message({
  1533. message: '已复制到剪贴板',
  1534. type: 'success',
  1535. duration: 1500
  1536. });
  1537. },
  1538. getProjectList() {
  1539. this.projectLoading = true
  1540. listCourseQuestionBank(this.projectQueryParams).then(response => {
  1541. this.projectList = response.rows;
  1542. this.projectListTotal = response.total;
  1543. // 如果存在已选择的项目,预选中表格中对应的行
  1544. this.$nextTick(() => {
  1545. // 获取表格组件实例
  1546. const projectTable = this.$refs.projectTable;
  1547. if (projectTable) {
  1548. if (this.selectedProjectIds.length > 0) {
  1549. // 遍历项目列表,找到匹配的ID并选中对应行
  1550. const selectedIds = this.selectedProjectIds;
  1551. this.projectList.forEach(row => {
  1552. if (selectedIds.includes(row.id)) {
  1553. projectTable.toggleRowSelection(row, true);
  1554. }
  1555. });
  1556. }
  1557. }
  1558. });
  1559. this.projectLoading = false
  1560. });
  1561. },
  1562. /** 打开项目选择弹窗 */
  1563. openProjectDialog(projectIds, type) {
  1564. this.$nextTick(() => {
  1565. if (this.$refs.customSelect) {
  1566. this.$refs.customSelect.blur();
  1567. }
  1568. });
  1569. // 重置查询参数
  1570. this.projectQueryParams = {
  1571. pageNum: 1,
  1572. pageSize: 10,
  1573. questionType: null,
  1574. title: null
  1575. };
  1576. this.selectedType = type
  1577. // 设置选中的项目IDs
  1578. if (projectIds) {
  1579. if (typeof projectIds === 'string') {
  1580. this.selectedProjectIds = projectIds.split(',').map(id => parseInt(id));
  1581. } else if (Array.isArray(projectIds)) {
  1582. this.selectedProjectIds = [...projectIds];
  1583. } else if (typeof projectIds === 'number') {
  1584. this.selectedProjectIds = [projectIds];
  1585. }
  1586. } else {
  1587. this.selectedProjectIds = [];
  1588. }
  1589. // 显示弹窗
  1590. this.projectDialogVisible = true;
  1591. // 加载分类树数据
  1592. this.initCategoryTree();
  1593. // 加载项目列表
  1594. this.getProjectList();
  1595. },
  1596. /** 确认选择项目 */
  1597. confirmSelectProject() {
  1598. // 更新表单中的项目ID
  1599. if (this.selectedType === 0) {
  1600. this.form.projectIds = this.selectedProjectIds;
  1601. }
  1602. else if (this.selectedType === 1) {
  1603. this.batchUploadForm.projectIds = this.selectedProjectIds;
  1604. }
  1605. else if (this.selectedType === 2) {
  1606. this.batchEditDialog.form.projectIds = this.selectedProjectIds;
  1607. }
  1608. else if (this.selectedType === 3) {
  1609. const params = {
  1610. id: this.currentRow.id,
  1611. projectIds: this.selectedProjectIds.join(",")
  1612. }
  1613. updateVideoResource(params).then(response => {
  1614. if (response.code === 200) {
  1615. this.msgSuccess("修改成功");
  1616. this.open = false;
  1617. this.getList();
  1618. }
  1619. });
  1620. }
  1621. else if (this.selectedType === 4) {
  1622. this.currentRow.projectIds = this.selectedProjectIds
  1623. }
  1624. this.projectDialogVisible = false;
  1625. },
  1626. /** 取消选择项目 */
  1627. cancelSelectProject() {
  1628. const projectTable = this.$refs.projectTable;
  1629. if (projectTable) {
  1630. // 清空表格数据
  1631. projectTable.clearSelection();
  1632. }
  1633. this.projectDialogVisible = false;
  1634. },
  1635. handleProjectSelect(selection) {
  1636. this.selectedProjectIds = selection.map(item => item.id);
  1637. selection.forEach(item => {
  1638. // 检查是否已存在该项目,不存在则添加
  1639. if (!this.projectShowList.some(p => p.id === item.id)) {
  1640. this.projectShowList.push(item);
  1641. }
  1642. });
  1643. },
  1644. /** 项目列表页码变更 */
  1645. handleProjectPageChange(page) {
  1646. this.projectQueryParams.pageNum = page;
  1647. this.getProjectList();
  1648. },
  1649. /** 项目列表每页条数变更 */
  1650. handleProjectPageSizeChange(size) {
  1651. this.projectQueryParams.pageNum = 1;
  1652. this.projectQueryParams.pageSize = size;
  1653. this.getProjectList();
  1654. },
  1655. /** 处理查看项目 */
  1656. handleViewProject(row, type) {
  1657. // 保存当前选择的行,以便后续操作
  1658. this.currentRow = row;
  1659. // 设置form对象的projectIds为当前行的项目IDs
  1660. this.projectShowList = [];
  1661. if (!row.projectIds || row.projectIds.length === 0) {
  1662. this.openProjectDialog(null, type)
  1663. return;
  1664. }
  1665. let projectIds = row.projectIds
  1666. if (Array.isArray(row.projectIds)) {
  1667. projectIds = projectIds.join(',');
  1668. }
  1669. getByIds({ids: projectIds}).then(response => {
  1670. this.projectShowList = response.data;
  1671. })
  1672. // 打开弹窗展示列表
  1673. this.projectListDialogVisible = true;
  1674. },
  1675. /** 初始化分类树 */
  1676. initCategoryTree() {
  1677. // 获取分类列表
  1678. listUserCourseCategory().then(response => {
  1679. const treeDate = this.handleTree(response.data, "cateId", "pid");
  1680. this.categoryTreeData = [{
  1681. cateId: 0,
  1682. cateName: '全部',
  1683. children: treeDate
  1684. }];
  1685. });
  1686. },
  1687. filterNode(value, data) {
  1688. if (!value) return true;
  1689. return data.cateName.indexOf(value) !== -1;
  1690. },
  1691. /** 处理分类点击 */
  1692. handleCategoryClick(data, node) {
  1693. // 更新查询参数
  1694. this.projectQueryParams.pageNum = 1;
  1695. // 如果是全部分类,则清空分类过滤
  1696. if (node.level === 1) {
  1697. this.projectQueryParams.questionType = null;
  1698. this.projectQueryParams.questionSubType = null;
  1699. }
  1700. else if (node.level === 2) {
  1701. this.projectQueryParams.questionType = data.cateId;
  1702. this.projectQueryParams.questionSubType = null;
  1703. }
  1704. else if (node.level === 3) {
  1705. this.projectQueryParams.questionType = null;
  1706. this.projectQueryParams.questionSubType = data.cateId;
  1707. }
  1708. // 重新加载项目列表
  1709. this.getProjectList();
  1710. },
  1711. /** 搜索项目 */
  1712. searchProjects() {
  1713. this.projectQueryParams.pageNum = 1;
  1714. this.getProjectList();
  1715. },
  1716. /** 视频预览弹窗关闭前的处理函数 */
  1717. handleCloseVideoPreview(done) {
  1718. // 停止视频播放
  1719. const video = document.getElementById('video');
  1720. if (video) {
  1721. video.pause();
  1722. video.currentTime = 0;
  1723. }
  1724. // 关闭弹窗
  1725. this.videoPreviewVisible = false;
  1726. done();
  1727. },
  1728. // 批量上传 - 腾讯云
  1729. async uploadVideoToTxPcdnBatch(file, tempVideo) {
  1730. console.log("--------------",JSON.stringify(tempVideo))
  1731. try {
  1732. const data = await uploadObject(file, (progress) => {
  1733. const progressPercent = Math.floor(progress.percent * 100);
  1734. const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
  1735. if (index !== -1) {
  1736. this.videoList[index].uploadDetails.line1 = progressPercent;
  1737. this.videoList[index].uploadDetails.line1Status = 'uploading';
  1738. // 更新总进度
  1739. this.updateBatchProgress(index);
  1740. }
  1741. }, 1);
  1742. let line_1 = `${process.env.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
  1743. tempVideo.fileKey = data.urlPath.substring(1);
  1744. tempVideo.videoUrl = line_1;
  1745. tempVideo.line1 = line_1;
  1746. return { success: true, url: line_1 };
  1747. } catch (error) {
  1748. return { success: false, error: error.message };
  1749. }
  1750. },
  1751. // 批量上传 - 华为云
  1752. async uploadVideoToHwObsBatch(file, tempVideo) {
  1753. try {
  1754. const data = await uploadToOBS(file, (progress) => {
  1755. const progressPercent = Math.floor(progress);
  1756. const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
  1757. if (index !== -1) {
  1758. this.videoList[index].uploadDetails.line2 = progressPercent;
  1759. this.videoList[index].uploadDetails.line2Status = 'uploading';
  1760. // 更新总进度
  1761. this.updateBatchProgress(index);
  1762. }
  1763. }, 1);
  1764. tempVideo.line2 = `${process.env.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
  1765. return { success: true, url: tempVideo.line2 };
  1766. } catch (error) {
  1767. return { success: false, error: error.message };
  1768. }
  1769. },
  1770. // 更新批量上传的总进度
  1771. updateBatchProgress(index) {
  1772. if (index >= 0 && index < this.videoList.length) {
  1773. const item = this.videoList[index];
  1774. const line1Progress = item.uploadDetails.line1 || 0;
  1775. const line2Progress = item.uploadDetails.line2 || 0;
  1776. // 只有两个线路都成功才算100%
  1777. if (item.uploadDetails.line1Status === 'success' &&
  1778. item.uploadDetails.line2Status === 'success') {
  1779. item.progress = 100;
  1780. } else if (item.uploadDetails.line1Status === 'failed' ||
  1781. item.uploadDetails.line2Status === 'failed') {
  1782. // 如果任一线路失败,总进度保持当前状态,不超过99%
  1783. item.progress = Math.min((line1Progress + line2Progress) / 2, 99);
  1784. } else {
  1785. // 正常上传中,计算平均进度,不超过99%
  1786. item.progress = Math.min((line1Progress + line2Progress) / 2, 99);
  1787. }
  1788. }
  1789. },
  1790. // 重试批量上传
  1791. async retryBatchUpload(row) {
  1792. // const index = this.videoList.findIndex(item => item.tempId === row.tempId);
  1793. // if (index === -1) return;
  1794. // const {line1, line2,line1Status,line2Status} = this.videoList[index].uploadDetails
  1795. // // 重置状态
  1796. // this.videoList[index].uploadStatus = 'uploading';
  1797. // // this.videoList[index].progress = 0;
  1798. // this.videoList[index].uploadDetails = {
  1799. // line1: line1 == 100?line1:0,
  1800. // line2: line2 == 100?line2:0,
  1801. // line1Status: line1Status =='success'?line1Status:'pending',
  1802. // line2Status: line2Status =='success'?line2Status:'pending'
  1803. // };
  1804. // const tempVideo = this.videoList[index];
  1805. // try {
  1806. // // 重新上传
  1807. // // const [line1Result, line2Result] = await Promise.allSettled([
  1808. // // this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo),
  1809. // // // this.uploadVideoToHwObsBatch(tempVideo.file, tempVideo)
  1810. // // ]);
  1811. // if (line1 !== 100) {
  1812. // const line1Result = await this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo)
  1813. // }
  1814. // if (line2 !== 100) {
  1815. // const line2Result = await this.uploadVideoToHwObsBatch(tempVideo.file, tempVideo)
  1816. // }
  1817. // const line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
  1818. // const line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
  1819. // if ( line1 == 100 || line1Success) {
  1820. // this.videoList[index].uploadDetails.line1Status = 'success';
  1821. // this.videoList[index].uploadDetails.line1 = 100;
  1822. // this.$message.success(`文件 ${tempVideo.fileName} 重试上传成功`);
  1823. // } else {
  1824. // this.videoList[index].uploadDetails.line1Status = line1Success ? 'success' : 'failed';
  1825. // this.$message.error(`文件 ${tempVideo.fileName} 重试上传失败`);
  1826. // }
  1827. // if (line2 == 100 || line2Success) {
  1828. // this.videoList[index].uploadDetails.line2Status = 'success';
  1829. // this.videoList[index].uploadDetails.line2 = 100;
  1830. // this.$message.success(`文件 ${tempVideo.fileName} 重试上传成功`);
  1831. // } else {
  1832. // this.videoList[index].uploadDetails.line2Status = line2Success ? 'success' : 'failed';
  1833. // this.$message.error(`文件 ${tempVideo.fileName} 重试上传失败`);
  1834. // }
  1835. // // if (line1Success && line2Success) {
  1836. // // this.videoList[index].progress = 100;
  1837. // // this.videoList[index].uploadStatus = 'success';
  1838. // // this.videoList[index].uploadDetails.line1Status = 'success';
  1839. // // this.videoList[index].uploadDetails.line2Status = 'success';
  1840. // // this.videoList[index].uploadDetails.line1 = 100;
  1841. // // this.videoList[index].uploadDetails.line2 = 100;
  1842. // // this.$message.success(`文件 ${tempVideo.fileName} 重试上传成功`);
  1843. // // } else {
  1844. // // this.videoList[index].uploadStatus = 'failed';
  1845. // // this.videoList[index].uploadDetails.line1Status = line1Success ? 'success' : 'failed';
  1846. // // this.videoList[index].uploadDetails.line2Status = line2Success ? 'success' : 'failed';
  1847. // // this.$message.error(`文件 ${tempVideo.fileName} 重试上传失败`);
  1848. // // }
  1849. // } catch (error) {
  1850. // this.videoList[index].uploadStatus = 'failed';
  1851. // this.$message.error(`文件 ${tempVideo.fileName} 重试上传失败`);
  1852. // }
  1853. const index = this.videoList.findIndex(item => item.tempId === row.tempId);
  1854. if (index === -1) return;
  1855. const tempVideo = this.videoList[index];
  1856. const uploadDetails = tempVideo.uploadDetails || {};
  1857. // 检查哪些线路需要重试
  1858. const needRetryLine1 = uploadDetails.line1Status === 'failed' || uploadDetails.line1Status === 'pending';
  1859. const needRetryLine2 = uploadDetails.line2Status === 'failed' || uploadDetails.line2Status === 'pending';
  1860. if (!needRetryLine1 && !needRetryLine2) {
  1861. this.$message.info('所有线路都已上传成功,无需重试');
  1862. return;
  1863. }
  1864. // 更新整体状态为上传中
  1865. this.videoList[index].uploadStatus = 'uploading';
  1866. // 只重置需要重试的线路状态
  1867. if (needRetryLine1) {
  1868. this.videoList[index].uploadDetails.line1 = 0;
  1869. this.videoList[index].uploadDetails.line1Status = 'pending';
  1870. }
  1871. if (needRetryLine2) {
  1872. this.videoList[index].uploadDetails.line2 = 0;
  1873. this.videoList[index].uploadDetails.line2Status = 'pending';
  1874. }
  1875. try {
  1876. const uploadPromises = [];
  1877. // 根据需要重试的线路创建上传任务
  1878. if (needRetryLine1) {
  1879. uploadPromises.push(
  1880. this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo)
  1881. .then(result => ({ line: 'line1', result }))
  1882. .catch(error => ({ line: 'line1', result: { success: false, error: error.message } }))
  1883. );
  1884. } else {
  1885. // 如果线路1不需要重试,创建一个已成功的Promise
  1886. uploadPromises.push(Promise.resolve({ line: 'line1', result: { success: true } }));
  1887. }
  1888. if (needRetryLine2) {
  1889. uploadPromises.push(
  1890. this.uploadVideoToHwObsBatch(tempVideo.file, tempVideo)
  1891. .then(result => ({ line: 'line2', result }))
  1892. .catch(error => ({ line: 'line2', result: { success: false, error: error.message } }))
  1893. );
  1894. } else {
  1895. // 如果线路2不需要重试,创建一个已成功的Promise
  1896. uploadPromises.push(Promise.resolve({ line: 'line2', result: { success: true } }));
  1897. }
  1898. // 等待所有上传任务完成
  1899. const results = await Promise.all(uploadPromises);
  1900. // 处理结果
  1901. let line1Success = true;
  1902. let line2Success = true;
  1903. let retryMessages = [];
  1904. results.forEach(({ line, result }) => {
  1905. if (line === 'line1') {
  1906. line1Success = result.success;
  1907. if (needRetryLine1) {
  1908. if (result.success) {
  1909. this.videoList[index].uploadDetails.line1Status = 'success';
  1910. this.videoList[index].uploadDetails.line1 = 100;
  1911. retryMessages.push('线路1重试成功');
  1912. } else {
  1913. this.videoList[index].uploadDetails.line1Status = 'failed';
  1914. retryMessages.push('线路1重试失败');
  1915. }
  1916. }
  1917. } else if (line === 'line2') {
  1918. line2Success = result.success;
  1919. if (needRetryLine2) {
  1920. if (result.success) {
  1921. this.videoList[index].uploadDetails.line2Status = 'success';
  1922. this.videoList[index].uploadDetails.line2 = 100;
  1923. retryMessages.push('线路2重试成功');
  1924. } else {
  1925. this.videoList[index].uploadDetails.line2Status = 'failed';
  1926. retryMessages.push('线路2重试失败');
  1927. }
  1928. }
  1929. }
  1930. });
  1931. // 更新总体状态和进度
  1932. if (line1Success && line2Success) {
  1933. this.videoList[index].progress = 100;
  1934. this.videoList[index].uploadStatus = 'success';
  1935. this.$message.success(`文件 ${tempVideo.fileName} 重试完成:${retryMessages.join(',')}`);
  1936. } else {
  1937. this.videoList[index].uploadStatus = 'failed';
  1938. // 重新计算进度
  1939. this.updateBatchProgress(index);
  1940. this.$message.error(`文件 ${tempVideo.fileName} 重试完成:${retryMessages.join(',')}`);
  1941. }
  1942. } catch (error) {
  1943. this.videoList[index].uploadStatus = 'failed';
  1944. this.$message.error(`文件 ${tempVideo.fileName} 重试过程中发生错误:${error.message || '未知错误'}`);
  1945. }
  1946. },
  1947. // 重试单个上传
  1948. async retryUpload(row) {
  1949. this.$confirm('确认要重新上传该视频吗?', '提示', {
  1950. confirmButtonText: '确定',
  1951. cancelButtonText: '取消',
  1952. type: 'warning'
  1953. }).then(async () => {
  1954. // 这里需要重新触发上传,但由于原始文件可能已经不存在
  1955. // 建议用户重新选择文件上传
  1956. this.$message.info('请重新选择文件进行上传');
  1957. this.handleUpdate(row);
  1958. }).catch(() => {});
  1959. },
  1960. // 获取上传状态图标
  1961. getUploadStatusIcon(status) {
  1962. switch (status) {
  1963. case 'success':
  1964. return 'el-icon-success';
  1965. case 'failed':
  1966. return 'el-icon-error';
  1967. case 'uploading':
  1968. return 'el-icon-loading';
  1969. default:
  1970. return 'el-icon-time';
  1971. }
  1972. },
  1973. // 获取上传状态颜色
  1974. getUploadStatusColor(status) {
  1975. switch (status) {
  1976. case 'success':
  1977. return '#67C23A';
  1978. case 'failed':
  1979. return '#F56C6C';
  1980. case 'uploading':
  1981. return '#409EFF';
  1982. default:
  1983. return '#909399';
  1984. }
  1985. },
  1986. // 获取上传状态文本
  1987. getUploadStatusText(status) {
  1988. switch (status) {
  1989. case 'success':
  1990. return '上传成功';
  1991. case 'failed':
  1992. return '上传失败';
  1993. case 'uploading':
  1994. return '上传中';
  1995. default:
  1996. return '待上传';
  1997. }
  1998. },
  1999. // 获取线路状态图标
  2000. getLineStatusIcon(status) {
  2001. switch (status) {
  2002. case 'success':
  2003. return 'el-icon-check';
  2004. case 'failed':
  2005. return 'el-icon-close';
  2006. case 'uploading':
  2007. return 'el-icon-loading';
  2008. default:
  2009. return 'el-icon-minus';
  2010. }
  2011. },
  2012. // 获取线路状态颜色
  2013. getLineStatusColor(status) {
  2014. switch (status) {
  2015. case 'success':
  2016. return '#67C23A';
  2017. case 'failed':
  2018. return '#F56C6C';
  2019. case 'uploading':
  2020. return '#409EFF';
  2021. default:
  2022. return '#C0C4CC';
  2023. }
  2024. },
  2025. // 获取进度条状态
  2026. getProgressStatus(row) {
  2027. if (row.progress === 100 && row.uploadStatus === 'success') {
  2028. return 'success';
  2029. } else if (row.uploadStatus === 'failed') {
  2030. return 'exception';
  2031. }
  2032. return '';
  2033. },
  2034. }
  2035. }
  2036. </script>
  2037. <style scoped>
  2038. /* 自定义表格样式 */
  2039. .el-table .video-cell {
  2040. padding: 5px;
  2041. }
  2042. /* 设置删除和修改按钮的间距 */
  2043. .el-button + .el-button {
  2044. margin-left: 5px;
  2045. }
  2046. /* 上传状态样式 */
  2047. .upload-status-container {
  2048. display: flex;
  2049. flex-direction: column;
  2050. align-items: center;
  2051. gap: 4px;
  2052. }
  2053. .status-indicator {
  2054. display: flex;
  2055. align-items: center;
  2056. gap: 4px;
  2057. }
  2058. .status-text {
  2059. font-size: 12px;
  2060. }
  2061. .upload-details {
  2062. display: flex;
  2063. flex-direction: column;
  2064. gap: 2px;
  2065. font-size: 11px;
  2066. }
  2067. .line-status {
  2068. display: flex;
  2069. align-items: center;
  2070. gap: 4px;
  2071. }
  2072. .line-label {
  2073. min-width: 35px;
  2074. color: #606266;
  2075. }
  2076. .line-progress {
  2077. color: #909399;
  2078. }
  2079. /* 双线上传进度样式 */
  2080. .dual-upload-progress {
  2081. display: flex;
  2082. flex-direction: column;
  2083. align-items: center;
  2084. gap: 4px;
  2085. }
  2086. .total-progress {
  2087. margin-bottom: 4px;
  2088. }
  2089. .line-progress-container {
  2090. display: flex;
  2091. flex-direction: column;
  2092. gap: 2px;
  2093. width: 100%;
  2094. }
  2095. .line-progress-item {
  2096. display: flex;
  2097. align-items: center;
  2098. gap: 4px;
  2099. font-size: 10px;
  2100. }
  2101. .line-label {
  2102. min-width: 30px;
  2103. color: #606266;
  2104. }
  2105. .line-status-text {
  2106. min-width: 25px;
  2107. color: #909399;
  2108. font-size: 10px;
  2109. }
  2110. /* 批量上传进度样式 */
  2111. .batch-upload-progress {
  2112. display: flex;
  2113. flex-direction: column;
  2114. gap: 4px;
  2115. }
  2116. .total-progress-row {
  2117. display: flex;
  2118. align-items: center;
  2119. gap: 8px;
  2120. white-space: nowrap; /* 防止换行 */
  2121. min-width: 0; /* 允许flex项目收缩 */
  2122. }
  2123. .progress-label {
  2124. font-size: 12px;
  2125. color: #606266;
  2126. min-width: 40px;
  2127. }
  2128. .line-progress-rows {
  2129. display: flex;
  2130. flex-direction: column;
  2131. gap: 2px;
  2132. }
  2133. .line-progress-row {
  2134. display: flex;
  2135. align-items: center;
  2136. gap: 4px;
  2137. font-size: 11px;
  2138. }
  2139. .line-percentage {
  2140. min-width: 30px;
  2141. color: #909399;
  2142. font-size: 11px;
  2143. }
  2144. ::v-deep .upload-icon {
  2145. font-size: 28px;
  2146. color: #8c939d;
  2147. }
  2148. ::v-deep .upload-text {
  2149. font-size: 12px;
  2150. color: #606266;
  2151. margin-top: 10px;
  2152. }
  2153. /* 表单样式 */
  2154. ::v-deep .el-form-item {
  2155. margin-bottom: 22px;
  2156. }
  2157. /* 批量选择弹窗样式 */
  2158. ::v-deep .batch-dialog .el-dialog__body {
  2159. padding: 0 20px 20px;
  2160. max-height: 70vh;
  2161. overflow-y: auto;
  2162. }
  2163. ::v-deep .el-dialog .el-dialog__body {
  2164. padding: 0 20px 20px;
  2165. max-height: 70vh;
  2166. overflow-y: auto;
  2167. }
  2168. .filter-container {
  2169. padding: 15px 0;
  2170. background-color: #fff;
  2171. border-bottom: 1px solid #ebeef5;
  2172. position: relative;
  2173. text-align: right;
  2174. }
  2175. .dialog-footer {
  2176. text-align: right;
  2177. margin-top: 20px;
  2178. padding-right: 20px;
  2179. }
  2180. ::v-deep .batch-dialog .el-table {
  2181. margin-top: 10px;
  2182. }
  2183. /* 按钮样式 */
  2184. ::v-deep .el-button--primary {
  2185. background-color: #1890ff;
  2186. border-color: #1890ff;
  2187. }
  2188. ::v-deep .el-button--primary:hover {
  2189. background-color: #40a9ff;
  2190. border-color: #40a9ff;
  2191. }
  2192. ::v-deep .el-button--primary:focus {
  2193. background-color: #40a9ff;
  2194. border-color: #40a9ff;
  2195. }
  2196. /* 表格头部样式 */
  2197. ::v-deep .batch-dialog .el-table__header-wrapper th {
  2198. background-color: #f5f7fa;
  2199. color: #606266;
  2200. font-weight: 500;
  2201. padding: 8px 0;
  2202. }
  2203. ::v-deep .el-table__header-wrapper th {
  2204. background-color: #f5f7fa;
  2205. color: #606266;
  2206. font-weight: 500;
  2207. padding: 8px 0;
  2208. }
  2209. /* 确保弹窗中表格内容垂直居中 */
  2210. ::v-deep .batch-dialog .el-table .cell {
  2211. line-height: 23px;
  2212. }
  2213. ::v-deep .el-table .cell {
  2214. line-height: 23px;
  2215. }
  2216. /* 自定义滚动条样式 */
  2217. ::v-deep .batch-dialog .el-dialog__body::-webkit-scrollbar {
  2218. width: 6px;
  2219. height: 6px;
  2220. }
  2221. ::v-deep .el-dialog .el-dialog__body::-webkit-scrollbar {
  2222. width: 6px;
  2223. height: 6px;
  2224. }
  2225. ::v-deep .batch-dialog .el-dialog__body::-webkit-scrollbar-thumb {
  2226. background: #c0c4cc;
  2227. border-radius: 3px;
  2228. }
  2229. ::v-deep .el-dialog .el-dialog__body::-webkit-scrollbar-thumb {
  2230. background: #c0c4cc;
  2231. border-radius: 3px;
  2232. }
  2233. ::v-deep .batch-dialog .el-dialog__body::-webkit-scrollbar-track {
  2234. background: #f5f7fa;
  2235. }
  2236. ::v-deep .el-dialog .el-dialog__body::-webkit-scrollbar-track {
  2237. background: #f5f7fa;
  2238. }
  2239. /* 批量上传视频弹窗样式 */
  2240. .upload-dialog .el-dialog__body {
  2241. padding: 20px;
  2242. }
  2243. ::v-deep .upload-dialog .el-dialog__header {
  2244. padding: 15px 20px;
  2245. background-color: #f9f9f9;
  2246. border-bottom: 1px solid #ebeef5;
  2247. }
  2248. ::v-deep .upload-dialog .el-dialog__title {
  2249. font-size: 16px;
  2250. font-weight: 500;
  2251. color: #303133;
  2252. }
  2253. /* 项目选择弹窗样式 */
  2254. ::v-deep .el-dialog__wrapper {
  2255. z-index: 2001 !important;
  2256. }
  2257. ::v-deep .el-dialog__header {
  2258. padding: 15px 20px;
  2259. background-color: #f9f9f9;
  2260. border-bottom: 1px solid #ebeef5;
  2261. }
  2262. ::v-deep .el-dialog__title {
  2263. font-size: 16px;
  2264. font-weight: 500;
  2265. color: #303133;
  2266. }
  2267. ::v-deep .el-pagination {
  2268. text-align: center;
  2269. margin-top: 10px;
  2270. }
  2271. /* 项目选择弹窗的样式 */
  2272. .project-container {
  2273. display: flex;
  2274. height: 500px;
  2275. }
  2276. .category-tree {
  2277. width: 250px;
  2278. height: 100%;
  2279. border-right: 1px solid #ebeef5;
  2280. padding: 0;
  2281. display: flex;
  2282. flex-direction: column;
  2283. overflow: hidden;
  2284. flex-shrink: 0;
  2285. }
  2286. .tree-fixed-header {
  2287. padding: 10px;
  2288. background-color: #fff;
  2289. border-bottom: 1px solid #ebeef5;
  2290. z-index: 10;
  2291. box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  2292. }
  2293. .tree-content {
  2294. flex: 1;
  2295. overflow-y: auto;
  2296. padding: 10px 10px 10px 10px;
  2297. }
  2298. .project-list {
  2299. flex: 1;
  2300. padding: 10px;
  2301. height: 100%;
  2302. display: flex;
  2303. flex-direction: column;
  2304. width: calc(100% - 250px); /* 固定宽度为剩余空间 */
  2305. }
  2306. .project-list .filter-container {
  2307. padding: 0 0 15px 0;
  2308. text-align: left;
  2309. }
  2310. .project-list .table-footer {
  2311. margin-top: 15px;
  2312. }
  2313. ::v-deep .el-tree-node__content {
  2314. height: 36px;
  2315. border-radius: 4px;
  2316. margin-bottom: 2px;
  2317. }
  2318. ::v-deep .el-tree-node:focus > .el-tree-node__content {
  2319. background-color: #e6f7ff;
  2320. }
  2321. ::v-deep .el-tree-node__content:hover {
  2322. background-color: #f0f7ff;
  2323. }
  2324. ::v-deep .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  2325. background-color: #e6f7ff;
  2326. color: #1890ff;
  2327. }
  2328. ::v-deep .custom-tree-node {
  2329. flex: 1;
  2330. display: flex;
  2331. align-items: center;
  2332. justify-content: space-between;
  2333. font-size: 14px;
  2334. padding: 0 8px;
  2335. }
  2336. /* 视频预览弹窗样式 */
  2337. ::v-deep .video-preview-dialog {
  2338. z-index: 3000 !important;
  2339. }
  2340. ::v-deep .video-preview-dialog .el-dialog {
  2341. margin-top: 10vh !important;
  2342. }
  2343. ::v-deep .video-preview-dialog .el-dialog__header {
  2344. padding: 15px 20px;
  2345. background-color: #f9f9f9;
  2346. border-bottom: 1px solid #ebeef5;
  2347. }
  2348. ::v-deep .video-preview-dialog .el-dialog__body {
  2349. padding: 15px;
  2350. background-color: #000;
  2351. display: flex;
  2352. justify-content: center;
  2353. align-items: center;
  2354. }
  2355. ::v-deep .video-preview-dialog video {
  2356. max-width: 100%;
  2357. max-height: 70vh;
  2358. }
  2359. /* 题目列表样式 */
  2360. .project-list-container {
  2361. background-color: #f5f7fa;
  2362. border-radius: 4px;
  2363. }
  2364. .question-card {
  2365. background-color: #ffffff;
  2366. border-radius: 4px;
  2367. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  2368. padding: 15px;
  2369. margin-bottom: 15px;
  2370. position: relative;
  2371. }
  2372. .question-header {
  2373. display: flex;
  2374. align-items: flex-start;
  2375. margin-bottom: 10px;
  2376. border-bottom: 1px solid #ebeef5;
  2377. padding-bottom: 10px;
  2378. }
  2379. .question-index {
  2380. display: flex;
  2381. justify-content: center;
  2382. align-items: center;
  2383. width: 24px;
  2384. height: 24px;
  2385. background-color: #409EFF;
  2386. color: white;
  2387. border-radius: 50%;
  2388. font-size: 14px;
  2389. margin-right: 10px;
  2390. flex-shrink: 0;
  2391. }
  2392. .question-title {
  2393. font-size: 16px;
  2394. font-weight: 500;
  2395. color: #303133;
  2396. line-height: 1.5;
  2397. word-break: break-all;
  2398. }
  2399. .question-type {
  2400. margin-bottom: 15px;
  2401. }
  2402. .content-title {
  2403. font-weight: 500;
  2404. color: #606266;
  2405. margin-bottom: 10px;
  2406. }
  2407. .question-content {
  2408. margin-bottom: 15px;
  2409. }
  2410. .question-item {
  2411. background-color: #f8f8f8;
  2412. border-left: 3px solid #409EFF;
  2413. padding: 10px;
  2414. margin-bottom: 10px;
  2415. border-radius: 0 4px 4px 0;
  2416. }
  2417. .question-item-header {
  2418. display: flex;
  2419. align-items: center;
  2420. margin-bottom: 5px;
  2421. }
  2422. .item-index {
  2423. display: inline-block;
  2424. margin-right: 10px;
  2425. font-weight: 500;
  2426. color: #409EFF;
  2427. }
  2428. .item-name {
  2429. color: #303133;
  2430. }
  2431. .question-answer {
  2432. background-color: #f0f9eb;
  2433. padding: 10px;
  2434. border-radius: 4px;
  2435. border-left: 3px solid #67c23a;
  2436. }
  2437. .answer-label {
  2438. font-weight: 500;
  2439. color: #67c23a;
  2440. margin-right: 10px;
  2441. }
  2442. .answer-content {
  2443. color: #606266;
  2444. }
  2445. ::v-deep .custom-select-class .el-select__tags {
  2446. display: flex;
  2447. flex-direction: column;
  2448. align-items: flex-start;
  2449. flex-wrap: nowrap;
  2450. max-height: 200px;
  2451. overflow-y: auto;
  2452. }
  2453. ::v-deep .custom-select-class .el-tag {
  2454. margin-bottom: 4px;
  2455. margin-right: 0;
  2456. }
  2457. </style>