Wishes.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div class="page-container">
  3. <el-card>
  4. <div slot="header">
  5. <span>心愿管理</span>
  6. <el-button
  7. type="primary"
  8. size="small"
  9. style="float: right"
  10. @click="handleRefresh"
  11. :loading="loading"
  12. >
  13. 刷新
  14. </el-button>
  15. </div>
  16. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  17. <!-- 待处理列表 -->
  18. <el-tab-pane label="待处理" name="pending">
  19. <!-- 统计卡片 -->
  20. <el-row :gutter="20" style="margin-bottom: 20px">
  21. <el-col :span="6">
  22. <el-card shadow="hover" class="stat-card draft">
  23. <div class="stat-num">{{ draftCount }}</div>
  24. <div class="stat-label">待定价</div>
  25. </el-card>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-card shadow="hover" class="stat-card pending">
  29. <div class="stat-num">{{ pendingCount }}</div>
  30. <div class="stat-label">待审批</div>
  31. </el-card>
  32. </el-col>
  33. <el-col :span="6">
  34. <el-card shadow="hover" class="stat-card approved">
  35. <div class="stat-num">{{ approvedCount }}</div>
  36. <div class="stat-label">待兑现</div>
  37. </el-card>
  38. </el-col>
  39. <el-col :span="6">
  40. <el-card shadow="hover" class="stat-card exchanging">
  41. <div class="stat-num">{{ exchangingCount }}</div>
  42. <div class="stat-label">待收货</div>
  43. </el-card>
  44. </el-col>
  45. </el-row>
  46. <!-- 待定价列表 -->
  47. <div v-if="draftWishes.length > 0" class="wish-section">
  48. <div class="section-title">📝 待定价</div>
  49. <div class="adm-table-wrap">
  50. <el-table style="width: 100%" height="100%" :data="draftWishes" border v-loading="loading">
  51. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  52. <el-table-column prop="childName" label="孩子" width="100"></el-table-column>
  53. <el-table-column prop="title" label="心愿名称" min-width="200"></el-table-column>
  54. <el-table-column prop="category" label="分类" width="100"></el-table-column>
  55. <el-table-column prop="createdAt" label="创建时间" width="180">
  56. <template slot-scope="scope">
  57. {{ formatDate(scope.row.createdAt) }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="操作" width="200" fixed="right">
  61. <template slot-scope="{ row }">
  62. <el-button size="mini" type="primary" @click="showPriceDialog(row)">定价</el-button>
  63. <el-dropdown trigger="hover" @command="(cmd) => handleActionCmd(row, cmd)">
  64. <el-button size="mini">
  65. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  66. </el-button>
  67. <el-dropdown-menu slot="dropdown">
  68. <el-dropdown-item command="reject" icon="el-icon-close">拒绝</el-dropdown-item>
  69. </el-dropdown-menu>
  70. </el-dropdown>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. </div>
  76. <!-- 待审批兑换列表 -->
  77. <div v-if="pendingExchangeWishes.length > 0" class="wish-section">
  78. <div class="section-title">⏳ 待审批兑换</div>
  79. <div class="adm-table-wrap">
  80. <el-table :data="pendingExchangeWishes" border v-loading="loading" style="width: 100%" height="100%">
  81. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  82. <el-table-column prop="childName" label="孩子" width="100"></el-table-column>
  83. <el-table-column prop="title" label="心愿名称" min-width="200"></el-table-column>
  84. <el-table-column prop="pointsRequired" label="所需积分" width="120">
  85. <template slot-scope="scope">
  86. <el-tag type="warning">{{ scope.row.pointsRequired }}</el-tag>
  87. </template>
  88. </el-table-column>
  89. <el-table-column prop="exchangeRequestedAt" label="申请时间" width="180">
  90. <template slot-scope="scope">
  91. {{ formatDate(scope.row.exchangeRequestedAt) }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="操作" width="200" fixed="right">
  95. <template slot-scope="{ row }">
  96. <el-button size="mini" type="primary" @click="handleApproveExchange(row, true)">批准</el-button>
  97. <el-dropdown trigger="hover" @command="(cmd) => handleActionCmd(row, cmd)">
  98. <el-button size="mini">
  99. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  100. </el-button>
  101. <el-dropdown-menu slot="dropdown">
  102. <el-dropdown-item command="rejectExchange" icon="el-icon-close">拒绝</el-dropdown-item>
  103. </el-dropdown-menu>
  104. </el-dropdown>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </div>
  109. </div>
  110. <!-- 待兑现列表 -->
  111. <div v-if="approvedWishes.length > 0" class="wish-section">
  112. <div class="section-title">📦 待兑现</div>
  113. <div class="adm-table-wrap">
  114. <el-table :data="approvedWishes" border v-loading="loading" style="width: 100%" height="100%">
  115. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  116. <el-table-column prop="childName" label="孩子" width="100"></el-table-column>
  117. <el-table-column prop="title" label="心愿名称" min-width="200"></el-table-column>
  118. <el-table-column prop="pointsRequired" label="已扣积分" width="120">
  119. <template slot-scope="scope">
  120. <el-tag type="success">{{ scope.row.pointsRequired }}</el-tag>
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="exchangeApprovedAt" label="批准时间" width="180">
  124. <template slot-scope="scope">
  125. {{ formatDate(scope.row.exchangeApprovedAt) }}
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" width="120" fixed="right">
  129. <template slot-scope="{ row }">
  130. <el-button size="mini" @click="handleFulfill(row)">已购买</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. </div>
  136. <!-- 待收货列表 -->
  137. <div v-if="exchangingWishes.length > 0" class="wish-section">
  138. <div class="section-title">🎁 待收货确认</div>
  139. <div class="adm-table-wrap">
  140. <el-table :data="exchangingWishes" border v-loading="loading" style="width: 100%" height="100%">
  141. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  142. <el-table-column prop="childName" label="孩子" width="100"></el-table-column>
  143. <el-table-column prop="title" label="心愿名称" min-width="200"></el-table-column>
  144. <el-table-column prop="fulfilledAt" label="购买时间" width="180">
  145. <template slot-scope="scope">
  146. {{ formatDate(scope.row.fulfilledAt) }}
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="状态" width="100">
  150. <template slot-scope="scope">
  151. <StatusTag type="info" text="等待确认" />
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. </div>
  156. </div>
  157. <!-- 空状态 -->
  158. <el-empty v-if="pendingWishes.length === 0" description="暂无待处理心愿"></el-empty>
  159. </el-tab-pane>
  160. <!-- 全部心愿 -->
  161. <el-tab-pane label="全部心愿" name="all">
  162. <!-- 搜索筛选 -->
  163. <el-form :inline="true" :model="searchForm" style="margin-bottom: 20px">
  164. <el-form-item label="家庭">
  165. <el-input
  166. v-model="searchForm.familyName"
  167. placeholder="点击选择家庭"
  168. readonly
  169. @click.native="showFamilySelector"
  170. >
  171. <el-button
  172. slot="append"
  173. icon="el-icon-close"
  174. v-if="searchForm.familyId"
  175. @click.stop="clearFamily"
  176. style="padding: 8px"
  177. ></el-button>
  178. <i slot="suffix" class="el-input__icon el-icon-arrow-down" @click.stop="showFamilySelector"></i>
  179. </el-input>
  180. </el-form-item>
  181. <el-form-item label="状态">
  182. <el-select v-model="searchForm.status" placeholder="全部状态" clearable @change="handleSearch">
  183. <el-option label="待定价" value="draft"></el-option>
  184. <el-option label="积攒中" value="active"></el-option>
  185. <el-option label="待审批" value="pending_exchange"></el-option>
  186. <el-option label="已批准" value="approved"></el-option>
  187. <el-option label="待收货" value="exchanging"></el-option>
  188. <el-option label="已完成" value="fulfilled"></el-option>
  189. <el-option label="已拒绝" value="rejected"></el-option>
  190. <el-option label="已取消" value="cancelled"></el-option>
  191. </el-select>
  192. </el-form-item>
  193. <el-form-item>
  194. <el-button type="primary" @click="handleSearch">搜索</el-button>
  195. <el-button @click="handleReset">重置</el-button>
  196. </el-form-item>
  197. </el-form>
  198. <!-- 家庭选择对话框 -->
  199. <el-dialog title="选择家庭" :visible.sync="familyDialogVisible" width="600px">
  200. <el-table :data="familyList" border v-loading="familyLoading" @row-click="selectFamily" style="cursor: pointer" :max-height="300">
  201. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  202. <el-table-column prop="name" label="家庭名称" min-width="150"></el-table-column>
  203. <el-table-column prop="inviteCode" label="邀请码" width="120"></el-table-column>
  204. <el-pagination
  205. style="margin-top: 15px; text-align: right"
  206. @current-change="loadFamilies"
  207. :current-page="familyPagination.current"
  208. :page-size="familyPagination.size"
  209. :total="familyPagination.total"
  210. layout="total, prev, pager, next"
  211. ></el-pagination>
  212. </el-dialog>
  213. <div class="adm-table-wrap">
  214. <el-table :data="tableData" border v-loading="loading" style="width: 100%" height="100%">
  215. <el-table-column prop="id" label="ID" width="80">
  216. <template slot="header">
  217. <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
  218. </template>
  219. </el-table-column>
  220. <el-table-column prop="childName" label="孩子" width="100">
  221. <template slot="header">
  222. <span class="sort-header" @click.stop="onSortClick('childName', $event)">孩子<span v-if="sortIndex('childName') !== null" class="sort-index" :class="sortClass('childName') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('childName') }}</span>{{ sortIcon('childName') }}</span>
  223. </template>
  224. </el-table-column>
  225. <el-table-column prop="title" label="心愿名称" min-width="200">
  226. <template slot="header">
  227. <span class="sort-header" @click.stop="onSortClick('title', $event)">心愿名称<span v-if="sortIndex('title') !== null" class="sort-index" :class="sortClass('title') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('title') }}</span>{{ sortIcon('title') }}</span>
  228. </template>
  229. </el-table-column>
  230. <el-table-column prop="pointsRequired" label="所需积分" width="120">
  231. <template slot-scope="scope">
  232. <el-tag v-if="scope.row.pointsRequired" type="warning">{{ scope.row.pointsRequired }}</el-tag>
  233. <span v-else class="no-price">未定价</span>
  234. </template>
  235. <template slot="header">
  236. <span class="sort-header" @click.stop="onSortClick('pointsRequired', $event)">所需积分<span v-if="sortIndex('pointsRequired') !== null" class="sort-index" :class="sortClass('pointsRequired') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('pointsRequired') }}</span>{{ sortIcon('pointsRequired') }}</span>
  237. </template>
  238. </el-table-column>
  239. <el-table-column prop="category" label="分类" width="100">
  240. <template slot="header">
  241. <span class="sort-header" @click.stop="onSortClick('category', $event)">分类<span v-if="sortIndex('category') !== null" class="sort-index" :class="sortClass('category') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('category') }}</span>{{ sortIcon('category') }}</span>
  242. </template>
  243. </el-table-column>
  244. <el-table-column prop="status" label="状态" width="100">
  245. <template slot-scope="scope">
  246. <el-tag :type="getStatusType(scope.row.status)" size="small">
  247. {{ scope.row.statusText }}
  248. </el-tag>
  249. </template>
  250. <template slot="header">
  251. <span class="sort-header" @click.stop="onSortClick('status', $event)">状态<span v-if="sortIndex('status') !== null" class="sort-index" :class="sortClass('status') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('status') }}</span>{{ sortIcon('status') }}</span>
  252. </template>
  253. </el-table-column>
  254. <el-table-column prop="creatorType" label="创建者" width="80">
  255. <template slot-scope="scope">
  256. <el-tag :type="scope.row.creatorType === 'parent' ? 'primary' : 'success'" size="small">
  257. {{ scope.row.creatorType === 'parent' ? '家长' : '孩子' }}
  258. </el-tag>
  259. </template>
  260. <template slot="header">
  261. <span class="sort-header" @click.stop="onSortClick('creatorType', $event)">创建者<span v-if="sortIndex('creatorType') !== null" class="sort-index" :class="sortClass('creatorType') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('creatorType') }}</span>{{ sortIcon('creatorType') }}</span>
  262. </template>
  263. </el-table-column>
  264. <el-table-column prop="createdAt" label="创建时间" width="180">
  265. <template slot-scope="scope">
  266. {{ formatDate(scope.row.createdAt) }}
  267. </template>
  268. <template slot="header">
  269. <span class="sort-header" @click.stop="onSortClick('createdAt', $event)">创建时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
  270. </template>
  271. </el-table-column>
  272. </el-table>
  273. </div>
  274. <
  275. <
  276. <
  277. <
  278. <
  279. <el-pagination
  280. style="margin-top: 20px; text-align: right"
  281. @size-change="handleSizeChange"
  282. @current-change="handleCurrentChange"
  283. :current-page="pagination.current"
  284. :page-sizes="[10, 20, 50, 100]"
  285. :page-size="pagination.size"
  286. :total="pagination.total"
  287. layout="total, sizes, prev, pager, next, jumper"
  288. ></el-pagination>
  289. </el-tab-pane>
  290. </el-tabs>
  291. </el-card>
  292. <!-- 定价对话框 -->
  293. <el-dialog title="设置积分" :visible.sync="priceDialogVisible" width="400px">
  294. <el-form label-width="100px">
  295. <el-form-item label="心愿名称">
  296. <span>{{ currentWish && currentWish.title }}</span>
  297. </el-form-item>
  298. <el-form-item label="所需积分">
  299. <el-input-number v-model="priceValue" :min="1" :max="10000"></el-input-number>
  300. </el-form-item>
  301. </el-form>
  302. <div slot="footer">
  303. <el-button @click="priceDialogVisible = false">取消</el-button>
  304. <el-button type="primary" @click="submitPrice" :loading="submitting">确定</el-button>
  305. </div>
  306. </el-dialog>
  307. </el-table>
  308. </div>
  309. </template>
  310. <script>
  311. import SortMixin from '@/mixins/SortMixin'
  312. import {
  313. getWishesList,
  314. getPendingWishes,
  315. setWishPrice,
  316. rejectWish,
  317. approveWishExchange,
  318. markWishFulfilled,
  319. getFamilyList
  320. } from '@/api/admin'
  321. export default {
  322. name: 'Wishes',
  323. mixins: [SortMixin],
  324. data() {
  325. return {
  326. activeTab: 'pending',
  327. loading: false,
  328. submitting: false,
  329. tableData: [],
  330. sortableColumns: { id: 'ID', childName: '孩子', title: '心愿名称', pointsRequired: '所需积分', category: '分类', status: '状态', creatorType: '创建者', createdAt: '创建时间' },
  331. pendingWishes: [],
  332. searchForm: {
  333. status: '',
  334. familyId: '',
  335. familyName: ''
  336. },
  337. pagination: {
  338. current: 1,
  339. size: 10,
  340. total: 0
  341. },
  342. // 家庭选择对话框
  343. familyDialogVisible: false,
  344. familyLoading: false,
  345. familyList: [],
  346. familyPagination: {
  347. current: 1,
  348. size: 10,
  349. total: 0
  350. },
  351. // 定价对话框
  352. priceDialogVisible: false,
  353. currentWish: null,
  354. priceValue: 100
  355. }
  356. },
  357. computed: {
  358. tableHeight() {
  359. return window.innerHeight - 340
  360. },
  361. draftWishes() {
  362. return this.pendingWishes.filter(w => w.status === 'draft')
  363. },
  364. pendingExchangeWishes() {
  365. return this.pendingWishes.filter(w => w.status === 'pending_exchange')
  366. },
  367. approvedWishes() {
  368. return this.pendingWishes.filter(w => w.status === 'approved')
  369. },
  370. exchangingWishes() {
  371. return this.pendingWishes.filter(w => w.status === 'exchanging')
  372. },
  373. draftCount() { return this.draftWishes.length },
  374. pendingCount() { return this.pendingExchangeWishes.length },
  375. approvedCount() { return this.approvedWishes.length },
  376. exchangingCount() { return this.exchangingWishes.length }
  377. },
  378. mounted() {
  379. this.loadPendingWishes()
  380. },
  381. methods: {
  382. loadList() {
  383. this.loadWishes()
  384. },
  385. handleActionCmd(row, cmd) {
  386. switch (cmd) {
  387. case 'price': this.showPriceDialog(row); break;
  388. case 'reject': this.handleReject(row); break;
  389. case 'approve': this.handleApproveExchange(row, true); break;
  390. case 'rejectExchange': this.handleApproveExchange(row, false); break;
  391. case 'fulfill': this.handleFulfill(row); break;
  392. }
  393. },
  394. async loadPendingWishes() {
  395. this.loading = true
  396. try {
  397. // 获取当前用户家庭ID
  398. const familyId = localStorage.getItem('familyId')
  399. if (familyId) {
  400. const res = await getPendingWishes(familyId)
  401. this.pendingWishes = res.data || []
  402. }
  403. } catch (error) {
  404. this.$message.error(error.message || '加载待处理列表失败')
  405. } finally {
  406. this.loading = false
  407. }
  408. },
  409. async loadWishes() {
  410. this.loading = true
  411. try {
  412. const params = {
  413. page: this.pagination.current,
  414. size: this.pagination.size,
  415. familyId: this.searchForm.familyId || undefined,
  416. status: this.searchForm.status || undefined
  417. }
  418. if (this.sortState.length > 0) params.sort = this.sortState
  419. const res = await getWishesList(params)
  420. this.tableData = res.data.records || res.data || []
  421. this.pagination.total = res.data.total || this.tableData.length
  422. } catch (error) {
  423. this.$message.error(error.message || '加载心愿列表失败')
  424. } finally {
  425. this.loading = false
  426. }
  427. },
  428. async loadFamilies(page = 1) {
  429. this.familyLoading = true
  430. try {
  431. const res = await getFamilyList({ page, size: this.familyPagination.size })
  432. this.familyList = res.data.records || res.data || []
  433. this.familyPagination.total = res.data.total || this.familyList.length
  434. this.familyPagination.current = page
  435. } catch (error) {
  436. this.$message.error(error.message || '加载家庭列表失败')
  437. } finally {
  438. this.familyLoading = false
  439. }
  440. },
  441. selectFamily(row) {
  442. this.searchForm.familyId = row.id
  443. this.searchForm.familyName = row.name
  444. this.familyDialogVisible = false
  445. this.handleSearch()
  446. },
  447. showFamilySelector() {
  448. this.familyDialogVisible = true
  449. this.loadFamilies()
  450. },
  451. clearFamily() {
  452. this.searchForm.familyId = ''
  453. this.searchForm.familyName = ''
  454. this.handleSearch()
  455. },
  456. handleTabClick(tab) {
  457. if (tab.name === 'all' && this.tableData.length === 0) {
  458. this.loadWishes()
  459. }
  460. },
  461. handleSearch() {
  462. this.pagination.current = 1
  463. this.loadWishes()
  464. },
  465. handleReset() {
  466. this.searchForm = { status: '', familyId: '', familyName: '' }
  467. this.handleSearch()
  468. },
  469. handleRefresh() {
  470. if (this.activeTab === 'pending') {
  471. this.loadPendingWishes()
  472. } else {
  473. this.loadWishes()
  474. }
  475. },
  476. handleSizeChange(val) {
  477. this.pagination.size = val
  478. this.pagination.current = 1
  479. this.loadWishes()
  480. },
  481. handleCurrentChange(val) {
  482. this.pagination.current = val
  483. this.loadWishes()
  484. },
  485. showPriceDialog(wish) {
  486. this.currentWish = wish
  487. this.priceValue = wish.pointsRequired || 100
  488. this.priceDialogVisible = true
  489. },
  490. async submitPrice() {
  491. if (!this.priceValue || this.priceValue <= 0) {
  492. this.$message.warning('请输入有效积分')
  493. return
  494. }
  495. this.submitting = true
  496. try {
  497. await setWishPrice(this.currentWish.id, this.priceValue)
  498. this.$message.success('定价成功')
  499. this.priceDialogVisible = false
  500. this.loadPendingWishes()
  501. } catch (error) {
  502. this.$message.error(error.message || '定价失败')
  503. } finally {
  504. this.submitting = false
  505. }
  506. },
  507. async handleReject(row) {
  508. this.$confirm(`确定要拒绝 "${row.title}" 吗?`, '提示', {
  509. confirmButtonText: '确定',
  510. cancelButtonText: '取消',
  511. type: 'warning'
  512. }).then(async () => {
  513. try {
  514. await rejectWish(row.id, '不符合要求')
  515. this.$message.success('已拒绝')
  516. this.loadPendingWishes()
  517. } catch (error) {
  518. this.$message.error(error.message || '操作失败')
  519. }
  520. }).catch(() => {})
  521. },
  522. async handleApproveExchange(row, approved) {
  523. const action = approved ? '批准' : '拒绝'
  524. this.$confirm(`确定要${action} "${row.title}" 的兑换申请吗?`, '提示', {
  525. confirmButtonText: '确定',
  526. cancelButtonText: '取消',
  527. type: 'warning'
  528. }).then(async () => {
  529. try {
  530. await approveWishExchange(row.id, approved)
  531. this.$message.success(`已${action}`)
  532. this.loadPendingWishes()
  533. } catch (error) {
  534. this.$message.error(error.message || '操作失败')
  535. }
  536. }).catch(() => {})
  537. },
  538. async handleFulfill(row) {
  539. this.$confirm(`确定已购买 "${row.title}" 吗?`, '提示', {
  540. confirmButtonText: '确定',
  541. cancelButtonText: '取消',
  542. type: 'warning'
  543. }).then(async () => {
  544. try {
  545. await markWishFulfilled(row.id)
  546. this.$message.success('已标记')
  547. this.loadPendingWishes()
  548. } catch (error) {
  549. this.$message.error(error.message || '操作失败')
  550. }
  551. }).catch(() => {})
  552. },
  553. getStatusType(status) {
  554. const types = {
  555. draft: 'info',
  556. active: 'success',
  557. pending_exchange: 'warning',
  558. approved: 'primary',
  559. exchanging: 'primary',
  560. fulfilled: 'success',
  561. cancelled: 'info',
  562. rejected: 'danger'
  563. }
  564. return types[status] || 'info'
  565. },
  566. }
  567. }
  568. </script>
  569. <style scoped>
  570. .stat-card {
  571. text-align: center;
  572. cursor: pointer;
  573. }
  574. .stat-card.draft { border-top: 3px solid #909399; }
  575. .stat-card.pending { border-top: 3px solid #E6A23C; }
  576. .stat-card.approved { border-top: 3px solid #409EFF; }
  577. .stat-card.exchanging { border-top: 3px solid #409EFF; }
  578. .stat-num {
  579. font-size: 32px;
  580. font-weight: bold;
  581. color: #333;
  582. }
  583. .stat-label {
  584. font-size: 14px;
  585. color: #666;
  586. margin-top: 5px;
  587. }
  588. .wish-section {
  589. margin-bottom: 30px;
  590. }
  591. .section-title {
  592. font-size: 16px;
  593. font-weight: bold;
  594. margin-bottom: 15px;
  595. color: #333;
  596. }
  597. .no-price {
  598. color: #999;
  599. font-size: 12px;
  600. }
  601. .sort-header {
  602. cursor: pointer;
  603. user-select: none;
  604. font-weight: 500;
  605. font-size: 12px;
  606. white-space: nowrap;
  607. }
  608. .sort-header:hover {
  609. color: #409eff;
  610. }
  611. </style>