courseList.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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. >
  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"></el-input>
  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. placeholder="请选择机构"
  42. v-model="form.agency"
  43. ref="select"
  44. @change="onSubmit"
  45. >
  46. <el-option
  47. :key="'myOrgList' + index"
  48. :label="statusItem.org_name"
  49. :value="statusItem.org_id"
  50. v-for="(statusItem, index) in myOrgList"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="发布状态">
  55. <el-select
  56. placeholder="请选择状态"
  57. v-model="form.publish_status"
  58. @change="onSubmit"
  59. >
  60. <el-option
  61. :key="statusItem.value"
  62. :label="statusItem.label"
  63. :value="statusItem.value"
  64. v-for="statusItem in statusList"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-button @click="onSubmit" size="medium" type="primary"
  69. >查询</el-button
  70. >
  71. </el-form-item>
  72. </el-form>
  73. <div class="table-box">
  74. <el-table
  75. :data="tableData"
  76. style="width: 100%"
  77. v-loading="tableloading"
  78. >
  79. <el-table-column
  80. class="table-firstC"
  81. label="名称"
  82. prop="name"
  83. width="150"
  84. ></el-table-column>
  85. <el-table-column
  86. label="英文名"
  87. prop="name_english"
  88. width="150"
  89. ></el-table-column>
  90. <el-table-column
  91. label="作者"
  92. prop="author"
  93. width="100"
  94. ></el-table-column>
  95. <el-table-column
  96. label="版本"
  97. prop="edition"
  98. width="100"
  99. ></el-table-column>
  100. <el-table-column
  101. label="出版社"
  102. prop="publisher"
  103. width="150"
  104. ></el-table-column>
  105. <el-table-column
  106. label="出版编号"
  107. prop="publish_number"
  108. width="100"
  109. ></el-table-column>
  110. <el-table-column
  111. label="所属机构"
  112. prop="org_name"
  113. width="150"
  114. ></el-table-column>
  115. <el-table-column
  116. :formatter="handleStatus"
  117. label="发布状态"
  118. prop="publish_status"
  119. width="100"
  120. ></el-table-column>
  121. <el-table-column
  122. :formatter="handleScope"
  123. label="发布范围"
  124. prop="publish_scope"
  125. width="100"
  126. ></el-table-column>
  127. <el-table-column fixed="right" label="操作" prop width="300">
  128. <template slot-scope="scope">
  129. <el-button @click="handleClick(scope.row)" type="text"
  130. >编辑</el-button
  131. >
  132. <el-button @click="handleView(scope.row)" type="text"
  133. >预览</el-button
  134. >
  135. <el-button
  136. @click="handleUp(scope.row, scope.$index)"
  137. type="text"
  138. >{{
  139. scope.row.publish_status === 0 ? "上架" : "下架"
  140. }}</el-button
  141. >
  142. <el-button
  143. @click="handleEdit(scope.row, scope.$index)"
  144. type="text"
  145. >教材信息</el-button
  146. >
  147. <el-button @click="handleDiscount(scope.row)" type="text"
  148. >授权码</el-button
  149. >
  150. <el-button @click="handleDel(scope.row)" type="text"
  151. >删除</el-button
  152. >
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. <el-pagination
  158. :current-page="currentPage"
  159. :page-size="10"
  160. :page-sizes="[1, 10, 20, 30, 40, 50]"
  161. :total="courseTotal"
  162. @current-change="handleCurrentChange"
  163. @size-change="handleSizeChange"
  164. layout="total, sizes, prev, pager, next, jumper"
  165. ></el-pagination>
  166. </div>
  167. </div>
  168. <el-dialog
  169. :before-close="handleClose"
  170. :title="titleEdit"
  171. :visible.sync="dialogFlag"
  172. :close-on-click-modal="false"
  173. >
  174. <el-form ref="formDialog" :model="formDialog" :rules="courseListRules">
  175. <el-form-item
  176. class="label-input"
  177. label="名称"
  178. label-width="90px"
  179. prop="name"
  180. >
  181. <el-input v-model="formDialog.name" autocomplete="off" name="name" />
  182. </el-form-item>
  183. <el-form-item
  184. class="label-input"
  185. label="英文名"
  186. label-width="90px"
  187. prop="name_english"
  188. >
  189. <el-input
  190. v-model="formDialog.name_english"
  191. autocomplete="off"
  192. name="name_english"
  193. />
  194. </el-form-item>
  195. <el-form-item label="教材类型" label-width="90px" prop="type_id">
  196. <!-- -->
  197. <el-select
  198. ref="typeSelects"
  199. v-model="formDialog.type_id"
  200. name="bookType"
  201. placeholder="请选择教材类型"
  202. >
  203. <el-option
  204. v-for="(item, index) in typeList"
  205. :key="'type' + index"
  206. :label="item.name"
  207. :value="item.id"
  208. />
  209. </el-select>
  210. </el-form-item>
  211. <el-form-item
  212. class="label-input"
  213. label="作者"
  214. label-width="90px"
  215. prop="author"
  216. >
  217. <el-input
  218. v-model="formDialog.author"
  219. autocomplete="off"
  220. name="author"
  221. />
  222. </el-form-item>
  223. <el-form-item
  224. class="label-input"
  225. label="版本"
  226. label-width="90px"
  227. prop="edition"
  228. >
  229. <el-input
  230. v-model="formDialog.edition"
  231. autocomplete="off"
  232. name="edition"
  233. />
  234. </el-form-item>
  235. <el-form-item
  236. class="label-input"
  237. label="出版社"
  238. label-width="90px"
  239. prop="publisher"
  240. >
  241. <el-input
  242. v-model="formDialog.publisher"
  243. autocomplete="off"
  244. name="publisher"
  245. />
  246. </el-form-item>
  247. <el-form-item
  248. class="label-input"
  249. label="出版编号"
  250. label-width="90px"
  251. prop="publish_number"
  252. >
  253. <el-input
  254. v-model="formDialog.publish_number"
  255. autocomplete="off"
  256. name="publish_number"
  257. />
  258. </el-form-item>
  259. <el-form-item
  260. class="label-input"
  261. label="丛书编号"
  262. label-width="90px"
  263. prop="series_code"
  264. >
  265. <el-input
  266. autocomplete="off"
  267. name="series_code"
  268. v-model="formDialog.series_code"
  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 label="教材描述" label-width="90px" prop="description">
  304. <el-input v-model="formDialog.description" type="textarea" />
  305. </el-form-item>
  306. <!-- <el-form-item label="发布状态" label-width="90px">
  307. <el-radio label="0" v-model="formDialog.publish_status">下架</el-radio>
  308. <el-radio label="1" v-model="formDialog.publish_status">上架</el-radio>
  309. </el-form-item>-->
  310. <el-form-item label="发布范围" label-width="90px" prop="publish_scope">
  311. <el-radio v-model="formDialog.publish_scope" :label="0"
  312. >机构内用户可见</el-radio
  313. >
  314. <el-radio v-model="formDialog.publish_scope" :label="1"
  315. >所有用户可见</el-radio
  316. >
  317. </el-form-item>
  318. <el-form-item label="主题颜色" label-width="90px" prop="theme_color">
  319. <el-radio v-model="formDialog.theme_color" label="red">红色</el-radio>
  320. <el-radio v-model="formDialog.theme_color" label="green"
  321. >绿色</el-radio
  322. >
  323. <el-radio v-model="formDialog.theme_color" label="brown"
  324. >棕色</el-radio
  325. >
  326. </el-form-item>
  327. <el-form-item label="教材图片" label-width="90px" prop="fileList">
  328. <el-upload
  329. :action="url"
  330. :file-list="fileList"
  331. :limit="1"
  332. :on-exceed="handleExceed"
  333. :on-preview="handlePreview"
  334. :on-remove="handleRemove"
  335. :on-success="handleSuccess"
  336. accept=".jpg, .jpeg, .png"
  337. class="upload-demo"
  338. list-type="picture"
  339. multiple
  340. style="width: 500px"
  341. >
  342. <el-button size="mini" type="success">点击上传</el-button>
  343. </el-upload>
  344. </el-form-item>
  345. </el-form>
  346. <div slot="footer" class="dialog-footer">
  347. <el-button @click="dialogFlag = false">取 消</el-button>
  348. <el-button :loading="loading" type="primary" @click="submitCourse"
  349. >确 定</el-button
  350. >
  351. </div>
  352. </el-dialog>
  353. </div>
  354. </template>
  355. <script>
  356. import { validNull, validPrice } from "@/utils/validate";
  357. import Header from "@/components/inputModules/common/Header";
  358. import Nav from "@/components/inputModules/common/Nav";
  359. import { getContent, getContentFile } from "@/api/ajax";
  360. import Cookies from "js-cookie";
  361. import { getToken } from "@/utils/auth";
  362. export default {
  363. name: "courselist",
  364. components: {
  365. Header,
  366. Nav,
  367. },
  368. data() {
  369. const validateNull = (rule, value, callback) => {
  370. if (!validNull(value)) {
  371. callback(new Error("请输入相应内容"));
  372. } else {
  373. callback();
  374. }
  375. };
  376. const validatePrice = (rule, value, callback) => {
  377. if (!validPrice(value)) {
  378. callback(new Error("请输入价格"));
  379. } else {
  380. callback();
  381. }
  382. };
  383. return {
  384. tableData: [], // 数据内容
  385. currentPage: 1, // 当前页码
  386. page_capacity: 10, // 每页条数
  387. courseTotal: 0, // 数据总条数
  388. searchInput: "", // 搜索内容
  389. form: {
  390. author: "",
  391. status: "",
  392. agency: "",
  393. name: "",
  394. name_english: "",
  395. edition: "",
  396. publisher: "",
  397. publish_number: "",
  398. series_code: "",
  399. publish_status: -1,
  400. },
  401. dialogFlag: false, // 新建教材弹出层
  402. agency: "",
  403. formDialog: {
  404. name: "",
  405. name_english: "",
  406. edition: "",
  407. description: "",
  408. author: "",
  409. price: null,
  410. org_id: "",
  411. org_name: "",
  412. publish_scope: 0,
  413. publish_number: "",
  414. series_code: "",
  415. picture_id: "",
  416. id: "",
  417. publisher: "",
  418. theme_color: "",
  419. type_id: "",
  420. },
  421. agencyList: [
  422. {
  423. id: "",
  424. name: "请选择",
  425. },
  426. ],
  427. agencyLists: [
  428. {
  429. id: "",
  430. name: "请选择",
  431. },
  432. ],
  433. publishStatus: {
  434. 0: "下架",
  435. 1: "上架",
  436. },
  437. publishScope: {
  438. 0: "机构内用户",
  439. 1: "所有用户",
  440. },
  441. fileList: [], // 上传图片数组
  442. pageIndex: 1,
  443. courseListRules: {
  444. // 填写规则
  445. name: [{ required: true, trigger: "blur", validator: validateNull }],
  446. author: [{ required: true, trigger: "blur", validator: validateNull }],
  447. edition: [{ required: true, trigger: "blur", validator: validateNull }],
  448. publisher: [
  449. { required: true, trigger: "blur", validator: validateNull },
  450. ],
  451. publish_number: [
  452. { required: true, trigger: "blur", validator: validateNull },
  453. ],
  454. type_id: [
  455. { required: true, message: "请选择教材类型", trigger: "change" },
  456. ],
  457. org_id: [{ required: true, message: "请选择机构", trigger: "change" }],
  458. price: [{ required: true, validator: validatePrice }],
  459. },
  460. loading: false,
  461. titleEdit: "新建教材",
  462. rowIndex: 0, // 记录编辑教材的index
  463. tableloading: true,
  464. selectLoading: false,
  465. noMore: false,
  466. statusList: [
  467. {
  468. label: "全部",
  469. value: -1,
  470. },
  471. {
  472. label: "上架",
  473. value: 1,
  474. },
  475. {
  476. label: "下架",
  477. value: 0,
  478. },
  479. ],
  480. myOrgList: [
  481. {
  482. org_id: "",
  483. org_name: "全部",
  484. },
  485. ],
  486. diaMyOrgList: [],
  487. typeList: [],
  488. };
  489. },
  490. mounted() {
  491. this.getList();
  492. this.getTypeList();
  493. this.getMyOrgList();
  494. this.getMyOrgListAgree();
  495. //this.createOptions(1);
  496. // this.$refs.select.$refs.scrollbar.$refs.wrap.addEventListener(
  497. // "scroll",
  498. // this.selectScroll
  499. // );
  500. },
  501. computed: {
  502. url() {
  503. let userInfor = getToken();
  504. let UserCode = "",
  505. UserType = "",
  506. SessionID = "";
  507. if (userInfor) {
  508. let user = JSON.parse(getToken());
  509. UserCode = user.user_code;
  510. UserType = user.user_type;
  511. SessionID = user.session_id;
  512. }
  513. return (
  514. process.env.VUE_APP_BASE_API +
  515. "/GCLSFileServer/WebFileUpload?UserCode=" +
  516. UserCode +
  517. "&UserType=" +
  518. UserType +
  519. "&SessionID=" +
  520. SessionID +
  521. "&SecurityLevel=Mid"
  522. );
  523. },
  524. },
  525. methods: {
  526. createOptions(len, start = 0) {
  527. //this.getAgencList();
  528. },
  529. selectScroll() {
  530. let e = this.$refs.select.$refs.scrollbar.$refs.wrap;
  531. if (this.noMore) return;
  532. let loadMore = e.scrollHeight - e.scrollTop <= e.clientHeight;
  533. if (loadMore) {
  534. this.loadMore();
  535. }
  536. },
  537. loadMore() {
  538. if (this.selectLoading) return;
  539. this.selectLoading = true;
  540. this.getAgencList();
  541. },
  542. // 切换每页条数
  543. handleSizeChange(val) {
  544. this.currentPage = 1;
  545. this.page_capacity = val;
  546. this.getList();
  547. },
  548. // 切换页码
  549. handleCurrentChange(val) {
  550. this.currentPage = val;
  551. this.getList();
  552. },
  553. // 回车搜索
  554. handleSearch() {
  555. console.log(this.searchInput);
  556. },
  557. // 点击查询按钮
  558. onSubmit() {
  559. this.currentPage = 1;
  560. this.getList();
  561. },
  562. handleClick(row) {
  563. sessionStorage.setItem("Bookdetail", JSON.stringify(row));
  564. this.$router.push("/input?bookId=" + row.id);
  565. },
  566. // 预览
  567. handleView(row) {
  568. sessionStorage.setItem("Bookdetail", JSON.stringify(row));
  569. this.$router.push("/courseview?bookId=" + row.id);
  570. },
  571. // 授权码
  572. handleDiscount(row) {
  573. this.$router.push("/discountCodeList?bookId=" + row.id);
  574. },
  575. // 新建教材
  576. handleAdd() {
  577. this.titleEdit = "新建教材";
  578. this.formDialog = {
  579. name: "",
  580. name_english: "",
  581. edition: "",
  582. description: "",
  583. author: "",
  584. price: null,
  585. org_id: "",
  586. org_name: "",
  587. publish_scope: 0,
  588. publish_number: "",
  589. series_code: "",
  590. picture_id: "",
  591. id: "",
  592. publisher: "",
  593. theme_color: "",
  594. type_id: "",
  595. };
  596. this.agency = "";
  597. this.fileList = [];
  598. this.dialogFlag = true;
  599. },
  600. // 新建教材提交
  601. submitCourse() {
  602. const _this = this;
  603. _this.$refs.formDialog.validate((valid) => {
  604. _this.formDialog.name = _this.formDialog.name.trim();
  605. _this.formDialog.author = _this.formDialog.author.trim();
  606. if (_this.formDialog.description !== "")
  607. _this.formDialog.description = _this.formDialog.description.trim();
  608. if (valid) {
  609. // if (
  610. // (!this.formDialog.price && this.formDialog.price != 0)
  611. // ) {
  612. // this.$message(
  613. // {
  614. // type: "warning",
  615. // message: "请填写价格!",
  616. // },
  617. // 2000
  618. // );
  619. // return false;
  620. // }
  621. // if (this.formDialog.org_id == "") {
  622. // this.$message(
  623. // {
  624. // type: "warning",
  625. // message: "请选择所属机构!",
  626. // },
  627. // 2000
  628. // );
  629. // return false;
  630. // }
  631. _this.loading = true;
  632. let MethodName;
  633. if (_this.formDialog.id) {
  634. MethodName = "book-book_manager-UpdateBook";
  635. } else {
  636. MethodName = "book-book_manager-AddBook";
  637. }
  638. this.formDialog.publish_status = 1;
  639. let data = JSON.parse(JSON.stringify(_this.formDialog));
  640. getContent(MethodName, data)
  641. .then((res) => {
  642. this.$message.success("操作成功");
  643. if (_this.formDialog.id) {
  644. this.$set(_this.tableData, this.rowIndex, data);
  645. } else {
  646. _this.currentPage = 1;
  647. _this.getList();
  648. _this.resetForm("formDialog");
  649. }
  650. _this.dialogFlag = false;
  651. this.loading = false;
  652. })
  653. .catch(() => {
  654. this.loading = false;
  655. });
  656. } else {
  657. this.loading = false;
  658. return false;
  659. }
  660. });
  661. },
  662. // 查询数据列表
  663. getList() {
  664. let MethodName = "book-book_manager-PageQueryBookList";
  665. let data = {
  666. name: this.form.name,
  667. page_capacity: this.page_capacity,
  668. cur_page: this.currentPage,
  669. org_id: this.form.agency,
  670. order_column: "create_time:desc",
  671. publish_status: this.form.publish_status,
  672. is_control_publish_scope: "false",
  673. };
  674. getContent(MethodName, data).then((res) => {
  675. let _this = this;
  676. _this.tableData = res.book_list;
  677. _this.courseTotal = res.total_count;
  678. _this.tableloading = false;
  679. });
  680. },
  681. // 机构列表
  682. getAgencList() {
  683. let MethodName = "org_manager-PageQueryOrgList";
  684. let data = {
  685. name: "",
  686. page_capacity: 50,
  687. cur_page: this.pageIndex,
  688. };
  689. let dataList = [];
  690. getContentFile(MethodName, data)
  691. .then((res) => {
  692. dataList = res.org_list;
  693. if (this.pageIndex === res.total_page) {
  694. // 获取到最后的值时,不再监听滚动条的动作,移除滚动事件
  695. this.$refs.select.$refs.scrollbar.$refs.wrap.removeEventListener(
  696. "scroll",
  697. this.selectScroll()
  698. );
  699. this.noMore = true;
  700. }
  701. this.pageIndex++;
  702. this.agencyList = this.agencyList.concat(dataList);
  703. this.agencyLists = this.agencyList;
  704. })
  705. .finally(() => (this.selectLoading = false));
  706. },
  707. //得到我的机构列表-org_manager-GetMyOrgList
  708. getMyOrgList() {
  709. let MethodName = "org_manager-GetMyOrgList";
  710. let data = {
  711. audited_status: -1,
  712. };
  713. console.log("MethodName");
  714. getContentFile(MethodName, data).then((res) => {
  715. if (res && res.org_list.length > 0) {
  716. this.myOrgList = this.myOrgList.concat(res.org_list);
  717. this.diaMyOrgList = res.org_list;
  718. }
  719. });
  720. },
  721. //得到我的机构列表-org_manager-GetMyOrgList--审核通过的
  722. getMyOrgListAgree() {
  723. let MethodName = "org_manager-GetMyOrgList";
  724. let data = {
  725. audited_status: 1,
  726. };
  727. console.log("MethodName");
  728. getContentFile(MethodName, data).then((res) => {
  729. if (res && res.org_list.length > 0) {
  730. this.diaMyOrgList = res.org_list;
  731. }
  732. });
  733. },
  734. // 处理发布状态
  735. handleStatus(row) {
  736. if (row) {
  737. return this.publishStatus[row.publish_status];
  738. }
  739. },
  740. // 处理发布范围
  741. handleScope(row) {
  742. if (row) {
  743. return this.publishScope[row.publish_scope];
  744. }
  745. },
  746. // 选择机构
  747. changeAgency(row) {
  748. for (let i = 0; i < this.diaMyOrgList.length; i++) {
  749. let item = this.diaMyOrgList[i];
  750. if (item.org_id === row) {
  751. this.formDialog.org_name = item.org_name;
  752. break;
  753. }
  754. }
  755. },
  756. // 教材类型列表
  757. getTypeList() {
  758. let MethodName = "dict_manager-GetBookTypeList";
  759. let data = {};
  760. getContentFile(MethodName, data).then((res) => {
  761. this.typeList = res.type_list;
  762. console.log(this.typeList);
  763. });
  764. },
  765. // 处理教材价格 最多两位小数
  766. inputPrice(e) {
  767. e = e.match(/^\d*(\.?\d{0,2})/g)[0] || "";
  768. this.formDialog.price = e;
  769. },
  770. // 处理教材价格 失去焦点保留两位小数
  771. blurPrice() {
  772. if (this.formDialog.price)
  773. this.formDialog.price = Number(this.formDialog.price).toFixed(2);
  774. },
  775. handleSuccess(response, file, fileList) {
  776. if (response.status == 1) {
  777. this.$message.success("上传成功");
  778. this.formDialog.picture_id = response.file_info_list[0].file_id;
  779. } else {
  780. this.fileList = [];
  781. this.$message.warning(response.msg);
  782. }
  783. },
  784. handleRemove(file, fileList) {
  785. this.fileList = fileList;
  786. this.formDialog.picture_id = "";
  787. },
  788. handlePreview(file) {
  789. console.log(file);
  790. },
  791. handleExceed(files, fileList) {
  792. this.$message.warning(
  793. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  794. files.length + fileList.length
  795. } 个文件`
  796. );
  797. },
  798. // 清空表单
  799. resetForm(formName) {
  800. this.$refs[formName].resetFields();
  801. this.formDialog.price = null;
  802. this.agency = "";
  803. this.fileList = [];
  804. this.formDialog.description = "";
  805. },
  806. // 编辑书籍信息
  807. handleEdit(row, index) {
  808. this.$nextTick(() => {
  809. if (this.$refs["formDialog"] !== undefined) {
  810. this.$refs["formDialog"].resetFields();
  811. }
  812. });
  813. this.rowIndex = index;
  814. this.titleEdit = "编辑教材";
  815. this.fileList = [];
  816. let MethodName = "book-book_manager-GetBook";
  817. let data = {
  818. id: row.id,
  819. };
  820. getContent(MethodName, data)
  821. .then((res) => {
  822. this.formDialog = {
  823. id: res.id,
  824. name: res.name,
  825. description: res.description,
  826. author: res.author,
  827. price: res.price.toFixed(2),
  828. org_id: res.org_id,
  829. org_name: res.org_name,
  830. publish_scope: res.publish_scope,
  831. picture_id: res.picture_id,
  832. name_english: res.name_english,
  833. publish_number: res.publish_number,
  834. series_code: res.series_code,
  835. publisher: res.publisher,
  836. edition: res.edition,
  837. theme_color: res.theme_color,
  838. type_id: res.type_id,
  839. };
  840. if (res.picture_url) {
  841. let obj = {
  842. name: "",
  843. url: res.picture_url,
  844. };
  845. this.fileList.push(obj);
  846. }
  847. this.agency = res.org_id;
  848. })
  849. .catch(() => {
  850. this.loading = false;
  851. });
  852. this.dialogFlag = true;
  853. // 循环select 有没有选中数据 没有插入
  854. },
  855. // 删除书籍
  856. handleDel(row) {
  857. if(row.publish_status==1){
  858. this.$message({
  859. type: "warning",
  860. message: "此教材处于上架状态不可以进行删除",
  861. });
  862. return false
  863. }
  864. this.$confirm("确定要删除此书籍吗?", "提示", {
  865. confirmButtonText: "确定",
  866. cancelButtonText: "取消",
  867. type: "warning",
  868. })
  869. .then(() => {
  870. let MethodName = "book-book_manager-DeleteBook";
  871. let data = {
  872. id: row.id,
  873. };
  874. getContent(MethodName, data)
  875. .then((res) => {
  876. this.currentPage = 1;
  877. this.getList();
  878. this.$message({
  879. type: "success",
  880. message: "删除成功!",
  881. });
  882. })
  883. .catch(() => {});
  884. })
  885. .catch(() => {});
  886. },
  887. // 上架
  888. handleUp(row, index) {
  889. let Mname = "book-book_manager-SetPublishStatusForBook";
  890. let updataData = JSON.parse(JSON.stringify(row));
  891. let data = {
  892. book_id: row.id,
  893. };
  894. if (row.publish_status == 0) {
  895. // 下架状态
  896. data.publish_status = 1;
  897. updataData.publish_status = 1;
  898. } else if (row.publish_status == 1) {
  899. data.publish_status = 0;
  900. updataData.publish_status = 0;
  901. }
  902. getContent(Mname, data).then((res) => {
  903. this.$message.success("操作成功");
  904. this.$set(this.tableData, index, updataData);
  905. });
  906. },
  907. // 关闭弹窗
  908. handleClose(done) {
  909. this.loading = false;
  910. this.formDialog.price = null;
  911. this.agency = "";
  912. this.fileList = [];
  913. this.formDialog.description = "";
  914. done();
  915. },
  916. },
  917. };
  918. </script>
  919. <style lang="scss" scoped>
  920. .container {
  921. width: 100%;
  922. background: #f5f5f5;
  923. .content {
  924. width: 100%;
  925. display: flex;
  926. justify-content: flex-start;
  927. align-items: flex-start;
  928. max-width: 1200px;
  929. margin: 0 auto;
  930. height: auto;
  931. .inner {
  932. width: 100%;
  933. margin: 0 auto;
  934. box-sizing: border-box;
  935. padding: 20px 0;
  936. position: relative;
  937. .btn-box {
  938. font-size: 0;
  939. position: absolute;
  940. right: 0;
  941. top: 40px;
  942. span {
  943. height: 36px;
  944. line-height: 36px;
  945. padding: 0 15px;
  946. display: flex;
  947. justify-content: center;
  948. align-items: center;
  949. background: #ff9900;
  950. border-radius: 4px;
  951. font-size: 14px;
  952. color: #ffffff;
  953. cursor: pointer;
  954. &:hover {
  955. opacity: 0.8;
  956. }
  957. }
  958. img {
  959. width: 20px;
  960. margin-right: 4px;
  961. }
  962. }
  963. .search-form {
  964. display: flex;
  965. justify-content: flex-start;
  966. align-items: center;
  967. flex-wrap: wrap;
  968. font-size: 0;
  969. margin-top: 20px;
  970. .el-cascader .el-input .el-input__inner {
  971. width: 240px;
  972. }
  973. }
  974. }
  975. }
  976. .el-dialog__body {
  977. padding-right: 20px;
  978. }
  979. .table-box {
  980. background: #fff;
  981. padding: 10px 32px 0 32px;
  982. border-radius: 4px;
  983. }
  984. }
  985. </style>
  986. <style lang="scss">
  987. .el-table th.is-leaf {
  988. border-color: #d5d5d5;
  989. }
  990. .el-table td {
  991. padding: 0.05rem 0;
  992. }
  993. .el-dialog {
  994. font-size: 0;
  995. }
  996. </style>