index.vue 6.9 KB

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