report.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="f-padding">
  3. <u-navbar
  4. :title="title"
  5. title-color="#fff"
  6. :border-bottom="false"
  7. :custom-back="customBack"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(99deg, #7A4398 0%, #5A5DB9 100%)' }"></u-navbar>
  10. <u-form :model="form" ref="uForm">
  11. <u-form-item label="路段/停车场:" prop="roadName" required :label-width="labelWidth">
  12. <u-input v-model="form.roadName" type="select" :border="true" placeholder="请选择" @click="selectShow = true" />
  13. <u-select v-model="selectShow" :list="roadList" value-name="roadNo" label-name="roadName" @confirm="selectConfirm"></u-select>
  14. </u-form-item>
  15. <u-form-item label="问题描述" prop="exceprionDes" required :label-width="labelWidth">
  16. <u-input type="textarea" :border="true" maxlength="200" v-model="form.exceprionDes" />
  17. </u-form-item>
  18. <u-form-item label="图片说明" :label-width="labelWidth" :border-bottom="false">
  19. <u-upload ref="uploadRef" :action="action" max-count="3"></u-upload>
  20. </u-form-item>
  21. <u-form-item label="处理员" prop="processBy" required :label-width="labelWidth">
  22. <u-input type="text" :border="true" maxlength="200" v-model="form.processBy" />
  23. </u-form-item>
  24. <u-form-item label="处理过程" prop="processDes" required :label-width="labelWidth">
  25. <u-input type="textarea" :border="true" maxlength="500" v-model="form.processDes" />
  26. </u-form-item>
  27. </u-form>
  28. <u-button type="primary" @click="submit" style="margin-top: 20vh;">提交</u-button>
  29. </view>
  30. </template>
  31. <script>
  32. export default{
  33. data(){
  34. return{
  35. title:'应急处置登记',
  36. labelWidth:190,
  37. action:this.config.upFileUrl,
  38. selectShow:false,
  39. selectList:[],
  40. roadList:[],
  41. form:{
  42. roadName:'',
  43. roadNo:'',
  44. exceprionDes:'',
  45. imgList:[]
  46. },
  47. rules:{
  48. roadName: [
  49. {
  50. required: true,
  51. message: '请选择路段',
  52. trigger: ['change','blur'],
  53. }
  54. ],
  55. exceprionDes: [
  56. {
  57. required: true,
  58. message: '请输入内容',
  59. trigger: ['change','blur'],
  60. }
  61. ],
  62. processBy: [
  63. {
  64. required: true,
  65. message: '请输入处理员',
  66. trigger: ['change','blur'],
  67. }
  68. ],
  69. processDes: [
  70. {
  71. required: true,
  72. message: '请输入处理过程',
  73. trigger: ['change','blur'],
  74. }
  75. ],
  76. }
  77. }
  78. },
  79. onLoad(){
  80. },
  81. onShow(){
  82. this.getRoadAllList();
  83. },
  84. onReady() {
  85. this.$refs.uForm.setRules(this.rules);
  86. },
  87. methods:{
  88. customBack(){
  89. // uni.reLaunch({
  90. // url: '/pages/index/index'
  91. // });
  92. uni.navigateBack()
  93. },
  94. getRoadAllList(){
  95. this.$u.api.getRoadAllList().then(res=>{
  96. if(res.code==200){
  97. this.roadList = res.data;
  98. // console.log('getDeviceStatis',res);
  99. }else{
  100. uni.showToast({
  101. icon:'none',
  102. title:res.msg
  103. })
  104. }
  105. console.log('res',res);
  106. }).catch(err=>{
  107. console.log('err',err);
  108. })
  109. },
  110. selectConfirm(e){
  111. // console.log('e',e);
  112. this.form.roadNo = e[0].value;
  113. this.form.roadName = e[0].label;
  114. // console.log('this.form',this.form);
  115. },
  116. submit(){
  117. let that = this;
  118. this.$refs.uForm.validate(valid => {
  119. if (valid) {
  120. console.log('验证通过');
  121. // delete this.dealForm.selectedUserList;
  122. let files = [];
  123. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  124. files = this.$refs.uploadRef.lists.filter(val => {
  125. return val.progress == 100;
  126. })
  127. console.log('files',files);
  128. // 如果您不需要进行太多的处理,直接如下即可
  129. // files = this.$refs.uUpload.lists;
  130. files.forEach(function(item){
  131. if(item.response.data){that.form.imgList.push(item.response.data.url)}
  132. });
  133. this.$u.api.reportEmergency(this.form).then(res=>{
  134. console.log('res',res);
  135. // this.form = {};
  136. uni.showToast({
  137. icon:'none',
  138. title:res.msg,
  139. duration:1500,
  140. });
  141. setTimeout(()=>{
  142. uni.switchTab({
  143. url: '/pages/index/index',
  144. })
  145. },1500)
  146. }).catch(err=>{
  147. uni.showToast({
  148. icon:'none',
  149. title:err.msg
  150. })
  151. console.log('err',err);
  152. })
  153. } else {
  154. console.log('验证失败');
  155. }
  156. });
  157. },
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. // @import './report.scss'
  163. </style>