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.

800 lines
24 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <!-- 支付凭证 -->
  2. <template>
  3. <el-row>
  4. <el-col>
  5. <el-card style="margin-bottom: 20px;margin-top:10px">
  6. <el-row style="margin-bottom: 5px">
  7. <el-col :span="6">
  8. <el-text size="large">精网号</el-text>
  9. <el-input v-model="rechargeAudit.jwcode" placeholder="请输入精网号" style="width: 240px" clearable/>
  10. </el-col>
  11. <el-col :span="6">
  12. <el-text size="large">活动名称</el-text>
  13. <el-select v-model="rechargeAudit.activity" placeholder="请选择活动名称" style="width: 240px" clearable>
  14. <el-option v-for="item in activity" :key="item" :label="item" :value="item"/>
  15. </el-select>
  16. </el-col>
  17. <el-col :span="6">
  18. <el-text size="large">支付方式</el-text>
  19. <el-select v-model="rechargeAudit.payModel" placeholder="请选择支付方式" style="width: 240px" clearable>
  20. <el-option v-for="item in payModel" :key="item.value" :label="item.label" :value="item.value"/>
  21. </el-select>
  22. </el-col>
  23. <el-col :span="6">
  24. <el-text class="mx-1" size="large">所属地区</el-text>
  25. <el-cascader
  26. v-model="selectedMarketPath"
  27. :options="markets"
  28. placeholder="请选择所属地区"
  29. clearable
  30. collapse-tags
  31. collapse-tags-tooltip
  32. style="width:180px"
  33. @change="handleMarketChange"
  34. :props="props"
  35. />
  36. </el-col>
  37. </el-row>
  38. <el-row>
  39. <el-col :span="12">
  40. <div class="time-controls">
  41. <div class="time-group">
  42. <el-text size="large" style="width: 80px">充值时间</el-text>
  43. <el-date-picker v-model="getTime" type="datetimerange" range-separator="" start-placeholder="起始时间"
  44. end-placeholder="结束时间" style="width: 400px" @change="handleDatePickerChange"
  45. :default-time="defaultTime"
  46. />
  47. <el-button @click="getToday()" style="margin-left: 10px"
  48. :type="activeTimeRange === 'today' ? 'primary' : ''">
  49. </el-button>
  50. <el-button @click="getYesterday()" style="margin-left: 10px"
  51. :type="activeTimeRange === 'yesterday' ? 'primary' : ''">
  52. </el-button>
  53. <el-button @click="get7Days()" style="margin-left: 10px"
  54. :type="activeTimeRange === '7days' ? 'primary' : ''"> 近7天
  55. </el-button>
  56. <el-button @click="resetSearch" type="success">重置</el-button>
  57. <el-button type="primary" @click="handleSearch">查询</el-button>
  58. </div>
  59. </div>
  60. </el-col>
  61. </el-row>
  62. </el-card>
  63. </el-col>
  64. </el-row>
  65. <el-row>
  66. <el-col>
  67. <el-card>
  68. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  69. <el-tab-pane label="待审核" name="wait"></el-tab-pane>
  70. <el-tab-pane label="已通过" name="pass"></el-tab-pane>
  71. <el-tab-pane label="已驳回" name="reject"></el-tab-pane>
  72. <div>
  73. 总条数{{ stats.totalNum }}&nbsp;&nbsp;&nbsp;&nbsp;
  74. 总金币数{{ (stats.permanentGolds + stats.freeGolds + stats.taskGolds).toFixed(2) }}金币&nbsp;&nbsp;&nbsp;&nbsp;
  75. 永久金币{{ stats.permanentGolds.toFixed(2) }}金币&nbsp;&nbsp;&nbsp;&nbsp;
  76. 免费金币{{ stats.freeGolds.toFixed(2) }}金币&nbsp;&nbsp;&nbsp;&nbsp;
  77. <!-- 任务金币{{ stats.taskGolds.toFixed(2) }}金币-->
  78. </div>
  79. </el-tabs>
  80. <!--表格-->
  81. <div style="height: 540px; overflow-y: auto">
  82. <el-table :data="tableData" style="width: 100%" height="540px" @sort-change="handleSortChange"
  83. :row-style="{ height: '50px' }">
  84. <el-table-column type="index" label="序号" width="100px" fixed="left">
  85. <template #default="scope">
  86. <span>{{ scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column fixed="left" prop="name" label="姓名" width="150px"/>
  90. <el-table-column fixed="left" prop="jwcode" label="精网号" width="110px"/>
  91. <el-table-column prop="market" label="所属地区" width="100px">
  92. <template #default="scope">
  93. {{ marketMapping[scope.row.market] || scope.row.market }}
  94. </template>
  95. </el-table-column>
  96. <el-table-column prop="activity" label="活动名称" width="100px" show-overflow-tooltip/>
  97. <el-table-column prop="money" label="充值金额" sortable="custom" width="110px">
  98. <template #default="scope">{{ scope.row.permanentGold / 100 }}</template>
  99. </el-table-column>
  100. <el-table-column prop="permanentGold" label="永久金币" width="110px" sortable="custom">
  101. <template #default="scope">{{ scope.row.permanentGold / 100 }}</template>
  102. </el-table-column>
  103. <el-table-column prop="freeGold" label="免费金币" sortable="custom" width="110px">
  104. <template #default="scope">{{ (scope.row.freeGold) / 100 }}</template>
  105. </el-table-column>
  106. <el-table-column prop="remark" label="备注" width="200px" show-overflow-tooltip/>
  107. <el-table-column prop="payModel" label="支付方式" width="110px"/>
  108. <el-table-column prop="voucher" label="支付凭证" width="110px">
  109. <template #default="scope">
  110. <div v-if="scope.row.voucher"
  111. style="display: flex; justify-content: center; align-items: center; cursor: pointer;"
  112. @click="previewImage(scope.row.voucher)">
  113. <img :src="scope.row.voucher" alt="支付凭证" style="width: auto; height: 40px;">
  114. </div>
  115. <div v-else style="display: flex; justify-content: center; align-items: center; height: 40px;">--</div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column prop="adminName" label="提交人" width="100px"/>
  119. <el-table-column prop="rejectReason" v-if="activeName === 'reject'" label="驳回理由" width="200px"
  120. show-overflow-tooltip/>
  121. <el-table-column v-if="activeName !== 'wait'" prop="auditName" label="审核人" width="100px"/>
  122. <el-table-column prop="payTime" sortable="custom" label="付款时间" width="200px">
  123. <template #default="scope">
  124. {{ moment(scope.row.payTime).format('YYYY-MM-DD HH:mm:ss') }}
  125. </template>
  126. </el-table-column>
  127. <el-table-column prop="createTime" sortable="custom" label="提交时间" width="200px">
  128. <template #default="scope">
  129. {{ moment(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}
  130. </template>
  131. </el-table-column>
  132. <el-table-column v-if="activeName !== 'wait'" prop="auditTime" label="审核时间" width="200px">
  133. <template #default="scope">
  134. {{ moment(scope.row.auditTime).format('YYYY-MM-DD HH:mm:ss') }}
  135. </template>
  136. </el-table-column>
  137. <el-table-column v-if="activeName === 'wait'" fixed="right" prop="operation" label="操作" width="150px">
  138. <template #default="scope">
  139. <div class="operation">
  140. <el-popconfirm title="确定要通过此条记录吗?" @confirm="handleApprove(scope.row)">
  141. <template #reference>
  142. <el-button :disabled="scope.row.auditStatus === 1 || scope.row.auditStatus === 2" type="primary"
  143. text>
  144. 通过
  145. </el-button>
  146. </template>
  147. </el-popconfirm>
  148. <el-button :disabled="scope.row.auditStatus === 1 || scope.row.auditStatus === 2" type="primary" text
  149. @click="showRejectDialog(scope.row)">
  150. 驳回
  151. </el-button>
  152. </div>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. <div class="pagination">
  158. <el-pagination background :page-size="getObj.pageSize" :page-sizes="[5, 10, 20, 50, 100]"
  159. layout="total, sizes, prev, pager, next, jumper" :total="total"
  160. @size-change="handlePagination('size', $event)"
  161. @current-change="handlePagination('page', $event)"></el-pagination>
  162. </div>
  163. </el-card>
  164. </el-col>
  165. </el-row>
  166. <el-dialog v-model="rejectDialogVisible" title="驳回理由" width="500px">
  167. <el-form>
  168. <el-form-item label="驳回理由" required>
  169. <el-input v-model="rejectReason" type="textarea" :rows="4" placeholder="请输入驳回理由" maxlength="200"
  170. show-word-limit/>
  171. </el-form-item>
  172. </el-form>
  173. <template #footer>
  174. <span class="dialog-footer">
  175. <el-button @click="rejectDialogVisible = false">取消</el-button>
  176. <el-button type="primary" @click="handleReject">确定</el-button>
  177. </span>
  178. </template>
  179. </el-dialog>
  180. </template>
  181. <script setup>
  182. import {onMounted, reactive, ref} from 'vue'
  183. import {marketMapping, reverseMarketMapping} from '@/utils/marketMap.js'
  184. import {ElMessage} from 'element-plus'
  185. import request from '@/util/http.js'
  186. import API from '@/util/http.js'
  187. import moment from 'moment'
  188. import {useAdminStore} from "@/store/index.js";
  189. import {storeToRefs} from "pinia";
  190. import {findMenuById, permissionMapping} from "@/utils/menuTreePermission.js"
  191. import dayjs from "dayjs";
  192. // 精网号去空格
  193. const trimJwCode = () => {
  194. if (rechargeAudit.value.jwcode) {
  195. rechargeAudit.value.jwcode = rechargeAudit.value.jwcode.replace(/\s/g, '');
  196. }
  197. }
  198. const formatTime = (val) => val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : ''
  199. const defaultTime = [
  200. new Date(2000, 1, 1, 0, 0, 0),
  201. new Date(2000, 2, 1,23 , 59, 59),
  202. ]
  203. // 这是获取用户信息的接口
  204. const adminData = ref({})
  205. // 充值明细表格
  206. const tableData = ref([])
  207. // 标记当前激活的时间范围按钮
  208. const activeTimeRange = ref('')
  209. // 日期选择器变化时清除按钮激活状态
  210. const handleDatePickerChange = () => {
  211. activeTimeRange.value = ''
  212. }
  213. // 搜索表单数据
  214. const rechargeAudit = ref({
  215. jwcode: "", // 精网号
  216. activity: "", // 活动名称
  217. payModel: "", // 支付方式
  218. startTime: "", // 充值时间开始
  219. endTime: "", // 充值时间结束
  220. markets: [], // 地区
  221. auditStatus: "0",
  222. })
  223. // 搜索对象
  224. const getObj = ref({
  225. pageNum: 1,
  226. pageSize: 50
  227. })
  228. // 分页总条目
  229. const total = ref(50)
  230. // 搜索对象时间
  231. const getTime = ref([])
  232. const activity = ref([])
  233. // 搜索地区列表
  234. const markets = ref([])
  235. // 驳回弹出框
  236. const rejectDialogVisible = ref(false)
  237. // 驳回理由
  238. const rejectReason = ref('')
  239. // 当前行信息
  240. const currentRecord = ref(null)
  241. // 标签页默认是待审批
  242. const activeName = ref('wait')
  243. // 支付方式选项
  244. const payModel = [
  245. // 现金、支票、刷卡、其他(各地区电子支付)
  246. {
  247. value: '现金',
  248. label: '现金'
  249. },
  250. {
  251. value: '支票',
  252. label: '支票'
  253. },
  254. {
  255. value: '刷卡',
  256. label: '刷卡'
  257. },
  258. {
  259. value: '其他(各地区电子支付)',
  260. label: '其他(各地区电子支付)'
  261. },
  262. ]
  263. // 表单验证ref
  264. const Ref = ref(null)
  265. // 统计合计数
  266. const stats = ref({
  267. totalNum: 0,
  268. totalCoins: 0,
  269. permanentGolds: 0,
  270. freeGolds: 0,
  271. taskGolds: 0
  272. })
  273. // 新增排序字段和排序方式
  274. const sortField = ref('')
  275. const sortOrder = ref('')
  276. // 表单验证
  277. const rules = reactive({
  278. rejectReason: [{required: true, message: '请输入驳回理由', trigger: 'blur'}]
  279. })
  280. const getAdminData = async function () {
  281. try {
  282. const result = await request({
  283. url: '/admin/userinfo',
  284. data: {}
  285. })
  286. adminData.value = result
  287. console.log('用户信息', adminData.value)
  288. } catch (error) {
  289. console.log('请求失败', error)
  290. }
  291. }
  292. // 搜索方法
  293. const getRecharge = async function (val) {
  294. try {
  295. // 搜索参数页码赋值
  296. if (typeof val === 'number') {
  297. getObj.value.pageNum = val
  298. }
  299. // 搜索参数时间赋值
  300. if (getTime.value && getTime.value.length === 2) {
  301. rechargeAudit.value.startTime = formatTime(getTime.value[0])
  302. rechargeAudit.value.endTime = formatTime(getTime.value[1])
  303. } else {
  304. rechargeAudit.value.startTime = ''
  305. rechargeAudit.value.endTime = ''
  306. }
  307. console.log('搜索参数', getObj.value)
  308. const result = await request({
  309. url: '/audit/selectRecharge',
  310. data: {
  311. pageNum: getObj.value.pageNum,
  312. pageSize: getObj.value.pageSize,
  313. rechargeAudit: {
  314. ...rechargeAudit.value,
  315. sortField: sortField.value,
  316. sortOrder: sortOrder.value
  317. }
  318. }
  319. })
  320. // 存储表格数据
  321. tableData.value = result.list
  322. // 存储总条数
  323. total.value = result.total
  324. } catch (error) {
  325. console.log('请求失败', error)
  326. }
  327. }
  328. const getStats = async () => {
  329. try {
  330. const params = {
  331. pageNum: getObj.value.pageNum,
  332. pageSize: getObj.value.pageSize,
  333. rechargeAudit: rechargeAudit.value
  334. }
  335. const res = await API({
  336. url: '/audit/sumRechargeGold',
  337. data: params
  338. })
  339. stats.value.totalNum = res.totalNum
  340. stats.value.permanentGolds = res.permanentGolds / 100
  341. stats.value.freeGolds = res.freeGolds / 100
  342. stats.value.taskGolds = res.taskGolds / 100
  343. console.log('see see stats和搜索对象', stats.value, params)
  344. } catch (error) {
  345. console.log('请求失败', error)
  346. }
  347. }
  348. // 搜索
  349. const handleSearch = function () {
  350. trimJwCode();
  351. getObj.value.pageNum = 1
  352. getRecharge()
  353. getStats()
  354. }
  355. // 重置
  356. const resetSearch = function () {
  357. rechargeAudit.value = {
  358. jwcode: "",
  359. activity: "",
  360. payModel: "",
  361. startTime: "",
  362. endTime: "",
  363. markets: [],
  364. auditStatus: rechargeAudit.value.auditStatus,
  365. }
  366. selectedMarketPath.value = []
  367. getTime.value = []
  368. activeTimeRange.value = '' // 清除激活状态
  369. getRecharge()
  370. getStats()
  371. }
  372. // 今天
  373. const getToday = function () {
  374. const today = dayjs()
  375. const startTime = today.startOf('day').format('YYYY-MM-DD HH:mm:ss')
  376. const endTime =today.endOf('day').format('YYYY-MM-DD HH:mm:ss')
  377. getTime.value = [startTime, endTime]
  378. console.log('getTime', getTime.value)
  379. activeTimeRange.value = 'today' // 标记当前激活状态
  380. getRecharge()
  381. getStats()
  382. }
  383. // 昨天
  384. const getYesterday = function () {
  385. const today = dayjs()
  386. const startTime = today.subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
  387. const endTime = today.subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
  388. getTime.value = [startTime, endTime]
  389. console.log('getTime', getTime.value)
  390. activeTimeRange.value = 'yesterday' // 标记当前激活状态
  391. getRecharge()
  392. getStats()
  393. }
  394. // 近7天
  395. const get7Days = function () {
  396. const today = dayjs()
  397. const startTime = today.subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
  398. const endTime = today.add(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
  399. getTime.value = [startTime, endTime]
  400. console.log('getTime', getTime.value)
  401. activeTimeRange.value = '7days' // 标记当前激活状态
  402. getRecharge()
  403. getStats()
  404. }
  405. // 待审核充值明细
  406. const adminWait = async function () {
  407. rechargeAudit.value.auditStatus = "0"
  408. getObj.value.pageNum = 1
  409. await getRecharge()
  410. await getStats()
  411. console.log('adminWait,这是点击待审核调用')
  412. }
  413. // 已通过充值明细
  414. const adminPass = async function () {
  415. rechargeAudit.value.auditStatus = "1"
  416. getObj.value.pageNum = 1
  417. await getRecharge()
  418. await getStats()
  419. console.log('adminWait,这是点击已通过调用')
  420. }
  421. // 已驳回充值明细
  422. const adminReject = async function () {
  423. rechargeAudit.value.auditStatus = "2"
  424. getObj.value.pageNum = 1
  425. await getRecharge()
  426. await getStats()
  427. console.log('adminWait,这是点击已驳回调用')
  428. }
  429. const handleClick = function (tab, event) {
  430. activeName.value = tab.props.name
  431. if (tab.props.name === 'wait') {
  432. adminWait()
  433. } else if (tab.props.name === 'pass') {
  434. adminPass()
  435. } else if (tab.props.name === 'reject') {
  436. adminReject()
  437. }
  438. }
  439. const getActivity = async function () {
  440. try {
  441. const result = await request({
  442. url: '/general/activity',
  443. data: {}
  444. })
  445. activity.value = result.data
  446. console.log('activity', activity.value)
  447. } catch (error) {
  448. console.log('请求失败', error)
  449. }
  450. }
  451. const handlePagination = (type, val) => {
  452. if (type === 'size') {
  453. getObj.value.pageSize = val
  454. } else {
  455. getObj.value.pageNum = val
  456. }
  457. getRecharge()
  458. getStats()
  459. }
  460. const adminStore = useAdminStore();
  461. const {menuTree} = storeToRefs(adminStore);
  462. // 处理通过操作
  463. const handleApprove = async (row) => {
  464. if (findMenuById(menuTree.value, permissionMapping.Recharge_Approval)) {
  465. try {
  466. const params = {
  467. orderCode: row.orderCode,
  468. auditId: adminData.value.id,
  469. action: 1,
  470. rejectReason: ''
  471. }
  472. await request({url: '/audit/audit', data: params})
  473. ElMessage.success('审核通过成功')
  474. await getRecharge()
  475. await getStats()
  476. } catch (error) {
  477. console.error('审核通过失败', error)
  478. ElMessage.error('操作失败')
  479. }
  480. } else {
  481. ElMessage.error('无权限')
  482. }
  483. }
  484. // 显示驳回对话框
  485. const showRejectDialog = (row) => {
  486. currentRecord.value = row
  487. rejectReason.value = '' // 清空之前的
  488. if (findMenuById(menuTree.value, permissionMapping.Recharge_Approval)) {
  489. rejectDialogVisible.value = true
  490. }else {
  491. ElMessage.error('无权限')
  492. }
  493. }
  494. // 处理驳回操作
  495. const handleReject = async () => {
  496. if (findMenuById(menuTree.value, permissionMapping.Recharge_Approval)) {
  497. if (!rejectReason.value.trim()) {
  498. ElMessage.warning('请输入驳回理由')
  499. return
  500. }
  501. try {
  502. const params = {
  503. orderCode: currentRecord.value.orderCode,
  504. auditId: adminData.value.id,
  505. action: 2,
  506. rejectReason: rejectReason.value
  507. }
  508. await request({url: '/audit/audit', data: params})
  509. ElMessage.success('驳回操作成功')
  510. rejectDialogVisible.value = false
  511. await getRecharge()
  512. await getStats()
  513. } catch (error) {
  514. console.error('驳回操作失败', error)
  515. ElMessage.error('操作失败')
  516. }
  517. } else {
  518. ElMessage.error('无权限')
  519. }
  520. }
  521. // 处理排序事件
  522. const handleSortChange = (column) => {
  523. console.log('排序字段:', column.prop)
  524. console.log('排序方式:', column.order)
  525. if (column.prop === 'money') {
  526. sortField.value = 'permanent_gold'
  527. } else if (column.prop === 'permanentGold') {
  528. sortField.value = 'permanent_gold'
  529. } else if (column.prop === 'freeGold') {
  530. sortField.value = 'freeGold'
  531. } else if (column.prop === 'createTime') {
  532. sortField.value = 'create_time'
  533. } else if (column.prop === 'payTime') {
  534. sortField.value = 'pay_time'
  535. } else if (column.prop === 'auditTime') {
  536. sortField.value = 'audit_time'
  537. }
  538. sortOrder.value = column.order === 'ascending' ? 'asc' : 'desc'
  539. getRecharge()
  540. getStats()
  541. }
  542. // 预览图片函数
  543. const previewImage = (imageUrl) => {
  544. // 使用 element-plus 的 el-image 组件实现图片预览功能
  545. const imageElement = document.createElement('img');
  546. imageElement.src = imageUrl;
  547. imageElement.style.maxWidth = '80vw';
  548. imageElement.style.maxHeight = '80vh';
  549. const viewer = document.createElement('div');
  550. viewer.style.position = 'fixed';
  551. viewer.style.top = '0';
  552. viewer.style.left = '0';
  553. viewer.style.width = '100vw';
  554. viewer.style.height = '100vh';
  555. viewer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  556. viewer.style.display = 'flex';
  557. viewer.style.justifyContent = 'center';
  558. viewer.style.alignItems = 'center';
  559. viewer.style.zIndex = '9999';
  560. viewer.style.overflow = 'auto';
  561. viewer.appendChild(imageElement);
  562. document.body.appendChild(viewer);
  563. viewer.addEventListener('click', () => {
  564. document.body.removeChild(viewer);
  565. });
  566. };
  567. // 存储地区选择变化
  568. const selectedMarketPath = ref([])
  569. //处理地区选择变化
  570. const handleMarketChange = (value) => {
  571. if (Array.isArray(value) && value.length > 0) {
  572. const ids = new Set();
  573. value.forEach(path => {
  574. const lastName = path[path.length - 1];
  575. const id = reverseMarketMapping[lastName];
  576. if (id) ids.add(Number(id));
  577. });
  578. // 添加额外处理:如果一个父节点下所有子节点都被选中,则把父节点也加入
  579. const getAllLeafNames = (nodes) => {
  580. const leafNames = [];
  581. const traverse = (node, parentName = null) => {
  582. if (!node.children || node.children.length === 0) {
  583. leafNames.push({name: node.label, parent: parentName});
  584. } else {
  585. node.children.forEach(child => traverse(child, node.label));
  586. }
  587. };
  588. nodes.forEach(node => traverse(node));
  589. return leafNames;
  590. };
  591. const leafNameMap = getAllLeafNames(markets.value); // 所有叶子节点和对应父级名称
  592. // 列表构建
  593. const parentToChildren = {};
  594. leafNameMap.forEach(({name, parent}) => {
  595. if (!parentToChildren[parent]) parentToChildren[parent] = [];
  596. parentToChildren[parent].push(name);
  597. });
  598. // 构建当前被选中的叶子节点
  599. const selectedLeafNames = value.map(path => path[path.length - 1]);
  600. // 如果 parent 下所有子节点都选中了,就把 parent 加进来
  601. Object.entries(parentToChildren).forEach(([parent, children]) => {
  602. const allChildrenSelected = children.every(child => selectedLeafNames.includes(child));
  603. if (allChildrenSelected && reverseMarketMapping[parent]) {
  604. ids.add(Number(reverseMarketMapping[parent]));
  605. }
  606. });
  607. rechargeAudit.value.markets = Array.from(ids);
  608. } else {
  609. rechargeAudit.value.markets = [];
  610. }
  611. console.log('最终映射后的 market IDs:', rechargeAudit.value.markets);
  612. };
  613. const props = {multiple: true}
  614. // 获取地区,修改为级联下拉框
  615. const getMarket = async function () {
  616. try {
  617. // 发送POST请求
  618. const result = await API({
  619. url: '/market/selectMarket',
  620. });
  621. // 将响应结果存储到响应式数据中
  622. console.log('请求成功', result)
  623. // 递归转换树形结构为级联选择器需要的格式(跳过第一级节点)
  624. const transformTree = (nodes) => {
  625. // 直接处理第一级节点的子节点
  626. const allChildren = nodes.flatMap(node => node.children || []);
  627. return allChildren.map(child => {
  628. const grandchildren = child.children && child.children.length
  629. ? transformTree([child]) // 递归处理子节点
  630. : null;
  631. return {
  632. value: child.name,
  633. label: child.name,
  634. children: grandchildren
  635. };
  636. });
  637. };
  638. // 存储地区信息
  639. markets.value = transformTree(result.data)
  640. console.log('转换后的地区树==============', markets.value)
  641. } catch (error) {
  642. console.log('请求失败', error)
  643. }
  644. }
  645. // 挂载
  646. onMounted(async function () {
  647. await getAdminData()
  648. await getActivity()
  649. await getMarket()
  650. await getRecharge()
  651. console.log('111')
  652. await getStats()
  653. })
  654. </script>
  655. <style scoped>
  656. .pagination {
  657. display: flex;
  658. }
  659. .operation {
  660. display: flex;
  661. }
  662. .green-dot {
  663. background-color: #67C23A;
  664. }
  665. .grey-dot {
  666. background-color: #909399;
  667. }
  668. .red-dot {
  669. background-color: #F56C6C;
  670. }
  671. .time-controls {
  672. display: flex;
  673. align-items: center;
  674. }
  675. .time-group {
  676. display: flex;
  677. align-items: center;
  678. gap: 10px;
  679. }
  680. .quick-buttons {
  681. display: flex;
  682. align-items: center;
  683. }
  684. .status {
  685. display: flex;
  686. align-items: center;
  687. /* 确保子元素垂直居中对齐 */
  688. gap: 6px;
  689. /* 设置圆点和文字之间的间距 */
  690. }
  691. .green-dot,
  692. .grey-dot,
  693. .red-dot {
  694. display: inline-block;
  695. width: 8px;
  696. height: 8px;
  697. border-radius: 50%;
  698. flex-shrink: 0;
  699. /* 防止圆点在空间不足时缩小 */
  700. margin: 0;
  701. /* 移除原有的 margin-right */
  702. }
  703. /* 备注列样式 */
  704. .remark-cell {
  705. display: block;
  706. width: 100%;
  707. overflow: hidden;
  708. text-overflow: ellipsis;
  709. white-space: nowrap;
  710. }
  711. /* 设置单元格内容溢出隐藏 */
  712. .el-table .el-table__cell {
  713. overflow: hidden;
  714. text-overflow: ellipsis;
  715. white-space: nowrap;
  716. }
  717. </style>