index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="wrap">
  3. <template v-if="itemList.length>0">
  4. <view class="checklist" v-for="(checklist,idx) in itemList" :key="idx">
  5. <view class="title">{{checklist.itemTitle}}</view>
  6. <view class="item-cont" v-if="checklist.children&&checklist.children.length>0">
  7. <view class="checklistItem" v-for="(checklistItem,itemIdx) in checklist.children" :key="itemIdx">
  8. <view class="itemTitle">{{checklistItem.itemTitle}}</view>
  9. <view class="point-cont" v-if="checklistItem.recordList&&checklistItem.recordList.length>0">
  10. <view class="point" v-for="(point,pointIdx) in checklistItem.recordList" :key="pointIdx" @click="check(point)">
  11. <view class="pointContent">{{point.pointContent}}</view>
  12. <view class="status" v-if="point.checkResult===1">通过</view>
  13. <view class="status" v-if="point.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 {checklistInit,getchecklistRecord,checklistComplete,checklistCancel,checklistBatchUpdate} from '@/api/openApi.js'
  31. export default {
  32. data() {
  33. return {
  34. defaultProps: {
  35. id: 'itemId',
  36. children: 'children',
  37. label: 'itemTitle'
  38. },
  39. divider: false,
  40. edit: true,
  41. itemList:[],
  42. recordId:undefined,
  43. checklistId:undefined,
  44. handleVisiable:false
  45. }
  46. },
  47. onLoad({id,recordId,type}) {
  48. this.checklistId=id
  49. this.recordId=recordId
  50. if(type==="app"){
  51. this.initCheckList(id)
  52. this.handleVisiable=true
  53. }else{
  54. this.getchecklistRecord(id,recordId)
  55. }
  56. },
  57. methods: {
  58. async initCheckList(checklistId){
  59. let qrcode=uni.getStorageSync('qrcode')
  60. let {data}=await checklistInit({
  61. ocId:qrcode.ocId,
  62. targetId:qrcode.targetId,
  63. targetType:qrcode.targetType,
  64. targetTitle:qrcode.riskPointTitle,
  65. targetGroupId:qrcode.groupId,
  66. targetGroupName:qrcode.groupName,
  67. checklistId
  68. })
  69. this.itemList=data.itemList
  70. this.recordId=data.recordId
  71. },
  72. getchecklistRecord(checklistId,recordId){
  73. getchecklistRecord(checklistId,recordId).then((res)=>{
  74. this.itemList=res.data.itemList
  75. let userInfo=uni.getStorageSync('accountInfo')
  76. this.handleVisiable=(res.data.status===0)&&(res.data.accountId===userInfo.userId)
  77. })
  78. },
  79. check(point){
  80. uni.setStorageSync('point',point)
  81. uni.navigateTo({
  82. url:"/pages/app_views/checkList/from/from"
  83. })
  84. },
  85. handleSubmit(type){
  86. let recordId=this.recordId;
  87. let checklistId=this.checklistId;
  88. if(type===1){//完成
  89. checklistComplete(recordId,checklistId).then(()=>{
  90. uni.$emit('type',1)
  91. uni.switchTab({
  92. url:'/pages/history/history'
  93. })
  94. }).catch(()=>{
  95. uni.showToast({
  96. icon:"none",
  97. title:"操作失败"
  98. })
  99. })
  100. }
  101. if(type===2){//放弃
  102. checklistCancel(recordId).then(()=>{
  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===3){
  114. checklistBatchUpdate(recordId,1).then(()=>{
  115. this.getchecklistRecord(checklistId,recordId)
  116. })
  117. }
  118. if(type===4){
  119. checklistBatchUpdate(recordId,-1).then(()=>{
  120. this.getchecklistRecord(checklistId,recordId)
  121. })
  122. }
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .wrap{
  129. padding: 20rpx;
  130. margin-bottom: 100rpx;
  131. .checklist{
  132. .title{
  133. color: #333;
  134. font-size: 36rpx;
  135. height: 60rpx;
  136. line-height: 60rpx;
  137. }
  138. .item-cont{
  139. padding-left: 20rpx;
  140. .checklistItem{
  141. .itemTitle{
  142. color: #424242;
  143. font-size: 32rpx;
  144. line-height: 1;
  145. padding: 10rpx 0;
  146. }
  147. }
  148. .point-cont{
  149. padding-left: 30rpx;
  150. .point{
  151. display: flex;
  152. color: #666;
  153. font-size: 28rpx;
  154. line-height: 1;
  155. padding: 10rpx 0;
  156. .pointContent{
  157. flex: 1;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. .handle-container{
  164. position: fixed;
  165. width: 100%;
  166. left: 0;
  167. bottom: 0;
  168. background-color: #fff;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. border-top: 1rpx solid #eaeaea;
  173. .handle{
  174. display: inline-block;
  175. background-color: #3384FF;
  176. color: #fff;
  177. padding: 15rpx 20rpx;
  178. width: 25%;
  179. box-sizing: border-box;
  180. border-right: 1rpx solid #eaeaea;
  181. font-size: 30rpx;
  182. &:nth-child(4){
  183. border: 0;
  184. }
  185. }
  186. }
  187. }
  188. </style>