dailyReport.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
  3. <u-navbar :titleStyle="{ color: '#000' }" :autoBack="false" title="日报" :placeholder="true" :safeAreaInsetTop="true" bgColor="#fff">
  4. <template #left>
  5. <u-icon name="arrow-left" size="20" color="#000" @click="returnTo('business/common/projectMange/statistics/index')"></u-icon>
  6. </template>
  7. </u-navbar>
  8. </u-sticky>
  9. <view class="timeSelect">
  10. <view @click="daySwitch(0)"><u-icon name="arrow-left" size="14" color="#000" class="left"></u-icon></view>
  11. <view><text>{{ day }}</text></view>
  12. <view @click="daySwitch(1)" ><u-icon name="arrow-right" size="14" :color="statusNext ? '#000' : '#ccc'" class="right" aria-disabled="true"></u-icon></view>
  13. </view>
  14. <view class="container">
  15. <view class="menu-list">
  16. <view class="list-cell">
  17. <view class="list" :class="{ active: query.queryType == item.value }" @click="tabsClick(item.value)" v-for="(item,index) in activeList" :key="index">
  18. <text>{{ index == 0 ? statistics.submitOnTime :index == 1 ? statistics.submitLate : index == 2 ? statistics.notSubmitted : '' }}</text>
  19. <text>{{ item.name }}</text>
  20. <text v-if="item.value == 0 || item.value == 1"></text>
  21. <text class="line"></text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="report-list">
  26. <view class="report-cell" v-for="(el,index) in reportList" :key="index">
  27. <view class="flex report" @click="toPage(el.id,el.lockStatus)">
  28. <image :src="el.avatar" class="content-area-center-avatarImg mr10" v-if="el.avatar" />
  29. <u-avatar
  30. v-if="!el.avatar && query.queryType != 2 && el.createBy"
  31. class="content-area-center-avatar mr10"
  32. :text="el.createBy.length > 2 ? el.createBy.slice(1, 3) : el.createBy"
  33. shape="square"
  34. fontSize="12"
  35. color="#ffffff"
  36. :bgColor="proxy.$settingStore.themeColor.color"
  37. ></u-avatar>
  38. <u-avatar
  39. v-if="!el.avatar && query.queryType == 2 && el.userName"
  40. class="content-area-center-avatar mr10"
  41. :text="el.nickName.length > 2 ? el.nickName.slice(1, 3) : el.nickName"
  42. shape="square"
  43. fontSize="12"
  44. color="#ffffff"
  45. :bgColor="proxy.$settingStore.themeColor.color"
  46. ></u-avatar>
  47. <view class="left">
  48. <view class="content-area-center-title font14 mb5">{{ query.queryType == 2 ? el.nickName : el.createBy }}</view>
  49. <view class="content-area-center-time font12">{{ el.deptName }}</view>
  50. </view>
  51. <view class="right" v-if="query.queryType != 2">
  52. <view class="content-area-center-time font12">{{ el.submitDateOutput }}</view>
  53. <image src="@/static/images/projectMange/lock.png" alt="" style="width: 10px;height: 12.5px;margin-top:10px;" v-if="el.lockStatus" />
  54. <view class="content-area-center-time font12" v-if="!el.lockStatus" :style="{color: el.readStatus ? '#999' : '#2A98FF',marginTop: '10px'}">{{ el.readStatus ? '已读' : '未读' }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="noData" v-if="!total">
  59. <image src="@/static/images/data.png" alt="" />
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script setup>
  65. /*----------------------------------依赖引入-----------------------------------*/
  66. import { onLoad, onShow, onReady } from "@dcloudio/uni-app";
  67. import { ref, getCurrentInstance, reactive } from "vue";
  68. /*----------------------------------接口引入-----------------------------------*/
  69. import { projectApi } from "@/api/business/project.js";
  70. import { listDeptNoAuth } from "@/api/system/user";
  71. // import dayjs from 'dayjs/esm/index'
  72. /*----------------------------------组件引入-----------------------------------*/
  73. /*----------------------------------store引入-----------------------------------*/
  74. import { useStores } from "@/store/modules/index";
  75. import dayjs from "dayjs";
  76. /*----------------------------------公共方法引入-----------------------------------*/
  77. /*----------------------------------公共变量-----------------------------------*/
  78. const { proxy } = getCurrentInstance();
  79. const useStore = useStores();
  80. const day = ref("")
  81. const statusNext = ref(false)//下一天按钮状态
  82. const currentDate = ref("")//当前日期
  83. const date = reactive({
  84. year:"",
  85. month:"",
  86. day:""
  87. })
  88. const activeList = reactive([
  89. {name:"按时提交",value:0},
  90. {name:"迟交",value:1},
  91. {name:"未提交",value:2},
  92. ])
  93. const query = ref({
  94. queryType:0,
  95. submitDate:null,
  96. reportId:null,
  97. pageNum:1,
  98. pageSize:1000,
  99. })
  100. /*----------------------------------变量声明-----------------------------------*/
  101. const statistics = ref({
  102. submitOnTime: 0, //按时提交
  103. submitLate: 0, //迟交
  104. notSubmitted:0, //未交
  105. })
  106. const loading = ref(false)
  107. const reportList = ref([])
  108. const pageSize = ref(20)
  109. const current = ref(1)
  110. const total = ref(0)
  111. var pages = getCurrentPages(); //获取当前页面栈的实例;
  112. /**
  113. * @页面初始化
  114. */
  115. function init(id,statisticalDate) {
  116. if(id){
  117. query.value.queryType = id
  118. }
  119. var time;
  120. if(statisticalDate){
  121. time = statisticalDate.split("-")
  122. day.value = `${time[0]}年${time[1]>=10 ? time[1] : time[1].slice(1)}月${time[2]>=10 ? time[2] : time[2].slice(1)}日`
  123. query.value.submitDate = statisticalDate
  124. }else{
  125. time = dayjs().format("YYYY-MM-DD").split("-")
  126. day.value = `${time[0]}年${time[1]}月${time[2]}日`
  127. query.value.submitDate = dayjs().format("YYYY-MM-DD")
  128. }
  129. currentDate.value = dayjs().format("YYYYMMDD")
  130. date.value = {
  131. year:time[0],
  132. month:time[1],
  133. day:time[2]
  134. }
  135. if(`${time[0]}${time[1]}${time[2]}` < currentDate.value){
  136. statusNext.value = true
  137. }else{
  138. statusNext.value = false
  139. }
  140. if(statisticalDate){
  141. getStatistics(statisticalDate)
  142. }else{
  143. getStatistics()
  144. }
  145. getPageList()
  146. }
  147. //获取统计数据
  148. function getStatistics(time) {
  149. projectApi().pmTimeConfCount(time ? {submitDate:query.value.submitDate} : null ).then((res) => {
  150. statistics.value = res.data;
  151. });
  152. }
  153. //获取分页数据
  154. function getPageList() {
  155. reportList.value = []
  156. projectApi().pmTimeConfPage(query.value).then((res) => {
  157. if(res.data.records){
  158. reportList.value = res.data.records[0];
  159. total.value = res.data.total;
  160. var deptItem = []
  161. listDeptNoAuth().then((res)=>{//部门名称
  162. deptItem = res.data
  163. for(let i=0;i<reportList.value.length;i++){
  164. reportList.value[i].deptName = deptItem.find(item => item.deptId == reportList.value[i].deptId).deptName
  165. if(query.value.queryType != 2){ //按时提交/迟交
  166. var monthDayWrap = reportList.value[i].submitDate.split(" ")[0]
  167. var time = reportList.value[i].submitDate.split(" ")[1].slice(0,5)
  168. var month = monthDayWrap.split("-")[1] >= 10 ? monthDayWrap.split("-")[1] : monthDayWrap.split("-")[1].slice(1)
  169. var day = monthDayWrap.split("-")[2] >= 10 ? monthDayWrap.split("-")[2] : monthDayWrap.split("-")[2].slice(1)
  170. reportList.value[i].submitDateOutput = `${month}月${day}日 ${time}` //提交时间
  171. reportList.value[i].lockStatus = reportList.value[i].ccTo.indexOf(useStore.userId) > -1 ? false : true //锁定状态
  172. reportList.value[i].readStatus = reportList.value[i].pmReportReaders.readAlready.map((item) => item).length > 0 ? true : false //阅读状态
  173. if(reportList.value[i].createBy == useStore.userName){//本人
  174. reportList.value[i].lockStatus = false
  175. reportList.value[i].readStatus = true
  176. }
  177. }
  178. }
  179. })
  180. }
  181. });
  182. }
  183. /** 日期选择*/
  184. function daySwitch(id){
  185. const targetDate = dayjs(`${date.value.year}-${date.value.month}-${date.value.day}`);
  186. var previousDay;
  187. if(id == 0){
  188. previousDay = targetDate.subtract(1, 'day');
  189. }
  190. if(id == 1){
  191. previousDay = targetDate.subtract(-1, 'day');
  192. }
  193. var time = previousDay.format("YYYY-MM-DD")
  194. var time2 = previousDay.format("YYYYMMDD")
  195. if(id == 0){
  196. uni.redirectTo({
  197. url:`/pages/business/common/projectMange/statistics/dailyReport?id=${query.value.queryType}&statisticalDate=${time}`
  198. })
  199. }
  200. if(id == 1 && time2 <= currentDate.value){
  201. uni.redirectTo({
  202. url:`/pages/business/common/projectMange/statistics/dailyReport?id=${query.value.queryType}&statisticalDate=${time}`
  203. })
  204. }
  205. }
  206. /**类型选择 */
  207. function tabsClick(id){
  208. query.value.queryType = id
  209. getStatistics(query.value.submitDate)
  210. getPageList()
  211. }
  212. /** 跳转到详情页 */
  213. function toPage(id,permission){
  214. if(query.value.queryType != 2){
  215. if(!permission){
  216. proxy.$tab.navigateTo(`/pages/business/common/projectMange/record/details?reportId=${id}`);
  217. }else{
  218. uni.showToast({
  219. title: '你不是接收人不能查看内容',
  220. icon: "none",
  221. duration: 2000,
  222. });
  223. }
  224. }
  225. }
  226. /**
  227. * 返回上级页面
  228. * @param defaultPage 默认页面
  229. */
  230. function returnTo(defaultPage) {
  231. if(getCurrentPages().length > 1){
  232. uni.navigateBack()
  233. }else{
  234. uni.redirectTo({
  235. url: `/pages/${defaultPage}`
  236. })
  237. }
  238. }
  239. onLoad((options) => {
  240. if(options?.id && options?.statisticalDate){
  241. init(options.id,options.statisticalDate)
  242. }else if(options?.id){
  243. init(options.id)
  244. }else if(options?.statisticalDate){
  245. init(null,options.statisticalDate)
  246. }else{
  247. init()
  248. }
  249. });
  250. onShow(() => {
  251. //调用系统主题颜色
  252. proxy.$settingStore.systemThemeColor([1]);
  253. });
  254. </script>
  255. <style lang="scss" scoped>
  256. .timeSelect{
  257. width:100%;
  258. height:35px;
  259. background: #fff;
  260. >view{
  261. display: inline-block;
  262. height:35px;
  263. line-height: 35px;
  264. position: relative;
  265. .left{
  266. position: absolute;
  267. top:11px;
  268. right:20px;
  269. }
  270. .right{
  271. position: absolute;
  272. top:11px;
  273. left:20px;
  274. }
  275. }
  276. view:nth-child(1),view:nth-child(3){
  277. width:20%;
  278. }
  279. view:nth-child(2){
  280. width:60%;
  281. text{
  282. position: absolute;
  283. width:100%;
  284. text-align: center;
  285. }
  286. }
  287. }
  288. .container{
  289. width:100%;
  290. height:calc(100% - 20px);
  291. margin:10px 0;
  292. .menu-list{
  293. width:100%;
  294. margin:0px 0 0 0px;
  295. padding:15px 10px;
  296. background: #ffffff;
  297. border-radius: 10px;
  298. .list-cell{
  299. display: flex;
  300. padding:0;
  301. .list{
  302. flex:1;
  303. text-align: center;
  304. position: relative;
  305. text{
  306. display: block;
  307. color:#999999;
  308. }
  309. text:nth-child(1){
  310. font-weight: 700;
  311. font-size: 14px;
  312. }
  313. text:nth-child(2){
  314. font-size: 12px;
  315. margin-top:10px;
  316. }
  317. }
  318. .list:nth-child(1),.list:nth-child(2){
  319. text:nth-child(3){
  320. width:1px;
  321. height:50%;
  322. position: absolute;
  323. top:25%;
  324. right:0;
  325. background: #E7E7E7;
  326. }
  327. }
  328. .active{
  329. text{
  330. color:#000;
  331. }
  332. .line{
  333. position: absolute;
  334. bottom:-36%;
  335. left:25%;
  336. width:50%;
  337. height:4px;
  338. border-radius: 2px;
  339. background: #000;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .report-list{
  346. height:calc(100vh - 160px);
  347. padding-bottom:50px;
  348. overflow: scroll;
  349. .report{
  350. padding:15px 10px;
  351. background: #ffffff;
  352. margin-top:4px;
  353. .left,.right{
  354. width:calc(50% - 25px);
  355. }
  356. .right{
  357. text-align: right;
  358. }
  359. }
  360. .noData{
  361. image{
  362. width:50%;
  363. margin:20px 25%;
  364. }
  365. }
  366. }
  367. .content-area {
  368. &-time {
  369. padding: 10px;
  370. text-align: left;
  371. color: #000000;
  372. font-weight: 600;
  373. }
  374. &-center {
  375. margin: 0;
  376. padding: 15px;
  377. overflow: hidden;
  378. border-bottom: 1px solid #eaeef1;
  379. &:last-child {
  380. border-bottom: 0px solid #eaeef1;
  381. }
  382. &-avatar {
  383. margin: auto 0;
  384. width:40px !important;
  385. height:40px !important;
  386. }
  387. &-avatarImg {
  388. width:40px !important;
  389. height:40px !important;
  390. border-radius: 4px;
  391. >img{
  392. width:100% !important;
  393. }
  394. }
  395. &-title {
  396. margin: 0 0 15px 0;
  397. font-weight: 600;
  398. color: #000000;
  399. }
  400. }
  401. }
  402. .list-cell::after{
  403. border:none;
  404. }
  405. </style>