index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 {
  33. checklistInit,
  34. getchecklistRecord,
  35. checklistComplete,
  36. checklistCancel,
  37. checklistBatchUpdate,
  38. } from '@/api/aqpt/checklistPoint.js'
  39. export default {
  40. data() {
  41. return {
  42. defaultProps: {
  43. id: 'itemId',
  44. children: 'children',
  45. label: 'itemTitle'
  46. },
  47. divider: false,
  48. edit: true,
  49. itemList:[],
  50. recordId:undefined,
  51. checklistId:undefined,
  52. handleVisiable:false
  53. }
  54. },
  55. onLoad({id,recordId,type}) {
  56. this.checklistId=id
  57. this.recordId=recordId
  58. if(type==="app"){
  59. this.initCheckList(id)
  60. this.handleVisiable=true
  61. }else{
  62. this.getchecklistRecord(id,recordId)
  63. }
  64. },
  65. methods: {
  66. async initCheckList(checklistId){
  67. let qrcode=uni.getStorageSync('qrcode')
  68. let {data}=await checklistInit({
  69. ocId:qrcode.ocId,
  70. targetId:qrcode.targetId,
  71. targetType:qrcode.targetType,
  72. targetTitle:qrcode.riskPointTitle,
  73. targetGroupId:qrcode.groupId,
  74. targetGroupName:qrcode.groupName,
  75. checklistId
  76. })
  77. this.itemList=data.itemList
  78. this.recordId=data.recordId
  79. },
  80. getchecklistRecord(checklistId,recordId){
  81. /* status
  82. 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】
  83. */
  84. getchecklistRecord(checklistId,recordId).then((res)=>{
  85. this.itemList=res.data.itemList
  86. let userInfo=uni.getStorageSync('accountInfo')
  87. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===userInfo.userId)
  88. })
  89. },
  90. check(point){
  91. if(!this.handleVisiable) return
  92. uni.setStorageSync('point',point)
  93. uni.redirectTo({
  94. url:"/pages/app_views/checkList/form/form"
  95. })
  96. },
  97. handleSubmit(type){
  98. let recordId=this.recordId;
  99. let checklistId=this.checklistId;
  100. if(type===1){//完成
  101. checklistComplete(recordId,checklistId).then(()=>{
  102. uni.$emit('type',1)
  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. checklistCancel(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. checklistBatchUpdate(recordId,1).then(()=>{
  127. this.getchecklistRecord(checklistId,recordId)
  128. })
  129. }
  130. if(type===4){
  131. checklistBatchUpdate(recordId,-1).then(()=>{
  132. this.getchecklistRecord(checklistId,recordId)
  133. })
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .page{
  141. background-color: #F5F6F8;
  142. padding: 20rpx;
  143. min-height: 100vh;
  144. box-sizing: border-box;
  145. margin-bottom: 100rpx;
  146. }
  147. .wrap{
  148. padding: 20rpx;
  149. background-color: #fff;
  150. .checklist{
  151. .title{
  152. color: #222222;
  153. font-size: 32rpx;
  154. height: 98rpx;
  155. line-height: 98rpx;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. border-bottom: 1px dashed #E8E8E8;
  159. }
  160. .more{
  161. background-image: url('/static/tree_more.png');
  162. background-size: 30rpx 30rpx;
  163. padding-left: 40rpx;
  164. background-position: center left;
  165. background-repeat: no-repeat;
  166. }
  167. .item-cont{
  168. padding-left: 20rpx;
  169. border-bottom: 1px dashed #E8E8E8;
  170. .checklistItem{
  171. .itemTitle{
  172. color: #222222;
  173. font-size: 32rpx;
  174. height: 98rpx;
  175. line-height: 98rpx;
  176. }
  177. }
  178. .point-cont{
  179. padding-left: 30rpx;
  180. .point{
  181. display: flex;
  182. color: #666;
  183. font-size: 28rpx;
  184. height: 98rpx;
  185. line-height: 98rpx;
  186. .pointContent{
  187. flex: 1;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. .handle-container{
  194. position: fixed;
  195. width: 100%;
  196. left: 0;
  197. bottom: 0;
  198. background-color: #fff;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. border-top: 1rpx solid #eaeaea;
  203. .handle{
  204. display: inline-block;
  205. background-color: #3384FF;
  206. color: #fff;
  207. padding: 15rpx 20rpx;
  208. width: 25%;
  209. box-sizing: border-box;
  210. border-right: 1rpx solid #eaeaea;
  211. font-size: 30rpx;
  212. &:nth-child(4){
  213. border: 0;
  214. }
  215. }
  216. }
  217. }
  218. </style>