index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="wrap">
  3. <template v-if="itemList.length>0">
  4. <view class="checklist" v-for="(hazard,idx) in itemList" :key="idx">
  5. <view class="title">{{hazard.hazardTitle}}</view>
  6. <view class="item-cont" v-if="hazard.riskList&&hazard.riskList.length>0">
  7. <view class="checklistItem" v-for="(risk,itemIdx) in hazard.riskList" :key="itemIdx">
  8. <view class="itemTitle">{{risk.riskTitle}}</view>
  9. <view class="point-cont" v-if="risk.recordList&&risk.recordList.length>0">
  10. <view class="point" v-for="(measure,measureIdx) in risk.recordList" :key="measureIdx" @click="check(measure)">
  11. <view class="pointContent">{{measure.measureContent}}</view>
  12. <view class="status" v-if="measure.checkResult===1">通过</view>
  13. <view class="status" v-if="measure.checkResult===-1">不通过</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="handle-container" v-if="handleVisiable">
  20. <view class="handle" @click="handleSubmit(3)">全部通过</view>
  21. <view class="handle" @click="handleSubmit(4)">全不通过</view>
  22. <view class="handle" @click="handleSubmit(1)">提交</view>
  23. <view class="handle" @click="handleSubmit(2)">撤销</view>
  24. </view>
  25. </template>
  26. <template v-else>没有可处理的清单^-_-^</template>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. initChecklistHazardRecord,
  32. getChecklistHazardRecordViewById,
  33. completeChecklistDoing,
  34. cancelChecklistDoing,
  35. batchUpdateChecklistHazardRecordDoing,
  36. } from '@/api/aqpt/checklistHazardRecordApi.js'
  37. export default {
  38. data() {
  39. return {
  40. defaultProps: {
  41. id: 'itemId',
  42. children: 'children',
  43. label: 'itemTitle'
  44. },
  45. divider: false,
  46. edit: true,
  47. itemList:[],
  48. recordId:undefined,
  49. checklistId:undefined,
  50. handleVisiable:false
  51. }
  52. },
  53. onLoad({id,recordId,type}) {
  54. this.checklistId=id
  55. this.recordId=recordId
  56. if(type==="app"){
  57. this.initCheckList(id)
  58. this.handleVisiable=true
  59. }else{
  60. this.getChecklistHazardRecordViewById(id,recordId)
  61. }
  62. },
  63. methods: {
  64. async initCheckList(checklistId){
  65. let qrcode=uni.getStorageSync('qrcode')
  66. let {data}=await initChecklistHazardRecord({
  67. ocId:qrcode.ocId,
  68. targetId:qrcode.targetId,
  69. targetType:qrcode.targetType,
  70. targetTitle:qrcode.targetTitle,
  71. targetGroupId:qrcode.groupId,
  72. targetGroupName:qrcode.groupName,
  73. checklistId
  74. })
  75. this.itemList=data.hazardList
  76. this.recordId=data.recordId
  77. },
  78. getChecklistHazardRecordViewById(checklistId,recordId){
  79. /* status 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】*/
  80. getChecklistHazardRecordViewById(recordId,checklistId).then((res)=>{
  81. this.itemList=res.data.hazardList
  82. let wxId=uni.getStorageSync('wxId')
  83. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===wxId)
  84. })
  85. },
  86. check(measure){
  87. if(!this.handleVisiable) return
  88. uni.setStorageSync('hazard',{
  89. ...measure,
  90. checklistId:this.checklistId,
  91. recordId:this.recordId
  92. })
  93. uni.navigateTo({
  94. url:"/pages/app_views/hazard/form/form"
  95. })
  96. },
  97. handleSubmit(type){
  98. let recordId=this.recordId;
  99. let checklistId=this.checklistId;
  100. if(type===1){//完成
  101. completeChecklistDoing(recordId,checklistId).then(()=>{
  102. uni.$emit('type',4)
  103. uni.switchTab({
  104. url:'/pages/history/history'
  105. })
  106. }).catch(()=>{
  107. uni.showToast({
  108. icon:"none",
  109. title:"操作失败"
  110. })
  111. })
  112. }
  113. if(type===2){//放弃
  114. cancelChecklistDoing(recordId).then(()=>{
  115. uni.switchTab({
  116. url:'/pages/history/history'
  117. })
  118. }).catch(()=>{
  119. uni.showToast({
  120. icon:"none",
  121. title:"操作失败"
  122. })
  123. })
  124. }
  125. if(type===3){
  126. batchUpdateChecklistHazardRecordDoing(recordId,1).then(()=>{
  127. this.getChecklistHazardRecordViewById(checklistId,recordId)
  128. })
  129. }
  130. if(type===4){
  131. batchUpdateChecklistHazardRecordDoing(recordId,-1).then(()=>{
  132. this.getChecklistHazardRecordViewById(checklistId,recordId)
  133. })
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .wrap{
  141. padding: 20rpx;
  142. margin-bottom: 100rpx;
  143. .checklist{
  144. .title{
  145. color: #333;
  146. font-size: 36rpx;
  147. height: 60rpx;
  148. line-height: 60rpx;
  149. }
  150. .item-cont{
  151. padding-left: 20rpx;
  152. .checklistItem{
  153. .itemTitle{
  154. color: #424242;
  155. font-size: 32rpx;
  156. line-height: 1;
  157. padding: 10rpx 0;
  158. }
  159. }
  160. .point-cont{
  161. padding-left: 30rpx;
  162. .point{
  163. display: flex;
  164. color: #666;
  165. font-size: 28rpx;
  166. line-height: 1;
  167. padding: 10rpx 0;
  168. .pointContent{
  169. flex: 1;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. .handle-container{
  176. position: fixed;
  177. width: 100%;
  178. left: 0;
  179. bottom: 0;
  180. background-color: #fff;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. border-top: 1rpx solid #eaeaea;
  185. .handle{
  186. display: inline-block;
  187. background-color: #3384FF;
  188. color: #fff;
  189. padding: 15rpx 20rpx;
  190. width: 25%;
  191. box-sizing: border-box;
  192. border-right: 1rpx solid #eaeaea;
  193. font-size: 30rpx;
  194. text-align: center;
  195. &:nth-child(4){
  196. border: 0;
  197. }
  198. }
  199. }
  200. }
  201. </style>