count.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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 id="main" style="width:250px;height:250px;margin:0 auto"></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">已提交</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">待提交</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">未填写</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="item.name" :value="item.department" title-style="color:#666"></van-cell>
  88. </template>
  89. </van-cell-group>
  90. <Footer page="index"></Footer>
  91. </div>
  92. </template>
  93. <script>
  94. import Footer from "@/components/Footer";
  95. export default {
  96. components: {
  97. Footer
  98. },
  99. data() {
  100. return{
  101. user: JSON.parse(localStorage.userInfo),
  102. reportsCompany: false,
  103. reportsDept: false,
  104. monthSelectShow: false,
  105. monthDatetime: new Date(),
  106. maxDate: new Date(),
  107. nowMonthTitle: '',
  108. dateArray:[],
  109. weekString:['日','一','二','三','四','五','六'],
  110. nowDay: new Date().getDate(),
  111. nowLookDate: '', //当前选中的日期
  112. unfillSelKey: 0,
  113. submitList:[], //已提交人员列表
  114. unSubmitList:[], //未提交人员列表
  115. unFillList:[], //未填写人员列表
  116. unFillLeaveList:[],
  117. showList:[],
  118. listLoading: false,
  119. stateActive: 'submit'
  120. }
  121. },
  122. methods: {
  123. formatter(type, val) {
  124. if (type === 'year') {
  125. return `${val}年`;
  126. } else if (type === 'month') {
  127. return `${val}月`;
  128. }
  129. return val;
  130. },
  131. monthChange(value){
  132. this.nowMonthTitle = value.getFullYear() + '年' + (value.getMonth() + 1) + '月'
  133. this.monthSelectShow = false
  134. let daylength = new Date(value.getFullYear(),(value.getMonth() + 1),0).getDate()
  135. this.dateArray = []
  136. for(let i = 1; i < daylength + 1; i++){
  137. let item = {
  138. day: i,
  139. weekday: new Date(value.getFullYear(),value.getMonth(),i).getDay()
  140. }
  141. this.dateArray.push(item)
  142. }
  143. let newdate = new Date()
  144. if(value.getFullYear() == newdate.getFullYear() && value.getMonth() == newdate.getMonth()){
  145. this.dateChange(newdate.getDate())
  146. }else{
  147. this.dateChange(1)
  148. }
  149. // console.log('当前月份',this.dateArray);
  150. },
  151. dateChange(name){
  152. this.nowDay = name
  153. let nyear = this.monthDatetime.getFullYear()
  154. let nmonth = this.monthDatetime.getMonth() + 1
  155. this.nowLookDate = nyear + '-' + (nmonth < 10 ? '0' + nmonth : nmonth) + '-' + (name < 10 ? '0' + name : name)
  156. // console.log('日期切换',this.nowLookDate,this.nowDay)
  157. this.getCountData()
  158. },
  159. stateChange(active){
  160. this.stateActive = active
  161. if(active == 'submit'){
  162. this.showList = this.submitList
  163. }else if(active == 'unsubmit'){
  164. this.showList = this.unSubmitList
  165. }else if(active == 'unfill'){
  166. this.unfillSelect(0)
  167. }
  168. },
  169. unfillSelect(name){
  170. this.unfillSelKey = name
  171. if(name == 0){
  172. this.showList = this.unFillList
  173. }else{
  174. this.showList = this.unFillLeaveList
  175. }
  176. },
  177. getCountData(){ //获取填报统计数据
  178. let parameter = {
  179. date: this.nowLookDate
  180. }
  181. if (this.user.manageDeptId != 0 && !this.reportsCompany && !this.reportsDept) {
  182. parameter.manageDeptId = this.user.manageDeptId;
  183. }
  184. this.listLoading = true
  185. this.submitList = []
  186. this.unSubmitList = []
  187. this.unFillList = []
  188. this.unFillLeaveList = []
  189. this.$axios.post('/report/getMembList', parameter)
  190. .then(res => {
  191. if(res.code == 'ok'){
  192. this.extractUser(res.data)
  193. this.drawChart()
  194. this.listLoading = false
  195. this.stateChange('submit')
  196. }else {
  197. this.listLoading = false
  198. this.$toast.clear();
  199. this.$toast.fail('获取失败:'+res.msg);
  200. }
  201. }).catch(err=> {
  202. this.listLoading = false
  203. this.$toast.clear();
  204. });
  205. },
  206. extractUser(list){
  207. for(let i in list){
  208. if(list[i].children){
  209. this.extractUser(list[i].children)
  210. }
  211. if(list[i].userList){
  212. let deptname = list[i].label
  213. list[i].userList.forEach(element => {
  214. element.department = deptname
  215. if(element.workingTime){
  216. if(element.state == 3){ //待提交
  217. this.unSubmitList.push(element)
  218. }else{ //已提交
  219. this.submitList.push(element)
  220. }
  221. }else{ //未填写
  222. 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)){
  223. this.unFillLeaveList.push(element) //全天请假
  224. }else{
  225. this.unFillList.push(element) //非全天请假
  226. }
  227. }
  228. });
  229. }
  230. }
  231. },
  232. drawChart(){
  233. this.$echarts.init(document.getElementById('main')).dispose()
  234. var myChart = this.$echarts.init(document.getElementById('main'));
  235. // 绘制图表
  236. myChart.setOption({
  237. series: [
  238. {
  239. type: 'pie',
  240. color:['#5d9cec','#fc8d52','#ed5555'],
  241. label: {
  242. show: false
  243. },
  244. data: [this.submitList.length, this.unSubmitList.length, this.unFillList.length + this.unFillLeaveList.length]
  245. // data: [30,20,10]
  246. }
  247. ]
  248. });
  249. myChart.on('click',(params)=>{
  250. if(params.dataIndex == 0){
  251. this.stateChange('submit')
  252. }else if(params.dataIndex == 1){
  253. this.stateChange('unsubmit')
  254. }else{
  255. this.stateChange('unfill')
  256. }
  257. })
  258. }
  259. },
  260. mounted() {
  261. this.monthChange(new Date())
  262. for(let i in this.user.functionList){
  263. if(this.user.functionList[i].name == '查看全公司工时'){
  264. this.reportsCompany = true
  265. }
  266. if(this.user.functionList[i].name == '查看本部门工时'){
  267. this.reportsDept = true
  268. }
  269. }
  270. // console.log('请假填报',this.leaveFil);
  271. }
  272. }
  273. </script>
  274. <style>
  275. body{
  276. background: #fff;
  277. }
  278. .monthSelectContent {
  279. padding: 16px 16px 16px;
  280. }
  281. .monthSel {
  282. background-color: #20a0ff;
  283. color: #fff;
  284. font-size: 12px !important;
  285. padding-top: 0.14rem;
  286. padding-left: 0.43rem;
  287. padding-bottom: 0.3rem;
  288. }
  289. .monthSel::after{
  290. display: none;
  291. }
  292. .stateActiveClass{
  293. padding: 0.15rem 0;
  294. }
  295. .stateActiveClass .van-tabbar-item{
  296. font-size: 0.3rem;
  297. }
  298. .stateActiveClass .van-tabbar-item .van-tabbar-item__text{
  299. padding-top: 0.1rem;
  300. }
  301. .title111 {
  302. background-color: #20a0ff;
  303. /* border-radius: 5px; */
  304. overflow: hidden;
  305. }
  306. .title111 .van-tabs__line{
  307. background-color: #f7f7f7;
  308. }
  309. </style>