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 22 kB

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