index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view class="page">
  3. <view class="wrap">
  4. <template v-if="itemList.length>0">
  5. <view class="checklist" v-for="(hazardlist,idx) in itemList" :key="idx">
  6. <view class="title more">{{hazardlist.hazardTitle}}</view>
  7. <view class="item-cont" v-if="hazardlist.riskList&&hazardlist.riskList.length>0">
  8. <view class="checklistItem" v-for="(riskItem,itemIdx) in hazardlist.riskList" :key="itemIdx">
  9. <view class="itemTitle more"> {{riskItem.riskTitle}}</view>
  10. <view class="point-cont" v-if="riskItem.recordList&&riskItem.recordList.length>0">
  11. <view class="point" v-for="(measure,measureIdx) in riskItem.recordList" :key="measureIdx" @click="check(measure)">
  12. <view class="pointContent">
  13. <text style="padding-right: 5px;">{{measureIdx+1}})</text>
  14. <text>{{measure.measureContent}}</text>
  15. </view>
  16. <view class="status">【<span class="text">{{measure.checkResult|checkResultFilter}}</span>】</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="handle-container" v-if="handleVisiable">
  23. <view class="handle" @click="handleSubmit(3)">全部通过</view>
  24. <view class="handle" @click="handleSubmit(4)">全不通过</view>
  25. <view class="handle submit" @click="handleSubmit(1)" v-if="canSubmit">提交</view>
  26. <!-- <view class="more" @mouseenter="hover(1)" @mouseleave="hover">
  27. <text class="text">更多</text>
  28. <view class="list" v-if="showMore">
  29. <view class="hand-item-box">
  30. <view class="handle-item" @click="handleSubmit(2)">撤销</view>
  31. </view>
  32. </view>
  33. </view> -->
  34. </view>
  35. </template>
  36. <template v-else>没有可处理的清单^-_-^</template>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. initChecklistHazardRecord,
  43. getChecklistHazardRecordViewById,
  44. completeChecklistDoing,
  45. cancelChecklistDoing,
  46. batchUpdateChecklistHazardRecordDoing,
  47. } from '@/api/aqpt/checklistHazardRecordApi.js'
  48. export default {
  49. data() {
  50. return {
  51. defaultProps: {
  52. id: 'itemId',
  53. children: 'children',
  54. label: 'itemTitle'
  55. },
  56. divider: false,
  57. edit: true,
  58. itemList:[],
  59. recordId:undefined,
  60. checklistId:undefined,
  61. handleVisiable:false,
  62. showMore:false,
  63. submit_bt_state:false,
  64. type:undefined,
  65. status:undefined,
  66. canSubmit:false
  67. }
  68. },
  69. filters: {
  70. checkResultFilter(i) {
  71. if (i >= 0) {
  72. const strs = [
  73. '未检查',
  74. '通过'
  75. ]
  76. return strs[i]
  77. } else {
  78. if (i === -1) {
  79. return '未通过'
  80. } else if (i === -2) {
  81. return '发现隐患'
  82. }
  83. }
  84. }
  85. },
  86. onLoad({id,recordId,type}) {
  87. this.checklistId=id
  88. this.recordId=recordId
  89. this.type=type
  90. if(type==="app"){
  91. this.initCheckList(id)
  92. this.handleVisiable=true
  93. }else{
  94. this.getChecklistHazardRecordViewById(id,recordId)
  95. }
  96. },
  97. methods: {
  98. async initCheckList(checklistId){
  99. let qrcode=uni.getStorageSync('qrcode')
  100. let {data}=await initChecklistHazardRecord({
  101. ocId:qrcode.ocId,
  102. targetId:qrcode.targetId,
  103. targetType:qrcode.targetType,
  104. targetTitle:qrcode.targetTitle,
  105. targetGroupId:qrcode.groupId,
  106. targetGroupName:qrcode.groupName,
  107. checklistId
  108. })
  109. this.itemList=data.hazardList
  110. this.recordId=data.recordId
  111. },
  112. getChecklistHazardRecordViewById(checklistId,recordId){
  113. /* status 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】*/
  114. getChecklistHazardRecordViewById(recordId,checklistId).then((res)=>{
  115. this.itemList=res.data.hazardList
  116. let userId=uni.getStorageSync('userId')
  117. this.status=res.data.status
  118. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===userId)
  119. })
  120. },
  121. check(measure){
  122. uni.setStorageSync('hazard',{
  123. ...measure,
  124. checklistId:this.checklistId,
  125. recordId:this.recordId
  126. })
  127. if(this.type==='history'){
  128. if(this.status===2||this.status===-1){
  129. uni.navigateTo({
  130. url:"/pages/app_views/hazard/detail/detail"
  131. })
  132. }
  133. if(this.handleVisiable){
  134. uni.navigateTo({
  135. url:"/pages/app_views/hazard/form/form"
  136. })
  137. }
  138. }else{
  139. if(!this.handleVisiable) return
  140. uni.navigateTo({
  141. url:"/pages/app_views/hazard/form/form"
  142. })
  143. }
  144. },
  145. handleSubmit(type){
  146. let recordId=this.recordId;
  147. let checklistId=this.checklistId;
  148. if(type===1){//完成
  149. let isNotChecked=true
  150. for(let i=0;i<this.itemList.length;i++){
  151. if(this.itemList[i].riskList){
  152. this.itemList[i].riskList.map(child=>{
  153. child.recordList.map(measure=>{
  154. if(measure.checkResult===-1||measure.checkResult===1){
  155. isNotChecked=false
  156. }
  157. })
  158. })
  159. }
  160. }
  161. if(isNotChecked){
  162. uni.showToast({
  163. icon:"none",
  164. title:"请检查后再提交"
  165. })
  166. return
  167. }
  168. completeChecklistDoing(recordId,checklistId).then(()=>{
  169. if(this.isAllPass()){
  170. uni.$emit('type',4)
  171. uni.switchTab({
  172. url:'/pages/history/history'
  173. })
  174. return
  175. }
  176. uni.showModal({
  177. title: '提示',
  178. content: '本次检查有未通过项,是否需要登记隐患?',
  179. success: function (res) {
  180. if (res.confirm) {
  181. uni.reLaunch({
  182. url:`/pages/app_views/danger/submit/submit?tid=${recordId}`
  183. })
  184. } else if (res.cancel) {
  185. uni.$emit('type',4)
  186. uni.switchTab({
  187. url:'/pages/history/history'
  188. })
  189. }
  190. }
  191. });
  192. }).catch(()=>{
  193. uni.showToast({
  194. icon:"none",
  195. title:"操作失败"
  196. })
  197. })
  198. }
  199. if(type===2){//放弃
  200. cancelChecklistDoing(recordId).then(()=>{
  201. uni.switchTab({
  202. url:'/pages/history/history'
  203. })
  204. }).catch(()=>{
  205. uni.showToast({
  206. icon:"none",
  207. title:"操作失败"
  208. })
  209. })
  210. }
  211. if(type===3){
  212. batchUpdateChecklistHazardRecordDoing(recordId,1).then(()=>{
  213. this.getChecklistHazardRecordViewById(checklistId,recordId)
  214. this.canSubmit=true
  215. })
  216. }
  217. if(type===4){
  218. batchUpdateChecklistHazardRecordDoing(recordId,-1).then(()=>{
  219. this.getChecklistHazardRecordViewById(checklistId,recordId)
  220. this.canSubmit=true
  221. })
  222. }
  223. },
  224. isAllPass(){
  225. let items=[]
  226. for(let i=0;i<this.itemList.length;i++){
  227. if(this.itemList[i].riskList){
  228. this.itemList[i].riskList.map(child=>{
  229. child.recordList.map(measure=>{
  230. items.push(measure)
  231. })
  232. })
  233. }
  234. }
  235. let index=items.findIndex(item=>item.checkResult===-1)
  236. return index<0
  237. },
  238. hover(state){
  239. this.showMore=state===1
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .page{
  246. background-color: #F5F6F8;
  247. padding: 20rpx;
  248. min-height: 100vh;
  249. box-sizing: border-box;
  250. padding-bottom: 120rpx;
  251. .page-head{
  252. text-align: right;
  253. padding-bottom: 10rpx;
  254. .handle{
  255. display: inline-block;
  256. background-color: #3384FF;
  257. color: #fff;
  258. padding: 10rpx 15rpx;
  259. box-sizing: border-box;
  260. border-right: 1rpx solid #eaeaea;
  261. font-size: 30rpx;
  262. text-align: center;
  263. &:nth-child(4){
  264. border: 0;
  265. }
  266. }
  267. }
  268. }
  269. .wrap{
  270. padding: 20rpx;
  271. background-color: #fff;
  272. .checklist{
  273. .title{
  274. color: #222222;
  275. font-size: 32rpx;
  276. height: 98rpx;
  277. line-height: 98rpx;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. border-bottom: 1px dashed #E8E8E8;
  281. }
  282. .more{
  283. background-image: url('/static/tree_more.png');
  284. background-size: 30rpx 30rpx;
  285. padding-left: 40rpx;
  286. background-position: center left;
  287. background-repeat: no-repeat;
  288. }
  289. .item-cont{
  290. padding-left: 20rpx;
  291. border-bottom: 1px dashed #E8E8E8;
  292. .checklistItem{
  293. .itemTitle{
  294. color: #222222;
  295. font-size: 32rpx;
  296. height: 98rpx;
  297. line-height: 98rpx;
  298. }
  299. }
  300. .point-cont{
  301. padding-left: 30rpx;
  302. .point{
  303. display: flex;
  304. color: #666;
  305. font-size: 28rpx;
  306. // height: 98rpx;
  307. // line-height: 98rpx;
  308. .pointContent{
  309. flex: 1;
  310. }
  311. .status{
  312. .text{
  313. color: #3384FF;
  314. font-weight: 800;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. .handle-container{
  322. position: fixed;
  323. width: 100%;
  324. left: 0;
  325. bottom: 0;
  326. background-color: #fff;
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. border-top: 1rpx solid #eaeaea;
  331. padding: 15rpx 0;
  332. .handle{
  333. display:inline-block;
  334. color: #222;
  335. padding: 15rpx 20rpx;
  336. box-sizing: border-box;
  337. border: 1rpx solid #eaeaea;
  338. font-size: 26rpx;
  339. text-align: center;
  340. border-radius: 50rpx;
  341. margin: 0 10rpx;
  342. &.danger{
  343. background-color: #FA5B41;
  344. color: #fff;
  345. }
  346. &.submit{
  347. background-color: #3384FF;
  348. color: #fff;
  349. padding: 18rpx 38rpx;
  350. }
  351. }
  352. .more{
  353. position: relative;
  354. padding: 15rpx 20rpx;
  355. // .text:hover{
  356. // &+.list>.hand-item-box{
  357. // display: block;
  358. // }
  359. // }
  360. .list{
  361. position: absolute;
  362. bottom: 100rpx;
  363. right: 0;
  364. box-shadow: 0px 2px 12px 0px #0000001F;
  365. padding:0 20rpx;
  366. background-color: #fff;
  367. .hand-item-box{
  368. position: relative;
  369. // display: none;
  370. &.show{
  371. display: block;
  372. }
  373. &::after{
  374. width: 0;
  375. height: 0;
  376. content: "";
  377. display: block;
  378. border-width: 26rpx 26rpx 0 0;
  379. border-color: #fff transparent;
  380. border-style: solid;
  381. position: absolute;
  382. bottom: -20rpx;
  383. right: -20rpx;
  384. }
  385. .handle-item{
  386. width: 180rpx;
  387. height: 50rpx;
  388. font-size: 26rpx;
  389. line-height: 50rpx;
  390. background-color: #fff;
  391. text-align: center;
  392. border-bottom: 1px solid #ccc;
  393. padding:10rpx 0;
  394. &:last-child{
  395. border: 0;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. }
  403. </style>