form.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. async onSubmit() {
  54. let point=uni.getStorageSync('point')
  55. let attachList=[]
  56. for(let i=0;i<this.formData.attachList.length;i++){
  57. let filePath=this.formData.attachList[i].url
  58. let fileresq=await upload({filePath})
  59. fileresq=JSON.parse(fileresq)
  60. attachList.push(fileresq.data)
  61. }
  62. await updateChecklistPoint({
  63. recordId:point.recordId,
  64. checklistId:point.checklistId,
  65. itemId:point.itemId,
  66. pointId:point.pointId,
  67. checkResult:this.formData.checkResult,
  68. remark:this.formData.remark,
  69. attachList,
  70. }).catch(()=>{
  71. uni.showToast({
  72. icon:'none',
  73. title:"提交失败!"
  74. })
  75. })
  76. uni.showToast({
  77. icon:'none',
  78. title:"提交成功!",
  79. complete() {
  80. uni.redirectTo({
  81. url:`/pages/app_views/checkList/index/index?type=form&id=${point.checklistId}&recordId=${point.recordId}`
  82. })
  83. }
  84. })
  85. },
  86. uploadSuccess(e){
  87. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  88. attachList.push(e.tempFiles[0])
  89. this.formData.attachList=attachList
  90. },
  91. deleteFile(e){
  92. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  93. attachList.filter(item=>item.uuid!==e.tempFile.uuid)
  94. this.formData.attachList=attachList
  95. },
  96. },
  97. onUnload() {
  98. uni.removeStorageSync('point')
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .wrap{
  104. padding: 20rpx;
  105. .submit-BT {
  106. width: 750rpx;
  107. color: #4D73FF;
  108. text-align: center;
  109. font-size: 32rpx;
  110. padding-bottom: 68rpx;
  111. background-color: #fff;
  112. position: fixed;
  113. left: 0;
  114. bottom: 0;
  115. z-index: 99;
  116. box-shadow: 0px 0px 12px 0px #0000000A;
  117. border-radius: 8px 8px 0px 0px
  118. }
  119. ::v-deep .uni-forms-item{
  120. .uni-forms-item__content{
  121. .uni-data-checkbox-wrap{
  122. height: 100%;
  123. display: flex;
  124. align-items: center;
  125. }
  126. }
  127. }
  128. }
  129. </style>