query.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <el-card shadow="never" class="aui-card--fill">
  3. <div class="mod-home">
  4. <div class="page-title">{{ pageTitle }}</div>
  5. <div class="query">
  6. <div class="query-left">
  7. <el-form :inline="true" :model="queryParams" @keyup.enter.native="getList">
  8. <el-form-item label="善行少年编号" style="margin-right: 50px;">
  9. <el-input v-model="queryParams.uniqueNo" placeholder="请输入"></el-input>
  10. </el-form-item>
  11. <el-form-item label="用户名" style="margin-right: 50px;">
  12. <el-input v-model="queryParams.realName" placeholder="请输入"></el-input>
  13. </el-form-item>
  14. <el-form-item label="渠道方">
  15. <el-select v-model="queryParams.channelId" placeholder="请选择渠道方" class="select-box">
  16. <el-option v-for="item in channelOptions" :key="item.id" :label="item.channelName" :value="item.id"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. </el-form>
  20. </div>
  21. <div class="query-right">
  22. <div class="form-btns">
  23. <el-button type="primary" @click="getList">查询</el-button>
  24. <el-button type="default" @click="reset" style="margin-left: 24px;">重置</el-button>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="table-title adfacjb">
  29. <div class="table-title-left">会员列表共({{ total }})人</div>
  30. <div class="table-title-right adfac">
  31. <el-button type="default" @click="handleDownloadTieket" v-if="$hasPermission('core:appuser:downloadTicket')">下载专享券导入模板</el-button>
  32. <el-upload v-if="$hasPermission('core:appuser:importTicket')"
  33. :action="uploadUrl"
  34. :headers="uploadHeaders"
  35. :on-success="uploadFileSuccess"
  36. :before-upload="beforeAvatarUpload"
  37. :limit="1">
  38. <el-button type="primary" style="margin-left: 10px;">导入专享券</el-button>
  39. </el-upload>
  40. <el-button type="default" @click="handleDownloadLove" style="margin-left: 10px;" v-if="$hasPermission('core:appuser:downloadLove')">下载爱心值导入模板</el-button>
  41. <el-upload v-if="$hasPermission('core:appuser:importLove')"
  42. :action="uploadUrl2"
  43. :headers="uploadHeaders"
  44. :on-success="uploadFileSuccess"
  45. :before-upload="beforeAvatarUpload"
  46. :limit="1">
  47. <el-button type="primary" style="margin-left: 10px;">导入爱心值</el-button>
  48. </el-upload>
  49. <el-button type="primary" @click="handleAdd" v-if="$hasPermission('core:appuser:save')" style="margin-left: 10px;">新增会员</el-button>
  50. <el-button type="default" @click="handleExcel" v-if="$hasPermission('core:appuser:export')">导出Excel</el-button>
  51. </div>
  52. </div>
  53. <el-table :data="dataList" border cell-class-name="vertical-top-cell" v-loading="loading" empty-text="暂无会员" style="margin-top: 22px;">
  54. <el-table-column prop="xxx" label="序号" width="70">
  55. <template #default="{ $index }">{{ ($index + 1) + (queryParams.page - 1) * queryParams.limit }}</template>
  56. </el-table-column>
  57. <el-table-column prop="xxx" label="会员信息" width="180">
  58. <template #default="{ row }">
  59. <div class="userinfo adfac">
  60. <img :src="row.avatarPath||require('@/assets/img/default_avatar.png')">
  61. <div class="userinfo-text">
  62. <div class="userinfo-text-name">{{ row.nickName||'' }}</div>
  63. <div class="userinfo-text-phone">{{ row.phoneCopy||'' }}</div>
  64. </div>
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="uniqueNo" label="善行少年编号" width="220"></el-table-column>
  69. <el-table-column prop="channelName" label="渠道方" width="150"></el-table-column>
  70. <el-table-column prop="realName" label="用户名"></el-table-column>
  71. <el-table-column prop="phoneCopy" label="手机号"></el-table-column>
  72. <!-- <el-table-column prop="welfareName" label="家庭公益名称" width="130"></el-table-column>
  73. <el-table-column prop="welfareSlogan" label="家庭公益口号" width="130"></el-table-column> -->
  74. <el-table-column prop="totalConsumeLove" label="累计捐献爱心值" width="140">
  75. <template #default="{ row }">{{ row.totalConsumeLove||0 }}</template>
  76. </el-table-column>
  77. <el-table-column prop="totalImportLove" label="累计导入爱心值" width="140"></el-table-column>
  78. <el-table-column prop="welfareCount" label="参与公益次数" width="130">
  79. <template #default="{ row }">{{ row.welfareCount||0 }}次</template>
  80. </el-table-column>
  81. <el-table-column prop="userLevel" label="会员等级">
  82. <template #default="{ row }">Lv.{{ row.userLevel||0 }}</template>
  83. </el-table-column>
  84. <el-table-column label="操作" width="180" fixed="right">
  85. <template #default="scope">
  86. <el-button link type="text" @click="handleDetail(scope.row)" v-if="$hasPermission('core:appuser:detail')">会员详情</el-button>
  87. <!-- <el-button link type="text" @click="handleCreateCode(scope.row)" v-if="$hasPermission('core:appuser:code')">生成邀请码</el-button> -->
  88. <el-button link type="text" @click="handleDelete(scope.row)" v-if="$hasPermission('core:appuser:delete')">删除</el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination
  93. :current-page="queryParams.page"
  94. :page-sizes="[10, 20, 50, 100]"
  95. :page-size="queryParams.limit"
  96. :total="total"
  97. layout="total, sizes, prev, pager, next, jumper"
  98. @size-change="pageSizeChangeHandle"
  99. @current-change="pageCurrentChangeHandle">
  100. </el-pagination>
  101. </div>
  102. </el-card>
  103. </template>
  104. <script>
  105. import Cookies from 'js-cookie'
  106. import qs from 'qs'
  107. export default {
  108. data () {
  109. return {
  110. pageTitle: '',
  111. queryParams: {
  112. page: 1,
  113. limit: 10,
  114. uniqueNo: '',
  115. realName: '',
  116. channelId: ''
  117. },
  118. total: 0,
  119. channelOptions: [],
  120. dataList: [],
  121. loading: false,
  122. uploadUrl: `${window.SITE_CONFIG['apiURL']}/core/activity/coupon/import`,
  123. uploadUrl2: `${window.SITE_CONFIG['apiURL']}/core/love/value/record/import`,
  124. uploadHeaders: {
  125. token: Cookies.get('token')
  126. }
  127. }
  128. },
  129. created () {
  130. this.getSupplierOptions()
  131. },
  132. mounted () {
  133. this.pageTitle = this.$router.currentRoute.meta.title
  134. this.getList()
  135. },
  136. methods: {
  137. getSupplierOptions () {
  138. this.$http.get('/core/channel/page', { params: { page: 1, limit: -1 } }).then(res => {
  139. this.channelOptions = res.data.data.list.filter(item => item.type === 1) || []
  140. })
  141. },
  142. getList () {
  143. this.loading = true
  144. this.$http.get('/core/app/user/page', { params: this.queryParams }).then(res => {
  145. this.dataList = res.data.data.list || []
  146. this.dataList.forEach(item => {
  147. item.phoneCopy = item.phone && item.phone.replace(/^(\d{3})\d*(\d{4})$/, '$1****$2')
  148. })
  149. this.total = res.data.data.total || 0
  150. this.loading = false
  151. })
  152. },
  153. reset () {
  154. this.queryParams = {
  155. page: 1,
  156. limit: 10,
  157. uniqueNo: '',
  158. nickName: '',
  159. channelId: ''
  160. }
  161. this.getList()
  162. },
  163. handleDownloadTieket () {
  164. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/activity/coupon/download?token=${Cookies.get('token')}`
  165. },
  166. handleExportTicket () {
  167. },
  168. handleDownloadLove () {
  169. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/love/value/record/download?token=${Cookies.get('token')}`
  170. },
  171. handleExportHeart () {
  172. },
  173. beforeAvatarUpload (file) {
  174. const isXls = file.type === 'application/vnd.ms-excel'
  175. const isXlsx = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  176. if (!isXls && !isXlsx) {
  177. this.$message.error('上传文件只能是 xls 或 xlsx 格式!')
  178. }
  179. return isXls || isXlsx
  180. },
  181. uploadFileSuccess (response, file, fileList) {
  182. if (response && response.code === 0) {
  183. this.$message.success('导入成功!')
  184. this.getList()
  185. } else {
  186. this.$message.error(response.msg || '文件上传失败!')
  187. }
  188. },
  189. handleAdd () {
  190. this.$router.push({ name: 'memberAdd' })
  191. },
  192. handleExcel () {
  193. let newDataForm = Object.assign({}, this.queryParams)
  194. var params = qs.stringify({
  195. 'token': Cookies.get('token'),
  196. ...newDataForm
  197. })
  198. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/app/user/export?${params}`
  199. },
  200. handleDetail (row) {
  201. this.$router.push({ name: 'memberDetail', query: { id: row.id, avatar: row.avatarPath } })
  202. },
  203. handleCreateCode (row) {
  204. },
  205. handleDelete (row) {
  206. this.$confirm(`确定要删除会员【${row.nickName}】吗?`, '提示', {
  207. type: 'warning'
  208. }).then(() => {
  209. this.$http.delete('/core/app/user', { 'data': [row.id] }).then(res => {
  210. if (res.data.code !== 0) return this.$message.error(res.data.msg)
  211. this.$message.success('删除成功')
  212. this.getList()
  213. })
  214. })
  215. },
  216. pageSizeChangeHandle (val) {
  217. this.queryParams.limit = val
  218. this.getList()
  219. },
  220. pageCurrentChangeHandle (val) {
  221. this.queryParams.page = val
  222. this.getList()
  223. }
  224. }
  225. }
  226. </script>
  227. <style scoped lang="scss">
  228. ::v-deep .el-upload-list{
  229. display: none;
  230. }
  231. .page-title{
  232. font-family: PingFang-SC, PingFang-SC;
  233. font-weight: bold;
  234. font-size: 16px;
  235. color: #252525;
  236. line-height: 22px;
  237. }
  238. .query{
  239. margin-top: 14px;
  240. display: flex;
  241. justify-content: space-between;
  242. &-right{
  243. .form-btns{
  244. display: flex;
  245. align-items: center;
  246. justify-content: flex-end;
  247. }
  248. }
  249. }
  250. .table-title{
  251. margin-top: 10px;
  252. &-left{
  253. font-family: PingFang-SC, PingFang-SC;
  254. font-weight: bold;
  255. font-size: 16px;
  256. color: #252525;
  257. line-height: 22px;
  258. width: 200px;
  259. }
  260. &-right{
  261. width: calc(100% - 200px);
  262. justify-content: flex-end;
  263. }
  264. }
  265. .userinfo{
  266. img{
  267. width: 36px;
  268. height: 36px;
  269. border-radius: 50%;
  270. }
  271. &-text{
  272. margin-left: 5px;
  273. &-name{
  274. font-family: PingFangSC, PingFang SC;
  275. font-weight: 400;
  276. font-size: 14px;
  277. color: #252525;
  278. line-height: 14px;
  279. }
  280. &-phone{
  281. font-family: PingFangSC, PingFang SC;
  282. font-weight: 400;
  283. font-size: 14px;
  284. color: #252525;
  285. line-height: 14px;
  286. margin-top: 10px;
  287. }
  288. }
  289. }
  290. </style>