courseList.vue 28 KB

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