count.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div>
  3. <div>
  4. <div class="title111">
  5. <van-sticky offset-top="-0.9rem">
  6. <van-cell :title="'选择月份:' + nowMonthTitle" @click="monthSelectShow = true" class="monthSel" />
  7. <van-action-sheet v-model="monthSelectShow">
  8. <div class="monthSelectContent">
  9. <van-datetime-picker
  10. v-model="monthDatetime"
  11. type="year-month"
  12. title="选择月份"
  13. :max-date="maxDate"
  14. :formatter="formatter"
  15. @confirm="monthChange"
  16. @cancel="monthSelectShow = false"
  17. />
  18. </div>
  19. </van-action-sheet>
  20. <van-tabs background="#20a0ff" title-active-color="#fff" title-inactive-color="#3c3c45" @change="dateChange" v-model="nowDay" style="height:1.17333rem">
  21. <van-tab v-for="item in dateArray" :key="item.day" :name="item.day">
  22. <template #title>
  23. <div style="text-align:center;width:0.6rem;padding-bottom:10px">
  24. <span style="font-size:90%;">{{weekString[item.weekday]}}</span><br>
  25. <span>{{item.day}}</span>
  26. </div>
  27. </template>
  28. </van-tab>
  29. </van-tabs>
  30. </van-sticky>
  31. </div>
  32. <div style="width:100%;height:250px;background-color:#fff"><div id="main" style="width:250px;height:250px;margin:0 auto"></div></div>
  33. <van-sticky offset-top="1.35333rem">
  34. <div style="background:#fff;">
  35. <van-tabs v-model="stateActive" :fixed="false" @change="stateChange" class="stateActiveClass" color="#20a0ff">
  36. <van-tab name="submit">
  37. <template #title>
  38. <div style="text-align:center">
  39. <span style="color:#409eff;font-size:0.58rem">{{submitList.length}}</span>
  40. <span style="font-size:0.32rem;color:#333">人</span>
  41. </div>
  42. <div style="font-size:0.32rem;color:#333;text-align:center">已提交</div>
  43. </template>
  44. </van-tab>
  45. <van-tab name="unsubmit">
  46. <template #title>
  47. <div style="text-align:center">
  48. <span style="color:#ffa366;font-size:0.58rem">{{unSubmitList.length}}</span>
  49. <span style="font-size:0.32rem;color:#333">人</span>
  50. </div>
  51. <div style="font-size:0.32rem;color:#333;text-align:center">待提交</div>
  52. </template>
  53. </van-tab>
  54. <van-tab name="unfill">
  55. <template #title>
  56. <div style="text-align:center">
  57. <span style="color:#ff4500;font-size:0.58rem">{{unFillList.length + unFillLeaveList.length}}</span>
  58. <span style="font-size:0.32rem;color:#333">人</span>
  59. </div>
  60. <div style="font-size:0.32rem;color:#333;text-align:center">未填写</div>
  61. </template>
  62. </van-tab>
  63. </van-tabs>
  64. <van-cell v-if="stateActive == 'unfill' && (user.timeType.syncCorpwxTime == 1 || user.timeType.syncDingding == 1 || user.company.packageOa == 1)">
  65. <template #default>
  66. <van-tabs type="card" @change="unfillSelect" v-model="unfillSelKey" color="#20a0ff">
  67. <van-tab title="当天未填" :name="0"></van-tab>
  68. <van-tab title="全天请假" :name="1"></van-tab>
  69. </van-tabs>
  70. </template>
  71. </van-cell>
  72. </div>
  73. </van-sticky>
  74. </div>
  75. <van-cell-group>
  76. <van-cell v-if="listLoading">
  77. <template #default>
  78. <van-loading color="#1989fa" size="24" text-size="12" style="text-align:center;">加载中...</van-loading>
  79. </template>
  80. </van-cell>
  81. <van-cell v-if="showList.length == 0">
  82. <template #default>
  83. <div style="text-align:center;color:#7d7e80;font-size:13px">暂无数据</div>
  84. </template>
  85. </van-cell>
  86. <template v-else>
  87. <van-cell v-for="item in showList" :key="item.id" title-style="color:#666">
  88. <template #title>
  89. <div style="text-align:left;margin-left:0.42667rem;">{{item.name}}</div>
  90. </template>
  91. <template #default>
  92. <div style="text-align:right;margin-right:0.42667rem;">{{item.department}}</div>
  93. </template>
  94. </van-cell>
  95. </template>
  96. </van-cell-group>
  97. <Footer page="index"></Footer>
  98. </div>
  99. </template>
  100. <script>
  101. import Footer from "@/components/Footer";
  102. export default {
  103. components: {
  104. Footer
  105. },
  106. data() {
  107. return{
  108. user: JSON.parse(localStorage.userInfo),
  109. reportsCompany: false,
  110. reportsDept: false,
  111. monthSelectShow: false,
  112. monthDatetime: new Date(),
  113. maxDate: new Date(),
  114. nowMonthTitle: '',
  115. dateArray:[],
  116. weekString:['日','一','二','三','四','五','六'],
  117. nowDay: new Date().getDate(),
  118. nowLookDate: '', //当前选中的日期
  119. unfillSelKey: 0,
  120. submitList:[], //已提交人员列表
  121. unSubmitList:[], //未提交人员列表
  122. unFillList:[], //未填写人员列表
  123. unFillLeaveList:[],
  124. showList:[],
  125. listLoading: false,
  126. stateActive: 'submit'
  127. }
  128. },
  129. methods: {
  130. formatter(type, val) {
  131. if (type === 'year') {
  132. return `${val}年`;
  133. } else if (type === 'month') {
  134. return `${val}月`;
  135. }
  136. return val;
  137. },
  138. monthChange(value){
  139. this.nowMonthTitle = value.getFullYear() + '年' + (value.getMonth() + 1) + '月'
  140. this.monthSelectShow = false
  141. let daylength = new Date(value.getFullYear(),(value.getMonth() + 1),0).getDate()
  142. this.dateArray = []
  143. for(let i = 1; i < daylength + 1; i++){
  144. let item = {
  145. day: i,
  146. weekday: new Date(value.getFullYear(),value.getMonth(),i).getDay()
  147. }
  148. this.dateArray.push(item)
  149. }
  150. let newdate = new Date()
  151. if(value.getFullYear() == newdate.getFullYear() && value.getMonth() == newdate.getMonth()){
  152. this.dateChange(newdate.getDate())
  153. }else{
  154. this.dateChange(1)
  155. }
  156. // console.log('当前月份',this.dateArray);
  157. },
  158. dateChange(name){
  159. this.nowDay = name
  160. let nyear = this.monthDatetime.getFullYear()
  161. let nmonth = this.monthDatetime.getMonth() + 1
  162. this.nowLookDate = nyear + '-' + (nmonth < 10 ? '0' + nmonth : nmonth) + '-' + (name < 10 ? '0' + name : name)
  163. // console.log('日期切换',this.nowLookDate,this.nowDay)
  164. this.getCountData()
  165. },
  166. stateChange(active){
  167. this.stateActive = active
  168. if(active == 'submit'){
  169. this.showList = this.submitList
  170. }else if(active == 'unsubmit'){
  171. this.showList = this.unSubmitList
  172. }else if(active == 'unfill'){
  173. this.unfillSelect(0)
  174. }
  175. },
  176. unfillSelect(name){
  177. this.unfillSelKey = name
  178. if(name == 0){
  179. this.showList = this.unFillList
  180. }else{
  181. this.showList = this.unFillLeaveList
  182. }
  183. },
  184. getCountData(){ //获取填报统计数据
  185. let parameter = {
  186. date: this.nowLookDate
  187. }
  188. if (this.user.manageDeptId != 0 && !this.reportsCompany && !this.reportsDept) {
  189. parameter.manageDeptId = this.user.manageDeptId;
  190. }
  191. this.listLoading = true
  192. this.submitList = []
  193. this.unSubmitList = []
  194. this.unFillList = []
  195. this.unFillLeaveList = []
  196. this.$axios.post('/report/getMembList', parameter)
  197. .then(res => {
  198. if(res.code == 'ok'){
  199. this.extractUser(res.data)
  200. this.drawChart()
  201. this.listLoading = false
  202. this.stateChange('submit')
  203. }else {
  204. this.listLoading = false
  205. this.$toast.clear();
  206. this.$toast.fail('获取失败:'+res.msg);
  207. }
  208. }).catch(err=> {
  209. this.listLoading = false
  210. this.$toast.clear();
  211. });
  212. },
  213. extractUser(list){
  214. for(let i in list){
  215. if(list[i].children){
  216. this.extractUser(list[i].children)
  217. }
  218. if(list[i].userList){
  219. let deptname = list[i].label
  220. list[i].userList.forEach(element => {
  221. element.department = deptname
  222. if(element.workingTime){
  223. if(element.state == 3){ //待提交
  224. this.unSubmitList.push(element)
  225. }else{ //已提交
  226. this.submitList.push(element)
  227. }
  228. }else{ //未填写
  229. if((element.leaveDays >= 1 || element.leaveTimes >= this.user.timeType.allday) && (this.user.timeType.syncCorpwxTime == 1 || this.user.timeType.syncDingding == 1 || this.user.company.packageOa == 1)){
  230. this.unFillLeaveList.push(element) //全天请假
  231. }else{
  232. this.unFillList.push(element) //非全天请假
  233. }
  234. }
  235. });
  236. }
  237. }
  238. },
  239. drawChart(){
  240. this.$echarts.init(document.getElementById('main')).dispose()
  241. var myChart = this.$echarts.init(document.getElementById('main'));
  242. // 绘制图表
  243. myChart.setOption({
  244. series: [
  245. {
  246. type: 'pie',
  247. color:['#5d9cec','#fc8d52','#ed5555'],
  248. label: {
  249. show: false
  250. },
  251. data: [this.submitList.length, this.unSubmitList.length, this.unFillList.length + this.unFillLeaveList.length]
  252. // data: [30,20,10]
  253. }
  254. ]
  255. });
  256. myChart.on('click',(params)=>{
  257. if(params.dataIndex == 0){
  258. this.stateChange('submit')
  259. }else if(params.dataIndex == 1){
  260. this.stateChange('unsubmit')
  261. }else{
  262. this.stateChange('unfill')
  263. }
  264. })
  265. }
  266. },
  267. mounted() {
  268. this.monthChange(new Date())
  269. for(let i in this.user.functionList){
  270. if(this.user.functionList[i].name == '查看全公司工时'){
  271. this.reportsCompany = true
  272. }
  273. if(this.user.functionList[i].name == '查看本部门工时'){
  274. this.reportsDept = true
  275. }
  276. }
  277. // console.log('请假填报',this.leaveFil);
  278. }
  279. }
  280. </script>
  281. <style>
  282. body{
  283. background: #fff;
  284. }
  285. .monthSelectContent {
  286. padding: 16px 16px 16px;
  287. }
  288. .monthSel {
  289. background-color: #20a0ff;
  290. color: #fff;
  291. font-size: 12px !important;
  292. padding-top: 0.14rem;
  293. padding-left: 0.43rem;
  294. padding-bottom: 0.3rem;
  295. height: 1.08rem;
  296. }
  297. .monthSel::after{
  298. display: none;
  299. }
  300. .stateActiveClass{
  301. padding: 0.15rem 0;
  302. }
  303. .stateActiveClass .van-tabbar-item{
  304. font-size: 0.3rem;
  305. }
  306. .stateActiveClass .van-tabbar-item .van-tabbar-item__text{
  307. padding-top: 0.1rem;
  308. }
  309. .stateActiveClass .van-tab__text--ellipsis{
  310. -webkit-line-clamp: initial;
  311. padding-bottom: 0.1rem;
  312. }
  313. .title111 {
  314. background-color: #20a0ff;
  315. /* border-radius: 5px; */
  316. overflow: hidden;
  317. }
  318. .title111 .van-tabs__line{
  319. background-color: #f7f7f7;
  320. }
  321. </style>