securityLog.vue 13 KB

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