courseList.vue 27 KB

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