index.vue 6.8 KB

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