recommend.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div>
  3. <!-- 搜索筛选区域 -->
  4. <div style="margin:5px;display: inline-block;">
  5. <span>手机号:</span>
  6. <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入手机号"
  7. v-model="phone"></el-input>
  8. </div>&emsp;&emsp;
  9. <div style="margin:5px;display: inline-block;">
  10. <span>昵称:</span>
  11. <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入昵称"
  12. v-model="campus"></el-input>
  13. </div>&emsp;&emsp;
  14. <div style="margin:5px;display: inline-block;">
  15. <span>开始时间:</span>
  16. <el-date-picker style="width: 160px;margin-left: 10px;" v-model="startTime" align="right"
  17. type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择开始时间">
  18. </el-date-picker>&nbsp;&nbsp;&nbsp;
  19. </div>
  20. <div style="margin:5px;display: inline-block;">
  21. <span>截止时间:</span>
  22. <el-date-picker style="width: 160px;margin-left: 10px;" v-model="endTime" align="right" type="date"
  23. format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择截止时间">
  24. </el-date-picker>
  25. </div>
  26. <div style="display: inline-block;">
  27. <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="select">查询
  28. </el-button>
  29. <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans">重置
  30. </el-button>
  31. <el-button style='margin-left:15px;' size="mini" type="warning" icon="document" :disabled="!isAuth('user:daochu')" @click="exportBtn">导出Excel
  32. </el-button>
  33. </div>
  34. <!-- 表格区域 -->
  35. <el-table v-loading="tableDataLoading" :data="tableData.list">
  36. <el-table-column prop="userId" label="编号" width="150" fixed="left"></el-table-column>
  37. <el-table-column fixed prop="userName" label="昵称" width="200">
  38. <template slot-scope="scope">
  39. <span style="color: #f56c6c;" v-if="!isAuth('userList:phone') && scope.row.userName1">{{ scope.row.userName1 ? scope.row.userName1 : '未绑定' }}</span>
  40. <span style="color: #f56c6c;" v-else>{{ scope.row.userName ? scope.row.userName : '未绑定' }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="图像">
  44. <template slot-scope="scope">
  45. <img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40"
  46. height="40">
  47. <img v-else :src="scope.row.avatar" alt="" width="40" height="40">
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="phone" label="手机号" >
  51. <template slot-scope="scope">
  52. <span v-if="isAuth('userList:phone')">
  53. {{ scope.row.phone ? scope.row.phone : '未绑定' }}
  54. </span>
  55. <span v-else>
  56. {{ scope.row.phone1 ? scope.row.phone1 : '-' }}
  57. </span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="invitationCode" label="邀请码" width="150">
  61. <template slot-scope="scope">
  62. <span style="color: #4f9dec;cursor: pointer;"
  63. @click="onChangeShow(scope.row.invitationCode,scope.row.userId,scope.row.userName)">{{ scope.row.invitationCode }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="createTime" label="创建时间" width="200"></el-table-column>
  67. </el-table>
  68. <!-- 分页 -->
  69. <div style="text-align: center;margin-top: 10px;">
  70. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  71. :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit" :current-page="page"
  72. layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
  73. </el-pagination>
  74. </div>
  75. <!-- 邀请人员弹窗 -->
  76. <!-- 邀请人员弹窗 -->
  77. <el-dialog title="邀请人员" :visible.sync="isShow">
  78. <el-table :data="dataSource" >
  79. <el-table-column property="userName" label="姓名"></el-table-column>
  80. <!-- 新增:电话列 -->
  81. <el-table-column property="phone" label="电话"></el-table-column>
  82. <el-table-column property="createTime" label="邀请时间"></el-table-column>
  83. <!-- 新增:状态列(带颜色)-->
  84. <el-table-column label="状态">
  85. <template slot-scope="scope">
  86. <el-tag
  87. :type="scope.row.status === 1 ? 'success' : 'info'"
  88. >
  89. {{ scope.row.status === 1 ? '已达标' : '已注册' }}
  90. </el-tag>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <el-pagination
  95. style="margin-top:15px;text-align:right"
  96. small
  97. background
  98. @current-change="onChangeDataSourcePage"
  99. layout="prev, pager, next"
  100. :current-page="dataParams.page"
  101. :page-size="dataParams.limit"
  102. :total="dataParams.total">
  103. </el-pagination>
  104. </el-dialog>
  105. </div>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. return {
  111. limit: 10,
  112. page: 1,
  113. phone: '',
  114. campus: '',
  115. tableDataLoading: true,
  116. tableData: [],
  117. startTime: '',
  118. endTime: '',
  119. // 邀请人员相关
  120. isShow: false,
  121. dataSource: [],
  122. dataParams: {
  123. page: 1,
  124. total: 0,
  125. limit: 10,
  126. },
  127. invitationCode: '',
  128. invitationUserId: '',
  129. userName: '',
  130. status:0
  131. }
  132. },
  133. methods: {
  134. // 显示邀请人员
  135. onChangeShow(code, id, userName) {
  136. this.isShow = true
  137. this.invitationCode = code
  138. this.invitationUserId = id
  139. this.userName = userName
  140. this.getDataSource()
  141. },
  142. getDataSource(page = 1) {
  143. this.$http({
  144. url: this.$http.adornUrl(`user/selectUsersByInvitationCode?page=${page}&limit=${this.dataParams.limit}&invitationCode=${this.invitationCode}`),
  145. method: 'get'
  146. }).then((res) => {
  147. this.dataSource = res.data.data.list
  148. this.dataParams = {
  149. page: res.data.data.currPage,
  150. limit: res.data.data.pageSize,
  151. total: res.data.data.totalCount,
  152. }
  153. })
  154. },
  155. onChangeDataSourcePage(page) {
  156. this.getDataSource(page)
  157. },
  158. // 分页
  159. handleSizeChange(val) {
  160. this.limit = val
  161. this.dataSelect()
  162. },
  163. handleCurrentChange(val) {
  164. this.page = val
  165. this.dataSelect()
  166. },
  167. // 查询
  168. select() {
  169. this.page = 1
  170. this.dataSelect()
  171. },
  172. // 重置
  173. cleans() {
  174. this.page = 1
  175. this.campus = ''
  176. this.phone = ''
  177. this.startTime = ''
  178. this.endTime = ''
  179. this.dataSelect()
  180. },
  181. // 获取数据列表(默认企业总用户)
  182. dataSelect() {
  183. if(this.startTime!=""&&this.startTime !==null){
  184. if (this.endTime == ''||this.endTime ==null) {
  185. this.$notify({
  186. title: '提示',
  187. duration: 1800,
  188. message: '请选择截止时间',
  189. type: 'warning'
  190. });
  191. return
  192. }
  193. }
  194. if(this.endTime!=""&&this.endTime !==null){
  195. if (this.startTime == ''||this.startTime ==null) {
  196. this.$notify({
  197. title: '提示',
  198. duration: 1800,
  199. message: '请选择开始时间',
  200. type: 'warning'
  201. });
  202. return
  203. }
  204. }
  205. this.tableDataLoading = true
  206. this.$http({
  207. url: this.$http.adornUrl('user/selectUserList'),
  208. method: 'get',
  209. params: this.$http.adornParams({
  210. 'page': this.page,
  211. 'limit': this.limit,
  212. 'phone': this.phone,
  213. 'userName': this.campus,
  214. // 'userType': 2,
  215. // 'isCompanyVip': '',
  216. 'startTime': this.startTime,
  217. 'endTime': this.endTime,
  218. 'isRecommender':1
  219. })
  220. }).then(({data}) => {
  221. this.tableDataLoading = false
  222. if(data.data&&data.data.list.length>0){
  223. for(var i in data.data.list){
  224. var pattern = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  225. var phone1 = data.data.list[i].phone
  226. var userName1 = data.data.list[i].userName
  227. if(pattern.test(phone1)){
  228. var one = phone1.slice(0, 3)
  229. var two = phone1.slice(7, 11)
  230. data.data.list[i].phone1 = one+'****'+two
  231. }
  232. if(pattern.test(userName1)){
  233. var one = userName1.slice(0, 3)
  234. var two = userName1.slice(7, 11)
  235. data.data.list[i].userName1 = one+'****'+two
  236. }
  237. }
  238. }
  239. let returnData = data.data
  240. this.tableData = returnData
  241. })
  242. },
  243. // 导出
  244. exportBtn() {
  245. var endTime=this.endTime
  246. if(this.endTime!=''){
  247. endTime=this.endTime+" 23:59:59"
  248. }
  249. this.$http({
  250. url: this.$http.adornUrl('user/exportExcelUser'),
  251. method: 'get',
  252. responseType: 'blob',
  253. params: this.$http.adornParams({
  254. 'phone': this.phone,
  255. 'userName': this.campus,
  256. // 'userType': 2,
  257. 'startTime': this.startTime,
  258. 'endTime': this.endTime,
  259. })
  260. }).then(({data}) => {
  261. let blob = new Blob([data], {
  262. type: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  263. })
  264. if (window.navigator.msSaveOrOpenBlob) {
  265. navigator.msSaveBlob(blob)
  266. } else {
  267. let url = window.URL.createObjectURL(blob)
  268. let elink = document.createElement('a')
  269. elink.download = '推荐官列表.xlsx'
  270. elink.style.display = 'none'
  271. elink.href = url
  272. document.body.appendChild(elink)
  273. elink.click();
  274. document.body.removeChild(elink)
  275. }
  276. })
  277. },
  278. },
  279. mounted() {
  280. this.dataSelect()
  281. }
  282. }
  283. </script>
  284. <style scoped="scoped">
  285. .el-button+.el-button {
  286. margin-left: 0 !important;
  287. margin-top: 5px !important;
  288. }
  289. </style>