count.vue 10 KB

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