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.

897 lines
29 KiB

7 months ago
7 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
7 months ago
7 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
10 months ago
7 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
10 months ago
  1. <template>
  2. <el-card class="card1" style="margin-bottom: 0.5vh;">
  3. <el-col style="margin-bottom: 1vh">
  4. <div class="select">
  5. <div class="selectRow">
  6. <el-text class="text" size="large">{{ $t('common.jwcode') }}</el-text>
  7. <el-input class="selectContent" v-model="searchForm.jwcode" :placeholder="$t('common.jwcodePlaceholder')"
  8. clearable />
  9. </div>
  10. <div class="selectRow">
  11. <el-text class="text" size="large">{{ $t('common.goodsName') }}</el-text>
  12. <el-select class="selectContent" v-model="searchForm.goodsName"
  13. :placeholder="$t('common.goodsNamePlaceholder')" clearable>
  14. <el-option v-for="item in refundGoodsOptions" :key="item" :label="item" :value="item"></el-option>
  15. </el-select>
  16. </div>
  17. <div class="selectRow">
  18. <el-text class="text" size="large">{{ $t('common.refundType') }}</el-text>
  19. <el-select class="selectContent" v-model="searchForm.refundType"
  20. :placeholder="$t('common.refundTypePlaceholder')" clearable>
  21. <el-option :label="$t('audit.refundTypeOptions.商品退款')" value="商品退款" />
  22. <el-option :label="$t('audit.refundTypeOptions.金币退款')" value="金币退款" />
  23. </el-select>
  24. </div>
  25. <div class="selectRow">
  26. <el-text class="text" size="large">{{ $t('common.market') }}</el-text>
  27. <el-cascader class="selectContent" style="width: 12vw;" v-model="selectedMarketPath" :options="market"
  28. :placeholder="$t('common.marketPlaceholder')" clearable @change="handleMarketChange" />
  29. </div>
  30. </div>
  31. </el-col>
  32. <el-col>
  33. <div class="select">
  34. <div class="selectRow" style="width: 36vw;">
  35. <el-text class="text" size="large">
  36. {{ (activeName === 'wait' || activeName === 'change') ? $t('common.submitTime') : $t('common.auditTime') }}
  37. </el-text>
  38. <el-date-picker class="selectContent" v-model="dateRange" type="datetimerange"
  39. :range-separator="$t('common.to')" :start-placeholder="$t('common.startTime')"
  40. :end-placeholder="$t('common.endTime')" style="margin-right:1vw;width:25vw" @change="handleDatePickerChange"
  41. :default-time="defaultTime" :disabled-date="disabledDate" />
  42. <div v-if="false">
  43. <el-button @click="getToday()" :type="activeTimeRange === 'today' ? 'primary' : ''"></el-button>
  44. <el-button @click="getYesterday()" :type="activeTimeRange === 'yesterday' ? 'primary' : ''"></el-button>
  45. <el-button @click="get7Days()" :type="activeTimeRange === '7days' ? 'primary' : ''">近7天</el-button>
  46. </div>
  47. </div>
  48. <div class="selectRow" style="justify-content: flex-start;">
  49. <el-button @click="handleSearch" type="primary">{{ $t('common.search') }}</el-button>
  50. <el-button @click="resetSearch" type="success">{{ $t('common.reset') }}</el-button>
  51. </div>
  52. </div>
  53. </el-col>
  54. </el-card>
  55. <el-card class="card2">
  56. <div class="custom-button-group">
  57. <el-button v-if="hasrefundWait && hasrefundWaitShow" :type="activeName === 'wait' ? 'primary' : 'default'"
  58. @click="handleButtonClick('wait')" class="custom-tab-button">
  59. {{ $t('audit.waitAudit') }}
  60. </el-button>
  61. <el-button v-if="hasrefundThrough" :type="activeName === 'pass' ? 'primary' : 'default'"
  62. @click="handleButtonClick('pass')" class="custom-tab-button">
  63. {{ $t('audit.passed') }}
  64. </el-button>
  65. <el-button v-if="hasrefundReject" :type="activeName === 'reject' ? 'primary' : 'default'"
  66. @click="handleButtonClick('reject')" class="custom-tab-button">
  67. {{ $t('audit.rejected') }}
  68. </el-button>
  69. <el-button v-if="hasrefundWait && hasrefundWaitShow" :type="activeName === 'change' ? 'primary' : 'default'"
  70. @click="handleButtonClick('change')" class="custom-tab-button">
  71. {{ $t('audit.changed') }}
  72. </el-button>
  73. </div>
  74. <div class="goldStatistics">
  75. {{ $t('audit.refundTotalGold') }}{{
  76. format3((stats.permanentGolds + stats.freeGolds + stats.taskGolds).toFixed(2))
  77. }}{{ $t('common.goldCoin') }}&nbsp;&nbsp;&nbsp;&nbsp;
  78. {{ $t('audit.permanentGold') }}{{ format3(stats.permanentGolds.toFixed(2)) }}{{ $t('common.goldCoin')
  79. }}&nbsp;&nbsp;&nbsp;&nbsp;
  80. {{ $t('audit.freeGold') }}{{ format3(stats.freeGolds.toFixed(2)) }}{{ $t('common.goldCoin')
  81. }}&nbsp;&nbsp;&nbsp;&nbsp;
  82. {{ $t('audit.taskGold') }}{{ format3(stats.taskGolds.toFixed(2)) }}{{ $t('common.goldCoin') }}
  83. </div>
  84. <el-table ref="tableRef" :data="tableData" style="height:61vh;width:82vw" @sort-change="handleSortChange"
  85. :row-style="{ height: '50px' }">
  86. <el-table-column fixed="left" type="index" :label="$t('audit.id')" width="60">
  87. <template #default="scope">
  88. {{ scope.$index + 1 + (pagination.pageNum - 1) * pagination.pageSize }}
  89. </template>
  90. </el-table-column>
  91. <el-table-column fixed="left" prop="name" :label="$t('audit.name')" width="120" show-overflow-tooltip />
  92. <el-table-column fixed="left" prop="jwcode" :label="$t('audit.jwcode')" width="120" />
  93. <el-table-column prop="market" :label="$t('audit.market')" width="120" />
  94. <el-table-column prop="orderCode" :label="$t('audit.orderCode')" width="260px" show-overflow-tooltip />
  95. <el-table-column prop="refundType" :label="$t('audit.refundType')" width="120" />
  96. <el-table-column prop="refundModel" :label="$t('audit.refundModel')" width="120">
  97. <template #default="{ row }">
  98. {{ row.refundModel === 0 ? $t('audit.allRefund') : $t('audit.partialRefund') }}
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="goodsName" :label="$t('audit.refundGoods')" width="120" show-overflow-tooltip />
  102. <el-table-column prop="sumGold" :label="$t('audit.refundTotalGold')" width="190" sortable="custom">
  103. <template #default="{ row }">
  104. {{ row.sumGold / 100 }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="permanentGold" :label="$t('audit.permanentGold')" width="130" sortable="custom">
  108. <template #default="{ row }">
  109. {{ row.permanentGold / 100 }}
  110. </template>
  111. </el-table-column>
  112. <el-table-column prop="freeGold" :label="$t('audit.freeGold')" width="130" sortable="custom">
  113. <template #default="{ row }">
  114. {{ (row.freeJune + row.freeDecember) / 100 }}
  115. </template>
  116. </el-table-column>
  117. <el-table-column prop="taskGold" :label="$t('audit.taskGold')" width="130" sortable="custom">
  118. <template #default="{ row }">
  119. {{ row.taskGold / 100 }}
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. v-if="activeName === 'change'"
  124. prop="redDiff"
  125. label="金币补差额"
  126. width="130"
  127. sortable="custom"
  128. >
  129. <template #default="{ row }">
  130. {{ row.redDiff != null ? (row.redDiff / 100) : 0 }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="remark" :label="$t('audit.note')" width="150" show-overflow-tooltip />
  134. <el-table-column prop="adminName" :label="$t('audit.submitter')" width="120" />
  135. <el-table-column v-if="checkTab === 'reject'" prop="rejectReason" :label="$t('audit.rejectReason')" width="150"
  136. show-overflow-tooltip />
  137. <el-table-column v-if="checkTab === 'pass' || checkTab === 'reject'" prop="auditName" :label="$t('audit.auditor')" width="120" />
  138. <el-table-column prop="createTime" :label="$t('audit.submitTime')" width="180" sortable="custom">
  139. <template #default="{ row }">
  140. {{
  141. moment(row.createTime).format('YYYY-MM-DD HH:mm:ss')
  142. }}
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. v-if="checkTab !== 'pending' && checkTab !== 'change'"
  147. prop="auditTime"
  148. :label="$t('audit.auditTime')"
  149. width="180"
  150. >
  151. <template #default="{ row }">
  152. {{ row.auditTime ? moment(row.auditTime).format('YYYY-MM-DD HH:mm:ss') : '--' }}
  153. </template>
  154. </el-table-column>
  155. <el-table-column
  156. v-if="(checkTab === 'pending' || checkTab === 'change') && (hasrefundWaitThough || hasrefundWaitReject) && hasrefundWaitShow" fixed="right"
  157. prop="operation" :label="$t('audit.operation')" width="150px">
  158. <template #default="scope">
  159. <div class="operation">
  160. <el-link :underline="false" class="pass-btn" v-if="hasrefundWaitThough" :disabled="clicked || cancelClicked"
  161. type="primary" @click="showApproveDialog(scope.row)">
  162. {{ $t('common.pass') }}
  163. </el-link>
  164. <el-link :underline="false" class="reject-btn" v-if="hasrefundWaitReject"
  165. :disabled="clicked || cancelClicked" type="primary" @click="showRejectDialog(scope.row)">
  166. {{ $t('common.reject') }}
  167. </el-link>
  168. </div>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <el-pagination class="pagination" background :current-page="pagination.pageNum" :page-size="pagination.pageSize"
  173. layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" @size-change="handlePageSizeChange"
  174. @current-change="handleCurrentChange"></el-pagination>
  175. </el-card>
  176. <!-- 退款驳回理由输入框 -->
  177. <el-dialog v-model="rejectReasonDialogVisible" :title="$t('audit.rejectReason')" width="500px"
  178. @close="handleRejectReasonCancel">
  179. <el-form>
  180. <el-form-item :label="$t('audit.rejectReason')" required>
  181. <el-input v-model="rejectReason" type="textarea" :rows="4" :placeholder="$t('audit.rejectReasonPlaceholder')"
  182. maxlength="200" show-word-limit />
  183. </el-form-item>
  184. </el-form>
  185. <template #footer>
  186. <span class="dialog-footer">
  187. <el-button @click="handleRejectReasonCancel">{{ $t('common.cancel') }}</el-button>
  188. <el-button :disabled="cancelClicked" type="primary" @click="handleReject">{{ $t('common.confirm') }}</el-button>
  189. </span>
  190. </template>
  191. </el-dialog>
  192. <ConfirmDialog v-model="rejectDialogVisible" :message="$t('audit.rejectRecord')" @confirm="showRejectReasonInput"
  193. @cancel="handleRejectCancel" @close="handleRejectClose" />
  194. <!-- 新增使用ConfirmDialog组件 -->
  195. <ConfirmDialog v-model="approveDialogVisible" :message="$t('audit.passRecord')" @confirm="throttledHandleApproveConfirm"
  196. @cancel="handleApproveCancel" @close="handleApproveClose" />
  197. </template>
  198. <script setup>
  199. import { onMounted, reactive, ref, watch } from 'vue'
  200. import { ElMessage } from 'element-plus'
  201. import API from '@/util/http.js'
  202. import moment from 'moment'
  203. import { useAdminStore } from "@/store/index.js";
  204. import { storeToRefs } from "pinia";
  205. import dayjs from "dayjs";
  206. import { permissionMapping, hasMenuPermission } from "@/utils/menuTreePermission.js"
  207. import ConfirmDialog from '@/components/dialogs/ConfirmDialog.vue';
  208. import { useI18n } from 'vue-i18n';
  209. import {reverseMarketMapping} from "@/utils/marketMap.js";
  210. const { t } = useI18n();
  211. const adminStore = useAdminStore();
  212. const { adminData, menuTree, flag } = storeToRefs(adminStore);
  213. // 监听全局flag状态变化
  214. watch(flag, (newFlag, oldFlag) => {
  215. // 当flag状态改变时,重新发送请求
  216. if (newFlag !== oldFlag) {
  217. get()
  218. getStats()
  219. }
  220. })
  221. const defaultTime = [
  222. new Date(2000, 1, 1, 0, 0, 0),
  223. new Date(2000, 2, 1, 23, 59, 59),
  224. ]
  225. // 当前激活的时间按钮
  226. const activeTimeRange = ref('')
  227. const currentRecord = ref(null) // 当前行信息
  228. const rejectDialogVisible = ref(false)
  229. const rejectReasonDialogVisible = ref(false)
  230. const rejectReason = ref('')
  231. const approveDialogVisible = ref(false)
  232. // 状态常量
  233. const STATUS = {
  234. PENDING: 0, // 待审核
  235. APPROVED: 1, // 通过
  236. REJECTED: 2, // 驳回
  237. WAIT_HANDLE: 4 // 待处理(红包)
  238. }
  239. //无法选择的时间
  240. const disabledDate = (time) => {
  241. const limitDate = new Date(2025, 0, 1);
  242. return time.getTime() < limitDate.getTime();
  243. }
  244. // 搜索表单数据
  245. const searchForm = ref({
  246. jwcode: '',
  247. refundModel: '',
  248. goodsName: '',
  249. market: "",
  250. startTime: '',
  251. endTime: '',
  252. auditStatus: '0'
  253. })
  254. const checkTab = ref('pending') // 能否不用STATUS常量,0是待审批,1是已通过,2是驳回,参数status需要Integer
  255. const dateRange = ref([])
  256. const pagination = ref({
  257. pageNum: 1,
  258. pageSize: 50,
  259. total: 0
  260. })
  261. const tableData = ref([])
  262. const tableRef = ref(null)
  263. const marketOptions = ref([])
  264. const refundGoodsOptions = ref([])
  265. const adminInfo = ref({})
  266. // 统计合计数
  267. const stats = ref({
  268. totalNum: 0,
  269. totalCoins: 0,
  270. permanentGolds: 0,
  271. freeGolds: 0,
  272. taskGolds: 0
  273. })
  274. const rejectVisible = ref(false)
  275. const rejectObj = ref({})
  276. const passObj = ref({})
  277. // 标签页默认是待审批
  278. const activeName = ref('wait')
  279. const sortField = ref('')
  280. const sortOrder = ref('')
  281. const market = ref("")
  282. //退款操作权限
  283. const hasrefundThrough = ref(false) // 退款审核已通过
  284. const hasrefundReject = ref(false) // 退款审核已驳回
  285. const hasrefundWait = ref(false) // 退款审核待审核
  286. const hasrefundWaitShow = ref(false) // 退款审核待审核查看
  287. const hasrefundWaitThough = ref(false) // 退款审核通过
  288. const hasrefundWaitReject = ref(false) // 退款审核驳回
  289. // 初始化权限状态
  290. const initPermissions = async () => {
  291. if (!menuTree.value || !menuTree.value.length) return;
  292. // 退款相关权限
  293. hasrefundThrough.value = hasMenuPermission(menuTree.value, permissionMapping.gold_coin_refund_approved);
  294. hasrefundReject.value = hasMenuPermission(menuTree.value, permissionMapping.gold_coin_refund_rejected);
  295. hasrefundWait.value = hasMenuPermission(menuTree.value, permissionMapping.gold_coin_refund_pending);
  296. hasrefundWaitShow.value = hasMenuPermission(menuTree.value, permissionMapping.view_gold_refund_pending);
  297. hasrefundWaitThough.value = hasMenuPermission(menuTree.value, permissionMapping.pass_gold_refund_audit);
  298. hasrefundWaitReject.value = hasMenuPermission(menuTree.value, permissionMapping.reject_gold_refund_audit);
  299. console.log('退款权限赋值完成');
  300. };
  301. // 处理排序事件
  302. const handleSortChange = (column) => {
  303. if (column.prop === 'sumGold') {
  304. sortField.value = 'sum_gold'
  305. } else if (column.prop === 'permanentGold') {
  306. sortField.value = 'permanent_gold'
  307. } else if (column.prop === 'freeGold') {
  308. sortField.value = 'freeGold'
  309. } else if (column.prop === 'taskGold') {
  310. sortField.value = 'task_gold'
  311. } else if (column.prop === 'redDiff') {
  312. sortField.value = 'red_diff'
  313. } else if (column.prop === 'createTime') {
  314. sortField.value = 'create_time'
  315. } else if (column.prop === 'auditTime') {
  316. sortField.value = 'audit_time'
  317. } else {
  318. sortField.value = ''
  319. }
  320. sortOrder.value = column.order === 'ascending' ? 'asc' : 'desc'
  321. console.log('排序字段:', sortField.value)
  322. console.log('排序方式:', sortOrder.value)
  323. get()
  324. }
  325. // 查商品名
  326. const getRefundGoods = async () => {
  327. try {
  328. const res = await API({ url: '/general/goods' })
  329. refundGoodsOptions.value = res.data || []
  330. } catch (error) {
  331. console.error('获取商品列表失败', error)
  332. }
  333. }
  334. // 搜索方法
  335. const get = async function (val) {
  336. if (!hasrefundWaitShow) {
  337. ElMessage.error(t('elmessage.noPermission'))
  338. return
  339. }
  340. try {
  341. if (typeof val === 'number') {
  342. pagination.value.pageNum = val
  343. }
  344. if (dateRange.value && dateRange.value.length === 2) {
  345. searchForm.value.startTime = moment(dateRange.value[0]).format('YYYY-MM-DD HH:mm:ss')
  346. searchForm.value.endTime = moment(dateRange.value[1]).format('YYYY-MM-DD HH:mm:ss')
  347. } else {
  348. searchForm.value.startTime = ''
  349. searchForm.value.endTime = ''
  350. }
  351. const auditStatusNum = Number(searchForm.value.auditStatus)
  352. if (
  353. !sortField.value &&
  354. !sortOrder.value &&
  355. (auditStatusNum === STATUS.PENDING || auditStatusNum === STATUS.WAIT_HANDLE)
  356. ) {
  357. sortField.value = 'create_time'
  358. sortOrder.value = 'desc'
  359. }
  360. // if (searchForm.value.market === '总部' || searchForm.value.market === '研发部') {
  361. // searchForm.value.market = '';
  362. // }
  363. const params = {
  364. pageNum: pagination.value.pageNum,
  365. pageSize: pagination.value.pageSize,
  366. refundAudit: {
  367. ...searchForm.value,
  368. sortField: sortField.value,
  369. sortOrder: sortOrder.value,
  370. flag: flag.value
  371. }
  372. }
  373. console.log('看看传给后端的参数:', params)
  374. // 校验精网号(数字格式)
  375. if (searchForm.value.jwcode) {
  376. // 纯数字
  377. const numberRegex = /^\d{1,9}$/;
  378. // 检查是否不是数字
  379. if (!numberRegex.test(searchForm.value.jwcode)) {
  380. ElMessage.error(t('elmessage.checkJwcodeFormat'))
  381. // 上面提示过了
  382. return
  383. }
  384. }
  385. const res = await API({ url: '/audit/selectRefund', data: params })
  386. tableData.value = res.list || []
  387. pagination.value.total = res.total || 0
  388. console.log('查全部的total', pagination.value.total, res.total)
  389. } catch (error) {
  390. console.error('获取数据失败', error)
  391. }
  392. }
  393. const clicked = ref(false);
  394. // 显示通过确认对话框
  395. const showApproveDialog = (row) => {
  396. if (!hasrefundWaitThough) {
  397. ElMessage.error(t('elmessage.noPermission'))
  398. return
  399. }
  400. currentRecord.value = row
  401. approveDialogVisible.value = true
  402. }
  403. // 使用handleApproveConfirm函数代替handleApprove
  404. const handleApproveConfirm = async () => {
  405. clicked.value = true
  406. try {
  407. const params = {
  408. orderCode: currentRecord.value.orderCode,
  409. auditId: adminData.value.id,
  410. action: 1, // action的1是通过,2是驳回
  411. rejectReason: '',
  412. price: currentRecord.value.price,
  413. linkId: currentRecord.value.linkId,
  414. refundModel: currentRecord.value.refundModel,
  415. }
  416. const res = await API({ url: '/audit/audit', data: params })
  417. if (res && res.success === false) {
  418. ElMessage.error(res.message || '红包退票失败')
  419. } else if (res && res.success === true) {
  420. ElMessage.success(t('elmessage.approveSuccess'))
  421. } else {
  422. ElMessage.error(res.msg || t('elmessage.operationFailed'))
  423. }
  424. approveDialogVisible.value = false
  425. await get()
  426. await getStats()
  427. } catch (error) {
  428. console.error(t('elmessage.approveFailed'), error)
  429. ElMessage.error(t('elmessage.operationFailed'))
  430. } finally {
  431. clicked.value = false
  432. }
  433. }
  434. import _ from 'lodash';
  435. // handleApproveConfirm
  436. const throttledHandleApproveConfirm = _.throttle(handleApproveConfirm, 5000, {
  437. trailing: false
  438. })
  439. // 处理通过取消操作
  440. const handleApproveCancel = () => {
  441. approveDialogVisible.value = false
  442. }
  443. // 处理通过关闭操作
  444. const handleApproveClose = () => {
  445. approveDialogVisible.value = false
  446. }
  447. // 显示驳回对话框
  448. const showRejectDialog = (row) => {
  449. if (!hasrefundWaitReject) {
  450. ElMessage.error(t('elmessage.noPermission'))
  451. return
  452. }
  453. currentRecord.value = row
  454. rejectReason.value = ''
  455. rejectDialogVisible.value = true
  456. }
  457. //控制驳回确认按钮禁用状态
  458. const cancelClicked = ref(false)
  459. // 处理驳回操作
  460. const handleReject = async () => {
  461. if (!hasrefundWaitReject) {
  462. ElMessage.error(t('elmessage.noPermission'))
  463. return
  464. }
  465. cancelClicked.value = true
  466. if (!rejectReason.value.trim()) {
  467. ElMessage.warning(t('elmessage.rejectReasonPlaceholder'))
  468. cancelClicked.value = false // 重置按钮状态
  469. return
  470. }
  471. try {
  472. const params = {
  473. orderCode: currentRecord.value.orderCode,
  474. auditId: adminData.value.id,
  475. action: 2,
  476. rejectReason: rejectReason.value
  477. }
  478. await API({ url: '/audit/audit', data: params })
  479. ElMessage.success(t('elmessage.rejectSuccess'))
  480. rejectReasonDialogVisible.value = false
  481. await get()
  482. cancelClicked.value = false
  483. await getStats()
  484. console.log('看看驳回参数', params)
  485. } catch (error) {
  486. console.error(t('elmessage.rejectFailed'), error)
  487. ElMessage.error(t('elmessage.operationFailed'))
  488. }
  489. }
  490. // 确认驳回后显示理由输入框
  491. const showRejectReasonInput = () => {
  492. rejectDialogVisible.value = false // 关闭确认对话框
  493. rejectReasonDialogVisible.value = true // 打开驳回理由输入框
  494. }
  495. // 处理驳回取消操作
  496. const handleRejectCancel = () => {
  497. rejectDialogVisible.value = false
  498. }
  499. // 处理驳回关闭操作
  500. const handleRejectClose = () => {
  501. rejectDialogVisible.value = false
  502. }
  503. // 处理驳回理由对话框关闭和取消操作
  504. const handleRejectReasonCancel = () => {
  505. rejectReasonDialogVisible.value = false
  506. cancelClicked.value = false // 重置禁用状态
  507. rejectReason.value = '' // 清空驳回理由
  508. }
  509. const getStats = async () => {
  510. if (!hasrefundWaitShow) {
  511. return
  512. }
  513. try {
  514. const params = {
  515. pageNum: pagination.value.pageNum,
  516. pageSize: pagination.value.pageSize,
  517. refundAudit: {
  518. ...searchForm.value,
  519. flag: flag.value
  520. }
  521. }
  522. if (searchForm.value.jwcode) {
  523. // 纯数字
  524. const numberRegex = /^\d{1,9}$/;
  525. // 检查是否不是数字
  526. if (!numberRegex.test(searchForm.value.jwcode)) {
  527. // ElMessage.error('精网号必须为数字格式')
  528. // 上面提示过了
  529. return
  530. }
  531. }
  532. const res = await API({
  533. url: '/audit/sumRefundGold',
  534. data: params
  535. })
  536. stats.value.totalNum = res.totalNum
  537. stats.value.permanentGolds = res.permanentGolds / 100
  538. stats.value.freeGolds = res.freeGolds / 100
  539. stats.value.taskGolds = res.taskGolds / 100
  540. console.log('see see stats和搜索对象', stats.value, params)
  541. } catch (error) {
  542. console.log('请求失败', error)
  543. }
  544. }
  545. // 搜索
  546. const handleSearch = function () {
  547. trimJwCode()
  548. get()
  549. getStats()
  550. }
  551. // 重置
  552. const resetSearch = function () {
  553. const auditStatus = searchForm.value.auditStatus;
  554. searchForm.value = {
  555. jwcode: '',
  556. refundType: '',
  557. goodsName: '',
  558. market: "",
  559. startTime: '',
  560. endTime: '',
  561. sortField: '',
  562. sortOrder: '',
  563. auditStatus: auditStatus
  564. }
  565. // 重置页码
  566. pagination.value.pageNum = 1
  567. dateRange.value = []
  568. activeTimeRange.value = '' // 清除激活状态
  569. selectedMarketPath.value = []
  570. get()
  571. getStats()
  572. }
  573. // 今天
  574. const getToday = function () {
  575. const today = dayjs()
  576. const startTime = today.startOf('day').format('YYYY-MM-DD HH:mm:ss')
  577. const endTime = today.endOf('day').format('YYYY-MM-DD HH:mm:ss')
  578. dateRange.value = [startTime, endTime]
  579. console.log('dateRange', dateRange.value)
  580. activeTimeRange.value = 'today'
  581. get()
  582. getStats()
  583. }
  584. // 昨天
  585. const getYesterday = function () {
  586. const today = dayjs()
  587. const startTime = today.subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
  588. const endTime = today.subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
  589. dateRange.value = [startTime, endTime]
  590. console.log('dateRange', dateRange.value)
  591. activeTimeRange.value = 'yesterday'
  592. get()
  593. getStats()
  594. }
  595. // 近7天
  596. const get7Days = function () {
  597. const today = dayjs()
  598. const startTime = today.subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
  599. const endTime = today.endOf('day').format('YYYY-MM-DD HH:mm:ss')
  600. dateRange.value = [startTime, endTime]
  601. console.log('dateRange', dateRange.value)
  602. activeTimeRange.value = '7days'
  603. get()
  604. getStats()
  605. }
  606. const handleButtonClick = function (name) {
  607. activeName.value = name
  608. if (name === 'wait') {
  609. if (!hasrefundWait) {
  610. ElMessage.error(t('elmessage.noPermission'))
  611. return
  612. }
  613. if (hasrefundWaitShow) {
  614. adminWait()
  615. }
  616. } else if (name === 'pass') {
  617. if (!hasrefundThrough) {
  618. ElMessage.error(t('elmessage.noPermission'))
  619. return
  620. }
  621. adminPass()
  622. } else if (name === 'reject') {
  623. if (!hasrefundReject) {
  624. ElMessage.error(t('elmessage.noPermission'))
  625. return
  626. }
  627. adminReject()
  628. } else if (name === 'change') {
  629. if (!hasrefundWait) {
  630. ElMessage.error(t('elmessage.noPermission'))
  631. return
  632. }
  633. if (hasrefundWaitShow) {
  634. adminChange()
  635. }
  636. }
  637. }
  638. // const handleClick = function (tab, event) {
  639. // activeName.value = tab.props.name
  640. // if (tab.props.name === 'wait') {
  641. // console.log(hasrefundWait.value);
  642. // if (!hasrefundWait) {
  643. // ElMessage.error('暂无权限')
  644. // return
  645. // }
  646. // adminWait()
  647. // } else if (tab.props.name === 'pass') {
  648. // if (!hasrefundThrough.value) {
  649. // ElMessage.error('暂无权限')
  650. // return
  651. // }
  652. // adminPass()
  653. // } else if (tab.props.name === 'reject') {
  654. // if (!hasrefundReject) {
  655. // ElMessage.error('暂无权限')
  656. // return
  657. // }
  658. // adminReject()
  659. // }
  660. // }
  661. // 待审核
  662. const adminWait = async function () {
  663. checkTab.value = 'pending'
  664. searchForm.value.auditStatus = STATUS.PENDING
  665. await get()
  666. await getStats()
  667. }
  668. // 待处理(红包)
  669. const adminChange = async function () {
  670. checkTab.value = 'change'
  671. searchForm.value.auditStatus = STATUS.WAIT_HANDLE
  672. await get()
  673. await getStats()
  674. }
  675. // 已通过
  676. const adminPass = async function () {
  677. checkTab.value = 'pass'
  678. searchForm.value.auditStatus = STATUS.APPROVED
  679. sortField.value = ''
  680. sortOrder.value = ''
  681. await get()
  682. await getStats()
  683. }
  684. // 已驳回
  685. const adminReject = async function () {
  686. checkTab.value = 'reject'
  687. searchForm.value.auditStatus = STATUS.REJECTED
  688. sortField.value = ''
  689. sortOrder.value = ''
  690. await get()
  691. await getStats()
  692. }
  693. const selectedMarketPath = ref("")
  694. const handleMarketChange = (value) => {
  695. if (value && value.length > 0) {
  696. const lastValue = value[value.length - 1]
  697. searchForm.value.market = reverseMarketMapping[lastValue]
  698. } else {
  699. searchForm.value.market = ''
  700. }
  701. }
  702. // 获取地区,修改为级联下拉框
  703. const getMarket = async function () {
  704. try {
  705. const result = await API({
  706. url: '/market/selectMarket',
  707. })
  708. console.log('请求成功', result)
  709. // 递归转换树形结构为级联选择器需要的格式(跳过第一级节点)
  710. const transformTree = (nodes) => {
  711. // 直接处理第一级节点的子节点
  712. const allChildren = nodes.flatMap(node => node.children || []);
  713. return allChildren.map(child => {
  714. const grandchildren = child.children && child.children.length
  715. ? transformTree([child]) // 递归处理子节点
  716. : null;
  717. return {
  718. value: child.name,
  719. label: child.name,
  720. children: grandchildren
  721. };
  722. });
  723. };
  724. market.value = transformTree(result.data)
  725. console.log('转换后的地区树==============', market.value)
  726. } catch (error) {
  727. console.log('请求失败', error)
  728. }
  729. }
  730. const trimJwCode = () => {
  731. if (searchForm.value.jwcode) {
  732. searchForm.value.jwcode = searchForm.value.jwcode.replace(/\s/g, '');
  733. }
  734. }
  735. // 日期选择器变化时清除按钮激活状态
  736. const handleDatePickerChange = () => {
  737. activeTimeRange.value = ''
  738. }
  739. const format3 = (num) => {
  740. // 每三位添加逗号
  741. return num.toLocaleString('en-US')
  742. }
  743. // 表单验证
  744. const rules = reactive({
  745. reason: [{ required: true, message: '请输入驳回理由', trigger: 'blur' }]
  746. })
  747. const handlePageSizeChange = function (val) {
  748. pagination.value.pageSize = val
  749. tableRef.value.setScrollTop(0)
  750. get()
  751. }
  752. const handleCurrentChange = function (val) {
  753. pagination.value.pageNum = val
  754. tableRef.value.setScrollTop(0)
  755. get()
  756. }
  757. onMounted(async () => {
  758. await initPermissions()
  759. if (hasrefundWaitShow.value) {
  760. searchForm.value.auditStatus = '0'
  761. } else if (hasrefundThrough.value) {
  762. searchForm.value.auditStatus = '1'
  763. } else if (hasrefundReject) {
  764. searchForm.value.auditStatus = '2'
  765. }
  766. getRefundGoods()
  767. await getMarket()
  768. await get()
  769. await getStats()
  770. })
  771. </script>
  772. <style scoped lang="scss">
  773. .pagination {
  774. display: flex;
  775. margin-top: 1vh;
  776. }
  777. .operation {
  778. display: flex;
  779. }
  780. // 搜索的卡片样式
  781. .card1 {
  782. background: #F3FAFE;
  783. }
  784. // 表单的卡片样式
  785. .card2 {
  786. background: #E7F4FD;
  787. }
  788. // 新币总数等等
  789. .goldStatistics {
  790. margin-left: 1vw;
  791. margin-bottom: 1vh;
  792. color: #000000;
  793. font-family: "PingFang SC";
  794. font-size: 16px;
  795. font-style: normal;
  796. font-weight: 700;
  797. line-height: 20px;
  798. }
  799. // 表头背景等
  800. :deep(.el-table__header-wrapper),
  801. :deep(.el-table__body-wrapper),
  802. :deep(.el-table__cell),
  803. /* 表格 */
  804. :deep(.el-table__body td) {
  805. background-color: #F3FAFE !important;
  806. }
  807. /* 表头 */
  808. :deep(.el-table__header th) {
  809. background-color: #F3FAFE !important;
  810. }
  811. /* 鼠标悬停 */
  812. :deep(.el-table__row:hover > .el-table__cell) {
  813. background-color: #E5EBFE !important;
  814. }
  815. /* 自定义按钮组布局 */
  816. .custom-button-group {
  817. display: flex;
  818. margin-bottom: 16px;
  819. }
  820. /* 自定义激活状态样式 - 使用正确的Element Plus类选择器 */
  821. :deep(.el-button.custom-tab-button.el-button--primary) {
  822. background-color: #2741DE !important;
  823. border-color: #2741DE !important;
  824. color: #F3FAFE !important;
  825. }
  826. /* 鼠标悬停效果 */
  827. :deep(.el-button.custom-tab-button:hover:not(.is-disabled)) {
  828. opacity: 0.8;
  829. }
  830. .select {
  831. display: flex;
  832. .selectRow {
  833. width: 17vw;
  834. display: flex;
  835. align-items: center;
  836. justify-content: center;
  837. padding: 0 0.5vw;
  838. .text {
  839. width: 5vw;
  840. font-size: 15px;
  841. }
  842. .selectContent {
  843. flex: 1;
  844. }
  845. }
  846. }
  847. </style>