supervisorLog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view style="overflow: hidden;">
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">监理日志</block>
  5. <block slot="content"></block>
  6. <block slot="right">
  7. <view class=" flex justify-center">
  8. <!-- <button class="margin-top-ssm cu-btn round bg-blue text-blue"><text class="cuIcon-add"></text></button> -->
  9. </view>
  10. </block>
  11. </cu-custom>
  12. <!-- 项目合同信息 -->
  13. <!-- <view style="padding: 22rpx 0;background-color: #F7F7F7;">
  14. <cu-project :projectList="projectList" style="height: 236rpx;background-color: #C6E6FF;"></cu-project>
  15. </view> -->
  16. <view style="padding: 0rpx 0rpx 22rpx;background-color: #F7F7F7;">
  17. <view class="cu-item shadowType" style="height: 100%;background-color: #FFFFFF;border-radius: 0 0 20rpx 20rpx;border-top: 2rpx solid#0A8CD5;" >
  18. <calendar @selected-change="datechange" ref="calendarData" :showBack="true" :dotList="dotList" :dotStyle="dotStyle"></calendar>
  19. </view>
  20. </view>
  21. <!-- 日志 -->
  22. <view class="journal_b">
  23. <view class="journal_1">
  24. <view :class="chooseTime=='' ? 'journal_ts':'journal_time'">
  25. {{chooseTime=='' ? '请选择时间':chooseTime}}
  26. ({{personLength}}人)
  27. </view>
  28. <view>
  29. <button @click="navTo()" v-if="type==0 && chooseTime!=''" class="journal-btn" >立即填报</button>
  30. <button @click="navTo()" v-if="type==1 && chooseTime!=''" class="journal-btn" >编辑</button>
  31. <text v-if="type==2 && chooseTime!=''" class="text-gray">未开始</text>
  32. <text v-if="type==4" class="text-gray"></text><!-- 别人的日志只能看不能操作 -->
  33. </view>
  34. </view>
  35. </view>
  36. <view>
  37. <view style="overflow-x: scroll;width: 100%;margin: 20rpx 0 0 16rpx ;display: flex;">
  38. <view class="name-box" style="flex-shrink: 0;"
  39. :class="index == curPersonIndex ? 'name-sele' : '' "
  40. v-for="(person,index) in personList" :key="index"
  41. @click="selectPerson(index)">{{person.username}}</view>
  42. </view>
  43. </view>
  44. <view v-if="type==0 || type==2 || type ==null || chooseTime==''" class="padding bg-white text-center">
  45. <view class="padding">
  46. <image class="menuImageNoTask" src="../../static/task/noTask.png"></image>
  47. </view>
  48. <view class="padding">暂时没有提交日志~</view>
  49. </view>
  50. <view v-else style="padding: 22rpx 22rpx 80rpx;">
  51. <view class="margin-bottom-sm">
  52. <text class="margin-right-sm">天气:
  53. <text class="margin-right-sm2">{{logData.weather}}</text>
  54. </text>
  55. </view>
  56. <view class="margin-bottom-sm">
  57. <text class="margin-right-sm">编号:
  58. <text class="margin-right-sm2">{{logData.serialNumber}}</text>
  59. </text>
  60. </view>
  61. <view class="margin-bottom-sm">
  62. <text class="margin-right-sm">审核人:
  63. <text class="margin-right-sm2">{{logData.reviewer}}</text>
  64. </text>
  65. </view>
  66. <view class="margin-bottom-sm">
  67. <text class="margin-right-sm">主要施工情况:
  68. <text class="margin-right-sm2">{{logData.jobContent}}</text>
  69. </text>
  70. </view>
  71. <view class="margin-bottom-sm">
  72. <text class="margin-right-sm">监理主要作业:
  73. <text class="margin-right-sm2">{{logData.buildContent}}</text>
  74. </text>
  75. </view>
  76. <view class="margin-bottom-sm">
  77. <text class="margin-right-sm">问题及处理情况:
  78. <text class="margin-right-sm2">{{logData.problem}}</text>
  79. </text>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. export default {
  86. data() {
  87. return {
  88. userInfo:"",
  89. projectList:'',
  90. index:0,
  91. content:"",
  92. dotList:[],
  93. dotStyle:{color: 'black'},
  94. type:null,
  95. chooseTime:"",
  96. logData:"",
  97. chooseData:"",
  98. personList:[],
  99. curPersonIndex:0,
  100. }
  101. },
  102. computed:{
  103. personLength: function () {
  104. var num = 0;
  105. for (let i = 0; i < this.personList.length; i++) {
  106. if(this.personList[i].id){
  107. num ++;
  108. }
  109. }
  110. return num;
  111. }
  112. },
  113. onShow() {
  114. var that = this;
  115. that.onLoadData();
  116. that.chooseTime='';
  117. /* 监听今天 */
  118. uni.$on("clickToday", res => {
  119. that.findDiaryByToday();
  120. });
  121. },
  122. methods: {
  123. datechange(e){
  124. var nowDate =new Date().toISOString().slice(0, 10);
  125. this.chooseTime = e.fullDate;
  126. if(nowDate<e.fullDate || !e.info){//超出今天或者在项目开始前都算 未开始
  127. this.type=2;
  128. this.personList = [];
  129. return;
  130. }
  131. //未填写过不查询
  132. if(!(e.info && e.info.id)){
  133. this.type = 0;
  134. this.personList = [];
  135. return;
  136. }
  137. this.curPersonIndex = [0];
  138. this.http.request('/app/superEntity/getDataByDate', { recorderId:'',contractId:this.projectList.contractId,date:e.fullDate}).then((res)=>{
  139. //如果没人填写过
  140. if(!res.datas || res.datas.length < 1){
  141. this.type = 0;
  142. this.personList = [];
  143. return;
  144. }
  145. //console.log(res)
  146. //根据数据获取当前是否 已经填写了
  147. let myIndex = -1;
  148. res.datas.forEach((item,index)=>{
  149. if(item.recorderId == this.userInfo.id){
  150. myIndex = index;
  151. return;
  152. }
  153. })
  154. if(myIndex > -1){
  155. this.type = 1;
  156. //把自己放到第一位
  157. let myData = res.datas.splice(myIndex,1);
  158. res.datas.unshift(myData[0]);
  159. }else{
  160. this.type = 0;
  161. res.datas.unshift({
  162. username:this.userInfo.userName,
  163. recorderId:this.userInfo.id,
  164. id:''
  165. });
  166. }
  167. this.personList = res.datas;
  168. this.chooseData = res.datas[0];
  169. this.logData = res.datas[0];
  170. })
  171. },
  172. // datechange(e) {
  173. // console.log(e);
  174. // //debugger
  175. // if(e.isToday){//判断是否为今天
  176. // if(e.info){
  177. // if(e.info.id){//判断是否有施工日志
  178. // this.type=1;
  179. // this.logData=e.info;
  180. // }else{
  181. // this.type=0
  182. // }
  183. // }else{
  184. // this.type=2
  185. // }
  186. // }else{
  187. // var nowDate =new Date().toISOString().slice(0, 10);
  188. // if(nowDate<e.fullDate){//判断是否为超前时间
  189. // this.type=2
  190. // }else{
  191. // if(e.info){//判断是否在合同段的计划时间内
  192. // if(e.info.id){//判断是否有施工日志
  193. // this.type=1;
  194. // this.logData=e.info;
  195. // }else{
  196. // this.type=0
  197. // }
  198. // }else{
  199. // this.type=2
  200. // }
  201. // }
  202. // }
  203. // this.chooseTime =e.fullDate;
  204. // this.chooseData =e.info;
  205. // },
  206. navTo(){
  207. uni.navigateTo({
  208. url:"update/update?time="+this.chooseTime+"&type="+this.type+"&id="+this.chooseData.id
  209. })
  210. },
  211. /* 刷新方法 */
  212. onLoadData(){
  213. var userInfo = uni.getStorageSync("userInfo")
  214. if(userInfo){
  215. this.userInfo = userInfo;
  216. }
  217. var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  218. if(project){
  219. this.projectList =project;//获取选中的当前项目
  220. }else{
  221. this.findProject();
  222. }
  223. this.findDiaryDate();
  224. },
  225. /* 查询项目 */
  226. findProject(){
  227. var that =this;
  228. that.http.request('/app/login', { userId:this.userInfo.id }).then((result)=>{
  229. if(result.datas.length!=0){
  230. that.projectList=result.datas[0];
  231. //默认选中第一条
  232. uni.setStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id,that.projectList);
  233. }
  234. })
  235. },
  236. /* 获取施工日志*/
  237. findDiaryDate(){
  238. var that =this;
  239. that.http.request('/app/superEntity/list', { recorderId:that.userInfo.id,contractId:that.projectList.contractId }).then((result)=>{
  240. that.dotList = result;
  241. if(!that.$refs.calendarData || !that.$refs.calendarData.selectedItem){
  242. //如果当前没有选择的日期获取今天的
  243. let today =that.intervalTime.getTime();
  244. this.chooseTime = today
  245. //如果不在日期范围内不请求
  246. let dateListSort = JSON.parse(JSON.stringify(result));
  247. dateListSort.sort(function(a, b) {
  248. return b.date < a.date ? -1 : 1
  249. })
  250. //console.log(dateListSort)
  251. if(today>dateListSort[0].date || today<dateListSort[dateListSort.length-1].date){
  252. return
  253. }
  254. that.findDiaryByToday();
  255. }
  256. if(that.$refs.calendarData && that.$refs.calendarData.selectedItem){
  257. //如果有获取当前的
  258. var selectedItem = that.$refs.calendarData.selectedItem
  259. var time = selectedItem.fullDate;
  260. //console.log(that.dotList)
  261. that.dotList.forEach(item=>{
  262. if(item.date == time){
  263. that.datechange(Object.assign(selectedItem,{'info':item}));
  264. return;
  265. }
  266. })
  267. }
  268. })
  269. },
  270. /* 根据当前时间获取施工日志数据*/
  271. findDiaryByToday(){
  272. var that =this;
  273. var time =that.intervalTime.getTime();
  274. //console.log(time)
  275. this.http.request('/app/superEntity/getDataByDate', { recorderId:'',contractId:this.projectList.contractId,date:time}).then((res)=>{
  276. //如果没人填写过
  277. if(!res.datas || res.datas.length < 1){
  278. this.chooseTime = time;
  279. this.type = 0;
  280. this.personList = [];
  281. return;
  282. }
  283. //console.log(res)
  284. this.chooseTime = time;
  285. //根据数据获取当前是否 已经填写了
  286. let myIndex = -1;
  287. res.datas.forEach((item,index)=>{
  288. if(item.recorderId == this.userInfo.id){
  289. myIndex = index;
  290. return;
  291. }
  292. })
  293. if(myIndex > -1){
  294. this.type = 1;
  295. //把自己放到第一位
  296. let myData = res.datas.splice(myIndex,1);
  297. res.datas.unshift(myData[0]);
  298. }else{
  299. this.type = 0;
  300. res.datas.unshift({
  301. username:this.userInfo.userName,
  302. recorderId:this.userInfo.id,
  303. id:''
  304. });
  305. }
  306. this.personList = res.datas;
  307. this.chooseData = res.datas[0];
  308. this.logData = res.datas[0];
  309. })
  310. },
  311. selectPerson(index){
  312. this.curPersonIndex = index;
  313. //是否有填写日志
  314. if(this.personList[index].id){
  315. //只能看别人
  316. if(this.personList[index].recorderId == this.userInfo.id){
  317. this.type = 1;
  318. }else{
  319. this.type = 4;
  320. }
  321. this.chooseData = this.personList[index];
  322. this.logData = this.personList[index];
  323. }else{
  324. this.type = 0;
  325. }
  326. }
  327. }
  328. }
  329. </script>
  330. <style>
  331. page{background-color: #fff;}
  332. .solid-bottom-type{
  333. border-bottom: 0.5px solid #eee;
  334. }
  335. .solid-top-type{
  336. border-top: 2px solid #0A8CD5;
  337. }
  338. .shadowType {
  339. -moz-box-shadow: 0px 1px 4px #D0D0D0;
  340. -webkit-box-shadow: 0px 1px 4px #D0D0D0;
  341. box-shadow: 0px 1px 4px #D0D0D0;
  342. }
  343. .journal_b{background-color: #F7F7F7;}
  344. .journal_1{background-color: #FFFFFF;border-bottom: 1rpx solid #E3E1E1;border-radius: 20rpx 20rpx 0 0;height: 100rpx;display: flex;align-items: center;justify-content: space-between;padding: 0 22rpx;box-shadow: 1px -1px 2px #D0D0D0}
  345. .journal_ts{font-size: 30rpx;}
  346. .journal_time{font-size: 30rpx;color: #101010;font-weight: bold;}
  347. .journal-btn{width: 100%;height: 60rpx;line-height: 60rpx;font-size: 26rpx;color: #0A8CD5;border-radius: 100rpx;border: 2rpx solid #0A8CD5;background-color: #fff;}
  348. .journal-btn::after{
  349. border: none;
  350. }
  351. .margin-bottom-sm{margin-bottom: 22rpx;}
  352. .margin-right-sm{margin-right: 16rpx;font-size: 30rpx;color: #101010;}
  353. .margin-right-sm2{font-size: 30rpx;color: #8a8a8a;}
  354. .name-box{
  355. /* width: 140rpx;
  356. height: 50rpx;
  357. border-radius: 50rpx;
  358. line-height: 50rpx;
  359. text-align: center; */
  360. background-color: #F7F7F7;
  361. margin-right: 20rpx;
  362. padding: 10rpx 26rpx;
  363. border-radius: 50rpx;
  364. }
  365. .name-sele{
  366. background-color: #E2F3FD;
  367. }
  368. </style>