index.vue 6.7 KB

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