index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div class="manage-root organize-manage">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu
  6. class="manage-root-contain-left"
  7. :activeMenuIndex="activeMenuIndex"
  8. ></nav-menu>
  9. <div class="manage-root-contain-right personnel-manage-right">
  10. <breadcrumb
  11. :breadcrumbList="breadcrumbList"
  12. class="breadcrumb-box"
  13. ></breadcrumb>
  14. <div class="personal-inner">
  15. <div class="common-title-box">
  16. <h3>专辑管理</h3>
  17. <div class="btn-box">
  18. <el-button type="primary" size="small" @click="handleEdit()"
  19. >创建专辑</el-button
  20. >
  21. </div>
  22. </div>
  23. <div class="search-box">
  24. <div class="search-item">
  25. <label>搜索</label>
  26. <el-input
  27. placeholder="输入搜索内容"
  28. v-model="searchInput"
  29. maxlength="200"
  30. >
  31. <i
  32. slot="suffix"
  33. class="el-input__icon el-icon-search"
  34. @click="getList(1)"
  35. style="cursor: pointer"
  36. ></i>
  37. </el-input>
  38. </div>
  39. <div class="search-item">
  40. <label>状态</label>
  41. <el-select
  42. v-model="searchStatus"
  43. @change="getList(1)"
  44. placeholder="请选择"
  45. >
  46. <el-option
  47. v-for="item in checkStatusList"
  48. :key="item.value"
  49. :label="item.label"
  50. :value="item.value"
  51. >
  52. </el-option>
  53. </el-select>
  54. </div>
  55. <div class="search-item">
  56. <label>学段</label>
  57. <el-select
  58. v-model="searchStudy"
  59. @change="getList(1)"
  60. placeholder="请选择"
  61. >
  62. <el-option
  63. v-for="item in $studyTypeAll"
  64. :key="item.study_phase"
  65. :label="item.study_phase_name"
  66. :value="item.study_phase"
  67. >
  68. </el-option>
  69. </el-select>
  70. </div>
  71. </div>
  72. <el-table
  73. class="search-table"
  74. :data="tableData"
  75. style="width: 100%"
  76. @sort-change="handleSort"
  77. :default-sort="dataSort"
  78. :max-height="tableHeight"
  79. key="checked-table"
  80. v-loading="tableLoading"
  81. >
  82. <el-table-column
  83. type="index"
  84. label="#"
  85. sortable
  86. width="56"
  87. :index="(pageNumber - 1) * pageSize + 1"
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. prop="name"
  92. label="名称"
  93. sortable="custom"
  94. min-width="226"
  95. >
  96. </el-table-column>
  97. <el-table-column prop="study_phase" label="学段" width="72">
  98. <template slot-scope="scope">
  99. {{ formatterStudy(scope.row) }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column prop="goods_type" label="类型" width="72">
  103. <template slot-scope="scope">
  104. {{ typeList[scope.row.goods_type] }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="status" label="状态" width="104">
  108. <template slot-scope="scope">
  109. <div class="status-box">
  110. <span
  111. :style="{
  112. background: $checkStatusColorList[scope.row.status].bg,
  113. }"
  114. ></span>
  115. <b
  116. :style="{
  117. color: $checkStatusColorList[scope.row.status].color,
  118. }"
  119. >{{ $checkStatusColorList[scope.row.status].text }}</b
  120. >
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. prop="creator_name"
  126. label="创建人"
  127. width="120"
  128. sortable="custom"
  129. >
  130. </el-table-column>
  131. <el-table-column
  132. prop="create_time"
  133. label="创建时间"
  134. width="144"
  135. sortable="custom"
  136. >
  137. <template slot-scope="scope">
  138. {{
  139. scope.row.create_time
  140. ? scope.row.create_time.substring(0, 16)
  141. : "-"
  142. }}
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. prop="last_modifier_name"
  147. label="最近编辑"
  148. min-width="96"
  149. >
  150. </el-table-column>
  151. <el-table-column
  152. prop="last_modify_time"
  153. label="最近编辑时间"
  154. width="144"
  155. sortable="custom"
  156. >
  157. <template slot-scope="scope">
  158. {{
  159. scope.row.last_modify_time
  160. ? scope.row.last_modify_time.substring(0, 16)
  161. : "-"
  162. }}
  163. </template>
  164. </el-table-column>
  165. <el-table-column fixed="right" label="操作" width="180">
  166. <template slot-scope="scope">
  167. <el-button
  168. @click.native.prevent="handleEdit(scope.row)"
  169. type="text"
  170. size="small"
  171. class="primary-btn"
  172. >
  173. 编辑
  174. </el-button>
  175. <el-button
  176. @click.native.prevent="handleUp(scope.row, scope.$index)"
  177. type="text"
  178. size="small"
  179. class="red-btn"
  180. v-if="scope.row.status === 2"
  181. >
  182. 下架
  183. </el-button>
  184. <el-button
  185. @click.native.prevent="handleUp(scope.row, scope.$index)"
  186. type="text"
  187. size="small"
  188. class="primary-btn"
  189. v-else
  190. >
  191. 上架
  192. </el-button>
  193. <el-button
  194. @click.native.prevent="handleDelete(scope.row, scope.$index)"
  195. type="text"
  196. size="small"
  197. class="red-btn"
  198. >
  199. 删除
  200. </el-button>
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. <el-pagination
  205. background
  206. @size-change="
  207. (val) => handleSizeChange(val, 'pageSize', 'pageNumber')
  208. "
  209. @current-change="(val) => handleCurrentChange(val, 'pageNumber')"
  210. :current-page="pageNumber"
  211. :page-sizes="[10, 20, 30, 40]"
  212. :page-size="pageSize"
  213. layout="total, prev, pager, next, sizes, jumper"
  214. :total="total_count"
  215. >
  216. </el-pagination>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. </template>
  222. <script>
  223. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  224. //例如:import 《组件名称》from ‘《组件路径》';
  225. import Header from "../../../components/Header.vue";
  226. import NavMenu from "../../../components/NavMenu.vue";
  227. import Breadcrumb from "../../../components/Breadcrumb.vue";
  228. import { mapState } from "vuex";
  229. import { getLogin } from "@/api/ajax";
  230. export default {
  231. //import引入的组件需要注入到对象中才能使用
  232. components: { Header, NavMenu, Breadcrumb },
  233. props: {},
  234. data() {
  235. //这里存放数据
  236. return {
  237. activeMenuIndex: "album_manage",
  238. breadcrumbList: [
  239. {
  240. icon: "file-list-line",
  241. url: "",
  242. text: "",
  243. },
  244. {
  245. icon: "",
  246. url: "",
  247. notLink: true,
  248. text: "内容管理",
  249. },
  250. {
  251. icon: "",
  252. url: "",
  253. text: "专辑管理",
  254. },
  255. ],
  256. searchInput: "",
  257. searchStudy: -1,
  258. searchStatus: -1,
  259. studyList: [
  260. {
  261. value: "",
  262. label: "全部",
  263. },
  264. {
  265. value: "0",
  266. label: "初一",
  267. },
  268. {
  269. value: "1",
  270. label: "初二",
  271. },
  272. {
  273. value: "2",
  274. label: "初三",
  275. },
  276. {
  277. value: "3",
  278. label: "高一",
  279. },
  280. ],
  281. checkStatusList: [
  282. {
  283. value: -1,
  284. label: "全部",
  285. },
  286. {
  287. value: 1,
  288. label: "未上架",
  289. },
  290. {
  291. value: 2,
  292. label: "已上架",
  293. },
  294. ],
  295. typeList: {
  296. 0: "课程",
  297. 2: "报纸",
  298. 3: "精读",
  299. 4: "画刊",
  300. 5: "练习册",
  301. },
  302. tableData: [],
  303. pageSize: window.localStorage.getItem("pageSize")
  304. ? Number(window.localStorage.getItem("pageSize"))
  305. : 10,
  306. pageNumber: window.localStorage.getItem("pageNumber")
  307. ? Number(window.localStorage.getItem("pageNumber"))
  308. : 1,
  309. tableHeight: "", // 表格高度
  310. total_count: 0,
  311. dataSort: {},
  312. tableLoading: false,
  313. };
  314. },
  315. //计算属性 类似于data概念
  316. computed: {
  317. ...mapState(["$studyTypeAll", "$checkStatusColorList"]),
  318. },
  319. //监控data中数据变化
  320. watch: {},
  321. //方法集合
  322. methods: {
  323. handleSort(value) {
  324. let dataSort = {
  325. prop: value.prop,
  326. order: value.order,
  327. };
  328. this.dataSort = dataSort;
  329. this.getList();
  330. },
  331. // 处理学段
  332. formatterStudy(row) {
  333. let studyCn = "";
  334. let list = this.$studyTypeAll;
  335. if (row.study_phase) {
  336. for (let i = 0; i < list.length; i++) {
  337. if (row.study_phase === list[i].study_phase) {
  338. studyCn = list[i].study_phase_name;
  339. }
  340. }
  341. } else {
  342. studyCn = "未知";
  343. }
  344. return studyCn;
  345. },
  346. // 创建机构或者编辑信息
  347. handleEdit(row) {
  348. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  349. // 点击时记录页码和每页条数
  350. window.localStorage.setItem("pageSize", this.pageSize);
  351. window.localStorage.setItem("pageNumber", this.pageNumber);
  352. window.localStorage.removeItem("albumId");
  353. window.localStorage.removeItem("albumType");
  354. window.localStorage.removeItem("albumStudyPhase");
  355. this.$router.push({
  356. path: "/createAlbum",
  357. query: {
  358. id: row ? row.id : "",
  359. isCreate: !row ? "true" : "false",
  360. },
  361. });
  362. },
  363. // 停用 启用
  364. handleUp(row, index) {
  365. let Mname = "/ShopServer/Manager/AlbumManager/ShelveAlbum";
  366. let updataData = JSON.parse(JSON.stringify(row));
  367. let data = {
  368. id: row.id,
  369. };
  370. if (row.status === 2) {
  371. // 上架状态
  372. data.is_pass = "false";
  373. updataData.status = 1;
  374. } else {
  375. data.is_pass = "true";
  376. updataData.status = 2;
  377. }
  378. getLogin(Mname, data).then((res) => {
  379. this.$message.success("操作成功");
  380. this.getList();
  381. });
  382. },
  383. // 审核
  384. handleCheck(row, index) {
  385. let Mname = "/PaperServer/Manager/IssueManager/EditIssueStatus";
  386. let updataData = JSON.parse(JSON.stringify(row));
  387. let data = {
  388. id: row.id,
  389. };
  390. this.$confirm("审核", "提示", {
  391. confirmButtonText: "审核通过",
  392. cancelButtonText: "驳回",
  393. distinguishCancelAndClose: true,
  394. type: "warning",
  395. })
  396. .then(() => {
  397. data.iss_status = 1;
  398. updataData.iss_status = 1;
  399. getLogin(Mname, data).then((res) => {
  400. this.$message.success("操作成功");
  401. this.getList();
  402. });
  403. })
  404. .catch((action) => {
  405. if (action === "cancel") {
  406. data.iss_status = 3;
  407. updataData.iss_status = 3;
  408. getLogin(Mname, data).then((res) => {
  409. this.$message.success("操作成功");
  410. this.getList();
  411. });
  412. }
  413. });
  414. },
  415. // 删除
  416. handleDelete(row) {
  417. this.$confirm("确定删除吗?", "提示", {
  418. confirmButtonText: "确定",
  419. cancelButtonText: "取消",
  420. type: "warning",
  421. })
  422. .then(() => {
  423. let Mname = "/ShopServer/Manager/AlbumManager/DeleteAlbum";
  424. let data = {
  425. id: row.id,
  426. };
  427. getLogin(Mname, data).then((res) => {
  428. this.$message({
  429. type: "success",
  430. message: "删除成功!",
  431. });
  432. this.getList();
  433. });
  434. })
  435. .catch(() => {});
  436. },
  437. handleSizeChange(val, type, page) {
  438. this[type] = val;
  439. this[page] = 1;
  440. this.getList();
  441. },
  442. handleCurrentChange(val, type) {
  443. this[type] = val;
  444. this.getList();
  445. },
  446. //计算table高度(动态设置table高度)
  447. getTableHeight() {
  448. let tableH = 420; //距离页面下方的高度
  449. let tableHeightDetil = window.innerHeight - tableH;
  450. if (tableHeightDetil <= 300) {
  451. this.tableHeight = 300;
  452. } else {
  453. this.tableHeight = window.innerHeight - tableH;
  454. }
  455. },
  456. getList(val) {
  457. this.tableLoading = true;
  458. if (val) {
  459. this.pageNumber = val;
  460. }
  461. let MethodName = "/ShopServer/Manager/AlbumManager/PageQueryAlbumList";
  462. let order_column_list = [];
  463. if (this.dataSort != {}) {
  464. if (this.dataSort.order == "descending") {
  465. order_column_list.push({
  466. name: this.dataSort.prop,
  467. asc: false,
  468. });
  469. } else if (this.dataSort.order == "ascending") {
  470. order_column_list.push({
  471. name: this.dataSort.prop,
  472. asc: true,
  473. });
  474. } else {
  475. order_column_list = [
  476. {
  477. name: "update_time",
  478. asc: false,
  479. },
  480. ];
  481. }
  482. } else {
  483. order_column_list = [
  484. {
  485. name: "update_time",
  486. asc: false,
  487. },
  488. ];
  489. }
  490. let data = {
  491. search_content: this.searchInput.trim(),
  492. status: this.searchStatus,
  493. study_phase: this.searchStudy,
  494. page_capacity: this.pageSize,
  495. cur_page: this.pageNumber,
  496. order_bys: order_column_list,
  497. };
  498. getLogin(MethodName, data)
  499. .then((res) => {
  500. this.tableLoading = false;
  501. if (res.status === 1) {
  502. this.tableData = res.album_list;
  503. this.total_count = res.total_count;
  504. }
  505. })
  506. .catch(() => {
  507. this.tableLoading = false;
  508. });
  509. },
  510. },
  511. //生命周期 - 创建完成(可以访问当前this实例)
  512. created() {
  513. this.getTableHeight();
  514. this.getList();
  515. },
  516. //生命周期 - 挂载完成(可以访问DOM元素)
  517. mounted() {
  518. let _this = this;
  519. let input = document.querySelector("input");
  520. input.addEventListener("keyup", function (event) {
  521. // 判断是否按下回车键
  522. if (event.keyCode === 13) {
  523. // 回车键被按下,执行你想要的操作
  524. _this.getList(1);
  525. }
  526. });
  527. },
  528. //生命周期-创建之前
  529. beforeCreated() {},
  530. //生命周期-挂载之前
  531. beforeMount() {},
  532. //生命周期-更新之前
  533. beforUpdate() {},
  534. //生命周期-更新之后
  535. updated() {},
  536. //生命周期-销毁之前
  537. beforeDestory() {},
  538. //生命周期-销毁完成
  539. destoryed() {},
  540. //如果页面有keep-alive缓存功能,这个函数会触发
  541. activated() {},
  542. };
  543. </script>
  544. <style lang="scss" scoped>
  545. /* @import url(); 引入css类 */
  546. .tabs {
  547. display: flex;
  548. padding: 16px 0 0 0;
  549. a {
  550. font-size: 14px;
  551. line-height: 22px;
  552. color: #4e5969;
  553. border-radius: 100px;
  554. padding: 5px 16px;
  555. margin-right: 12px;
  556. &:hover {
  557. background: #f2f3f5;
  558. }
  559. &.active {
  560. background: #f2f3f5;
  561. font-weight: 500;
  562. color: #165dff;
  563. }
  564. }
  565. }
  566. </style>
  567. <style lang="scss">
  568. .organize-manage {
  569. .el-cascader {
  570. width: 160px;
  571. height: 32px;
  572. line-height: 32px;
  573. .el-input {
  574. width: 100%;
  575. height: 32px;
  576. }
  577. }
  578. }
  579. </style>