index.vue 9.3 KB

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