index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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)">提交</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. }
  65. },
  66. filters: {
  67. checkResultFilter(i) {
  68. if (i >= 0) {
  69. const strs = [
  70. '未检查',
  71. '通过'
  72. ]
  73. return strs[i]
  74. } else {
  75. if (i === -1) {
  76. return '未通过'
  77. } else if (i === -2) {
  78. return '发现隐患'
  79. }
  80. }
  81. }
  82. },
  83. onLoad({id,recordId,type}) {
  84. this.checklistId=id
  85. this.recordId=recordId
  86. if(type==="app"){
  87. this.initCheckList(id)
  88. this.handleVisiable=true
  89. }else{
  90. this.getChecklistHazardRecordViewById(id,recordId)
  91. }
  92. },
  93. methods: {
  94. async initCheckList(checklistId){
  95. let qrcode=uni.getStorageSync('qrcode')
  96. let {data}=await initChecklistHazardRecord({
  97. ocId:qrcode.ocId,
  98. targetId:qrcode.targetId,
  99. targetType:qrcode.targetType,
  100. targetTitle:qrcode.targetTitle,
  101. targetGroupId:qrcode.groupId,
  102. targetGroupName:qrcode.groupName,
  103. checklistId
  104. })
  105. this.itemList=data.hazardList
  106. this.recordId=data.recordId
  107. },
  108. getChecklistHazardRecordViewById(checklistId,recordId){
  109. /* status 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】*/
  110. getChecklistHazardRecordViewById(recordId,checklistId).then((res)=>{
  111. this.itemList=res.data.hazardList
  112. let userId=uni.getStorageSync('userId')
  113. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===userId)
  114. })
  115. },
  116. check(measure){
  117. if(!this.handleVisiable) return
  118. uni.setStorageSync('hazard',{
  119. ...measure,
  120. checklistId:this.checklistId,
  121. recordId:this.recordId
  122. })
  123. uni.navigateTo({
  124. url:"/pages/app_views/hazard/form/form"
  125. })
  126. },
  127. handleSubmit(type){
  128. let recordId=this.recordId;
  129. let checklistId=this.checklistId;
  130. if(type===1){//完成
  131. completeChecklistDoing(recordId,checklistId).then(()=>{
  132. if(this.isAllPass()){
  133. uni.$emit('type',4)
  134. uni.switchTab({
  135. url:'/pages/history/history'
  136. })
  137. return
  138. }
  139. uni.showModal({
  140. title: '提示',
  141. content: '本次检查有未通过项,是否需要登记隐患?',
  142. success: function (res) {
  143. if (res.confirm) {
  144. uni.reLaunch({
  145. url:`/pages/app_views/danger/submit/submit?tid=${recordId}`
  146. })
  147. } else if (res.cancel) {
  148. uni.$emit('type',4)
  149. uni.switchTab({
  150. url:'/pages/history/history'
  151. })
  152. }
  153. }
  154. });
  155. }).catch(()=>{
  156. uni.showToast({
  157. icon:"none",
  158. title:"操作失败"
  159. })
  160. })
  161. }
  162. if(type===2){//放弃
  163. cancelChecklistDoing(recordId).then(()=>{
  164. uni.switchTab({
  165. url:'/pages/history/history'
  166. })
  167. }).catch(()=>{
  168. uni.showToast({
  169. icon:"none",
  170. title:"操作失败"
  171. })
  172. })
  173. }
  174. if(type===3){
  175. batchUpdateChecklistHazardRecordDoing(recordId,1).then(()=>{
  176. this.getChecklistHazardRecordViewById(checklistId,recordId)
  177. })
  178. }
  179. if(type===4){
  180. batchUpdateChecklistHazardRecordDoing(recordId,-1).then(()=>{
  181. this.getChecklistHazardRecordViewById(checklistId,recordId)
  182. })
  183. }
  184. },
  185. isAllPass(){
  186. let items=[]
  187. for(let i=0;i<this.itemList.length;i++){
  188. if(this.itemList[i].riskList){
  189. this.itemList[i].riskList.map(child=>{
  190. child.recordList.map(measure=>{
  191. items.push(measure)
  192. })
  193. })
  194. }
  195. }
  196. let index=items.findIndex(item=>item.checkResult===-1)
  197. return index<0
  198. },
  199. hover(state){
  200. this.showMore=state===1
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. .page{
  207. background-color: #F5F6F8;
  208. padding: 20rpx;
  209. min-height: 100vh;
  210. box-sizing: border-box;
  211. padding-bottom: 120rpx;
  212. .page-head{
  213. text-align: right;
  214. padding-bottom: 10rpx;
  215. .handle{
  216. display: inline-block;
  217. background-color: #3384FF;
  218. color: #fff;
  219. padding: 10rpx 15rpx;
  220. box-sizing: border-box;
  221. border-right: 1rpx solid #eaeaea;
  222. font-size: 30rpx;
  223. text-align: center;
  224. &:nth-child(4){
  225. border: 0;
  226. }
  227. }
  228. }
  229. }
  230. .wrap{
  231. padding: 20rpx;
  232. background-color: #fff;
  233. .checklist{
  234. .title{
  235. color: #222222;
  236. font-size: 32rpx;
  237. height: 98rpx;
  238. line-height: 98rpx;
  239. overflow: hidden;
  240. text-overflow: ellipsis;
  241. border-bottom: 1px dashed #E8E8E8;
  242. }
  243. .more{
  244. background-image: url('/static/tree_more.png');
  245. background-size: 30rpx 30rpx;
  246. padding-left: 40rpx;
  247. background-position: center left;
  248. background-repeat: no-repeat;
  249. }
  250. .item-cont{
  251. padding-left: 20rpx;
  252. border-bottom: 1px dashed #E8E8E8;
  253. .checklistItem{
  254. .itemTitle{
  255. color: #222222;
  256. font-size: 32rpx;
  257. height: 98rpx;
  258. line-height: 98rpx;
  259. }
  260. }
  261. .point-cont{
  262. padding-left: 30rpx;
  263. .point{
  264. display: flex;
  265. color: #666;
  266. font-size: 28rpx;
  267. // height: 98rpx;
  268. // line-height: 98rpx;
  269. .pointContent{
  270. flex: 1;
  271. }
  272. .status{
  273. .text{
  274. color: #3384FF;
  275. font-weight: 800;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. .handle-container{
  283. position: fixed;
  284. width: 100%;
  285. left: 0;
  286. bottom: 0;
  287. background-color: #fff;
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. border-top: 1rpx solid #eaeaea;
  292. padding: 15rpx 0;
  293. .handle{
  294. display:inline-block;
  295. color: #222;
  296. padding: 15rpx 20rpx;
  297. box-sizing: border-box;
  298. border: 1rpx solid #eaeaea;
  299. font-size: 26rpx;
  300. text-align: center;
  301. border-radius: 50rpx;
  302. margin: 0 10rpx;
  303. &.danger{
  304. background-color: #FA5B41;
  305. color: #fff;
  306. }
  307. &.submit{
  308. background-color: #3384FF;
  309. color: #fff;
  310. padding: 18rpx 38rpx;
  311. }
  312. }
  313. .more{
  314. position: relative;
  315. padding: 15rpx 20rpx;
  316. // .text:hover{
  317. // &+.list>.hand-item-box{
  318. // display: block;
  319. // }
  320. // }
  321. .list{
  322. position: absolute;
  323. bottom: 100rpx;
  324. right: 0;
  325. box-shadow: 0px 2px 12px 0px #0000001F;
  326. padding:0 20rpx;
  327. background-color: #fff;
  328. .hand-item-box{
  329. position: relative;
  330. // display: none;
  331. &.show{
  332. display: block;
  333. }
  334. &::after{
  335. width: 0;
  336. height: 0;
  337. content: "";
  338. display: block;
  339. border-width: 26rpx 26rpx 0 0;
  340. border-color: #fff transparent;
  341. border-style: solid;
  342. position: absolute;
  343. bottom: -20rpx;
  344. right: -20rpx;
  345. }
  346. .handle-item{
  347. width: 180rpx;
  348. height: 50rpx;
  349. font-size: 26rpx;
  350. line-height: 50rpx;
  351. background-color: #fff;
  352. text-align: center;
  353. border-bottom: 1px solid #ccc;
  354. padding:10rpx 0;
  355. &:last-child{
  356. border: 0;
  357. }
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>