小说后台管理系统
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

319 wiersze
8.2 KiB

  1. <template>
  2. <div class="home-box">
  3. <el-main>
  4. <ActionButton @handle-refresh="refreshData" />
  5. <div class="mod-title">Banner模块</div>
  6. <div class="banner-box">
  7. <el-table ref="dataList" :data="banner">
  8. <el-table-column label="序号" type="index" width="80" align="center">
  9. </el-table-column>
  10. <el-table-column label="名称" align="center">
  11. <template slot-scope="scope">
  12. <el-input placeholder="请输入名称" v-model="scope.row.name"></el-input>
  13. </template>
  14. </el-table-column>
  15. <el-table-column label="书籍" align="center">
  16. <template slot-scope="scope">
  17. <el-button
  18. type="primary"
  19. icon="el-icon-edit"
  20. size="mini"
  21. @click="onBooksAdd(scope.$index)"
  22. ></el-button>
  23. <el-tag style="margin-left: 10px" v-if="scope.row.value">{{
  24. scope.row.value | onValueBooks
  25. }}</el-tag>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="状态" align="center" show-overflow-tooltip>
  29. <template slot-scope="scope">
  30. <el-switch
  31. v-model="scope.row.status"
  32. :active-value="1"
  33. :inactive-value="0"
  34. ></el-switch>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="操作" align="center">
  38. <template slot-scope="scope">
  39. <div class="flex-box">
  40. <CustomButton
  41. tip-text="删除"
  42. type="danger"
  43. is-svg
  44. icon="delete"
  45. @onClick="onDeleteBanner(scope.$index)"
  46. />
  47. </div>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <el-button
  52. style="margin: 15px 0 15px 30px"
  53. type="primary"
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="onPushBanner"
  57. >模块</el-button
  58. >
  59. </div>
  60. <div class="mod-title">书籍展示模块</div>
  61. <div class="banner-box">
  62. <el-table ref="dataList" :data="book_show">
  63. <el-table-column label="序号" type="index" width="80" align="center">
  64. </el-table-column>
  65. <el-table-column label="书籍标题" align="center">
  66. <template slot-scope="scope">
  67. <el-input placeholder="请输入名称" v-model="scope.row.name"></el-input>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="排列样式" align="center">
  71. <template slot-scope="scope">
  72. <el-select v-model="scope.row.value.style" placeholder="请选择">
  73. <el-option
  74. v-for="item in options"
  75. :key="item.value"
  76. :label="item.label"
  77. :value="item.value"
  78. >
  79. </el-option>
  80. </el-select>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="书籍分类" align="center">
  84. <template slot-scope="scope">
  85. <el-select
  86. v-model.number="scope.row.value.category_id"
  87. placeholder="请选择"
  88. >
  89. <el-option
  90. v-for="item in booksData"
  91. :key="item.value"
  92. :label="item.category_name"
  93. :value="item.id"
  94. >
  95. </el-option>
  96. </el-select>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="状态" align="center" show-overflow-tooltip>
  100. <template slot-scope="scope">
  101. <el-switch
  102. v-model="scope.row.status"
  103. :active-value="1"
  104. :inactive-value="0"
  105. ></el-switch>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" align="center">
  109. <template slot-scope="scope">
  110. <div class="flex-box">
  111. <CustomButton
  112. tip-text="删除"
  113. type="danger"
  114. is-svg
  115. icon="delete"
  116. @onClick="onDeleteBook(scope.$index)"
  117. />
  118. </div>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <div>
  123. <el-button
  124. style="margin: 15px 0 15px 30px"
  125. type="primary"
  126. icon="el-icon-plus"
  127. size="mini"
  128. @click="onPushBook"
  129. >模块</el-button
  130. >
  131. <el-tooltip content="最多添加8个模块" placement="top" effect="light">
  132. <i class="el-icon-question" style="color: #3da2ff; margin-left: 10px"></i>
  133. </el-tooltip>
  134. </div>
  135. </div>
  136. <el-footer height="10%">
  137. <el-button type="primary" style="margin-right: 27px" @click="submitForm"
  138. >保存</el-button
  139. >
  140. <el-button type="info" plain @click="resetForm('selectItem')">重置</el-button>
  141. </el-footer>
  142. </el-main>
  143. <BooksDialog
  144. :isBooksShow="isBooksShow"
  145. @onSelectItem="onSelectItem"
  146. @handle-close="isBooksShow = false"
  147. :booksData="booksData"
  148. ></BooksDialog>
  149. </div>
  150. </template>
  151. <script>
  152. import ActionButton from "@/components/ActionButton/index";
  153. import CustomButton from "@/components/CustomButton/index";
  154. import BooksDialog from "./books-dialog/books-dialog";
  155. import { getCategoryList } from "@/api/sort-management";
  156. import { getHomePage, homeSetting } from "@/api/home";
  157. getHomePage;
  158. export default {
  159. filters: {
  160. onValueBooks(data) {
  161. console.log(data);
  162. return data;
  163. },
  164. },
  165. components: {
  166. ActionButton,
  167. CustomButton,
  168. BooksDialog,
  169. },
  170. data() {
  171. return {
  172. selectIndex: null,
  173. isBooksShow: false,
  174. banner: [
  175. { name: "", value: "", status: "" },
  176. { name: "", value: "", status: "" },
  177. ],
  178. book_show: [
  179. {
  180. name: "",
  181. value: { style: "", category_id: "" },
  182. status: "",
  183. },
  184. {
  185. name: "",
  186. value: { style: "", category_id: "" },
  187. status: "",
  188. },
  189. ],
  190. booksData: [],
  191. options: [
  192. {
  193. value: "1",
  194. label: "竖向排列",
  195. },
  196. {
  197. value: "2",
  198. label: "横向排列",
  199. },
  200. ],
  201. };
  202. },
  203. mounted() {
  204. this.init();
  205. this.openCheckBooksDialog();
  206. },
  207. methods: {
  208. // 初始化
  209. init() {
  210. getHomePage().then((res) => {
  211. this.banner = res.data.banner;
  212. this.book_show = res.data.book_show;
  213. });
  214. },
  215. /**
  216. * 添加书籍
  217. */
  218. onBooksAdd(i) {
  219. this.isBooksShow = true;
  220. this.selectIndex = i;
  221. },
  222. onSelectItem(data) {
  223. this.isBooksShow = false;
  224. this.banner[this.selectIndex].value = data.book_name;
  225. },
  226. // 删除banner
  227. onDeleteBanner(i) {
  228. this.banner.splice(i,1)
  229. },
  230. onDeleteBook(i) {
  231. this.book_show.splice(i,1)
  232. },
  233. // 刷新
  234. refreshData() {
  235. console.log("刷新");
  236. },
  237. // 打开查看书籍弹窗
  238. openCheckBooksDialog() {
  239. this.booksData = [];
  240. getCategoryList({
  241. source_platform: "1",
  242. need_num: true,
  243. }).then((res) => {
  244. this.booksData = res.data; // 分类列表
  245. });
  246. },
  247. onPushBanner() {
  248. this.banner.push({
  249. name: "",
  250. value: "",
  251. status: "",
  252. });
  253. },
  254. onPushBook() {
  255. this.book_show.push({
  256. name: "",
  257. value: { style: "", category_id: "" },
  258. status: "",
  259. });
  260. },
  261. submitForm() {
  262. console.log(this.book_show);
  263. console.log(this.banner);
  264. homeSetting({
  265. book_show: this.book_show,
  266. banner: this.banner,
  267. }).then((res) => {
  268. this.init();
  269. this.$message.success("保存成功");
  270. });
  271. },
  272. resetForm(){
  273. this.init()
  274. }
  275. },
  276. };
  277. </script>
  278. <style lang="scss" scoped>
  279. .mod-title {
  280. color: #333333;
  281. font-size: 14px;
  282. font-weight: bold;
  283. }
  284. .banner-box {
  285. background: #ffffff;
  286. border-radius: 10px;
  287. border: 1px solid #e3e3e3;
  288. width: 100%;
  289. box-sizing: border-box;
  290. padding: 20px;
  291. margin: 12px 0 20px;
  292. }
  293. </style>