index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="bannerManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.bannerName"
  7. size="small"
  8. placeholder="请输入名称"
  9. class="item-width-200 "
  10. ></el-input>
  11. <el-select
  12. v-model="query.menuId"
  13. size="small"
  14. clearable
  15. class="item-width-200 ml10"
  16. placeholder="请选择栏目"
  17. >
  18. <el-option
  19. v-for="item in options"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value"
  23. >
  24. </el-option>
  25. </el-select>
  26. <el-select
  27. v-model="platformType"
  28. multiple
  29. size="small"
  30. clearable
  31. class="item-width-200 ml10"
  32. placeholder="请选择所属平台"
  33. >
  34. <el-option
  35. v-for="item in masterShopOptions"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. >
  40. </el-option>
  41. </el-select>
  42. <el-button
  43. class="ml10"
  44. type="primary"
  45. size="small"
  46. icon="el-icon-search"
  47. @click="handleSearch"
  48. >
  49. 搜索
  50. </el-button>
  51. </div>
  52. <el-button class="add-btn" type="primary" size="small" @click="handleAdd"
  53. >添加</el-button
  54. >
  55. </div>
  56. <el-table
  57. :data="tableData"
  58. tooltip-effect="dark"
  59. border
  60. v-loading="loading"
  61. style="width: 100%"
  62. >
  63. <el-table-column
  64. prop="bannerName"
  65. align="center"
  66. label="名称"
  67. show-overflow-tooltip
  68. >
  69. </el-table-column>
  70. <el-table-column
  71. prop="createTime"
  72. align="center"
  73. label="banner图"
  74. show-overflow-tooltip
  75. >
  76. <template slot-scope="scope">
  77. <img class="icon" :src="scope.row.bannerImg" alt="">
  78. </template>
  79. </el-table-column>
  80. <el-table-column
  81. prop="menuId"
  82. align="center"
  83. label="栏目"
  84. show-overflow-tooltip
  85. >
  86. <template slot-scope="scope">
  87. <span>{{scope.row.menuId |filterMenu(that)}}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column
  91. prop="accountChildType"
  92. align="center"
  93. label="所属平台"
  94. fit
  95. >
  96. <template slot-scope="scope">
  97. {{filterMasterName(scope.row.platformType )}}
  98. </template>
  99. </el-table-column>
  100. <el-table-column
  101. prop="jumpUrl"
  102. align="center"
  103. label="跳转链接"
  104. show-overflow-tooltip
  105. >
  106. <template slot-scope="scope">
  107. <span>{{scope.row.jumpUrl || '-'}}</span>
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. prop="sort"
  112. align="center"
  113. label="权重"
  114. show-overflow-tooltip
  115. >
  116. </el-table-column>
  117. <el-table-column prop="address" align="center" label="操作">
  118. <template slot-scope="scope">
  119. <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
  120. <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <div class="page-box">
  125. <el-pagination
  126. @size-change="handleSizeChange"
  127. @current-change="handleCurrentChange"
  128. background
  129. :current-page="query.currentPage"
  130. :page-sizes="[10, 20, 30, 40]"
  131. :page-size="query.pageSize"
  132. layout="total, sizes, prev, pager, next, jumper"
  133. :total="total"
  134. >
  135. </el-pagination>
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. import { debounce } from "@/utils/index";
  141. import {bannerList,delBanner,getMenuName } from '@/api/appConfig'
  142. export default {
  143. name: "bannerManage",
  144. data() {
  145. return {
  146. that:this,
  147. tableData: [],
  148. options: [],
  149. loading: false,
  150. platformType:"",
  151. query: {
  152. platformType:null,
  153. menuId: "",
  154. bannerName: "",
  155. currentPage: 1,
  156. pageSize: 10,
  157. },
  158. title: "",
  159. total: 0,
  160. };
  161. },
  162. watch: {
  163. platformType(val) {
  164. if(val.length){
  165. this.query.platformType = val.join(',')
  166. }else{
  167. this.query.platformType = null
  168. }
  169. }
  170. },
  171. filters: {
  172. filterMenu: function(value,that) {
  173. let msg
  174. that.options.map(item=>{
  175. if(item.value == value){
  176. msg = item.label
  177. }
  178. })
  179. return msg;
  180. }
  181. },
  182. methods: {
  183. handleSearch(){
  184. this.query.currentPage = 1
  185. this.bannerList();
  186. },
  187. handleEdit(row){
  188. sessionStorage.setItem('bannerItem',JSON.stringify(row))
  189. // this.$router.push('/operationManage/bannerManage/editBanner')
  190. this.$router.push({
  191. path:'/operationManage/bannerManage/addBanner',
  192. query:{
  193. title:'编辑banner',
  194. }
  195. })
  196. },
  197. handleAdd(){
  198. this.$router.push({
  199. path:'/operationManage/bannerManage/addBanner',
  200. })
  201. },
  202. // 删除
  203. handleDel(id) {
  204. this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
  205. confirmButtonText: '确定',
  206. cancelButtonText: '取消',
  207. type: 'warning'
  208. }).then(() => {
  209. delBanner({bannerId:id}).then(res=>{
  210. if(res.state == 'Success'){
  211. this.$notify({
  212. title: '成功',
  213. message: '操作成功',
  214. type: 'success'
  215. });
  216. this.bannerList()
  217. }
  218. })
  219. })
  220. },
  221. handleSizeChange(val) {
  222. this.query.currentPage = 1;
  223. this.query.pageSize = val;
  224. this.bannerList()
  225. },
  226. handleCurrentChange(val) {
  227. this.query.currentPage = val;
  228. this.bannerList()
  229. },
  230. bannerList(){
  231. this.loading = true
  232. bannerList(this.query).then(res=>{
  233. this.loading = false
  234. if(res.state == 'Success'){
  235. this.tableData = res.content.records
  236. this.total = res.content.total
  237. }
  238. })
  239. },
  240. // 获取分类列表
  241. getMenuName(){
  242. getMenuName().then(res=>{
  243. if(res.state == 'Success'){
  244. for (const key in res.content) {
  245. if (res.content.hasOwnProperty.call(res.content, key)) {
  246. this.options.push({
  247. label:res.content[key],
  248. value:key
  249. })
  250. }
  251. }
  252. }
  253. })
  254. }
  255. },
  256. created() {
  257. this.getMenuName()
  258. this.bannerList()
  259. },
  260. };
  261. </script>
  262. <style lang="scss" scoped>
  263. .bannerManage {
  264. .search{
  265. justify-content: space-between;
  266. }
  267. .icon{
  268. width: 120px;
  269. height: 80px;
  270. }
  271. }
  272. </style>