You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserAnalysis.vue 21 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <div>
  3. <div style="margin-top: 10px;">
  4. <b class="pro_item">用户分析</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{lastUpdatedTime}} &nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
  5. </div>
  6. <div style="margin-top: 20px;">
  7. <span class="sta_iterm">统计周期:</span>
  8. <button type="button" class='btn' id ="yesterday_usr" v-bind:class="{colorChange:1==dynamic}" @click="resetPage(),getUserList('yesterday_usr',1)">昨天</button>
  9. <button type="button" class='btn' id = "current_week_usr" v-bind:class="{colorChange:2==dynamic}" @click="resetPage(),getUserList('current_week_usr',2)">本周</button>
  10. <button type="button" class='btn' id = "current_month_usr" v-bind:class="{colorChange:3==dynamic}" @click="resetPage(),getUserList('current_month_usr',3)">本月</button>
  11. <button type="button" class='btn' id = "last_month_usr" v-bind:class="{colorChange:4==dynamic}" @click="resetPage(),getUserList('last_month_usr',4)">上月</button>
  12. <button type="button" class='btn' id = "monthly_usr" v-bind:class="{colorChange:5==dynamic}" @click="resetPage(),getUserList('monthly_usr',5)">近30天</button>
  13. <button type="button" class='btn' id = "current_year_usr" v-bind:class="{colorChange:6==dynamic}" @click="resetPage(),getUserList('current_year_usr',6)">今年</button>
  14. <button type="button" class='btn' id = "all_usr" v-bind:class="{colorChange:7==dynamic}" @click="resetPage(),getUserList('all_usr',7)">所有</button>
  15. <span style="margin-left: 20px;">
  16. <el-date-picker
  17. v-model="value_time"
  18. prefix-icon="el-icon-time"
  19. @change="resetPage(),getUserList('',0)"
  20. type="daterange"
  21. size='small'
  22. unlink-panels
  23. range-separator="至"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期">
  26. </el-date-picker>
  27. </span>
  28. <span style="float:right; margin-right: 20px;" >
  29. <a style="display:inline-block;margin-left: 20px; " id = 'download'>
  30. <i class="el-icon-download"></i>
  31. <span ><a :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> </span>
  32. </a>
  33. <span style="display:inline-block;margin-left: 20px; ">
  34. <el-input size="small" placeholder="输入用户名搜索" v-model="search" class="input-with-select" @keyup.enter.native="searchName() "><i slot="suffix" class="el-input__icon el-icon-search" @click="searchName() "></i>
  35. </el-input>
  36. </span>
  37. </span>
  38. </div>
  39. <div style="margin-top: 30px;">
  40. <el-table
  41. :data="tableData"
  42. style="width: 100%"
  43. :header-cell-style="tableHeaderStyle"
  44. :cell-style='cellStyle'>
  45. <el-table-column
  46. label="ID"
  47. prop="ID"
  48. align="center"
  49. stripe
  50. >
  51. </el-table-column>
  52. <el-table-column
  53. label="用户名"
  54. align="center"
  55. prop="Name"
  56. width="100px">
  57. </el-table-column>
  58. <el-table-column
  59. prop="CodeMergeCount"
  60. label="PR数"
  61. align="center">
  62. </el-table-column>
  63. <el-table-column
  64. prop="CommitCount"
  65. label="commit数"
  66. align="center">
  67. </el-table-column>
  68. <el-table-column
  69. prop="IssueCount"
  70. label="提出任务数"
  71. align="center">
  72. </el-table-column>
  73. <el-table-column
  74. prop="CommentCount"
  75. label="评论数"
  76. align="center">
  77. </el-table-column>
  78. <el-table-column
  79. prop="FocusRepoCount"
  80. label="关注项目数"
  81. align="center">
  82. </el-table-column>
  83. <el-table-column
  84. prop="StarRepoCount"
  85. label="点赞项目数"
  86. align="center">
  87. </el-table-column>
  88. <el-table-column
  89. prop="LoginCount"
  90. label="登录次数"
  91. align="center">
  92. </el-table-column>
  93. <el-table-column
  94. prop="WatchedCount"
  95. label="关注者数"
  96. align="center">
  97. </el-table-column>
  98. <el-table-column
  99. prop="CommitCodeSize"
  100. label="commit代码行数"
  101. width="115px"
  102. align="center">
  103. </el-table-column>
  104. <el-table-column
  105. prop="SolveIssueCount"
  106. label="已解决任务数"
  107. align="center">
  108. </el-table-column>
  109. <el-table-column
  110. prop="EncyclopediasCount"
  111. label="百科页面贡献次数"
  112. width="130px"
  113. align="center">
  114. </el-table-column>
  115. <el-table-column
  116. prop="CreateRepoCount"
  117. label="创建项目"
  118. align="center">
  119. </el-table-column>
  120. <el-table-column
  121. prop="RegistDate"
  122. label="用户注册时间"
  123. width="120px"
  124. align="center">
  125. <template slot-scope="scope">
  126. {{scope.row.RegistDate | transformTimestamp}}
  127. </template>
  128. </el-table-column>
  129. <el-table-column
  130. prop="CountDate"
  131. label="系统统计时间"
  132. width="120px"
  133. align="center">
  134. <template slot-scope="scope">
  135. {{scope.row.CountDate | transformTimestamp}}
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. <div style="margin-top:50px;text-align:center">
  141. <el-pagination
  142. background
  143. @current-change="handleCurrentChange"
  144. :current-page="page"
  145. :page-size="pageSize"
  146. layout="prev, pager, next"
  147. :total="totalNum">
  148. </el-pagination>
  149. </div>
  150. </div>
  151. </template>
  152. <script>
  153. import { export2Excel } from '../excel/util.js'
  154. export default{
  155. name:'UserAnalysis',
  156. data() {
  157. return {
  158. type_val:'',
  159. recordBeginTime:'',
  160. lastUpdatedTime:'',
  161. page:1,
  162. pageSize:10,
  163. params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''},
  164. tableData: [],
  165. totalNum:0,
  166. pickerOptions: {
  167. },
  168. value_time: '',
  169. search:'',
  170. data:'',
  171. columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'cimmit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'系统统计时间',key:'CountDate'}],
  172. blob:'',
  173. fileName:'',
  174. dynamic:7,
  175. params_pro:{type:'all',page:1,pagesize:10,beginTime:'',endTime:'',q:'',sort:'openi'},
  176. };
  177. },
  178. methods: {
  179. exportData(){
  180. // this.getUserList('all_usr',7)
  181. var saveFileName = this.getFileName()
  182. export2Excel(this.columns,this.tableData,saveFileName)
  183. },
  184. getFileName(){
  185. var saveFileName=''
  186. var Date=(this.params.startDate).split('-')
  187. var startDate=Date[0]+''+Date[1]+''+Date[2]
  188. console.log(startDate)
  189. Date=(this.params.endDate).split('-')
  190. var endDate=Date[0]+Date[1]+Date[2]
  191. saveFileName = '用户分析_'+this.search+''+startDate+'_'+endDate
  192. if (this.type_val=='all_usr'){
  193. saveFileName = '用户分析_'+this.search+'_all'
  194. }
  195. return saveFileName
  196. },
  197. handleCurrentChange(val){
  198. this.params.page = val
  199. this.page = val
  200. this.getUserList(this.type_val,this.dynamic)
  201. },
  202. resetPage(){
  203. this.page=1
  204. this.params.page = 1
  205. },
  206. formatDate(myyear,mymonth,myweekday) {
  207. // var myyear = this.date.getFullYear();
  208. // var mymonth = this.date.getMonth() + 1;
  209. // var myweekday = this.date.getDate();
  210. if (mymonth < 10) {
  211. mymonth = "0" + mymonth;
  212. }
  213. if (myweekday < 10) {
  214. myweekday = "0" + myweekday;
  215. }
  216. return (myyear + "-" + mymonth + "-" + myweekday);
  217. },
  218. // 获得某月的天数
  219. getMonthDays(nowYear,month){
  220. let monthStartDate = new Date(nowYear, month, 1);
  221. let monthEndDate = new Date(nowYear, month + 1, 1);
  222. let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24);
  223. return days;
  224. },
  225. getUpdateTime(){
  226. this.$axios.get('../api/v1/projectboard/project',{
  227. params:this.params_pro
  228. }).then((res)=>{
  229. this.recordBeginTime=res.data.recordBeginTime
  230. this.lastUpdatedTime=res.data.lastUpdatedTime
  231. })
  232. },
  233. getUserList(type_val,index){
  234. this.type_val = type_val
  235. this.dynamic = index;
  236. console.log("dj:"+type_val)
  237. var now = new Date(); // 当前日期
  238. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  239. var nowDay = now.getDate(); // 当前日
  240. var nowMonth = now.getMonth(); // 当前月
  241. var nowYear = now.getFullYear(); // 当前年
  242. var today = this.formatDate(nowYear,nowMonth+1,nowDay);
  243. let lastMonthDate = new Date(); // 上月日期
  244. lastMonthDate.setDate(1);
  245. lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
  246. let lastYear = lastMonthDate.getYear();
  247. let lastMonth = lastMonthDate.getMonth();
  248. if (typeof type_val=="undefined" || type_val=="null" || type_val==""){
  249. this.params.startDate= this.formatDate(this.value_time[0].getFullYear(),this.value_time[0].getMonth() + 1,this.value_time[0].getDate());
  250. this.params.endDate = this.formatDate(this.value_time[1].getFullYear(),this.value_time[1].getMonth() + 1,this.value_time[1].getDate());
  251. }else{
  252. switch(type_val){
  253. case "yesterday_usr":{
  254. var now = new Date();
  255. var tmp = new Date(now.setTime(now.getTime()-24*60*60*1000));
  256. var yesterday = this.formatDate(tmp.getFullYear(),tmp.getMonth()+1,tmp.getDate());
  257. this.params.startDate = yesterday
  258. this.params.endDate = yesterday
  259. this.value_time=[]
  260. // document.getElementById("yesterday_usr").style.backgroundColor="409effd6"
  261. // document.getElementById("current_week_usr")
  262. break
  263. }
  264. case "current_week_usr":{
  265. var now = new Date(); // 当前日期
  266. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  267. var day = nowDayOfWeek || 7;
  268. this.params.startDate = this.formatDate(now.getFullYear(), nowMonth+1, nowDay + 1 - day);
  269. this.params.endDate = today
  270. this.value_time=[]
  271. break
  272. }
  273. case "current_month_usr":{
  274. this.params.startDate = this.formatDate(nowYear,nowMonth+1,1);
  275. this.params.endDate = today
  276. this.value_time=[]
  277. break
  278. }
  279. case "last_month_usr":{
  280. this.params.startDate=this.formatDate(nowYear, lastMonth+1, 1);
  281. this.params.endDate=this.formatDate(nowYear, lastMonth+1, this.getMonthDays(nowYear,lastMonth));
  282. this.value_time=[]
  283. break
  284. }
  285. case "monthly_usr":{
  286. var temp=new Date(now - 1000 * 60 * 60 * 24 * 30)
  287. this.params.startDate = this.formatDate(temp.getFullYear(),temp.getMonth()+1,temp.getDate());
  288. this.params.endDate = today
  289. this.value_time=[]
  290. break
  291. }
  292. case "current_year_usr":{
  293. this.params.startDate = this.formatDate(now.getFullYear(), 1, 1);
  294. this.params.endDate = today
  295. this.value_time=[]
  296. break
  297. }
  298. case "all_usr":{
  299. console.log("e:"+today)
  300. this.params.startDate = 'all'//this.formatDate(2000, 1, 1); //this.recordBeginTime//
  301. this.params.endDate = today
  302. this.value_time=[]
  303. break
  304. }
  305. }
  306. };
  307. this.$axios.get('../tool/query_user_static_page',{
  308. params:this.params
  309. }).then((res)=>{
  310. this.tableData = res.data.data
  311. // console.log("res.data:"+res.data.data)
  312. this.totalNum = res.data.count
  313. console.log("res.count:"+res.data.count)
  314. })
  315. // this.$axios.get('../tool/query_user_static',{
  316. // params:this.params
  317. // }).then((res)=>{
  318. // this.currentPage = 1
  319. // this.tableData = res.data
  320. // console.log(" this.tableData:", this.tableData.length)
  321. // for(var i=0;i<this.tableData.length;i++){
  322. // this.tableData[i].RegistDate = this.transformTimestamp(this.tableData[i].RegistDate)
  323. // this.tableData[i].CountDate = this.transformTimestamp(this.tableData[i].CountDate)
  324. // console.log(" this.tableData:", this.tableData[i].RegistDate)
  325. // }
  326. // })
  327. },
  328. searchName(){
  329. // this.params.q = this.search
  330. // this.params.page = 1
  331. // this.getUserList("all_usr")
  332. // var search = this.search;
  333. // this.getUserList("all_usr",7)
  334. // this.tableData = this.tableData.filter(data => !search || data.Name.toLowerCase().includes(search.toLowerCase()))
  335. this.params.userName = this.search
  336. this.params.page = 1
  337. this.page=1
  338. this.getUserList(this.type_val, this.dynamic)
  339. },
  340. // goToDetailPage(pro_id,pro_name){
  341. // sessionStorage.setItem("pro_id",pro_id);
  342. // sessionStorage.setItem("pro_name",pro_name);
  343. // document.getElementById("pro_main").style.display="none";
  344. // document.getElementById("pro_detail").style.display="block";
  345. // },
  346. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  347. if(rowIndex===0){
  348. return 'background:#f5f5f6;color:#606266'
  349. }
  350. },
  351. cellStyle({row,column,rowIndex,columnIndex}){
  352. if(rowIndex%2 === 1){
  353. return 'background:#f5f5f6;color:#606266'
  354. }
  355. },
  356. },
  357. filters:{
  358. transformTimestamp(timestamp){
  359. console.log("timestamp",timestamp)
  360. let a = new Date(timestamp*1000);
  361. const date = new Date(a);
  362. const Y = date.getFullYear() + '/';
  363. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/';
  364. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  365. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  366. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes());// + ':' ;
  367. // const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  368. const dateString = Y + M + D + h + m ;//+ s;
  369. console.log('dateString', dateString); // > dateString 2021-07-06 14:23
  370. return dateString;
  371. },
  372. // transformTimestamp(timestamp){
  373. // var dateString= new Date(timestamp);
  374. // return dateString.toLocaleDateString().replace(/\//g, "-") + " " + dateString.toTimeString().substr(0, 8);
  375. // },
  376. },
  377. mounted() {
  378. // document.getElementById("all_usr").style.outline="none"
  379. // document.getElementById("all_usr").focus()
  380. this.getUserList("all_usr",7)
  381. },
  382. created() {
  383. },
  384. watch:{
  385. search(val){
  386. // if(!val){
  387. // this.getUserList("all_usr",7)
  388. // }
  389. if(!val){
  390. this.params.userName = this.search
  391. this.params.page = 1
  392. this.page=1
  393. this.getUserList(this.type_val, this.dynamic)
  394. }
  395. }
  396. },
  397. }
  398. </script>
  399. <style scoped>
  400. .pro_item{
  401. font-size: 16px;
  402. color: rgba(16, 16, 16, 100);
  403. font-family: SourceHanSansSC-bold;
  404. }
  405. .sta_item{
  406. font-size: 14px;
  407. color: rgb(0 0 0);
  408. font-family: SourceHanSansSC-bold;
  409. }
  410. .update_time{
  411. line-height: 17px;
  412. font-size: 12px;
  413. color:rgba(187, 187, 187, 100);
  414. margin-left: 10px;
  415. }
  416. .btn{
  417. line-height: 1.5;
  418. margin: -3px;
  419. border: 1px solid #409effd6;
  420. background: #FFFF;
  421. color: #409eff;
  422. width: 60px;
  423. height: 30px;
  424. border-radius:4px ;
  425. }
  426. /* .btn:focus,
  427. .btn:active{
  428. background-color:#409effd6 ;
  429. } */
  430. /* /deep/ .el-date-picker {
  431. width: 220px;
  432. } */
  433. /deep/ .el-table {
  434. font-size: 12px;
  435. }
  436. /deep/ .el-table tbody tr:hover>td {
  437. background-color:#D3D3D3!important;
  438. opacity:1
  439. }
  440. /deep/ .el-range-separator{
  441. width: 20% !important;
  442. }
  443. .colorChange {
  444. background-color: #409effd6;
  445. color: #FFFF;
  446. }
  447. </style>