patrolLog.vue 11 KB

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