List.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="supply-manage-list">
  3. <el-card>
  4. <div slot="header">
  5. <span>供应商管理</span>
  6. <el-button style="float: right" type="primary" size="small" @click="$router.push('/supply-manage/create')">+ 新增供应商</el-button>
  7. </div>
  8. <el-form :inline="true" style="margin-bottom: 15px;">
  9. <el-form-item>
  10. <el-input v-model="searchKeyword" placeholder="搜索手机号/昵称/姓名" clearable @clear="loadData" @keyup.enter.native="loadData">
  11. <i slot="prefix" class="el-icon-search"></i>
  12. </el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-select v-model="searchVendorStatus" placeholder="服务商状态" clearable style="width: 150px" @change="loadData">
  16. <el-option label="待审核" value="pending"></el-option>
  17. <el-option label="已通过" value="approved"></el-option>
  18. <el-option label="已拒绝" value="rejected"></el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="loadData" :loading="loading">查询</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <div style="overflow:auto;max-height:calc(100vh - 300px);">
  26. <el-table :data="suppliers" stripe v-loading="loading" style="max-height:calc(100vh - 300px);">
  27. <el-table-column prop="id" label="ID" width="70"></el-table-column>
  28. <el-table-column prop="nickname" label="昵称" width="130"></el-table-column>
  29. <el-table-column prop="realName" label="真实姓名" width="120"></el-table-column>
  30. <el-table-column prop="phone" label="手机号" width="130"></el-table-column>
  31. <el-table-column label="服务商类型" width="130">
  32. <template slot-scope="scope">
  33. <el-tag size="small">{{ getVendorTypeLabel(scope.row.vendorType) }}</el-tag>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="服务商状态" width="100">
  37. <template slot-scope="scope">
  38. <el-tag :type="getStatusType(scope.row.vendorStatus)" size="small">
  39. {{ getStatusLabel(scope.row.vendorStatus) }}
  40. </el-tag>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="createdAt" label="创建时间" width="170">
  44. <template slot-scope="scope">{{ scope.row.createdAt | parseTime('{y}-{m}-{d} {h}:{i}') }}</template>
  45. </el-table-column>
  46. <el-table-column label="操作" width="220" fixed="right">
  47. <template slot-scope="scope">
  48. <el-button size="mini" type="primary" @click="viewDetail(scope.row)">详情</el-button>
  49. <el-button size="mini" @click="$router.push('/supply-manage/' + scope.row.id + '/edit')">编辑</el-button>
  50. <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. </div>
  55. <el-pagination
  56. v-if="total > 0"
  57. style="margin-top: 15px; text-align: right"
  58. background
  59. layout="total, prev, pager, next"
  60. :total="total"
  61. :page-size="pageSize"
  62. :current-page="page"
  63. @current-change="handlePageChange">
  64. </el-pagination>
  65. </el-card>
  66. </div>
  67. </template>
  68. <script>
  69. import { getSupplyManageList, deleteSupplyManage } from '@/api/admin'
  70. export default {
  71. name: 'SupplyManageList',
  72. data() {
  73. return {
  74. suppliers: [],
  75. loading: false,
  76. searchKeyword: '',
  77. searchVendorStatus: '',
  78. page: 1,
  79. pageSize: 10,
  80. total: 0
  81. }
  82. },
  83. created() {
  84. this.loadData()
  85. },
  86. methods: {
  87. async loadData() {
  88. this.loading = true
  89. try {
  90. const res = await getSupplyManageList({
  91. keyword: this.searchKeyword,
  92. vendorStatus: this.searchVendorStatus,
  93. page: this.page,
  94. size: this.pageSize
  95. })
  96. if (res.data) {
  97. this.suppliers = res.data.list || []
  98. this.total = res.data.total || 0
  99. }
  100. } catch (e) {
  101. this.$message.error('加载失败')
  102. } finally {
  103. this.loading = false
  104. }
  105. },
  106. handlePageChange(val) {
  107. this.page = val
  108. this.loadData()
  109. },
  110. async handleDelete(row) {
  111. try {
  112. await this.$confirm('确定要删除该供应商吗?', '提示', { type: 'warning' })
  113. await deleteSupplyManage({ id: row.id })
  114. this.$message.success('删除成功')
  115. this.loadData()
  116. } catch (e) {
  117. if (e !== 'cancel') {
  118. this.$message.error('删除失败')
  119. }
  120. }
  121. },
  122. viewDetail(row) {
  123. this.$router.push('/supply-manage/' + row.id)
  124. },
  125. getVendorTypeLabel(type) {
  126. const map = {
  127. planner: '成长规划师',
  128. activity_provider: '活动规划师',
  129. product_supplier: '商品供应商'
  130. }
  131. return map[type] || '-'
  132. },
  133. getStatusLabel(status) {
  134. const map = {
  135. pending: '待审核',
  136. approved: '已通过',
  137. rejected: '已拒绝',
  138. null: '-',
  139. '': '-'
  140. }
  141. return map[status] || status || '-'
  142. },
  143. getStatusType(status) {
  144. const map = {
  145. pending: 'warning',
  146. approved: 'success',
  147. rejected: 'danger'
  148. }
  149. return map[status] || 'info'
  150. }
  151. }
  152. }
  153. </script>
  154. <style scoped>
  155. .supply-manage-list {
  156. padding: 20px;
  157. }
  158. </style>