deepchart后台管理系统
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.

523 lines
12 KiB

3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
  1. <!-- @format -->
  2. <template>
  3. <div>
  4. <div class="page-container">
  5. <!-- 搜索区域 -->
  6. <div class="search-container" @keyup.enter="search">
  7. <div class="search-group">
  8. <div class="search-group1">
  9. <div class="search-item">
  10. <span class="form-label">账号</span>
  11. <el-input
  12. v-model="searchForm.dccode"
  13. placeholder="请输入账号"
  14. clearable
  15. style="height: 36px; width: 140px"
  16. />
  17. </div>
  18. <div class="search-item">
  19. <span class="form-label">姓名</span>
  20. <el-input
  21. v-model="searchForm.name"
  22. placeholder="请输入姓名"
  23. clearable
  24. style="height: 36px; width: 140px"
  25. />
  26. </div>
  27. <div class="search-item">
  28. <span class="form-label">归属</span>
  29. <el-input
  30. v-model="searchForm.inviter"
  31. placeholder="请输入归属账号"
  32. clearable
  33. style="height: 36px; width: 140px"
  34. />
  35. </div>
  36. </div>
  37. <div class="search-group2">
  38. <div class="search-item">
  39. <span class="form-label">兑换方式</span>
  40. <el-select
  41. v-model="searchForm.type"
  42. placeholder="请选择兑换方式"
  43. clearable
  44. style="height: 36px; width: 160px"
  45. >
  46. <el-option
  47. v-for="item in exchangeTypeList"
  48. :key="item.gold_id"
  49. :label="item.gold_type"
  50. :value="item.gold_id"
  51. />
  52. </el-select>
  53. </div>
  54. <div class="search-item">
  55. <span class="form-label">兑换日期</span>
  56. <el-date-picker
  57. v-model="searchDate"
  58. type="datetimerange"
  59. :shortcuts="shortcuts"
  60. range-separator="至"
  61. start-placeholder="开始时间"
  62. end-placeholder="结束时间"
  63. value-format="YYYY-MM-DD HH:mm:ss"
  64. style="height: 36px; width: 280px"
  65. />
  66. </div>
  67. </div>
  68. </div>
  69. <div class="button-group">
  70. <el-button type="primary" @click="search">搜索</el-button>
  71. <el-button type="success" @click="exportExcel"
  72. >导出Excel列表</el-button
  73. >
  74. <el-button color="#626aef" @click="exportList"
  75. >查看导出列表</el-button
  76. >
  77. <el-button type="primary" @click="resetBn">重置</el-button>
  78. </div>
  79. </div>
  80. <!-- 数据 -->
  81. <el-table
  82. :data="tableData"
  83. style="width: 100%; margin-top: 20px"
  84. header-cell-class-name="table-header"
  85. class="table-rounded"
  86. :loading="tableLoading"
  87. >
  88. <el-table-column
  89. prop="id"
  90. label="序号"
  91. align="center"
  92. header-align="center"
  93. width="80"
  94. >
  95. <template #default="scope">
  96. {{ (currentPage - 1) * pageSizeDM + scope.$index + 1 }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. prop="dccode"
  101. label="账号"
  102. align="center"
  103. header-align="center"
  104. />
  105. <el-table-column
  106. prop="name"
  107. label="姓名"
  108. align="center"
  109. header-align="center"
  110. />
  111. <el-table-column
  112. prop="inviter"
  113. label="归属"
  114. align="center"
  115. header-align="center"
  116. />
  117. <el-table-column
  118. prop="type"
  119. label="兑换方式"
  120. align="center"
  121. header-align="center"
  122. />
  123. <el-table-column
  124. prop="token_num"
  125. label="兑换数量"
  126. align="center"
  127. header-align="center"
  128. >
  129. <template #default="scope"> {{ scope.row.token_num }}Token </template>
  130. </el-table-column>
  131. <el-table-column
  132. prop="created_at"
  133. label="兑换时间"
  134. align="center"
  135. header-align="center"
  136. />
  137. </el-table>
  138. <!-- 分页组件 -->
  139. <div class="demo-pagination-block">
  140. <el-pagination
  141. @size-change="handleSizeChange"
  142. @current-change="handleCurrentChange"
  143. :current-page="currentPage"
  144. :page-sizes="[10, 20, 50, 100]"
  145. :page-size="pageSizeDM"
  146. layout="total, sizes, prev, pager, next, jumper"
  147. :total="datatotalDM"
  148. />
  149. </div>
  150. </div>
  151. </div>
  152. </template>
  153. <script setup>
  154. import { ref, reactive, onMounted, computed } from "vue";
  155. import { ElMessage } from "element-plus";
  156. import {
  157. getTokenExchangeRecordApi,
  158. exportTokenExchangeRecordApi,
  159. getDropDownListApi,
  160. } from "../../api/eventManagement";
  161. import router from "../../router";
  162. import { useRoute } from "vue-router";
  163. import { usePermissionStore } from "../../store/permission";
  164. const permissionStore = usePermissionStore();
  165. // 兑换方式列表
  166. const exchangeTypeList = ref([]);
  167. // token
  168. const token = localStorage.getItem("token");
  169. //permission
  170. const permission = ref("-1");
  171. // 获取路由实例
  172. const route = useRoute();
  173. // 组件挂载时:获取地区列表 + 初始化表格数据
  174. onMounted(async () => {
  175. permission.value = permissionStore.permission;
  176. fetchExchangeTypeList();
  177. getTableData();
  178. });
  179. const shortcuts = [
  180. {
  181. text: "最近7天",
  182. value: () => {
  183. const end = new Date();
  184. const start = new Date();
  185. start.setDate(start.getDate() - 7);
  186. return [start, end];
  187. },
  188. },
  189. {
  190. text: "最近1个月",
  191. value: () => {
  192. const end = new Date();
  193. const start = new Date();
  194. start.setMonth(start.getMonth() - 1);
  195. return [start, end];
  196. },
  197. },
  198. {
  199. text: "最近3个月",
  200. value: () => {
  201. const end = new Date();
  202. const start = new Date();
  203. start.setMonth(start.getMonth() - 3);
  204. return [start, end];
  205. },
  206. },
  207. ];
  208. // 搜索表单
  209. const searchForm = reactive({
  210. dccode: "",
  211. name: "",
  212. inviter: "",
  213. type: "",
  214. });
  215. const searchDate = ref([]);
  216. // 表格数据
  217. const tableData = ref([]);
  218. const tableLoading = ref(false);
  219. const datatotalDM = ref(0);
  220. // 分页参数
  221. const currentPage = ref(1);
  222. const pageSizeDM = ref(15);
  223. // 获取兑换方式列表
  224. const fetchExchangeTypeList = async () => {
  225. try {
  226. const data = await getDropDownListApi({
  227. token: token
  228. });
  229. exchangeTypeList.value = data;
  230. } catch (error) {
  231. console.error("获取兑换方式列表失败:", error);
  232. exchangeTypeList.value = [];
  233. }
  234. };
  235. // 获取表格数据
  236. const getTableData = async () => {
  237. try {
  238. tableLoading.value = true;
  239. const requestParams = {
  240. token: token,
  241. dccode: searchForm.dccode,
  242. name: searchForm.name,
  243. inviter: searchForm.inviter,
  244. type: Number(searchForm.type),
  245. start_at:
  246. searchDate.value && searchDate.value[0] ? searchDate.value[0] : "",
  247. end_at:
  248. searchDate.value && searchDate.value[1] ? searchDate.value[1] : "",
  249. page: currentPage.value,
  250. page_size: pageSizeDM.value,
  251. };
  252. const data = await getTokenExchangeRecordApi(requestParams);
  253. tableData.value = data.list;
  254. datatotalDM.value = data.total;
  255. } catch (error) {
  256. console.error("获取表格数据失败:", error);
  257. tableData.value = [];
  258. datatotalDM.value = 0;
  259. } finally {
  260. tableLoading.value = false;
  261. }
  262. };
  263. // 分页方法
  264. const handleSizeChange = (val) => {
  265. pageSizeDM.value = val;
  266. getTableData();
  267. console.log(`每页 ${val}`);
  268. };
  269. const handleCurrentChange = (val) => {
  270. currentPage.value = val;
  271. getTableData();
  272. console.log(`当前页: ${val}`);
  273. };
  274. // 搜索按钮
  275. const search = () => {
  276. currentPage.value = 1;
  277. getTableData();
  278. };
  279. // 重置按钮
  280. const resetBn = () => {
  281. searchForm.dccode = "";
  282. searchForm.name = "";
  283. searchForm.inviter = "";
  284. searchForm.type = "";
  285. searchDate.value = [];
  286. currentPage.value = 1;
  287. pageSizeDM.value = 15;
  288. getTableData();
  289. };
  290. // 导出Excel列表按钮
  291. const exportExcel = async () => {
  292. const requestParams = {
  293. token: token,
  294. dccode: searchForm.dccode,
  295. name: searchForm.name,
  296. inviter: searchForm.inviter,
  297. type: Number(searchForm.type),
  298. start_at:
  299. searchDate.value && searchDate.value[0] ? searchDate.value[0] : "",
  300. end_at:
  301. searchDate.value && searchDate.value[1] ? searchDate.value[1] : "",
  302. };
  303. const data = await exportTokenExchangeRecordApi(requestParams);
  304. if (data != "") {
  305. ElMessage.success("已导出");
  306. }
  307. };
  308. // 查看导出列表按钮
  309. const exportList = () => {
  310. router.push({
  311. path: "/userPermissions/export",
  312. });
  313. };
  314. // 格式化日期
  315. const formatDate = (date) => {
  316. if (!date) return "";
  317. const year = date.getFullYear();
  318. const month = String(date.getMonth() + 1).padStart(2, "0");
  319. const day = String(date.getDate()).padStart(2, "0");
  320. return `${year}/${month}/${day}`;
  321. };
  322. // 校验指标
  323. const checkmodel = () => {
  324. if (indicator_id.value.length === 0) {
  325. ElMessage.error("请至少选择一个指标");
  326. return false;
  327. }
  328. return true;
  329. };
  330. </script>
  331. <style scoped>
  332. /* 父容器 */
  333. .page-container {
  334. position: relative;
  335. min-height: 700px;
  336. }
  337. /* 搜索区域 */
  338. .search-container {
  339. display: flex;
  340. height: auto;
  341. flex-direction: row;
  342. flex-wrap: wrap;
  343. justify-content: space-between;
  344. align-items: center;
  345. gap: 12px;
  346. align-self: stretch;
  347. border-radius: 8px;
  348. background: #fefaf9;
  349. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
  350. padding: 15px;
  351. margin-bottom: 20px;
  352. }
  353. .search-group {
  354. display: flex;
  355. flex-direction: column;
  356. flex: 1;
  357. }
  358. .search-group1 {
  359. display: flex;
  360. align-items: center;
  361. gap: 15px;
  362. }
  363. .search-group2 {
  364. display: flex;
  365. margin-top: 15px;
  366. align-items: center;
  367. gap: 15px;
  368. }
  369. /* 单个搜索项 */
  370. .search-item {
  371. display: flex;
  372. align-items: center;
  373. gap: 6px;
  374. }
  375. /* 搜索标签文字 */
  376. .form-label {
  377. font-weight: 800 !important;
  378. font-size: 15px;
  379. text-align: left;
  380. color: #333;
  381. margin: 13px 0;
  382. font-family: "SimHei", "Heiti SC", "Microsoft YaHei", sans-serif !important;
  383. display: block;
  384. }
  385. /* 按钮组 */
  386. .button-group {
  387. display: flex;
  388. align-items: center;
  389. gap: 0px !important;
  390. margin-left: auto;
  391. flex-shrink: 0;
  392. }
  393. /* 按钮样式 */
  394. .button-group .el-button {
  395. padding: 6px 10px !important;
  396. font-size: 14px !important;
  397. height: 36px !important;
  398. }
  399. /* 表格样式 */
  400. .table-rounded {
  401. border-radius: 12px !important;
  402. overflow: hidden !important;
  403. border: 1px solid #e4e7ed !important;
  404. height: 650px;
  405. }
  406. .table-header {
  407. text-align: center !important;
  408. font-weight: 800 !important;
  409. font-size: 15px !important;
  410. color: #333 !important;
  411. background-color: #f8f9fa !important;
  412. }
  413. .el-table__cell {
  414. border-right: none !important;
  415. border-bottom: 1px solid #e4e7ed !important;
  416. }
  417. .el-table__header th.el-table__cell {
  418. border-right: none !important;
  419. border-bottom: 1px solid #e4e7ed !important;
  420. }
  421. .el-table__row:hover .el-table__cell {
  422. background-color: #fafafa !important;
  423. }
  424. /* 分页组件样式 */
  425. .demo-pagination-block {
  426. display: flex;
  427. width: 100%;
  428. height: 44px;
  429. padding: 0 16px;
  430. align-items: center;
  431. gap: 16px;
  432. position: absolute;
  433. margin-top: 10px;
  434. border-radius: 0 0 3px 3px;
  435. border-top: 1px solid #eaeaea;
  436. background: #fefbfb;
  437. box-sizing: border-box;
  438. }
  439. /* 添加/修改样式 */
  440. .form-item {
  441. margin-bottom: 24px;
  442. padding-left: 20px;
  443. padding-right: 20px;
  444. text-align: left;
  445. }
  446. /* 文本溢出省略样式(深度探索) */
  447. .ellipsis-text {
  448. display: inline-block;
  449. width: 100%;
  450. white-space: nowrap;
  451. overflow: hidden;
  452. text-overflow: ellipsis;
  453. vertical-align: middle;
  454. }
  455. :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
  456. background-color: #ff0000 !important;
  457. border-color: #ff0000 !important;
  458. }
  459. :deep(.el-checkbox__input.is-checked .el-checkbox__inner::after) {
  460. border-color: #fff !important;
  461. }
  462. :deep(.el-checkbox__input:hover .el-checkbox__inner) {
  463. border-color: #ff0000 !important;
  464. }
  465. :deep(.el-checkbox__input:focus .el-checkbox__inner) {
  466. box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.2) !important;
  467. }
  468. :deep(.el-checkbox__label) {
  469. color: #333 !important;
  470. font-size: 14px !important;
  471. }
  472. .label {
  473. color: #666;
  474. font-weight: 500;
  475. }
  476. .value {
  477. color: #333;
  478. }
  479. </style>