index.vue 5.5 KB

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