index.vue 7.6 KB

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