task.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. getchecklistRecord,
  45. checklistComplete,
  46. checklistCancel,
  47. checklistBatchUpdate,
  48. } from '@/api/aqpt/checklistPoint.js'
  49. export default {
  50. data() {
  51. return {
  52. defaultProps: {
  53. id: 'itemId',
  54. children: 'children',
  55. label: 'itemTitle'
  56. },
  57. accountInfo:{},
  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({rid,cid}) {
  69. this.checklistId=cid
  70. this.recordId=rid
  71. let accountInfo=uni.getStorageSync('accountInfo')
  72. this.accountInfo=accountInfo
  73. this.getchecklistRecord(cid,rid)
  74. },
  75. methods: {
  76. getchecklistRecord(checklistId,recordId){
  77. getchecklistRecord(checklistId,recordId).then((res)=>{
  78. this.itemList=res.data.itemList
  79. this.status=res.data.status
  80. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===this.accountInfo.userId)
  81. })
  82. },
  83. check(point){
  84. if(!this.handleVisiable) return
  85. uni.setStorageSync("point",point)
  86. uni.navigateTo({
  87. url:"/pages/index/handle/task/checkList/form/form"
  88. })
  89. },
  90. handleSubmit(type){
  91. let recordId=this.recordId;
  92. let checklistId=this.checklistId;
  93. if(type===1){//完成
  94. checklistComplete(recordId,checklistId).then(()=>{
  95. uni.$emit('type',1)
  96. uni.switchTab({
  97. url:'/pages/history/history'
  98. })
  99. }).catch(()=>{
  100. uni.showToast({
  101. icon:"none",
  102. title:"操作失败"
  103. })
  104. })
  105. }
  106. if(type===2){//放弃
  107. checklistCancel(recordId).then(()=>{
  108. uni.switchTab({
  109. url:'/pages/history/history'
  110. })
  111. }).catch(()=>{
  112. uni.showToast({
  113. icon:"none",
  114. title:"操作失败"
  115. })
  116. })
  117. }
  118. if(type===3){
  119. checklistBatchUpdate(recordId,1).then(()=>{
  120. this.getchecklistRecord(checklistId,recordId)
  121. })
  122. }
  123. if(type===4){
  124. checklistBatchUpdate(recordId,-1).then(()=>{
  125. this.getchecklistRecord(checklistId,recordId)
  126. })
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .page{
  134. background-color: #F5F6F8;
  135. padding: 20rpx;
  136. min-height: 100vh;
  137. box-sizing: border-box;
  138. margin-bottom: 100rpx;
  139. }
  140. .wrap{
  141. padding: 20rpx;
  142. background-color: #fff;
  143. .checklist{
  144. .title{
  145. color: #222222;
  146. font-size: 32rpx;
  147. height: 98rpx;
  148. line-height: 98rpx;
  149. overflow: hidden;
  150. text-overflow: ellipsis;
  151. border-bottom: 1px dashed #E8E8E8;
  152. }
  153. .more{
  154. background-image: url('/static/tree_more.png');
  155. background-size: 30rpx 30rpx;
  156. padding-left: 40rpx;
  157. background-position: center left;
  158. background-repeat: no-repeat;
  159. }
  160. .item-cont{
  161. padding-left: 20rpx;
  162. border-bottom: 1px dashed #E8E8E8;
  163. .checklistItem{
  164. .itemTitle{
  165. color: #222222;
  166. font-size: 32rpx;
  167. height: 98rpx;
  168. line-height: 98rpx;
  169. }
  170. }
  171. .point-cont{
  172. padding-left: 30rpx;
  173. .point{
  174. display: flex;
  175. color: #666;
  176. font-size: 28rpx;
  177. height: 98rpx;
  178. line-height: 98rpx;
  179. .pointContent{
  180. flex: 1;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. .handle-container{
  187. position: fixed;
  188. width: 100%;
  189. left: 0;
  190. bottom: 0;
  191. background-color: #fff;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. border-top: 1rpx solid #eaeaea;
  196. .handle{
  197. display: inline-block;
  198. background-color: #3384FF;
  199. color: #fff;
  200. padding: 15rpx 20rpx;
  201. width: 25%;
  202. box-sizing: border-box;
  203. border-right: 1rpx solid #eaeaea;
  204. font-size: 30rpx;
  205. text-align: center;
  206. &:nth-child(4){
  207. border: 0;
  208. }
  209. }
  210. }
  211. }
  212. </style>