You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

337 lines
8.6 KiB

3 months ago
  1. <template>
  2. <div class="page-container">
  3. <!-- 顶栏容器 -->
  4. <div class="top-bar">
  5. <span>详情</span>
  6. </div>
  7. <!-- 主体容器 -->
  8. <div class="main-container">
  9. <!-- 侧边栏容器 -->
  10. <div class="sidebar">
  11. <el-menu
  12. default-active="1"
  13. class="sidebar-menu"
  14. background-color="#f5f7fa"
  15. text-color="#333"
  16. active-text-color="#1890ff"
  17. >
  18. <el-menu-item index="1">
  19. <i class="el-icon-document"></i>
  20. <span slot="title">落地页管理</span>
  21. </el-menu-item>
  22. </el-menu>
  23. </div>
  24. <!-- 主要区域容器详情页内容 -->
  25. <div class="content-area">
  26. <div class="content-header">
  27. <el-button type="default" plain @click="goBack">返回上一级页面</el-button>
  28. </div>
  29. <!-- 筛选区域 -->
  30. <div class="filter-section">
  31. <el-form inline :model="filterForm" class="filter-form">
  32. <el-form-item label="打开网页时间">
  33. <el-date-picker
  34. v-model="filterForm.startTime"
  35. type="datetime"
  36. placeholder="请选择开始时间"
  37. style="width: 180px;"
  38. />
  39. <span class="time-separator"></span>
  40. <el-date-picker
  41. v-model="filterForm.endTime"
  42. type="datetime"
  43. placeholder="请选择结束时间"
  44. style="width: 180px;"
  45. />
  46. </el-form-item>
  47. <el-form-item label="收下状态">
  48. <el-select v-model="filterForm.status" placeholder="请选择状态" style="width: 150px;">
  49. <el-option label="是" value="1"></el-option>
  50. <el-option label="否" value="0"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button type="primary" @click="handleQuery">查询</el-button>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button type="primary" plain @click="handleExport">导出</el-button>
  58. </el-form-item>
  59. </el-form>
  60. </div>
  61. <!-- 数据表格 -->
  62. <el-table :data="tableData" stripe v-loading="loading" style="width: 100%; margin-bottom: 20px; border-top: 1px solid #e8e8e8;">
  63. <el-table-column
  64. type="index"
  65. label="序号"
  66. width="80"
  67. align="center"
  68. ></el-table-column>
  69. <el-table-column
  70. prop="userInfo"
  71. label="用户信息"
  72. min-width="180"
  73. align="center"
  74. ></el-table-column>
  75. <el-table-column
  76. prop="openTime"
  77. label="打开网页时间"
  78. min-width="180"
  79. align="center"
  80. ></el-table-column>
  81. <el-table-column
  82. label="收下状态"
  83. min-width="120"
  84. align="center"
  85. >
  86. <template v-slot:default="scope">
  87. {{ scope.row.status === 1 ? '是' : '否' }}
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <!-- 分页区域 -->
  92. <div class="pagination-container">
  93. <el-pagination
  94. @size-change="handleSizeChange"
  95. @current-change="handleCurrentChange"
  96. :current-page="currentPage"
  97. :page-sizes="[20, 50, 100]"
  98. :page-size="pageSize"
  99. layout="total, sizes, prev, pager, next, jumper"
  100. :total="totalCount"
  101. ></el-pagination>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import { getLandingListApi, exportLandingDetailApi } from '../../api/member.js';
  109. import { ElMessage } from 'element-plus';
  110. export default {
  111. name: 'LandingDetail',
  112. data() {
  113. return {
  114. // 活动详情数据
  115. detailData: '详情',
  116. // 筛选表单数据
  117. filterForm: {
  118. startTime: '',
  119. endTime: '',
  120. status: ''
  121. },
  122. // 表格数据
  123. tableData: [
  124. {
  125. userInfo: '张三(13800138000)',
  126. openTime: '2025-10-20 09:15:30',
  127. status: 1 // 对应“是”
  128. },
  129. {
  130. userInfo: '李四(13900139000)',
  131. openTime: '2025-10-20 10:22:15',
  132. status: 0 // 对应“否”
  133. },
  134. {
  135. userInfo: '王五(13700137000)',
  136. openTime: '2025-10-20 14:05:40',
  137. status: 1 // 对应“是”
  138. },
  139. {
  140. userInfo: '赵六(13600136000)',
  141. openTime: '2025-10-21 08:40:22',
  142. status: 0 // 对应“否”
  143. },
  144. {
  145. userInfo: '孙七(13500135000)',
  146. openTime: '2025-10-21 11:30:10',
  147. status: 1 // 对应“是”
  148. },
  149. ],
  150. // 分页参数
  151. currentPage: 1,
  152. pageSize: 20,
  153. totalCount: 0,
  154. // 加载状态
  155. loading: false
  156. }
  157. },
  158. mounted() {
  159. // 获取路由参数中的活动ID
  160. const activityId = this.$route.params.id;
  161. if (activityId) {
  162. // 调用接口获取活动详情及相关数据
  163. this.getActivityDetail(activityId);
  164. } else {
  165. ElMessage.error('未获取到活动ID,无法加载详情');
  166. }
  167. },
  168. methods: {
  169. // 返回上一级页面
  170. goBack() {
  171. this.$router.back();
  172. },
  173. // 获取活动详情及表格数据
  174. async getActivityDetail(id) {
  175. this.loading = true;
  176. try {
  177. const res = await getLandingListApi({
  178. id: id, // 活动ID
  179. page: this.currentPage,
  180. pageSize: this.pageSize,
  181. ...this.filterForm
  182. });
  183. if (res.code === 200) {
  184. this.tableData = res.data.list;
  185. this.totalCount = res.data.total;
  186. } else {
  187. ElMessage.error('获取活动详情失败');
  188. }
  189. } catch (error) {
  190. ElMessage.error('网络异常,无法加载数据');
  191. } finally {
  192. this.loading = false;
  193. }
  194. },
  195. // 执行查询操作
  196. handleQuery() {
  197. this.currentPage = 1;
  198. this.getActivityDetail(this.$route.params.id);
  199. },
  200. // 执行导出操作
  201. handleExport() {
  202. this.loading = true;
  203. try {
  204. // 调用导出接口(携带活动ID和筛选条件)
  205. exportLandingDetailApi({
  206. id: this.$route.params.id,
  207. ...this.filterForm
  208. }).then(res => {
  209. if (res.code === 200) {
  210. ElMessage.success('导出成功');
  211. // 处理文件下载逻辑(如创建a标签下载)
  212. const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
  213. const url = URL.createObjectURL(blob);
  214. const a = document.createElement('a');
  215. a.href = url;
  216. a.download = `${this.detailData?.name || '活动数据'}.xlsx`;
  217. a.click();
  218. URL.revokeObjectURL(url);
  219. } else {
  220. ElMessage.error(res.msg || '导出失败');
  221. }
  222. });
  223. } catch (error) {
  224. ElMessage.error('导出失败,请重试');
  225. } finally {
  226. this.loading = false;
  227. }
  228. },
  229. // 分页条数变更
  230. handleSizeChange(val) {
  231. this.pageSize = val;
  232. this.currentPage = 1;
  233. this.getActivityDetail(this.$route.params.id);
  234. },
  235. // 分页页码变更
  236. handleCurrentChange(val) {
  237. this.currentPage = val;
  238. this.getActivityDetail(this.$route.params.id);
  239. }
  240. }
  241. }
  242. </script>
  243. <style scoped>
  244. .activity-title {
  245. margin: 0 0 0 20px;
  246. font-size: 18px;
  247. color: #333;
  248. font-weight: 500;
  249. }
  250. .content-header {
  251. display: flex;
  252. justify-content: flex-end;
  253. margin-bottom: 15px;
  254. padding-bottom: 10px;
  255. border-bottom: 1px solid #e8e8e8;
  256. }
  257. .page-container {
  258. width: 100%;
  259. height: 100vh;
  260. overflow: hidden;
  261. display: flex;
  262. flex-direction: column;
  263. }
  264. .top-bar {
  265. height: 60px;
  266. background-color: #fff;
  267. color: #333;
  268. padding: 0 20px;
  269. display: flex;
  270. align-items: center;
  271. font-size: 18px;
  272. font-weight: 600;
  273. border-bottom: 1px solid #eee;
  274. }
  275. .main-container {
  276. display: flex;
  277. flex: 1;
  278. overflow: hidden;
  279. }
  280. .sidebar {
  281. width: 220px;
  282. background-color: #f5f7fa;
  283. border-right: 1px solid #e8e8e8;
  284. overflow-y: auto;
  285. }
  286. .sidebar-menu {
  287. border-right: none;
  288. height: 100%;
  289. }
  290. .content-area {
  291. flex: 1;
  292. padding: 20px;
  293. overflow-y: auto;
  294. background-color: #fff;
  295. }
  296. .filter-section {
  297. margin-bottom: 20px;
  298. }
  299. .filter-form {
  300. display: flex;
  301. align-items: center;
  302. flex-wrap: wrap;
  303. }
  304. .time-separator {
  305. margin: 0 10px;
  306. }
  307. .pagination-container {
  308. display: flex;
  309. justify-content: flex-end;
  310. align-items: center;
  311. margin-top: 10px;
  312. }
  313. </style>