index.vue 6.5 KB

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