courseList.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  1. <template>
  2. <div class="container courselist courselistNPC">
  3. <Header />
  4. <!-- <Nav navValue="教材列表" /> -->
  5. <div class="content">
  6. <div class="inner">
  7. <div class="btn-box">
  8. <span @click="handleAdd">
  9. <img src="../assets/common/icon-add.png" />新建教材
  10. </span>
  11. <!-- <el-button @click="handleAdd" size="small" type="primary"
  12. ><img src="../assets/common/icon-add.png">新建教材</el-button
  13. >-->
  14. <!-- <el-input
  15. @keyup.enter.native="handleSearch"
  16. placeholder="请输入内容"
  17. prefix-icon="el-icon-search"
  18. v-model="searchInput"
  19. ></el-input>-->
  20. </div>
  21. <el-form
  22. ref="form"
  23. :inline="true"
  24. :model="form"
  25. class="search-form"
  26. style="margin-left: 10px"
  27. >
  28. <el-form-item>
  29. <el-form-item
  30. class="label-input"
  31. label="名称"
  32. style="margin-right: 30px"
  33. >
  34. <el-input v-model="form.name" maxlength="100" />
  35. </el-form-item>
  36. <!-- <el-form-item class="label-input" label="作者">
  37. <el-input v-model="form.author"></el-input>
  38. </el-form-item>-->
  39. <el-form-item label="所属机构" style="margin-right: 30px">
  40. <el-select
  41. ref="select"
  42. v-model="form.agency"
  43. placeholder="请选择机构"
  44. @change="onSubmit"
  45. >
  46. <el-option
  47. v-for="(statusItem, index) in myOrgList"
  48. :key="'myOrgList' + index"
  49. :label="statusItem.org_name"
  50. :value="statusItem.org_id"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="发布状态">
  55. <el-select
  56. v-model="form.publish_status"
  57. placeholder="请选择状态"
  58. @change="onSubmit"
  59. >
  60. <el-option
  61. v-for="statusItem in statusList"
  62. :key="statusItem.value"
  63. :label="statusItem.label"
  64. :value="statusItem.value"
  65. />
  66. </el-select>
  67. </el-form-item>
  68. <el-button size="medium" type="primary" @click="onSubmit"
  69. >查询</el-button
  70. >
  71. </el-form-item>
  72. </el-form>
  73. <div class="table-box">
  74. <el-table
  75. v-loading="tableloading"
  76. :data="tableData"
  77. style="width: 100%"
  78. >
  79. <el-table-column
  80. class="table-firstC"
  81. label="名称"
  82. prop="name"
  83. width="150"
  84. />
  85. <el-table-column label="英文名" prop="name_english" width="150" />
  86. <el-table-column label="作者" prop="author" width="100" />
  87. <el-table-column label="版本" prop="edition" width="100" />
  88. <el-table-column label="出版社" prop="publisher" width="150" />
  89. <el-table-column
  90. label="出版编号"
  91. prop="publish_number"
  92. width="100"
  93. />
  94. <el-table-column label="所属机构" prop="org_name" width="150" />
  95. <el-table-column
  96. :formatter="handleStatus"
  97. label="发布状态"
  98. prop="publish_status"
  99. width="100"
  100. />
  101. <el-table-column
  102. :formatter="handleScope"
  103. label="发布范围"
  104. prop="publish_scope"
  105. width="100"
  106. />
  107. <el-table-column fixed="right" label="操作" prop width="370">
  108. <template slot-scope="scope">
  109. <el-button type="text" @click="handleClick(scope.row)"
  110. >编辑</el-button
  111. >
  112. <el-button type="text" @click="handleView(scope.row)"
  113. >预览</el-button
  114. >
  115. <el-button
  116. type="text"
  117. @click="handleUp(scope.row, scope.$index)"
  118. >{{
  119. scope.row.publish_status === 0 ? "上架" : "下架"
  120. }}</el-button
  121. >
  122. <el-button
  123. type="text"
  124. @click="handleEdit(scope.row, scope.$index)"
  125. >教材信息</el-button
  126. >
  127. <el-button type="text" @click="handleDiscount(scope.row)"
  128. >激活码</el-button
  129. >
  130. <el-button type="text" @click="handleCreatLink(scope.row)"
  131. >生成链接</el-button
  132. >
  133. <el-button type="text" @click="handleDel(scope.row)"
  134. >删除</el-button
  135. >
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. <el-pagination
  141. :current-page="currentPage"
  142. :page-size="10"
  143. :page-sizes="[1, 10, 20, 30, 40, 50]"
  144. :total="courseTotal"
  145. layout="total, sizes, prev, pager, next, jumper"
  146. @current-change="handleCurrentChange"
  147. @size-change="handleSizeChange"
  148. />
  149. </div>
  150. <div
  151. id="temporaryLinks"
  152. style="
  153. height: 0;
  154. width: 1200px;
  155. opacity: 0;
  156. z-index: -1;
  157. word-break: break-all;
  158. "
  159. ></div>
  160. </div>
  161. <el-dialog
  162. :before-close="handleClose"
  163. :title="titleEdit"
  164. :visible.sync="dialogFlag"
  165. :close-on-click-modal="false"
  166. >
  167. <el-form ref="formDialog" :model="formDialog" :rules="courseListRules">
  168. <el-tabs v-model="activeName">
  169. <el-tab-pane label="教材信息" name="courseInfo">
  170. <el-form-item
  171. class="label-input"
  172. label="名称"
  173. label-width="90px"
  174. prop="name"
  175. >
  176. <el-input
  177. v-model="formDialog.name"
  178. autocomplete="off"
  179. name="name"
  180. maxlength="100"
  181. show-word-limit
  182. />
  183. </el-form-item>
  184. <el-form-item
  185. class="label-input"
  186. label="英文名"
  187. label-width="90px"
  188. prop="name_english"
  189. >
  190. <el-input
  191. v-model="formDialog.name_english"
  192. autocomplete="off"
  193. name="name_english"
  194. maxlength="100"
  195. show-word-limit
  196. />
  197. </el-form-item>
  198. <el-form-item label="教材类型" label-width="90px" prop="type_id">
  199. <!-- -->
  200. <el-select
  201. ref="typeSelects"
  202. v-model="formDialog.type_id"
  203. name="bookType"
  204. placeholder="请选择教材类型"
  205. >
  206. <el-option
  207. v-for="(item, index) in typeList"
  208. :key="'type' + index"
  209. :label="item.name"
  210. :value="item.id"
  211. />
  212. </el-select>
  213. </el-form-item>
  214. <el-form-item
  215. class="label-input"
  216. label="作者"
  217. label-width="90px"
  218. prop="author"
  219. >
  220. <el-input
  221. v-model="formDialog.author"
  222. autocomplete="off"
  223. name="author"
  224. maxlength="20"
  225. show-word-limit
  226. />
  227. </el-form-item>
  228. <el-form-item
  229. class="label-input"
  230. label="版本"
  231. label-width="90px"
  232. prop="edition"
  233. >
  234. <el-input
  235. v-model="formDialog.edition"
  236. autocomplete="off"
  237. name="edition"
  238. maxlength="20"
  239. show-word-limit
  240. />
  241. </el-form-item>
  242. <el-form-item
  243. class="label-input"
  244. label="出版社"
  245. label-width="90px"
  246. prop="publisher"
  247. >
  248. <el-input
  249. v-model="formDialog.publisher"
  250. autocomplete="off"
  251. name="publisher"
  252. maxlength="20"
  253. show-word-limit
  254. />
  255. </el-form-item>
  256. <el-form-item
  257. class="label-input"
  258. label="出版编号"
  259. label-width="90px"
  260. prop="publish_number"
  261. >
  262. <el-input
  263. v-model="formDialog.publish_number"
  264. autocomplete="off"
  265. name="publish_number"
  266. maxlength="30"
  267. show-word-limit
  268. />
  269. </el-form-item>
  270. <el-form-item
  271. class="label-input"
  272. label="丛书编号"
  273. label-width="90px"
  274. prop="series_code"
  275. >
  276. <el-input
  277. autocomplete="off"
  278. name="series_code"
  279. v-model="formDialog.series_code"
  280. maxlength="26"
  281. show-word-limit
  282. ></el-input>
  283. </el-form-item>
  284. <el-form-item
  285. class="label-input"
  286. label="价格"
  287. label-width="90px"
  288. prop="price"
  289. >
  290. <el-input
  291. v-model="formDialog.price"
  292. autocomplete="off"
  293. name="price"
  294. type="number"
  295. @blur="blurPrice"
  296. @input="inputPrice"
  297. />
  298. </el-form-item>
  299. <el-form-item label="所属机构" label-width="90px" prop="org_id">
  300. <!-- -->
  301. <el-select
  302. ref="selects"
  303. v-model="formDialog.org_id"
  304. name="agency"
  305. placeholder="请选择机构"
  306. @change="changeAgency"
  307. >
  308. <el-option
  309. v-for="(statusItem, index) in diaMyOrgList"
  310. :key="'diaMyOrgList' + index"
  311. :label="statusItem.org_name"
  312. :value="statusItem.org_id"
  313. />
  314. </el-select>
  315. </el-form-item>
  316. <el-form-item
  317. label="教材描述"
  318. label-width="90px"
  319. prop="description"
  320. >
  321. <el-input
  322. v-model="formDialog.description"
  323. type="textarea"
  324. maxlength="500"
  325. show-word-limit
  326. />
  327. </el-form-item>
  328. <!-- <el-form-item label="发布状态" label-width="90px">
  329. <el-radio label="0" v-model="formDialog.publish_status">下架</el-radio>
  330. <el-radio label="1" v-model="formDialog.publish_status">上架</el-radio>
  331. </el-form-item>-->
  332. <el-form-item
  333. label="发布范围"
  334. label-width="90px"
  335. prop="publish_scope"
  336. >
  337. <el-radio v-model="formDialog.publish_scope" :label="0"
  338. >机构内用户可见</el-radio
  339. >
  340. <el-radio v-model="formDialog.publish_scope" :label="1"
  341. >所有用户可见</el-radio
  342. >
  343. </el-form-item>
  344. <el-form-item
  345. label="主题颜色"
  346. label-width="90px"
  347. prop="theme_color"
  348. >
  349. <el-radio v-model="formDialog.theme_color" label="red"
  350. >红色</el-radio
  351. >
  352. <el-radio v-model="formDialog.theme_color" label="green"
  353. >绿色</el-radio
  354. >
  355. <el-radio v-model="formDialog.theme_color" label="brown"
  356. >棕色</el-radio
  357. >
  358. </el-form-item>
  359. <el-form-item label="教材图片" label-width="90px" prop="fileList">
  360. <el-upload
  361. :action="url"
  362. :file-list="fileList"
  363. :limit="1"
  364. :before-upload="beforeUpload"
  365. :on-exceed="handleExceed"
  366. :on-preview="handlePreview"
  367. :on-remove="handleRemove"
  368. :on-success="handleSuccess"
  369. accept=".jpg, .jpeg, .png"
  370. class="upload-demo"
  371. list-type="picture"
  372. multiple
  373. style="width: 500px"
  374. >
  375. <el-button size="mini" type="success">上传封面</el-button>
  376. <div
  377. style="display: inline; padding-left: 30px"
  378. slot="tip"
  379. class="el-upload__tip"
  380. >
  381. 只能上传.jpg, .jpeg, .png文件,大小不超过2MB
  382. </div>
  383. </el-upload>
  384. </el-form-item>
  385. </el-tab-pane>
  386. <el-tab-pane label="教材资源" name="courseResource">
  387. <el-form-item
  388. label="视频资源"
  389. label-width="90px"
  390. prop="fileListVideo"
  391. >
  392. <el-upload
  393. :action="url"
  394. :file-list="fileListVideo"
  395. :limit="100"
  396. :before-upload="beforeUploadVideo"
  397. :on-exceed="handleExceedVideo"
  398. :on-remove="handleRemoveVideo"
  399. :on-success="handleSuccessVideo"
  400. :before-remove="beforeRemoveVideo"
  401. accept="video/*"
  402. class="upload-demo"
  403. multiple
  404. style="width: 500px"
  405. >
  406. <el-button size="mini" type="success" :loading="uploadingVideo"
  407. >上传视频</el-button
  408. >
  409. <div
  410. style="display: inline; padding-left: 30px"
  411. slot="tip"
  412. class="el-upload__tip"
  413. >
  414. 只能上传视频文件,大小不超过500MB
  415. </div>
  416. </el-upload>
  417. </el-form-item>
  418. <el-form-item
  419. label="课文音频"
  420. label-width="90px"
  421. prop="fileListAudio"
  422. >
  423. <el-upload
  424. :action="url"
  425. :file-list="fileListAudio"
  426. :limit="100"
  427. :before-upload="beforeUploadAudio"
  428. :on-exceed="handleExceedVideo"
  429. :on-remove="handleRemoveAudio"
  430. :on-success="handleSuccessAudio"
  431. :before-remove="beforeRemoveVideo"
  432. accept="audio/*"
  433. class="upload-demo"
  434. multiple
  435. style="width: 500px"
  436. >
  437. <el-button size="mini" type="success" :loading="uploadingAudio"
  438. >上传音频</el-button
  439. >
  440. <div
  441. style="display: inline; padding-left: 30px"
  442. slot="tip"
  443. class="el-upload__tip"
  444. >
  445. 只能上传音频文件,大小不超过20MB
  446. </div>
  447. </el-upload>
  448. </el-form-item>
  449. <el-form-item
  450. label="其他音频"
  451. label-width="90px"
  452. prop="fileListOtheraudio"
  453. >
  454. <el-upload
  455. :action="url"
  456. :file-list="fileListOtheraudio"
  457. :limit="100"
  458. :before-upload="beforeUploadOtherAudio"
  459. :on-exceed="handleExceedVideo"
  460. :on-remove="handleRemoveOtheraudio"
  461. :on-success="handleSuccesOthersAudio"
  462. :before-remove="beforeRemoveVideo"
  463. accept="audio/*"
  464. class="upload-demo"
  465. multiple
  466. style="width: 500px"
  467. >
  468. <el-button
  469. size="mini"
  470. type="success"
  471. :loading="uploadingOtherAudio"
  472. >上传音频</el-button
  473. >
  474. <div
  475. style="display: inline; padding-left: 30px"
  476. slot="tip"
  477. class="el-upload__tip"
  478. >
  479. 只能上传音频文件,大小不超过20MB
  480. </div>
  481. </el-upload>
  482. </el-form-item>
  483. <el-form-item label="试读PDF" label-width="90px" prop="fileListDoc">
  484. <el-upload
  485. :action="url"
  486. :file-list="fileListDoc"
  487. :limit="100"
  488. :before-upload="beforeUploadDoc"
  489. :on-exceed="handleExceedVideo"
  490. :on-remove="handleRemoveDoc"
  491. :on-success="handleSuccessDoc"
  492. :before-remove="beforeRemoveVideo"
  493. accept=".pdf"
  494. class="upload-demo"
  495. multiple
  496. style="width: 500px"
  497. >
  498. <el-button size="mini" type="success" :loading="uploadingDoc"
  499. >上传PDF</el-button
  500. >
  501. <div
  502. style="display: inline; padding-left: 30px"
  503. slot="tip"
  504. class="el-upload__tip"
  505. >
  506. 只能上传pdf文件,大小不超过20MB
  507. </div>
  508. </el-upload>
  509. </el-form-item>
  510. </el-tab-pane>
  511. </el-tabs>
  512. </el-form>
  513. <div slot="footer" class="dialog-footer">
  514. <el-button @click="dialogFlag = false">取 消</el-button>
  515. <el-button :loading="loading" type="primary" @click="submitCourse"
  516. >确 定</el-button
  517. >
  518. </div>
  519. </el-dialog>
  520. </div>
  521. </template>
  522. <script>
  523. import Header from "@/components/Header";
  524. import { validNull, validPrice } from "@/utils/validate";
  525. // import Nav from "@/components/inputModules/common/Nav";
  526. import { getContent, getContentFile } from "@/api/ajax";
  527. import { getToken } from "@/utils/auth";
  528. export default {
  529. name: "Courselist",
  530. components: {
  531. // Nav,
  532. Header
  533. },
  534. data() {
  535. const validateNull = (rule, value, callback) => {
  536. if (!validNull(value)) {
  537. callback(new Error("请输入相应内容"));
  538. } else {
  539. callback();
  540. }
  541. };
  542. const validatePrice = (rule, value, callback) => {
  543. if (!validPrice(value)) {
  544. callback(new Error("请输入价格"));
  545. } else {
  546. callback();
  547. }
  548. };
  549. return {
  550. tableData: [], // 数据内容
  551. currentPage: 1, // 当前页码
  552. page_capacity: 10, // 每页条数
  553. courseTotal: 0, // 数据总条数
  554. searchInput: "", // 搜索内容
  555. form: {
  556. author: "",
  557. status: "",
  558. agency: "",
  559. name: "",
  560. name_english: "",
  561. edition: "",
  562. publisher: "",
  563. publish_number: "",
  564. series_code: "",
  565. publish_status: -1
  566. },
  567. dialogFlag: false, // 新建教材弹出层
  568. agency: "",
  569. formDialog: {
  570. name: "",
  571. name_english: "",
  572. edition: "",
  573. description: "",
  574. author: "",
  575. price: null,
  576. org_id: "",
  577. org_name: "",
  578. publish_scope: 0,
  579. publish_number: "",
  580. series_code: "",
  581. picture_id: "",
  582. resource_file_id_list_video: [],
  583. resource_file_id_list_audio: [],
  584. resource_file_id_list_otheraudio: [],
  585. resource_file_id_list_doc: [],
  586. id: "",
  587. publisher: "",
  588. theme_color: "",
  589. type_id: ""
  590. },
  591. agencyList: [
  592. {
  593. id: "",
  594. name: "请选择"
  595. }
  596. ],
  597. agencyLists: [
  598. {
  599. id: "",
  600. name: "请选择"
  601. }
  602. ],
  603. publishStatus: {
  604. 0: "下架",
  605. 1: "上架"
  606. },
  607. publishScope: {
  608. 0: "机构内用户",
  609. 1: "所有用户"
  610. },
  611. fileList: [], // 上传图片数组
  612. fileListVideo: [], // 教材资源视频数组
  613. fileListAudio: [], // 教材资源视频数组
  614. fileListOtheraudio: [],
  615. fileListDoc: [], // 教材资源视频数组
  616. pageIndex: 1,
  617. courseListRules: {
  618. // 填写规则
  619. name: [{ required: true, trigger: "blur", validator: validateNull }],
  620. author: [{ required: true, trigger: "blur", validator: validateNull }],
  621. edition: [{ required: true, trigger: "blur", validator: validateNull }],
  622. publisher: [
  623. { required: true, trigger: "blur", validator: validateNull }
  624. ],
  625. publish_number: [
  626. { required: true, trigger: "blur", validator: validateNull }
  627. ],
  628. org_id: [{ required: true, message: "请选择机构", trigger: "change" }],
  629. type_id: [
  630. { required: true, message: "请选择教材类型", trigger: "change" }
  631. ],
  632. price: [{ required: true, validator: validatePrice }]
  633. },
  634. loading: false,
  635. uploadingVideo: false,
  636. uploadingAudio: false,
  637. uploadingOtherAudio: false,
  638. uploadingDoc: false,
  639. titleEdit: "新建教材",
  640. rowIndex: 0, // 记录编辑教材的index
  641. tableloading: true,
  642. selectLoading: false,
  643. noMore: false,
  644. statusList: [
  645. {
  646. label: "全部",
  647. value: -1
  648. },
  649. {
  650. label: "上架",
  651. value: 1
  652. },
  653. {
  654. label: "下架",
  655. value: 0
  656. }
  657. ],
  658. myOrgList: [
  659. {
  660. org_id: "",
  661. org_name: "全部"
  662. }
  663. ],
  664. diaMyOrgList: [],
  665. typeList: [],
  666. activeName: "courseInfo" // 教材信息tabs
  667. };
  668. },
  669. computed: {
  670. url() {
  671. let userInfor = getToken();
  672. let SessionID = "";
  673. let UserCode = "";
  674. let UserType = "";
  675. if (userInfor) {
  676. let user = JSON.parse(getToken());
  677. UserCode = user.user_code;
  678. UserType = user.user_type;
  679. SessionID = user.session_id;
  680. }
  681. return (
  682. process.env.VUE_APP_BASE_API +
  683. "/GCLSFileServer/WebFileUpload?UserCode=" +
  684. UserCode +
  685. "&UserType=" +
  686. UserType +
  687. "&SessionID=" +
  688. SessionID +
  689. "&SecurityLevel=Mid"
  690. );
  691. }
  692. },
  693. mounted() {
  694. this.getList();
  695. this.getTypeList();
  696. this.getMyOrgList();
  697. this.getMyOrgListAgree();
  698. // this.createOptions(1);
  699. // this.$refs.select.$refs.scrollbar.$refs.wrap.addEventListener(
  700. // "scroll",
  701. // this.selectScroll
  702. // );
  703. },
  704. methods: {
  705. createOptions(len, start = 0) {
  706. // this.getAgencList();
  707. },
  708. selectScroll() {
  709. let e = this.$refs.select.$refs.scrollbar.$refs.wrap;
  710. if (this.noMore) return;
  711. let loadMore = e.scrollHeight - e.scrollTop <= e.clientHeight;
  712. if (loadMore) {
  713. this.loadMore();
  714. }
  715. },
  716. loadMore() {
  717. if (this.selectLoading) return;
  718. this.selectLoading = true;
  719. this.getAgencList();
  720. },
  721. // 切换每页条数
  722. handleSizeChange(val) {
  723. this.currentPage = 1;
  724. this.page_capacity = val;
  725. this.getList();
  726. },
  727. // 切换页码
  728. handleCurrentChange(val) {
  729. this.currentPage = val;
  730. this.getList();
  731. },
  732. // 回车搜索
  733. handleSearch() {
  734. console.log(this.searchInput);
  735. },
  736. // 点击查询按钮
  737. onSubmit() {
  738. this.currentPage = 1;
  739. this.getList();
  740. },
  741. handleClick(row) {
  742. if (row.publish_status == 1) {
  743. this.$message({
  744. type: "warning",
  745. message: "此教材处于上架状态不可以进行编辑"
  746. });
  747. return false;
  748. }
  749. sessionStorage.setItem("Bookdetail", JSON.stringify(row));
  750. this.$router.push("/adultInput?bookId=" + row.id);
  751. },
  752. // 预览
  753. handleView(row) {
  754. sessionStorage.setItem("Bookdetail", JSON.stringify(row));
  755. this.$router.push("/courseview?bookId=" + row.id);
  756. },
  757. // 激活码
  758. handleDiscount(row) {
  759. this.$router.push("/discountCodeList?bookId=" + row.id);
  760. }, // 生成临时链接
  761. handleCreatLink(row) {
  762. let link =
  763. "https://" +
  764. window.location.host +
  765. "/GCLS-Book/#/BookBrowsing?bookId=" +
  766. row.id;
  767. document.getElementById("temporaryLinks").innerHTML = link;
  768. var doc = document,
  769. text = doc.getElementById("temporaryLinks"),
  770. range,
  771. selection;
  772. if (doc.body.createTextRange) {
  773. range = doc.body.createTextRange();
  774. range.moveToElementText(text);
  775. range.select();
  776. } else if (window.getSelection) {
  777. selection = window.getSelection();
  778. range = doc.createRange();
  779. range.selectNodeContents(text);
  780. selection.removeAllRanges();
  781. selection.addRange(range);
  782. }
  783. document.execCommand("copy");
  784. this.$message({
  785. message: "复制成功",
  786. type: "success"
  787. });
  788. window.getSelection().removeAllRanges();
  789. },
  790. // 新建教材
  791. handleAdd() {
  792. this.titleEdit = "新建教材";
  793. this.activeName = "courseInfo";
  794. this.formDialog = {
  795. name: "",
  796. name_english: "",
  797. edition: "",
  798. description: "",
  799. author: "",
  800. price: null,
  801. org_id: "",
  802. org_name: "",
  803. publish_scope: 0,
  804. publish_number: "",
  805. series_code: "",
  806. picture_id: "",
  807. resource_file_id_list_video: [],
  808. resource_file_id_list_audio: [],
  809. resource_file_id_list_otheraudio: [],
  810. resource_file_id_list_doc: [],
  811. id: "",
  812. publisher: "",
  813. theme_color: "",
  814. type_id: ""
  815. };
  816. this.agency = "";
  817. this.fileList = [];
  818. this.fileListVideo = [];
  819. this.fileListAudio = [];
  820. this.fileListOtheraudio = [];
  821. this.fileListDoc = [];
  822. this.dialogFlag = true;
  823. },
  824. // 新建教材提交
  825. submitCourse() {
  826. const _this = this;
  827. if (
  828. this.uploadingVideo ||
  829. this.uploadingAudio ||
  830. this.uploadingOtherAudio ||
  831. this.uploadingDoc
  832. ) {
  833. this.$message.warning("有文件尚未上传成功,请耐心等待");
  834. return false;
  835. }
  836. _this.$refs.formDialog.validate(valid => {
  837. _this.formDialog.name = _this.formDialog.name.trim();
  838. _this.formDialog.author = _this.formDialog.author.trim();
  839. if (_this.formDialog.description !== "") {
  840. _this.formDialog.description = _this.formDialog.description.trim();
  841. }
  842. if (valid) {
  843. _this.loading = true;
  844. let MethodName;
  845. if (_this.formDialog.id) {
  846. MethodName = "book-book_manager-UpdateBook";
  847. } else {
  848. MethodName = "book-book_manager-AddBook";
  849. }
  850. this.formDialog.publish_status = 1;
  851. let data = JSON.parse(JSON.stringify(_this.formDialog));
  852. getContent(MethodName, data)
  853. .then(res => {
  854. this.$message.success("操作成功");
  855. if (_this.formDialog.id) {
  856. this.$set(_this.tableData, this.rowIndex, data);
  857. } else {
  858. _this.currentPage = 1;
  859. _this.getList();
  860. _this.resetForm("formDialog");
  861. }
  862. _this.dialogFlag = false;
  863. this.loading = false;
  864. })
  865. .catch(() => {
  866. this.loading = false;
  867. });
  868. } else {
  869. this.loading = false;
  870. return false;
  871. }
  872. });
  873. },
  874. // 查询数据列表
  875. getList() {
  876. let MethodName = "book-book_manager-PageQueryBookList";
  877. let data = {
  878. name: this.form.name,
  879. page_capacity: this.page_capacity,
  880. cur_page: this.currentPage,
  881. org_id: this.form.agency,
  882. order_column: "create_time:desc",
  883. publish_status: this.form.publish_status,
  884. is_control_publish_scope: "false"
  885. };
  886. getContent(MethodName, data).then(res => {
  887. let _this = this;
  888. _this.tableData = res.book_list;
  889. _this.courseTotal = res.total_count;
  890. _this.tableloading = false;
  891. });
  892. },
  893. // 机构列表
  894. getAgencList() {
  895. let MethodName = "org_manager-PageQueryOrgList";
  896. let data = {
  897. name: "",
  898. page_capacity: 50,
  899. cur_page: this.pageIndex
  900. };
  901. let dataList = [];
  902. getContentFile(MethodName, data)
  903. .then(res => {
  904. dataList = res.org_list;
  905. if (this.pageIndex === res.total_page) {
  906. // 获取到最后的值时,不再监听滚动条的动作,移除滚动事件
  907. this.$refs.select.$refs.scrollbar.$refs.wrap.removeEventListener(
  908. "scroll",
  909. this.selectScroll()
  910. );
  911. this.noMore = true;
  912. }
  913. this.pageIndex++;
  914. this.agencyList = this.agencyList.concat(dataList);
  915. this.agencyLists = this.agencyList;
  916. })
  917. .finally(() => (this.selectLoading = false));
  918. },
  919. // 得到我的机构列表-org_manager-GetMyOrgList
  920. getMyOrgList() {
  921. let MethodName = "org_manager-GetMyOrgList";
  922. let data = {
  923. audited_status: 1
  924. };
  925. getContentFile(MethodName, data).then(res => {
  926. if (res && res.org_list.length > 0) {
  927. this.myOrgList = this.myOrgList.concat(res.org_list);
  928. this.diaMyOrgList = res.org_list;
  929. }
  930. });
  931. },
  932. // 得到我的机构列表-org_manager-GetMyOrgList--审核通过的
  933. getMyOrgListAgree() {
  934. let MethodName = "org_manager-GetMyOrgList";
  935. let data = {
  936. audited_status: 1
  937. };
  938. getContentFile(MethodName, data).then(res => {
  939. if (res && res.org_list.length > 0) {
  940. this.diaMyOrgList = res.org_list;
  941. }
  942. });
  943. },
  944. // 教材类型列表
  945. getTypeList() {
  946. let MethodName = "dict_manager-GetBookTypeList";
  947. let data = {};
  948. getContentFile(MethodName, data).then(res => {
  949. this.typeList = res.type_list;
  950. console.log(this.typeList);
  951. });
  952. },
  953. // 处理发布状态
  954. handleStatus(row) {
  955. if (row) {
  956. return this.publishStatus[row.publish_status];
  957. }
  958. },
  959. // 处理发布范围
  960. handleScope(row) {
  961. if (row) {
  962. return this.publishScope[row.publish_scope];
  963. }
  964. },
  965. // 选择机构
  966. changeAgency(row) {
  967. for (let i = 0; i < this.diaMyOrgList.length; i++) {
  968. let item = this.diaMyOrgList[i];
  969. if (item.org_id === row) {
  970. this.formDialog.org_name = item.org_name;
  971. break;
  972. }
  973. }
  974. },
  975. // 处理教材价格 最多两位小数
  976. inputPrice(e) {
  977. e = e.match(/^\d*(\.?\d{0,2})/g)[0] || "";
  978. this.formDialog.price = e;
  979. },
  980. // 处理教材价格 失去焦点保留两位小数
  981. blurPrice() {
  982. if (this.formDialog.price) {
  983. this.formDialog.price = Number(this.formDialog.price).toFixed(2);
  984. }
  985. },
  986. handleSuccess(response, file, fileList) {
  987. if (response.status == 1) {
  988. this.$message.success("上传成功");
  989. this.formDialog.picture_id = response.file_info_list[0].file_id;
  990. } else {
  991. this.fileList = [];
  992. this.$message.warning(response.msg);
  993. }
  994. },
  995. handleSuccessVideo(response, file, fileList) {
  996. this.uploadingVideo = false;
  997. if (response.status == 1) {
  998. this.$message.success("上传成功");
  999. this.formDialog.resource_file_id_list_video.push(
  1000. response.file_info_list[0].file_id
  1001. );
  1002. } else {
  1003. this.$message.warning(response.msg);
  1004. }
  1005. },
  1006. handleSuccessAudio(response, file, fileList) {
  1007. this.uploadingAudio = false;
  1008. if (response.status == 1) {
  1009. this.$message.success("上传成功");
  1010. this.formDialog.resource_file_id_list_audio.push(
  1011. response.file_info_list[0].file_id
  1012. );
  1013. } else {
  1014. this.$message.warning(response.msg);
  1015. }
  1016. },
  1017. handleSuccesOthersAudio(response, file, fileList) {
  1018. this.uploadingOtherAudio = false;
  1019. if (response.status == 1) {
  1020. this.$message.success("上传成功");
  1021. this.formDialog.resource_file_id_list_otheraudio.push(
  1022. response.file_info_list[0].file_id
  1023. );
  1024. } else {
  1025. this.$message.warning(response.msg);
  1026. }
  1027. },
  1028. handleSuccessDoc(response, file, fileList) {
  1029. this.uploadingDoc = false;
  1030. if (response.status == 1) {
  1031. this.$message.success("上传成功");
  1032. this.formDialog.resource_file_id_list_doc.push(
  1033. response.file_info_list[0].file_id
  1034. );
  1035. } else {
  1036. this.$message.warning(response.msg);
  1037. }
  1038. },
  1039. handleRemove(file, fileList) {
  1040. this.fileList = fileList;
  1041. this.formDialog.picture_id = "";
  1042. },
  1043. handleRemoveVideo(file, fileList) {
  1044. this.fileListVideo = fileList;
  1045. this.formDialog.resource_file_id_list_video = [];
  1046. fileList.forEach(item => {
  1047. this.formDialog.resource_file_id_list_video.push(item.file_id);
  1048. });
  1049. },
  1050. handleRemoveAudio(file, fileList) {
  1051. this.fileListAudio = fileList;
  1052. this.formDialog.resource_file_id_list_audio = [];
  1053. fileList.forEach(item => {
  1054. this.formDialog.resource_file_id_list_audio.push(item.file_id);
  1055. });
  1056. },
  1057. handleRemoveOtheraudio(file, fileList) {
  1058. this.fileListOtheraudio = fileList;
  1059. this.formDialog.resource_file_id_list_otheraudio = [];
  1060. fileList.forEach(item => {
  1061. this.formDialog.resource_file_id_list_otheraudio.push(item.file_id);
  1062. });
  1063. },
  1064. handleRemoveDoc(file, fileList) {
  1065. this.fileListDoc = fileList;
  1066. this.formDialog.resource_file_id_list_doc = [];
  1067. fileList.forEach(item => {
  1068. this.formDialog.resource_file_id_list_doc.push(item.file_id);
  1069. });
  1070. },
  1071. handlePreview(file) {
  1072. console.log(file);
  1073. },
  1074. beforeUpload(file) {
  1075. if (file.size > 2 * 1024 * 1024) {
  1076. this.$message.warning("上传图片大小不能超过2M");
  1077. return false; //必须返回false
  1078. }
  1079. },
  1080. beforeUploadVideo(file) {
  1081. if (this.uploadingVideo) {
  1082. return false;
  1083. } else {
  1084. this.uploadingVideo = true;
  1085. if (file.size > 500 * 1024 * 1024) {
  1086. this.$message.warning("上传视频大小不能超过500M");
  1087. this.uploadingVideo = false;
  1088. return false; //必须返回false
  1089. }
  1090. }
  1091. },
  1092. beforeUploadAudio(file) {
  1093. if (this.uploadingAudio) {
  1094. return false;
  1095. } else {
  1096. this.uploadingAudio = true;
  1097. if (file.size > 20 * 1024 * 1024) {
  1098. this.$message.warning("上传音频大小不能超过20M");
  1099. this.uploadingAudio = false;
  1100. return false; //必须返回false
  1101. }
  1102. }
  1103. },
  1104. beforeUploadOtherAudio(file) {
  1105. if (this.uploadingOtherAudio) {
  1106. return false;
  1107. } else {
  1108. this.uploadingOtherAudio = true;
  1109. if (file.size > 20 * 1024 * 1024) {
  1110. this.$message.warning("上传音频大小不能超过20M");
  1111. this.uploadingOtherAudio = false;
  1112. return false; //必须返回false
  1113. }
  1114. }
  1115. },
  1116. beforeUploadDoc(file) {
  1117. if (this.uploadingDoc) {
  1118. return false;
  1119. } else {
  1120. this.uploadingDoc = true;
  1121. if (file.size > 20 * 1024 * 1024) {
  1122. this.$message.warning("上传文件大小不能超过20M");
  1123. this.uploadingDoc = false;
  1124. return false; //必须返回false
  1125. }
  1126. }
  1127. },
  1128. handleExceed(files, fileList) {
  1129. this.$message.warning(
  1130. `当前限制选择 1 个文件,本次选择了 ${
  1131. files.length
  1132. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  1133. );
  1134. },
  1135. handleExceedVideo(files, fileList) {
  1136. this.uploadingVideo = false;
  1137. this.uploadingAudio = false;
  1138. this.uploadingOtherAudio = false;
  1139. this.uploadingDoc = false;
  1140. this.$message.warning(
  1141. `当前限制选择 100 个文件,本次选择了 ${
  1142. files.length
  1143. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  1144. );
  1145. },
  1146. beforeRemoveVideo(file) {
  1147. return this.$confirm(`确定移除 ${file.name}?`);
  1148. },
  1149. // 清空表单
  1150. resetForm(formName) {
  1151. this.$refs[formName].resetFields();
  1152. this.formDialog.price = null;
  1153. this.agency = "";
  1154. this.fileList = [];
  1155. this.fileListVideo = [];
  1156. this.fileListAudio = [];
  1157. this.fileListOtheraudio = [];
  1158. this.fileListDoc = [];
  1159. this.formDialog.description = "";
  1160. },
  1161. // 编辑书籍信息
  1162. handleEdit(row, index) {
  1163. this.$nextTick(() => {
  1164. if (this.$refs["formDialog"] !== undefined) {
  1165. this.$refs["formDialog"].resetFields();
  1166. }
  1167. });
  1168. this.rowIndex = index;
  1169. this.titleEdit = "编辑教材";
  1170. this.activeName = "courseInfo";
  1171. this.fileList = [];
  1172. this.fileListVideo = [];
  1173. this.fileListAudio = [];
  1174. this.fileListOtheraudio = [];
  1175. this.fileListDoc = [];
  1176. let MethodName = "book-book_manager-GetBook";
  1177. let data = {
  1178. id: row.id
  1179. };
  1180. getContent(MethodName, data)
  1181. .then(res => {
  1182. this.formDialog = {
  1183. id: res.id,
  1184. name: res.name,
  1185. description: res.description,
  1186. author: res.author,
  1187. price: res.price.toFixed(2),
  1188. org_id: res.org_id,
  1189. org_name: res.org_name,
  1190. publish_scope: res.publish_scope,
  1191. picture_id: res.picture_id,
  1192. name_english: res.name_english,
  1193. publish_number: res.publish_number,
  1194. series_code: res.series_code,
  1195. publisher: res.publisher,
  1196. theme_color: res.theme_color,
  1197. edition: res.edition,
  1198. type_id: res.type_id
  1199. };
  1200. sessionStorage.setItem("Bookdetail", JSON.stringify(this.formDialog));
  1201. if (res.picture_url) {
  1202. let obj = {
  1203. name: "",
  1204. url: res.picture_url
  1205. };
  1206. this.fileList.push(obj);
  1207. }
  1208. this.agency = res.org_id;
  1209. let MethodNames = "book-resource_manager-GetBookResourceList";
  1210. let datas = {
  1211. book_id: row.id
  1212. };
  1213. getContent(MethodNames, datas).then(res => {
  1214. if (res.status == 1) {
  1215. this.formDialog.resource_file_id_list_video = [];
  1216. this.formDialog.resource_file_id_list_audio = [];
  1217. this.formDialog.resource_file_id_list_otheraudio = [];
  1218. this.formDialog.resource_file_id_list_doc = [];
  1219. res.video_list.forEach(item => {
  1220. let obj = {
  1221. name: item.file_name,
  1222. file_id: item.file_id
  1223. };
  1224. this.fileListVideo.push(obj);
  1225. this.formDialog.resource_file_id_list_video.push(item.file_id);
  1226. });
  1227. res.audio_list.forEach(item => {
  1228. let obj = {
  1229. name: item.file_name,
  1230. file_id: item.file_id
  1231. };
  1232. this.fileListAudio.push(obj);
  1233. this.formDialog.resource_file_id_list_audio.push(item.file_id);
  1234. });
  1235. res.otheraudio_list.forEach(item => {
  1236. let obj = {
  1237. name: item.file_name,
  1238. file_id: item.file_id
  1239. };
  1240. this.fileListOtheraudio.push(obj);
  1241. this.formDialog.resource_file_id_list_otheraudio.push(
  1242. item.file_id
  1243. );
  1244. });
  1245. res.doc_list.forEach(item => {
  1246. let obj = {
  1247. name: item.file_name,
  1248. file_id: item.file_id
  1249. };
  1250. this.fileListDoc.push(obj);
  1251. this.formDialog.resource_file_id_list_doc.push(item.file_id);
  1252. });
  1253. }
  1254. });
  1255. })
  1256. .catch(() => {
  1257. this.loading = false;
  1258. });
  1259. this.dialogFlag = true;
  1260. // 循环select 有没有选中数据 没有插入
  1261. },
  1262. // 删除书籍
  1263. handleDel(row) {
  1264. if (row.publish_status == 1) {
  1265. this.$message({
  1266. type: "warning",
  1267. message: "此教材处于上架状态不可以进行删除"
  1268. });
  1269. return false;
  1270. }
  1271. this.$confirm("确定要删除此书籍吗?", "提示", {
  1272. confirmButtonText: "确定",
  1273. cancelButtonText: "取消",
  1274. type: "warning"
  1275. })
  1276. .then(() => {
  1277. let MethodName = "book-book_manager-DeleteBook";
  1278. let data = {
  1279. id: row.id
  1280. };
  1281. getContent(MethodName, data)
  1282. .then(res => {
  1283. this.currentPage = 1;
  1284. this.getList();
  1285. this.$message({
  1286. type: "success",
  1287. message: "删除成功!"
  1288. });
  1289. })
  1290. .catch(() => {});
  1291. })
  1292. .catch(() => {});
  1293. },
  1294. // 上架
  1295. handleUp(row, index) {
  1296. let Mname = "book-book_manager-SetPublishStatusForBook";
  1297. let updataData = JSON.parse(JSON.stringify(row));
  1298. let data = {
  1299. book_id: row.id
  1300. };
  1301. if (row.publish_status == 0) {
  1302. // 下架状态
  1303. data.publish_status = 1;
  1304. updataData.publish_status = 1;
  1305. } else if (row.publish_status == 1) {
  1306. data.publish_status = 0;
  1307. updataData.publish_status = 0;
  1308. }
  1309. getContent(Mname, data).then(res => {
  1310. this.$message.success("操作成功");
  1311. this.$set(this.tableData, index, updataData);
  1312. });
  1313. },
  1314. // 关闭弹窗
  1315. handleClose(done) {
  1316. this.loading = false;
  1317. this.formDialog.price = null;
  1318. this.agency = "";
  1319. this.fileList = [];
  1320. this.fileListVideo = [];
  1321. this.fileListAudio = [];
  1322. this.fileListOtheraudio = [];
  1323. this.fileListDoc = [];
  1324. this.formDialog.description = "";
  1325. done();
  1326. }
  1327. }
  1328. };
  1329. </script>
  1330. <style lang="scss" scoped>
  1331. .container {
  1332. width: 100%;
  1333. background: #f5f5f5;
  1334. .content {
  1335. width: 100%;
  1336. display: flex;
  1337. justify-content: flex-start;
  1338. align-items: flex-start;
  1339. max-width: 1200px;
  1340. margin: 0 auto;
  1341. height: auto;
  1342. .inner {
  1343. width: 100%;
  1344. margin: 0 auto;
  1345. box-sizing: border-box;
  1346. padding: 20px 0;
  1347. position: relative;
  1348. .btn-box {
  1349. font-size: 0;
  1350. position: absolute;
  1351. right: 0;
  1352. top: 40px;
  1353. span {
  1354. height: 36px;
  1355. line-height: 36px;
  1356. padding: 0 15px;
  1357. display: flex;
  1358. justify-content: center;
  1359. align-items: center;
  1360. background: #ff9900;
  1361. border-radius: 4px;
  1362. font-size: 14px;
  1363. color: #ffffff;
  1364. cursor: pointer;
  1365. &:hover {
  1366. opacity: 0.8;
  1367. }
  1368. }
  1369. img {
  1370. width: 20px;
  1371. margin-right: 4px;
  1372. }
  1373. }
  1374. .search-form {
  1375. display: flex;
  1376. justify-content: flex-start;
  1377. align-items: center;
  1378. flex-wrap: wrap;
  1379. font-size: 0;
  1380. margin-top: 20px;
  1381. .el-cascader .el-input .el-input__inner {
  1382. width: 240px;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. .el-dialog__body {
  1388. padding-right: 20px;
  1389. }
  1390. .table-box {
  1391. background: #fff;
  1392. padding: 10px 32px 0 32px;
  1393. border-radius: 4px;
  1394. }
  1395. }
  1396. </style>
  1397. <style lang="scss">
  1398. .el-table th.is-leaf {
  1399. border-color: #d5d5d5;
  1400. }
  1401. .el-table td {
  1402. padding: 0.05rem 0;
  1403. }
  1404. .el-dialog {
  1405. font-size: 0;
  1406. }
  1407. .courselistNPC {
  1408. .el-dialog__body {
  1409. padding: 0 20px;
  1410. }
  1411. .el-tabs__nav-wrap::after {
  1412. height: 0;
  1413. }
  1414. .el-upload-list {
  1415. max-height: 400px;
  1416. overflow-y: auto;
  1417. }
  1418. }
  1419. </style>