superpatrolLog.vue 13 KB

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