planDetail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <form action="">
  4. <view style='height:30rpx'></view>
  5. <view class="form-item">
  6. <view class="title">
  7. <text class="necessary">*</text>
  8. 上报名称:
  9. </view>
  10. <input type="text" v-model="reportName">
  11. </view>
  12. <view class="form-item margin-top">
  13. <view class="title">
  14. <text class="necessary">*</text>
  15. 维保状态:
  16. </view>
  17. <radio-group name="gender" @change="radioChange">
  18. <label class="margin-right-xs">
  19. <radio value="0" checked /><text>正常</text>
  20. </label>
  21. <label class="margin-right-xs">
  22. <radio value="1" /><text>异常</text>
  23. </label>
  24. <label class="margin-right-xs">
  25. <radio value="2" /><text>故障</text>
  26. </label>
  27. <label>
  28. <radio value="3" /><text>其他</text>
  29. </label>
  30. </radio-group>
  31. </view>
  32. <view class="form-item margin-top">
  33. <view class="title">
  34. <text class="necessary">*</text>
  35. 上传图片:
  36. </view>
  37. <view style="width:500rpx">
  38. <view ref="input" class="input">
  39. </view>
  40. </view>
  41. </view>
  42. <view class="form-item margin-top">
  43. <view class="title">
  44. <text class="necessary">*</text>
  45. 维保描述:
  46. </view>
  47. <textarea maxlength="-1" @input="textareaAInput" placeholder="" v-model="msg" width="250"></textarea>
  48. </view>
  49. <view class="btn-area submitBottomBtn padding-lr-sm">
  50. <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
  51. </view>
  52. </form>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. noClick:true,
  60. imgList: [],
  61. msg: '',
  62. id: '',
  63. reportName: '',
  64. radioOne: 0,
  65. zb_id:''
  66. }
  67. },
  68. onLoad: function(option) {
  69. this.id = option.id;
  70. this.zb_id=option.zb_id
  71. },
  72. mounted() {
  73. // 创建附件上传
  74. var _self = this;
  75. var input = document.createElement('input'); //创建元素
  76. input.type = 'file' //添加file类型
  77. input.onchange = (event) => {
  78. _self.upFile(input, event)
  79. }
  80. this.$refs.input.$el.appendChild(input)
  81. },
  82. methods: {
  83. radioChange(e) {
  84. console.log('type:' + e.detail.value);
  85. this.radioOne = e.detail.value;
  86. },
  87. upFile(input, event) {
  88. var _self = this;
  89. uni.uploadFile({
  90. url: this.$BASE_URL+'Inspection/setUpload',
  91. files: [{
  92. file: input.files[0],
  93. uri: event.srcElement.value
  94. }],
  95. success: (uploadFileRes) => {
  96. var data = JSON.parse(uploadFileRes.data)
  97. this.img = data.img_url;
  98. console.log(this.img)
  99. },
  100. fail: (err) => {
  101. console.log(err)
  102. }
  103. });
  104. },
  105. addSubmit() {
  106. if (!this.reportName.replace(/^\s*/g,'')) {
  107. uni.showToast({
  108. title: "请输入上报名称",
  109. icon: "none"
  110. });
  111. return
  112. }
  113. if (!this.msg.replace(/^\s*/g,'')) {
  114. uni.showToast({
  115. title: "请输入维保描述",
  116. icon: "none"
  117. });
  118. return
  119. }
  120. if (!this.img) {
  121. uni.showToast({
  122. title: "请上传图片",
  123. icon: "none"
  124. });
  125. return
  126. }
  127. this.powerSubmitRes({
  128. "zb_id": this.zb_id,
  129. "spot_id": this.id,
  130. "report_name": this.reportName,
  131. "spot_abnormal": this.radioOne,
  132. "img": this.img,
  133. "dwsb_remarks": this.msg,
  134. })
  135. },
  136. async powerSubmitRes(params = {}) {
  137. const res = await this.$myRequest({
  138. url: 'Inspection/setInspection',
  139. data: params
  140. })
  141. if (res.data.flag) {
  142. uni.showToast({
  143. title: "提交成功",
  144. });
  145. setTimeout(() => {
  146. uni.navigateTo({
  147. url: '/pages/weiBao/planInnerList/planInnerList?id=' + this.zb_id,
  148. });
  149. }, 1000);
  150. }
  151. },
  152. textareaAInput(e) {
  153. this.textareaAValue = e.detail.value
  154. },
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. </style>