problem_feedback.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="wrap">
  3. <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
  4. <uni-forms-item label="隐患等级" name="checkResult" required>
  5. <view class="uni-data-checkbox-wrap">
  6. <uni-data-checkbox v-model="formData.action" :localdata="actions" />
  7. </view>
  8. </uni-forms-item>
  9. <uni-forms-item label="处理结果" name="remark" v-if="formData.action===1">
  10. <uni-easyinput v-model="formData.handleRemark" type="textarea" :maxlength="-1" autoHeight placeholder="备注" />
  11. </uni-forms-item>
  12. <uni-forms-item label="执行人" name="accountId" required v-if="formData.action===2">
  13. <uni-data-select v-model="formData.accountId" :localdata="userList"></uni-data-select>
  14. </uni-forms-item>
  15. <uni-file-picker v-model="formData.attachList"
  16. fileMediatype="image"
  17. title="附件"
  18. limit="1"
  19. @select="uploadSuccess"
  20. @delete="deleteFile"></uni-file-picker>
  21. </uni-forms>
  22. <button type="primary" @click="onSubmit" class="submit-BT">提交</button>
  23. </view>
  24. </template>
  25. <script>
  26. import {upload} from '@/api/system/upload.js'
  27. import {getUserList} from '@/api/system/user.js'
  28. import {updateChecklistHazardRecordDoing} from '@/api/aqpt/checklistHazardRecordApi.js'
  29. import { getSnapshotById, completeSnapshot, transferSnapshot } from '@/api/aqpt/snapshotApi'
  30. export default {
  31. data() {
  32. return {
  33. actions:[
  34. {text:"完成处理",value:1},
  35. {text:"转交",value:2},
  36. ],
  37. formData:{
  38. action:1,
  39. handleRemark:"",
  40. attachList:[]
  41. },
  42. userList:[],
  43. rules:{},
  44. snapshot:{}
  45. }
  46. },
  47. onLoad() {
  48. this.init()
  49. },
  50. methods: {
  51. init(){
  52. let snapshot=uni.getStorageSync('snapshot');
  53. this.snapshot=snapshot;
  54. this.getUserList()
  55. },
  56. async onSubmit() {
  57. let snapshotId=uni.getStorageSync('snapshotId')
  58. let attachList=[]
  59. for(let i=0;i<this.formData.attachList.length;i++){
  60. let filePath=this.formData.attachList[i].url
  61. let fileresq=await upload({filePath})
  62. fileresq=JSON.parse(fileresq)
  63. attachList.push(fileresq.data)
  64. }
  65. let flow=this.userList.filter(item=>this.formData.accountId===item.accountId)[0]
  66. this.handleSelectUser(flow)
  67. if(this.formData.action===1){
  68. await completeSnapshot(snapshotId,this.formData).catch(()=>{
  69. uni.showToast({
  70. icon:'none',
  71. title:"提交失败!"
  72. })
  73. })
  74. }else{
  75. await transferSnapshot(snapshotId,this.formData).catch(()=>{
  76. uni.showToast({
  77. icon:'none',
  78. title:"提交失败!"
  79. })
  80. })
  81. }
  82. uni.showToast({
  83. icon:'none',
  84. title:"提交成功!",
  85. complete() {
  86. uni.redirectTo({
  87. url:`/pages/app_views/problem_feedback/record/record`
  88. })
  89. }
  90. })
  91. },
  92. uploadSuccess(e){
  93. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  94. attachList.push(e.tempFiles[0])
  95. this.formData.attachList=attachList
  96. },
  97. deleteFile(e){
  98. let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
  99. attachList.filter(item=>item.uuid!==e.tempFile.uuid)
  100. this.formData.attachList=attachList
  101. },
  102. handleSelectUser(obj) {
  103. this.formData.accountIdTo = obj.accountId
  104. this.formData.groupIdTo = obj.groupId
  105. this.formData.positionIdTo = obj.positionId
  106. this.formData.accountNameTo = obj.accountName
  107. this.formData.groupNameTo = obj.groupName
  108. this.formData.positionNameTo = obj.positionName
  109. },
  110. getUserList(){
  111. getUserList().then((res)=>{
  112. var userList=[]
  113. for (var i = 0; i < res.data.length; i++) {
  114. userList.push({
  115. value: -i,
  116. text: res.data[i].name,
  117. disable:true
  118. })
  119. for(let j = 0; j < res.data[i].children.length; j++){
  120. userList.push({
  121. ...res.data[i].children[j],
  122. value: res.data[i].children[j].accountId,
  123. text: res.data[i].children[j].accountName
  124. })
  125. }
  126. }
  127. this.userList=userList
  128. })
  129. }
  130. },
  131. onUnload() {
  132. uni.removeStorageSync('hazard')
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .wrap{
  138. padding: 32rpx;
  139. padding-bottom: 200rpx;
  140. .submit-BT {
  141. width: 750rpx;
  142. height:156rpx;
  143. line-height:88rpx;
  144. color: #4D73FF;
  145. text-align: center;
  146. font-size: 32rpx;
  147. padding-bottom: 68rpx;
  148. background-color: #fff;
  149. position: fixed;
  150. left: 0;
  151. bottom: 0;
  152. z-index: 99;
  153. box-shadow: 0px 0px 12px 0px #0000000A;
  154. border-radius: 8px 8px 0px 0px
  155. }
  156. }
  157. </style>