supersecurityLog.vue 12 KB

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