exclusive-img.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="app-container">
  3. <!-- 顶部操作区域 -->
  4. <div class="filter-container" style="padding-bottom: 0;">
  5. <div class="filter-control">
  6. <span>网站状态:</span>
  7. <el-select v-model="listQuery.status" style="width: 120px" clearable @change="getList">
  8. <el-option value="" label="请选择" />
  9. <el-option :value="0" label="已启用" />
  10. <el-option :value="1" label="已停用" />
  11. </el-select>
  12. </div>
  13. <div class="filter-control">
  14. <span>小程序状态:</span>
  15. <el-select v-model="listQuery.status" style="width: 120px" clearable @change="getList">
  16. <el-option value="" label="请选择" />
  17. <el-option :value="0" label="已启用" />
  18. <el-option :value="1" label="已停用" />
  19. </el-select>
  20. </div>
  21. <div class="filter-control">
  22. <el-button type="primary" @click="getList"> 查询 </el-button>
  23. <el-button type="primary" @click="handleoOerate('add')"> 添加专属广告图 </el-button>
  24. </div>
  25. </div>
  26. <!-- 列表 -->
  27. <el-table v-loading="isLoading" :data="list" border style="width: 100%" height="500">
  28. <el-table-column prop="title" label="轮播标题" align="center" width="200" />
  29. <el-table-column prop="image" label="网站广告图" align="center">
  30. <template slot-scope="{ row }">
  31. <img :src="row.image" alt="" style="width: 132px; height: 60px;" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="crmImage" label="小程序广告图" align="center">
  35. <template slot-scope="{ row }">
  36. <img v-if="row.crmImage" :src="row.crmImage" alt="" style="width: 132px; height: 60px;" />
  37. <span v-else>--</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="wwwEnabledStatus" label="网站状态" align="center" width="150">
  41. <template slot-scope="{ row }">
  42. <el-tag v-if="row.wwwEnabledStatus === 1" type="success" size="small">已启用</el-tag>
  43. <el-tag v-else type="danger" size="small">已停用</el-tag>
  44. <el-button v-if="row.wwwEnabledStatus === 1" type="primary" size="mini" @click="handleShangeStatus(row.id, row.wwwEnabledStatus, 0)">
  45. 停用
  46. </el-button>
  47. <el-button v-else type="primary" size="mini" @click="handleShangeStatus(row.id, row.wwwEnabledStatus, 0)">
  48. 启用
  49. </el-button>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="crmEnabledStatus" label="小程序状态" align="center" width="150">
  53. <template slot-scope="{ row }">
  54. <el-tag v-if="row.crmEnabledStatus === 1" type="success" size="small">已启用</el-tag>
  55. <el-tag v-else type="danger" size="small">已停用</el-tag>
  56. <el-button v-if="row.crmEnabledStatus === 1" type="primary" size="mini" @click="handleShangeStatus(row.id, row.crmEnabledStatus, 1)">
  57. 停用
  58. </el-button>
  59. <el-button v-else type="primary" size="mini" @click="handleShangeStatus(row.id, row.crmEnabledStatus, 1)">
  60. 启用
  61. </el-button>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="操作" align="center" width="220">
  65. <template slot-scope="{ row }">
  66. <el-button type="primary" size="mini" style="margin: 2px" @click="handleoOerate('edit', row)">
  67. 编辑
  68. </el-button>
  69. <el-button type="danger" size="mini" style="margin: 2px" @click="handleDelete(row)"> 删除 </el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <!-- 页码 -->
  74. <pagination
  75. :total="total"
  76. :page-sizes="[20]"
  77. :page-size="20"
  78. :page.sync="listQuery.pageNum"
  79. :limit.sync="listQuery.pageSize"
  80. @pagination="getTopAdvertisement"
  81. />
  82. </div>
  83. </template>
  84. <script>
  85. import { getTopAdvertisement, topAdvertisementDel, updateTopStatus } from '@/api/activity/home/home'
  86. export default {
  87. name: 'ExclusiveImg',
  88. filters: {},
  89. data() {
  90. return {
  91. isLoading: true,
  92. listQuery: {
  93. pageNum: 1,
  94. pageSize: 10
  95. },
  96. list: [],
  97. total: 0,
  98. timesValue: [],
  99. logoForm: {
  100. id: '',
  101. title: '',
  102. logo: ''
  103. },
  104. rules: {
  105. title: [{ required: true, message: '请输入广告图标题', trigger: 'blur' }],
  106. status: [{ required: true, message: '请设置统计状态', trigger: 'blur' }],
  107. logo: [{ required: true, message: '请上传弹窗图片', trigger: 'blur' }]
  108. }
  109. }
  110. },
  111. computed: {
  112. getToken() {
  113. return {
  114. token: this.$store.getters.token
  115. }
  116. },
  117. actionUrl() {
  118. return process.env.VUE_APP_BASE_API + '/formData/MultiPictareaddData'
  119. }
  120. },
  121. watch: {
  122. timesValue: {
  123. handler() {
  124. this.getList()
  125. },
  126. immediate: true
  127. }
  128. },
  129. created() {
  130. this.getList()
  131. },
  132. mounted() {},
  133. methods: {
  134. // 获取专属广告图列表
  135. getList() {
  136. this.listQuery.pageNum = 1
  137. this.list = []
  138. this.getTopAdvertisement()
  139. },
  140. // 获取专属广告图列表
  141. async getTopAdvertisement() {
  142. try {
  143. this.isLoading = true
  144. const res = await getTopAdvertisement(this.listQuery)
  145. this.list = res.data.results
  146. this.total = res.data.totalRecord
  147. this.isLoading = false
  148. } catch (error) {
  149. console.log(error)
  150. }
  151. },
  152. // 添加专属广告图
  153. handleoOerate(type, row) {
  154. if (type === 'add') {
  155. this.$router.push({
  156. path: '/operate/zones/exclusive-img-edit',
  157. query: { type: type }
  158. })
  159. } else {
  160. this.$router.push({
  161. path: '/operate/zones/exclusive-img-edit',
  162. query: { id: row.id, type: type }
  163. })
  164. }
  165. },
  166. // 操作启用停用广告图
  167. handleShangeStatus(id, status, type) {
  168. let confirmTxt = ''
  169. let paramsStatus
  170. if (status === 1) {
  171. confirmTxt = '确定停用该广告图?'
  172. paramsStatus = 0
  173. } else {
  174. confirmTxt = '确定启用该广告图?'
  175. paramsStatus = 1
  176. }
  177. this.$confirm(confirmTxt)
  178. .then((_) => {
  179. this.updateTopStatus(id, paramsStatus, type)
  180. })
  181. .catch(() => {
  182. this.$notify.info({ title: '用户取消操作~', message: '' })
  183. })
  184. },
  185. // 停用启用广告图
  186. async updateTopStatus(id, paramsStatus, type) {
  187. try {
  188. await updateTopStatus({ id: id, status: paramsStatus, type: type })
  189. this.$notify.success({ title: '更新成功~', message: '' })
  190. this.getList()
  191. } catch (error) {
  192. console.log('error', error)
  193. }
  194. },
  195. // 操作删除广告图
  196. async handleDelete(row) {
  197. try {
  198. await this.$confirm('确定删除该广告图吗?', {
  199. confirmButtonText: '确定',
  200. cancelButtonText: '取消',
  201. type: 'warning'
  202. })
  203. this.topAdvertisementDel(row)
  204. } catch (error) {
  205. this.$notify.info('用户取消操作~')
  206. }
  207. },
  208. // 调用删除广告图
  209. async topAdvertisementDel(row) {
  210. try {
  211. await topAdvertisementDel({ id: row.id })
  212. this.$notify.success({ title: '删除成功~', message: '' })
  213. this.getList()
  214. } catch (error) {
  215. console.log(error)
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style>
  222. </style>