count.vue 10 KB

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