courseList.vue 36 KB

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