Wishes.vue 25 KB

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