sentinelLog.vue 12 KB

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