index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. uni.removeStorageSync('point')
  79. },
  80. onShow() {
  81. let point=uni.getStorageSync('point')
  82. if(!point)return
  83. this.getchecklistRecord(point.checklistId,point.recordId)
  84. },
  85. methods: {
  86. async initCheckList(checklistId){
  87. let qrcode=uni.getStorageSync('qrcode')
  88. let {data}=await checklistInit({
  89. ocId:qrcode.ocId,
  90. targetId:qrcode.targetId,
  91. targetType:qrcode.targetType,
  92. targetTitle:qrcode.targetTitle,
  93. targetGroupId:qrcode.groupId,
  94. targetGroupName:qrcode.groupName,
  95. checklistId
  96. })
  97. this.itemList=data.itemList
  98. this.recordId=data.recordId
  99. },
  100. getchecklistRecord(checklistId,recordId){
  101. /* status
  102. 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】
  103. */
  104. getchecklistRecord(checklistId,recordId).then((res)=>{
  105. this.itemList=res.data.itemList
  106. let wxId=uni.getStorageSync('wxId')
  107. this.status=res.data.status
  108. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===wxId)
  109. })
  110. },
  111. check(point){
  112. uni.setStorageSync('point',point)
  113. if(this.type==='history'){
  114. if(this.status===2){
  115. uni.navigateTo({
  116. url:"/pages/app_views/checkList/detail/detail"
  117. })
  118. }
  119. if(this.handleVisiable){
  120. uni.navigateTo({
  121. url:"/pages/app_views/checkList/form/form"
  122. })
  123. }
  124. }else{
  125. if(!this.handleVisiable) return
  126. uni.navigateTo({
  127. url:"/pages/app_views/checkList/form/form"
  128. })
  129. }
  130. },
  131. handleSubmit(type){
  132. let recordId=this.recordId;
  133. let checklistId=this.checklistId;
  134. if(type===1){//完成
  135. checklistComplete(recordId,checklistId).then(()=>{
  136. uni.$emit('type',1)
  137. uni.switchTab({
  138. url:'/pages/history/history'
  139. })
  140. }).catch(()=>{
  141. uni.showToast({
  142. icon:"none",
  143. title:"操作失败"
  144. })
  145. })
  146. }
  147. if(type===2){//放弃
  148. checklistCancel(recordId).then(()=>{
  149. uni.switchTab({
  150. url:'/pages/history/history'
  151. })
  152. }).catch(()=>{
  153. uni.showToast({
  154. icon:"none",
  155. title:"操作失败"
  156. })
  157. })
  158. }
  159. if(type===3){
  160. checklistBatchUpdate(recordId,1).then(()=>{
  161. this.getchecklistRecord(checklistId,recordId)
  162. })
  163. }
  164. if(type===4){
  165. checklistBatchUpdate(recordId,-1).then(()=>{
  166. this.getchecklistRecord(checklistId,recordId)
  167. })
  168. }
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .page{
  175. background-color: #F5F6F8;
  176. padding: 20rpx;
  177. min-height: 100vh;
  178. box-sizing: border-box;
  179. margin-bottom: 100rpx;
  180. }
  181. .wrap{
  182. padding: 20rpx;
  183. background-color: #fff;
  184. .checklist{
  185. .title{
  186. color: #222222;
  187. font-size: 32rpx;
  188. height: 98rpx;
  189. line-height: 98rpx;
  190. overflow: hidden;
  191. text-overflow: ellipsis;
  192. border-bottom: 1px dashed #E8E8E8;
  193. }
  194. .more{
  195. background-image: url('/static/tree_more.png');
  196. background-size: 30rpx 30rpx;
  197. padding-left: 40rpx;
  198. background-position: center left;
  199. background-repeat: no-repeat;
  200. }
  201. .item-cont{
  202. padding-left: 20rpx;
  203. border-bottom: 1px dashed #E8E8E8;
  204. .checklistItem{
  205. .itemTitle{
  206. color: #222222;
  207. font-size: 32rpx;
  208. height: 98rpx;
  209. line-height: 98rpx;
  210. }
  211. }
  212. .point-cont{
  213. padding-left: 30rpx;
  214. .point{
  215. display: flex;
  216. color: #666;
  217. font-size: 28rpx;
  218. height: 98rpx;
  219. line-height: 98rpx;
  220. .pointContent{
  221. flex: 1;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. .handle-container{
  228. position: fixed;
  229. width: 100%;
  230. left: 0;
  231. bottom: 0;
  232. background-color: #fff;
  233. display: flex;
  234. justify-content: center;
  235. align-items: center;
  236. border-top: 1rpx solid #eaeaea;
  237. .handle{
  238. display: inline-block;
  239. background-color: #3384FF;
  240. color: #fff;
  241. padding: 15rpx 20rpx;
  242. width: 25%;
  243. box-sizing: border-box;
  244. border-right: 1rpx solid #eaeaea;
  245. font-size: 30rpx;
  246. text-align: center;
  247. &:nth-child(4){
  248. border: 0;
  249. }
  250. }
  251. }
  252. }
  253. </style>