form.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="wrap">
  3. <uni-section :title="point.pointContent" type="line">
  4. <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
  5. <uni-forms-item label="检查结果" name="checkResult" required>
  6. <view class="uni-data-checkbox-wrap">
  7. <uni-data-checkbox v-model="formData.checkResult" :localdata="checkResults" />
  8. </view>
  9. </uni-forms-item>
  10. <uni-forms-item label="备注" name="remark">
  11. <uni-easyinput v-model="formData.remark" type="textarea" :maxlength="-1" autoHeight placeholder="备注" />
  12. </uni-forms-item>
  13. <uni-file-picker v-model="formData.attachList"
  14. fileMediatype="image"
  15. title="请上传附件"
  16. limit="1"
  17. @select="uploadSuccess"
  18. @delete="deleteFile"></uni-file-picker>
  19. </uni-forms>
  20. </uni-section>
  21. <button type="primary" @click="onSubmit" class="submit-BT">提交</button>
  22. </view>
  23. </template>
  24. <script>
  25. import {upload} from '@/api/system/upload.js'
  26. import {updateChecklistPoint} from '@/api/aqpt/checklistPoint.js'
  27. export default {
  28. data() {
  29. return {
  30. checkResults:[
  31. {text:"通过",value:1},
  32. {text:"不通过",value:-1},
  33. ],
  34. formData:{
  35. checkResult:1,
  36. remark:"",
  37. attachList:[]
  38. },
  39. rules:{},
  40. point:{}
  41. }
  42. },
  43. onBackPress() {
  44. },
  45. onLoad() {
  46. this.init()
  47. },
  48. methods: {
  49. init(){
  50. let point=uni.getStorageSync('point');
  51. this.point=point;
  52. },
  53. getLocation(){
  54. const self=this;
  55. uni.getLocation({
  56. type: 'wgs84',
  57. success: function (res) {
  58. self.formData.dutyLongitude=res.longitude
  59. self.formData.dutyLatitude=res.latitude
  60. }
  61. });
  62. },
  63. async onSubmit() {
  64. let point=uni.getStorageSync('point')
  65. let attachList=[]
  66. for(let i=0;i<this.formData.attachList.length;i++){
  67. let filePath=this.formData.attachList[i].url
  68. let fileresq=await upload({filePath,formData:{
  69. additions: `经度:${this.formData.dutyLongitude};纬度:${this.formData.dutyLatitude}`
  70. }})
  71. fileresq=JSON.parse(fileresq)
  72. attachList.push(fileresq.data)
  73. }
  74. await updateChecklistPoint({
  75. recordId:point.recordId,
  76. checklistId:point.checklistId,
  77. itemId:point.itemId,
  78. pointId:point.pointId,
  79. checkResult:this.formData.checkResult,
  80. remark:this.formData.remark,
  81. attachList,
  82. }).catch(()=>{
  83. uni.showToast({
  84. icon:'none',
  85. title:"提交失败!"
  86. })
  87. })
  88. this.batchHandle()
  89. // uni.showToast({
  90. // icon:'none',
  91. // title:"提交成功!",
  92. // complete() {
  93. // uni.redirectTo({
  94. // url:`/pages/app_views/checkList/index/index?type=form&id=${point.checklistId}&recordId=${point.recordId}`
  95. // })
  96. // }
  97. // })
  98. },
  99. // 批量处理未处理的
  100. batchHandle(){
  101. let point=uni.getStorageSync('point')
  102. if(this.handles.length<1){
  103. uni.showToast({
  104. icon:'none',
  105. title:"处理完毕",
  106. duration:1000,
  107. complete() {
  108. uni.redirectTo({
  109. url:`/pages/app_views/checkList/index/index?type=form&id=${point.checklistId}&recordId=${point.recordId}`
  110. })
  111. }
  112. })
  113. return
  114. }
  115. let nextPoint=this.handles[0]
  116. this.formData={
  117. checkResult:1,
  118. remark:"",
  119. attachList:[]
  120. }
  121. this.handles.shift()
  122. uni.setStorageSync('point',nextPoint);
  123. this.point=nextPoint;
  124. },
  125. uploadSuccess(e){
  126. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  127. attachList.push(e.tempFiles[0])
  128. this.formData.attachList=attachList
  129. },
  130. deleteFile(e){
  131. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  132. attachList.filter(item=>item.uuid!==e.tempFile.uuid)
  133. this.formData.attachList=attachList
  134. },
  135. },
  136. onUnload() {
  137. uni.removeStorageSync('point')
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .wrap{
  143. padding: 20rpx;
  144. .submit-BT {
  145. width: 750rpx;
  146. color: #4D73FF;
  147. text-align: center;
  148. font-size: 32rpx;
  149. padding-bottom: 68rpx;
  150. background-color: #fff;
  151. position: fixed;
  152. left: 0;
  153. bottom: 0;
  154. z-index: 99;
  155. box-shadow: 0px 0px 12px 0px #0000000A;
  156. border-radius: 8px 8px 0px 0px
  157. }
  158. ::v-deep .uni-forms-item{
  159. .uni-forms-item__content{
  160. .uni-data-checkbox-wrap{
  161. height: 100%;
  162. display: flex;
  163. align-items: center;
  164. }
  165. }
  166. }
  167. }
  168. </style>