query.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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="220">
  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="270"></el-table-column>
  69. <el-table-column prop="channelName" label="渠道方" width="180"></el-table-column>
  70. <el-table-column prop="realName" label="用户名" width="150"></el-table-column>
  71. <el-table-column prop="phoneCopy" label="手机号" width="180"></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="170">
  75. <template #default="{ row }">{{ row.totalConsumeLove||0 }}</template>
  76. </el-table-column>
  77. <el-table-column prop="totalImportLove" label="累计导入爱心值" width="170"></el-table-column>
  78. <el-table-column prop="welfareCount" label="参与公益次数" width="160">
  79. <template #default="{ row }">{{ row.welfareCount||0 }}次</template>
  80. </el-table-column>
  81. <el-table-column prop="userLevel" label="会员等级" width="160">
  82. <template #default="{ row }">Lv.{{ row.userLevel||0 }}</template>
  83. </el-table-column>
  84. <el-table-column prop="couponNum" label="待使用专享券" width="160">
  85. <template #default="{ row }">{{ row.couponNum||0 }}张</template>
  86. </el-table-column>
  87. <el-table-column label="操作" width="200" fixed="right">
  88. <template #default="scope">
  89. <el-button link type="text" @click="handleDetail(scope.row)" v-if="$hasPermission('core:appuser:detail')">会员详情</el-button>
  90. <!-- <el-button link type="text" @click="handleCreateCode(scope.row)" v-if="$hasPermission('core:appuser:code')">生成邀请码</el-button> -->
  91. <el-button link type="text" @click="handleDelete(scope.row)" v-if="$hasPermission('core:appuser:delete')">删除</el-button>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <el-pagination
  96. :current-page="queryParams.page"
  97. :page-sizes="[10, 20, 50, 100]"
  98. :page-size="queryParams.limit"
  99. :total="total"
  100. layout="total, sizes, prev, pager, next, jumper"
  101. @size-change="pageSizeChangeHandle"
  102. @current-change="pageCurrentChangeHandle">
  103. </el-pagination>
  104. </div>
  105. </el-card>
  106. </template>
  107. <script>
  108. import Cookies from 'js-cookie'
  109. import qs from 'qs'
  110. export default {
  111. data () {
  112. return {
  113. pageTitle: '',
  114. queryParams: {
  115. page: 1,
  116. limit: 10,
  117. uniqueNo: '',
  118. realName: '',
  119. channelId: ''
  120. },
  121. total: 0,
  122. channelOptions: [],
  123. dataList: [],
  124. loading: false,
  125. uploadUrl: `${window.SITE_CONFIG['apiURL']}/core/activity/coupon/import`,
  126. uploadUrl2: `${window.SITE_CONFIG['apiURL']}/core/love/value/record/import`,
  127. uploadHeaders: {
  128. token: Cookies.get('token')
  129. }
  130. }
  131. },
  132. created () {
  133. this.getSupplierOptions()
  134. },
  135. mounted () {
  136. this.pageTitle = this.$router.currentRoute.meta.title
  137. this.getList()
  138. },
  139. methods: {
  140. getSupplierOptions () {
  141. this.$http.get('/core/channel/page', { params: { page: 1, limit: -1 } }).then(res => {
  142. this.channelOptions = res.data.data.list.filter(item => item.type === 1) || []
  143. })
  144. },
  145. getList () {
  146. this.loading = true
  147. this.$http.get('/core/app/user/page', { params: this.queryParams }).then(res => {
  148. this.dataList = res.data.data.list || []
  149. this.dataList.forEach(item => {
  150. item.phoneCopy = item.phone && item.phone.replace(/^(\d{3})\d*(\d{4})$/, '$1****$2')
  151. })
  152. this.total = res.data.data.total || 0
  153. this.loading = false
  154. })
  155. },
  156. reset () {
  157. this.queryParams = {
  158. page: 1,
  159. limit: 10,
  160. uniqueNo: '',
  161. nickName: '',
  162. channelId: ''
  163. }
  164. this.getList()
  165. },
  166. handleDownloadTieket () {
  167. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/activity/coupon/download?token=${Cookies.get('token')}`
  168. },
  169. handleExportTicket () {
  170. },
  171. handleDownloadLove () {
  172. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/love/value/record/download?token=${Cookies.get('token')}`
  173. },
  174. handleExportHeart () {
  175. },
  176. beforeAvatarUpload (file) {
  177. const isXls = file.type === 'application/vnd.ms-excel'
  178. const isXlsx = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  179. if (!isXls && !isXlsx) {
  180. this.$message.error('上传文件只能是 xls 或 xlsx 格式!')
  181. }
  182. return isXls || isXlsx
  183. },
  184. uploadFileSuccess (response, file, fileList) {
  185. if (response && response.code === 0) {
  186. this.$message.success('导入成功!')
  187. this.getList()
  188. } else {
  189. this.$message.error(response.msg || '文件上传失败!')
  190. }
  191. },
  192. handleAdd () {
  193. this.$router.push({ name: 'memberAdd' })
  194. },
  195. handleExcel () {
  196. let newDataForm = Object.assign({}, this.queryParams)
  197. var params = qs.stringify({
  198. 'token': Cookies.get('token'),
  199. ...newDataForm
  200. })
  201. window.location.href = `${window.SITE_CONFIG['apiURL']}/core/app/user/export?${params}`
  202. },
  203. handleDetail (row) {
  204. this.$router.push({ name: 'memberDetail', query: { id: row.id, avatar: row.avatarPath } })
  205. },
  206. handleCreateCode (row) {
  207. },
  208. handleDelete (row) {
  209. this.$confirm(`确定要删除会员【${row.nickName}】吗?`, '提示', {
  210. type: 'warning'
  211. }).then(() => {
  212. this.$http.delete('/core/app/user', { 'data': [row.id] }).then(res => {
  213. if (res.data.code !== 0) return this.$message.error(res.data.msg)
  214. this.$message.success('删除成功')
  215. this.getList()
  216. })
  217. })
  218. },
  219. pageSizeChangeHandle (val) {
  220. this.queryParams.limit = val
  221. this.getList()
  222. },
  223. pageCurrentChangeHandle (val) {
  224. this.queryParams.page = val
  225. this.getList()
  226. }
  227. }
  228. }
  229. </script>
  230. <style scoped lang="scss">
  231. ::v-deep .el-upload-list{
  232. display: none;
  233. }
  234. .page-title{
  235. font-family: PingFang-SC, PingFang-SC;
  236. font-weight: bold;
  237. font-size: 16px;
  238. color: #252525;
  239. line-height: 22px;
  240. }
  241. .query{
  242. margin-top: 14px;
  243. display: flex;
  244. justify-content: space-between;
  245. &-right{
  246. .form-btns{
  247. display: flex;
  248. align-items: center;
  249. justify-content: flex-end;
  250. }
  251. }
  252. }
  253. .table-title{
  254. margin-top: 10px;
  255. &-left{
  256. font-family: PingFang-SC, PingFang-SC;
  257. font-weight: bold;
  258. font-size: 16px;
  259. color: #252525;
  260. line-height: 22px;
  261. width: 200px;
  262. }
  263. &-right{
  264. width: calc(100% - 200px);
  265. justify-content: flex-end;
  266. }
  267. }
  268. .userinfo{
  269. img{
  270. width: 36px;
  271. height: 36px;
  272. border-radius: 50%;
  273. }
  274. &-text{
  275. margin-left: 5px;
  276. &-name{
  277. font-family: PingFangSC, PingFang SC;
  278. font-weight: 400;
  279. font-size: 14px;
  280. color: #252525;
  281. line-height: 14px;
  282. }
  283. &-phone{
  284. font-family: PingFangSC, PingFang SC;
  285. font-weight: 400;
  286. font-size: 14px;
  287. color: #252525;
  288. line-height: 14px;
  289. margin-top: 10px;
  290. }
  291. }
  292. }
  293. </style>