courseList.vue 41 KB

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