index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="bannerManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-select
  6. v-model="query.advertsType"
  7. size="small"
  8. clearable
  9. class="item-width-200"
  10. placeholder="请选择广告类型"
  11. >
  12. <el-option
  13. v-for="item in options"
  14. :key="item.value"
  15. :label="item.label"
  16. :value="item.value"
  17. >
  18. </el-option>
  19. </el-select>
  20. <el-button
  21. class="ml10"
  22. type="primary"
  23. size="small"
  24. icon="el-icon-search"
  25. @click="handleSearch"
  26. >
  27. 搜索
  28. </el-button>
  29. </div>
  30. <el-button class="add-btn" type="primary" size="small" @click="handleAdd"
  31. >添加</el-button
  32. >
  33. </div>
  34. <el-table
  35. :data="tableData"
  36. tooltip-effect="dark"
  37. border
  38. v-loading="loading"
  39. style="width: 100%"
  40. >
  41. <el-table-column
  42. prop="advertsName"
  43. align="center"
  44. label="名称"
  45. show-overflow-tooltip
  46. >
  47. </el-table-column>
  48. <el-table-column
  49. prop="createTime"
  50. align="center"
  51. label="广告图"
  52. show-overflow-tooltip
  53. >
  54. <template slot-scope="scope">
  55. <img class="icon" :src="scope.row.advertsImg" alt="">
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. align="center"
  60. label="小程序"
  61. show-overflow-tooltip
  62. >
  63. <template slot-scope="scope">
  64. <span>{{scope.row.belongType ==2?'慧研学':'贵大'}}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. prop="jumpUrl"
  69. align="center"
  70. label="跳转链接"
  71. show-overflow-tooltip
  72. >
  73. <template slot-scope="scope">
  74. <span>{{scope.row.jumpUrl || '-'}}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. prop="sort"
  79. align="center"
  80. label="权重"
  81. show-overflow-tooltip
  82. >
  83. </el-table-column>
  84. <el-table-column
  85. prop="sort"
  86. align="center"
  87. label="状态"
  88. show-overflow-tooltip
  89. >
  90. <template slot-scope="scope">
  91. <span>{{scope.row.status == 1?'显示':'隐藏'}}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="address" align="center" label="操作">
  95. <template slot-scope="scope">
  96. <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
  97. <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <div class="page-box">
  102. <el-pagination
  103. @size-change="handleSizeChange"
  104. @current-change="handleCurrentChange"
  105. background
  106. :current-page="query.currentPage"
  107. :page-sizes="[10, 20, 30, 40]"
  108. :page-size="query.pageSize"
  109. layout="total, sizes, prev, pager, next, jumper"
  110. :total="total"
  111. >
  112. </el-pagination>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import { debounce } from "@/utils/index";
  118. import {advList,delAdv} from '@/api/appConfig'
  119. export default {
  120. name: "bannerManage",
  121. data() {
  122. return {
  123. tableData: [],
  124. options:[
  125. {
  126. label:'首页banner',
  127. value:1
  128. },
  129. {
  130. label:'首页广告位',
  131. value:2
  132. }
  133. ],
  134. loading: false,
  135. query: {
  136. advertsType:'',
  137. currentPage: 1,
  138. pageSize: 10,
  139. },
  140. title: "",
  141. total: 0,
  142. };
  143. },
  144. // watch: {
  145. // query: {
  146. // handler: debounce(function (val) {
  147. // this.advList()
  148. // }),
  149. // deep: true,
  150. // },
  151. // },
  152. methods: {
  153. handleSearch(){
  154. this.query.currentPage = 1
  155. this.advList();
  156. },
  157. handleEdit(row){
  158. sessionStorage.setItem('advItem',JSON.stringify(row))
  159. this.$router.push({
  160. path:'/operationManage/advertisingManage/addAdv',
  161. query:{
  162. mode:'edit',
  163. title:'编辑广告位'
  164. }
  165. })
  166. },
  167. handleAdd(){
  168. this.$router.push('/operationManage/advertisingManage/addAdv')
  169. },
  170. // 删除
  171. handleDel(id) {
  172. this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
  173. confirmButtonText: '确定',
  174. cancelButtonText: '取消',
  175. type: 'warning'
  176. }).then(() => {
  177. delAdv({id}).then(res=>{
  178. if(res.state == 'Success'){
  179. this.$notify({
  180. title: '成功',
  181. message: '操作成功',
  182. type: 'success'
  183. });
  184. this.advList()
  185. }
  186. })
  187. })
  188. },
  189. handleSizeChange(val) {
  190. this.query.currentPage = 1;
  191. this.query.pageSize = val;
  192. this.advList()
  193. },
  194. handleCurrentChange(val) {
  195. this.query.currentPage = val;
  196. this.advList()
  197. },
  198. advList(){
  199. this.loading = true
  200. advList(this.query).then(res=>{
  201. this.loading = false
  202. if(res.state == 'Success'){
  203. this.tableData = res.content.records
  204. this.total = res.content.total
  205. }
  206. })
  207. },
  208. },
  209. created() {
  210. this.advList()
  211. },
  212. };
  213. </script>
  214. <style lang="scss" scoped>
  215. .bannerManage {
  216. .search{
  217. justify-content: space-between;
  218. }
  219. .icon{
  220. width: 120px;
  221. height: 80px;
  222. }
  223. }
  224. </style>