count.vue 13 KB

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