index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="payreturnPage">
  3. <!-- 搜索 -->
  4. <div class="formSearch">
  5. <!-- 搜索条件 -->
  6. <el-form :inline="true" :model="query" class="demo-form-inline">
  7. <el-form-item label="俱乐部名称">
  8. <el-input clearable v-model="query.name" placeholder="请输入活动名称" />
  9. </el-form-item>
  10. <el-form-item label="俱乐部区域编码">
  11. <el-cascader clearable style="width: 100%" v-model="query.areaCode" :props="regionProps" placeholder="请选择区域"></el-cascader>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" plain @click="search">查询</el-button>
  15. <el-button plain @click="clear">重置</el-button>
  16. <el-button type="primary" plain @click="$refs.clubModalRef && $refs.clubModalRef.show()">新增俱乐部</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </div>
  20. <!-- 表格 -->
  21. <div class="tableBox">
  22. <el-table ref="multipleTable" :data="tableData" border :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark" style="width: 100%">
  23. <el-table-column align="center" type="index" label="#" width="55"></el-table-column>
  24. <el-table-column prop="name" label="俱乐部名称" align="center" width="220" />
  25. <el-table-column prop="maxNumber" label="最大人数" align="center">
  26. <template slot-scope="scope">
  27. <el-tag size="mini">{{ scope.row.maxNumber || '未设置' }} 人</el-tag>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="currentNumber" label="当前人数" align="center">
  31. <template slot-scope="scope">
  32. <el-tag type="success" size="mini">{{ scope.row.currentNumber || '0' }} 人</el-tag>
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="areaCode" label="俱乐部区域编码" align="center">
  36. <template slot-scope="scope">
  37. <span v-if="!scope.row.areaCode">---</span>
  38. <el-tag type="info" size="mini">{{ scope.row.areaCode == 0 ? '全国' : scope.row.areaCode }}</el-tag>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="createTime" label="俱乐部创建时间" align="center" width="220" />
  42. <el-table-column width="280" label="操作" align="center" show-overflow-tooltip>
  43. <template slot-scope="scope">
  44. <div class="btnList">
  45. <el-button type="text" @click="$refs.clubModalRef && $refs.clubModalRef.show(scope.row)">编辑</el-button>
  46. <el-button type="text" @click="$refs.detailModalRef && $refs.detailModalRef.show(scope.row.id)">详情</el-button>
  47. <el-button type="text" style="color: #f56c6c" @click="handleDelete(scope.row)">删除</el-button>
  48. </div>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <div class="fenye">
  53. <el-pagination
  54. :current-page="query.page"
  55. :page-sizes="[10, 20, 50, 100]"
  56. :page-size="10"
  57. layout="total, sizes, prev, pager, next, jumper"
  58. :total="total"
  59. @size-change="handleSizeChange"
  60. @current-change="handleCurrentChange"
  61. />
  62. </div>
  63. </div>
  64. <DetailModal ref="detailModalRef"></DetailModal>
  65. <ClubModal @success="getAll" ref="clubModalRef"></ClubModal>
  66. </div>
  67. </template>
  68. <script>
  69. import { getClubListApi, deleteClubApi } from '@/api/rm-bank'
  70. import ClubModal from './components/ClubModal.vue'
  71. import DetailModal from './components/DetailModal.vue'
  72. import { getProvinceList, getChildAreaList } from '@/api/address'
  73. export default {
  74. components: {
  75. DetailModal,
  76. ClubModal
  77. },
  78. data() {
  79. return {
  80. query: {
  81. page: 1,
  82. pageSize: 10,
  83. name: undefined,
  84. areaCode: []
  85. },
  86. total: 1,
  87. tableData: [],
  88. regionProps: {
  89. checkStrictly: true,
  90. lazy: true,
  91. label: 'name',
  92. value: 'id',
  93. lazyLoad(node, resolve) {
  94. const { level, value } = node
  95. if (level === 0) {
  96. resolve([{ id: 0, parentId: 0, name: '全中国', shortName: '全国', longitude: '108.55', latitude: '34.32', level: 1, sort: 1, status: true }])
  97. } else if (level === 1) {
  98. getProvinceList().then((res) => {
  99. resolve(res.data)
  100. })
  101. } else if (level != 0 && level != 1) {
  102. getChildAreaList(value).then((res) => {
  103. resolve(
  104. res.data.map((item) => {
  105. item.leaf = level === 4
  106. return item
  107. })
  108. )
  109. })
  110. }
  111. }
  112. }
  113. }
  114. },
  115. created() {
  116. this.getAll()
  117. },
  118. methods: {
  119. async getAll() {
  120. const queryParams = JSON.parse(JSON.stringify(this.query))
  121. const { name, areaCode } = queryParams
  122. if (name) {
  123. queryParams['club.name'] = name
  124. }
  125. if (areaCode.length) {
  126. queryParams['club.areaCode'] = areaCode[areaCode.length - 1]
  127. }
  128. delete queryParams.name
  129. delete queryParams.areaCode
  130. const res = await getClubListApi(queryParams)
  131. this.tableData = res.data.list
  132. this.total = res.data.total
  133. },
  134. handleSizeChange(val) {
  135. this.query.pageSize = val
  136. this.getAll()
  137. },
  138. handleCurrentChange(val) {
  139. this.query.page = val
  140. this.getAll()
  141. },
  142. search() {
  143. this.total = 1
  144. this.query.page = 1
  145. this.getAll()
  146. },
  147. clear() {
  148. this.query = {
  149. page: 1,
  150. pageSize: 10,
  151. name: '',
  152. areaCode: []
  153. }
  154. this.getAll()
  155. },
  156. // 删除
  157. async handleDelete(row) {
  158. this.$confirm(`是否删除【${row.name}】这个俱乐部?`, '提示', {
  159. confirmButtonText: '确定',
  160. cancelButtonText: '取消',
  161. type: 'warning'
  162. })
  163. .then(async () => {
  164. const res = await deleteClubApi({ id: row.id })
  165. if (res.code == '200') {
  166. this.$message.success('删除成功')
  167. this.getAll()
  168. }
  169. })
  170. .catch(() => {})
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .payreturnPage {
  177. padding: 30px;
  178. .tableBox {
  179. .fenye {
  180. margin: 20px;
  181. }
  182. }
  183. }
  184. </style>