taskList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="task-page">
  3. <div class="title">{{viewData.taskTitle}}</div>
  4. <div class="info" v-if="items.length>0">
  5. <div class="item-checklist" v-for="item in items">
  6. <view class="name">{{item.checklistItemContent}}</view>
  7. <view class="cont">
  8. <uni-data-checkbox v-model="item.state" :localdata="checkState" @change="changeCheck(item)"/>
  9. </view>
  10. </div>
  11. </div>
  12. <view class="empty" v-else>
  13. 没有可检查项
  14. </view>
  15. <view class="footer" @click="onSubmit" v-if="items.length>0">提交</view>
  16. </view>
  17. </template>
  18. <script>
  19. import {parseTime} from '@/libs/index.js'
  20. import { getChecklistItemById } from '@/api/check'
  21. import { handleCheckTask } from '@/api/task'
  22. export default {
  23. data() {
  24. return {
  25. userData:{},
  26. viewData:{
  27. },
  28. flow:{
  29. status:"",
  30. time:"",
  31. desc:"",
  32. attachList:[]
  33. },
  34. items:[],
  35. checkState:[{"value": 1,"text": "通过" },{"value": 0,"text": "不通过"}]
  36. }
  37. },
  38. onLoad() {
  39. this.init()
  40. },
  41. methods: {
  42. parseTime,
  43. init(){
  44. let data=uni.getStorageSync('task-item')
  45. this.userData=uni.getStorageSync('accountInfo')
  46. let scanCode_info=uni.getStorageSync('scanCode-info')
  47. let checklistId=data.checklistId
  48. if(scanCode_info){
  49. checklistId=scanCode_info.checklistId
  50. }
  51. this.viewData=data
  52. getChecklistItemById(checklistId).then((res) => {
  53. this.items = res.data.map(item=>{
  54. return{
  55. ...item,
  56. state:1
  57. }
  58. })
  59. })
  60. },
  61. changeCheck(item){
  62. console.log(item.state)
  63. },
  64. onSubmit(){
  65. let viewData=uni.getStorageSync('task-item')
  66. let checkItemNopass = ''
  67. let checkItemPass = ''
  68. let checkResult=0
  69. let handleAccountId =this.userData.userId
  70. let handleAccountName =this.userData.userName
  71. let handlePositionId =this.userData.positionId
  72. let handlePositionName =this.userData.positionName
  73. let handleGroupId =this.userData.groupId
  74. let handleGroupName =this.userData.groupName
  75. this.items.forEach(item => {
  76. if (item.state===1) {
  77. checkItemPass += item.checklistItemContent + '通过;'
  78. }else{
  79. checkResult=1
  80. checkItemNopass += item.checklistItemContent + '不通过;'
  81. }
  82. })
  83. checkItemPass = checkItemPass.substring(0, checkItemPass.length - 1)
  84. checkItemNopass = checkItemNopass.substring(0, checkItemNopass.length - 1)
  85. if(checkResult===1){
  86. uni.showModal({
  87. title: '提示',
  88. content: "确认检查项是否提交准确",
  89. success: function (res) {
  90. if (res.confirm) {
  91. handleCheckTask({
  92. ...viewData,
  93. handleAccountId,
  94. handleAccountName,
  95. handlePositionId,
  96. handlePositionName,
  97. handleGroupId,
  98. handleGroupName,
  99. 'status': 1,
  100. checkResult,
  101. checkItemPass,
  102. checkItemNopass
  103. }).then(() => {
  104. let submit_data=uni.getStorageSync('task-item')
  105. uni.removeStorageSync('task-item')
  106. submit_data.checkItemNopass=checkItemNopass
  107. uni.setStorageSync('submit-data',submit_data)
  108. let viewData=
  109. uni.navigateTo({
  110. url:'/pages/task/submit/submit'
  111. })
  112. })
  113. }
  114. }
  115. });
  116. }else{
  117. handleCheckTask({
  118. ...viewData,
  119. handleAccountId,
  120. handleAccountName,
  121. handlePositionId,
  122. handlePositionName,
  123. handleGroupId,
  124. handleGroupName,
  125. 'status': 1,
  126. checkResult,
  127. checkItemPass,
  128. checkItemNopass
  129. }).then(() => {
  130. uni.switchTab({
  131. url:'/pages/index/index'
  132. })
  133. })
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .task-page{
  141. background-color: #F3F5FB;
  142. height: 100vh;
  143. .title{
  144. font-family: 'Source Han Sans CN';
  145. font-style: normal;
  146. font-weight: 700;
  147. font-size: 36rpx;
  148. line-height: 54rpx;
  149. color: #212121;
  150. padding:0 32rpx;
  151. }
  152. .info{
  153. padding: 0 10rpx;
  154. margin: 40rpx 0 0;
  155. padding-bottom: 150rpx;
  156. background: #FFFFFF;
  157. border-radius: 32rpx 32rpx 0px 0px;
  158. .item-checklist{
  159. display: flex;
  160. justify-content: space-between;
  161. padding: 18rpx 20rpx;
  162. border-bottom: 1rpx solid #EFF1F3;
  163. .name{
  164. flex: 1;
  165. }
  166. .cont{
  167. padding-left: 20rpx;
  168. width: 200rpx;
  169. display: flex;
  170. justify-content: flex-end;
  171. align-items: center;
  172. box-sizing: border-box;
  173. }
  174. }
  175. }
  176. .empty{
  177. text-align: center;
  178. font-size: 28rpx;
  179. margin-top: 10%;
  180. color: #666;
  181. }
  182. .footer{
  183. width: 100%;
  184. height: 136rpx;
  185. background: #FFFFFF;
  186. border-radius: 16upx 16upx 0px 0px;
  187. position: fixed;
  188. left: 0;
  189. bottom: 0;
  190. text-align: center;
  191. color: #168DEC;
  192. font-size: 32upx;
  193. padding-top: 20upx;
  194. letter-spacing: 2px;
  195. border-top: 1rpx solid #eaeaea;
  196. }
  197. }
  198. </style>