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 24 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <div class="el-col el-col-21" style="padding-right:10px">
  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='btnFirst' 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='btnLast' 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" href= "this.dataUrl + '?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a>
  31. <span >
  32. <a href= "this.dataUrl + '?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a>
  33. </span>
  34. </a>
  35. <span style="display:inline-block;margin-left: 20px; ">
  36. <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>
  37. </el-input>
  38. </span>
  39. </span>
  40. </div>
  41. <div style="margin-top: 30px;">
  42. <el-table
  43. :data="tableData"
  44. style="width: 100%"
  45. :header-cell-style="tableHeaderStyle"
  46. :cell-style='cellStyle'>
  47. <el-table-column
  48. label="ID"
  49. prop="ID"
  50. align="left"
  51. stripe
  52. >
  53. </el-table-column>
  54. <el-table-column
  55. fixed
  56. label="用户名"
  57. align="left"
  58. prop="Name"
  59. width="100px">
  60. <template slot-scope="scope">
  61. <a :href="AppSubUrl +'../../../../'+ scope.row.Name">{{scope.row.Name}} </a>
  62. </template>
  63. </el-table-column>
  64. <el-table-column
  65. prop="UserIndex"
  66. label="归一化用户指数"
  67. width="120px"
  68. align="center">
  69. <template slot-scope="scope">
  70. {{scope.row.UserIndex | rounding}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="UserIndexPrimitive"
  75. label="用户指数"
  76. width="120px"
  77. align="center">
  78. <template slot-scope="scope">
  79. {{scope.row.UserIndexPrimitive | rounding}}
  80. </template>
  81. </el-table-column>
  82. <el-table-column
  83. prop="CodeMergeCount"
  84. label="PR数"
  85. align="center">
  86. </el-table-column>
  87. <el-table-column
  88. prop="CommitCount"
  89. label="commit数"
  90. align="center">
  91. </el-table-column>
  92. <el-table-column
  93. prop="IssueCount"
  94. label="提出任务数"
  95. align="center">
  96. </el-table-column>
  97. <el-table-column
  98. prop="CommentCount"
  99. label="评论数"
  100. align="center">
  101. </el-table-column>
  102. <el-table-column
  103. prop="FocusRepoCount"
  104. label="关注项目数"
  105. align="center">
  106. </el-table-column>
  107. <el-table-column
  108. prop="StarRepoCount"
  109. label="点赞项目数"
  110. align="center">
  111. </el-table-column>
  112. <el-table-column
  113. prop="LoginCount"
  114. label="登录次数"
  115. align="center">
  116. </el-table-column>
  117. <el-table-column
  118. prop="WatchedCount"
  119. label="关注者数"
  120. align="center">
  121. </el-table-column>
  122. <el-table-column
  123. prop="CommitCodeSize"
  124. label="commit代码行数"
  125. width="115px"
  126. align="center">
  127. </el-table-column>
  128. <el-table-column
  129. prop="SolveIssueCount"
  130. label="已解决任务数"
  131. align="center">
  132. </el-table-column>
  133. <el-table-column
  134. prop="EncyclopediasCount"
  135. label="百科页面贡献次数"
  136. width="130px"
  137. align="center">
  138. </el-table-column>
  139. <el-table-column
  140. prop="CreateRepoCount"
  141. label="创建项目"
  142. align="center">
  143. </el-table-column>
  144. <el-table-column
  145. prop="CloudBrainTaskNum"
  146. label="云脑任务数"
  147. width="120px"
  148. align="center">
  149. </el-table-column>
  150. <el-table-column
  151. prop="CloudBrainRunTime"
  152. label="云脑运行时间(小时)"
  153. width="120px"
  154. align="center">
  155. <template slot-scope="scope">
  156. {{scope.row.CloudBrainRunTime | roundingToHour}}
  157. </template>
  158. </el-table-column>
  159. <el-table-column
  160. prop="CommitDatasetNum"
  161. label="上传(提交)数据集文件数"
  162. width="120px"
  163. align="center">
  164. </el-table-column>
  165. <el-table-column
  166. prop="CommitModelCount"
  167. label="提交模型数"
  168. width="120px"
  169. align="center">
  170. </el-table-column>
  171. <el-table-column
  172. prop="FocusOtherUser"
  173. label="关注他人数"
  174. width="120px"
  175. align="center">
  176. </el-table-column>
  177. <el-table-column
  178. prop="CollectDataset"
  179. label="收藏数据集"
  180. width="120px"
  181. align="center">
  182. </el-table-column>
  183. <el-table-column
  184. prop="CollectedDataset"
  185. label="被收藏数据集"
  186. width="120px"
  187. align="center">
  188. </el-table-column>
  189. <el-table-column
  190. prop="RecommendDataset"
  191. label="被推荐数据集数"
  192. width="120px"
  193. align="center">
  194. </el-table-column>
  195. <el-table-column
  196. prop="CollectImage"
  197. label="收藏镜像数"
  198. width="120px"
  199. align="center">
  200. </el-table-column>
  201. <el-table-column
  202. prop="CollectedImage"
  203. label="被收藏镜像数"
  204. width="120px"
  205. align="center">
  206. </el-table-column>
  207. <el-table-column
  208. prop="RecommendImage"
  209. label="被推荐镜像数"
  210. width="120px"
  211. align="center">
  212. </el-table-column>
  213. <el-table-column
  214. prop="RegistDate"
  215. label="用户注册时间"
  216. width="120px"
  217. align="center">
  218. <template slot-scope="scope">
  219. {{scope.row.RegistDate | transformTimestamp}}
  220. </template>
  221. </el-table-column>
  222. <el-table-column
  223. prop="DataDate"
  224. label="系统统计时间"
  225. width="120px"
  226. align="center">
  227. </el-table-column>
  228. </el-table>
  229. </div>
  230. <div style="margin-top:50px;text-align:center">
  231. <el-pagination
  232. background
  233. @size-change="handleSizeChange"
  234. @current-change="handleCurrentChange"
  235. :current-page="page"
  236. :page-size="pageSize"
  237. :page-sizes="[5,10,20]"
  238. layout="total, sizes, prev, pager, next,jumper"
  239. :total="totalNum">
  240. </el-pagination>
  241. </div>
  242. </div>
  243. </template>
  244. <script>
  245. import { export2Excel } from '../excel/util.js'
  246. export default{
  247. name:'UserAnalysis',
  248. data() {
  249. return {
  250. type_val:'',
  251. recordBeginTime:'',
  252. lastUpdatedTime:'',
  253. page:1,
  254. pageSize:10,
  255. params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''},
  256. tableData: [],
  257. totalNum:0,
  258. dataUrl:'../../api/v1/query_user_static_page',
  259. pickerOptions: {
  260. },
  261. value_time: '',
  262. search:'',
  263. data:'',
  264. 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:'CloudBrainTaskNum'},{title:'云脑运行时间(小时)',key:'CloudBrainRunTime'},{title:'上传(提交)数据集文件数',key:'CommitDatasetNum'},{title:'提交模型数',key:'CommitModelCount'},{title:'归一化用户指数',key:'UserIndex'},{title:'用户指数',key:'UserIndexPrimitive'},{title:'关注他人数',key:'FocusOtherUser'},{title:'收藏数据集',key:'CollectDataset'},{title:'被收藏数据集',key:'CollectedDataset'},{title:'被推荐数据集数',key:'RecommendDataset'},{title:'收藏镜像数',key:'CollectImage'},{title:'被收藏镜像数',key:'CollectedImage'},{title:'被推荐镜像数',key:'RecommendImage'},{title:'系统统计时间',key:'CountDate'}],
  265. blob:'',
  266. fileName:'',
  267. dynamic:7,
  268. params_pro:{type:'all',page:1,pagesize:10,beginTime:'',endTime:'',q:'',sort:'openi'},
  269. };
  270. },
  271. methods: {
  272. popMark(){
  273. alert("数据为空时,不能下载!")
  274. },
  275. exportData(){
  276. // this.getUserList('all_usr',7)
  277. var saveFileName = this.getFileName()
  278. export2Excel(this.columns,this.tableData,saveFileName)
  279. },
  280. getFileName(){
  281. var saveFileName=''
  282. var Date=(this.params.startDate).split('-')
  283. var startDate=Date[0]+''+Date[1]+''+Date[2]
  284. Date=(this.params.endDate).split('-')
  285. var endDate=Date[0]+Date[1]+Date[2]
  286. saveFileName = '用户分析_'+this.search+''+startDate+'_'+endDate
  287. if (this.type_val=='all_usr'){
  288. saveFileName = '用户分析_'+this.search+'_all'
  289. }
  290. return saveFileName
  291. },
  292. handleCurrentChange(val){
  293. this.params.page = val
  294. this.page = val
  295. this.getUserList(this.type_val,this.dynamic)
  296. },
  297. handleSizeChange(val){
  298. this.params.pageSize = val
  299. this.resetPage()
  300. this.getUserList(this.type_val,this.dynamic)
  301. },
  302. resetPage(){
  303. this.page=1
  304. this.params.page = 1
  305. },
  306. formatDate(myyear,mymonth,myweekday) {
  307. // var myyear = this.date.getFullYear();
  308. // var mymonth = this.date.getMonth() + 1;
  309. // var myweekday = this.date.getDate();
  310. if (mymonth < 10) {
  311. mymonth = "0" + mymonth;
  312. }
  313. if (myweekday < 10) {
  314. myweekday = "0" + myweekday;
  315. }
  316. return (myyear + "-" + mymonth + "-" + myweekday);
  317. },
  318. // 获得某月的天数
  319. getMonthDays(nowYear,month){
  320. let monthStartDate = new Date(nowYear, month, 1);
  321. let monthEndDate = new Date(nowYear, month + 1, 1);
  322. let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24);
  323. return days;
  324. },
  325. getUpdateTime(){
  326. this.$axios.get('../../api/v1/projectboard/project',{
  327. params:this.params_pro
  328. }).then((res)=>{
  329. this.recordBeginTime=res.data.recordBeginTime
  330. this.lastUpdatedTime=res.data.lastUpdatedTime
  331. })
  332. },
  333. getUserList(type_val,index){
  334. this.type_val = type_val
  335. this.dynamic = index;
  336. var now = new Date(); // 当前日期
  337. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  338. var nowDay = now.getDate(); // 当前日
  339. var nowMonth = now.getMonth(); // 当前月
  340. var nowYear = now.getFullYear(); // 当前年
  341. var today = this.formatDate(nowYear,nowMonth+1,nowDay);
  342. let lastMonthDate = new Date(); // 上月日期
  343. lastMonthDate.setDate(1);
  344. lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
  345. let lastYear = lastMonthDate.getYear();
  346. let lastMonth = lastMonthDate.getMonth();
  347. this.dataUrl = '../../api/v1/query_user_static_page';
  348. if (typeof type_val=="undefined" || type_val=="null" || type_val==""){
  349. this.params.startDate= this.formatDate(this.value_time[0].getFullYear(),this.value_time[0].getMonth() + 1,this.value_time[0].getDate());
  350. this.params.endDate = this.formatDate(this.value_time[1].getFullYear(),this.value_time[1].getMonth() + 1,this.value_time[1].getDate());
  351. }else{
  352. switch(type_val){
  353. case "yesterday_usr":{
  354. this.value_time=[]
  355. this.dataUrl = '../../api/v1/query_user_yesterday';
  356. break
  357. }
  358. case "current_week_usr":{
  359. this.value_time=[]
  360. this.dataUrl = '../../api/v1/query_user_current_week';
  361. break
  362. }
  363. case "last_week_usr":{
  364. this.value_time=[]
  365. this.dataUrl = '../../api/v1/query_user_last_week';
  366. break
  367. }
  368. case "current_month_usr":{
  369. this.value_time=[]
  370. this.dataUrl = '../../api/v1/query_user_current_month';
  371. break
  372. }
  373. case "last_month_usr":{
  374. this.value_time=[]
  375. this.dataUrl = '../../api/v1/query_user_last_month';
  376. break
  377. }
  378. case "monthly_usr":{
  379. this.value_time=[]
  380. this.dataUrl = '../../api/v1/query_user_last30_day';
  381. break
  382. }
  383. case "current_year_usr":{
  384. this.value_time=[]
  385. this.dataUrl = '../../api/v1/query_user_current_year';
  386. break
  387. }
  388. case "all_usr":{
  389. this.value_time=[]
  390. this.dataUrl = '../../api/v1/query_user_all';
  391. break
  392. }
  393. }
  394. };
  395. this.$axios.get(this.dataUrl,{
  396. params:this.params
  397. }).then((res)=>{
  398. this.tableData = res.data.data
  399. // console.log("res.data:"+res.data.data)
  400. this.totalNum = res.data.count
  401. })
  402. },
  403. searchName(){
  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. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  410. if(rowIndex===0){
  411. return 'background:#f5f5f6;color:#606266'
  412. }
  413. },
  414. cellStyle({row,column,rowIndex,columnIndex}){
  415. if(rowIndex%2 === 1){
  416. return 'background:#f5f5f6;color:#606266'
  417. }
  418. },
  419. },
  420. filters:{
  421. rounding (value) {
  422. return Number(value).toFixed(2)
  423. },
  424. roundingToHour (value) {
  425. return (Number(value)/3600).toFixed(2)
  426. },
  427. transformTimestamp(timestamp){
  428. let a = new Date(timestamp*1000);
  429. const date = new Date(a);
  430. const Y = date.getFullYear() + '/';
  431. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/';
  432. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  433. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  434. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes());// + ':' ;
  435. // const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  436. const dateString = Y + M + D + h + m ;//+ s;
  437. return dateString;
  438. },
  439. },
  440. mounted() {
  441. // document.getElementById("all_usr").style.outline="none"
  442. // document.getElementById("all_usr").focus()
  443. this.getUpdateTime()
  444. this.getUserList("all_usr",7)
  445. },
  446. created() {
  447. },
  448. watch:{
  449. search(val){
  450. if(!val){
  451. this.params.userName = this.search
  452. this.params.page = 1
  453. this.page=1
  454. this.getUserList(this.type_val, this.dynamic)
  455. }
  456. }
  457. },
  458. }
  459. </script>
  460. <style scoped>
  461. .pro_item{
  462. font-size: 16px;
  463. color: rgba(16, 16, 16, 100);
  464. font-family: SourceHanSansSC-bold;
  465. }
  466. .sta_item{
  467. font-size: 14px;
  468. color: rgb(0 0 0);
  469. font-family: SourceHanSansSC-bold;
  470. }
  471. .update_time{
  472. line-height: 17px;
  473. font-size: 12px;
  474. color:rgba(187, 187, 187, 100);
  475. margin-left: 10px;
  476. }
  477. /* .btn{
  478. line-height: 1.5;
  479. margin: -3px;
  480. border: 1px solid #409effd6;
  481. background: #FFFF;
  482. color: #409eff;
  483. width: 60px;
  484. height: 30px;
  485. border-radius:4px ;
  486. } */
  487. .btnFirst{
  488. line-height: 1.5;
  489. margin: -3.5px;
  490. border: 1px solid rgba(22, 132, 252, 100);
  491. border-right: none;
  492. background: #FFFF;
  493. color: #1684FC;
  494. width: 60px;
  495. height: 30px;
  496. border-radius:4px 0px 0px 4px;
  497. }
  498. .btn{
  499. line-height: 1.5;
  500. margin: -3.5px;
  501. border: 1px solid rgba(22, 132, 252, 100);
  502. border-right: none;
  503. background: #FFFF;
  504. color: #1684FC;
  505. width: 60px;
  506. height: 30px;
  507. }
  508. .btnLast{
  509. line-height: 1.5;
  510. margin: -3.5px;
  511. border: 1px solid rgba(22, 132, 252, 100);
  512. /* border-right: none; */
  513. background: #FFFF;
  514. color: #1684FC;
  515. width: 60px;
  516. height: 30px;
  517. border-radius:0px 4px 4px 0px;
  518. }
  519. .btnFirst,.btn,.btnLast {
  520. cursor: pointer;
  521. }
  522. /* .btn:focus,
  523. .btn:active{
  524. background-color:#409effd6 ;
  525. } */
  526. /* /deep/ .el-date-picker {
  527. width: 220px;
  528. } */
  529. /deep/ .el-table {
  530. font-size: 12px;
  531. }
  532. /deep/ .el-table tbody tr:hover>td {
  533. background-color:#D3D3D3!important;
  534. opacity:1
  535. }
  536. /deep/ .el-range-separator{
  537. width: 20% !important;
  538. }
  539. /deep/ .el-pagination {
  540. padding-bottom: 30px;
  541. }
  542. .colorChange {
  543. background-color: #1684FC;
  544. color: #FFFF;
  545. cursor: default;
  546. }
  547. </style>