planDetail.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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="">
  19. <radio value="0" checked /><text>正常</text>
  20. </label>
  21. <label class="">
  22. <radio value="1" /><text>异常</text>
  23. </label>
  24. <label class="">
  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 class="unload-box" @tap="goCamera()">
  38. <image v-if="this.imgUrl" mode="aspectFit" style="width:70rpx;height:70rpx" :src="this.imgUrl"
  39. :data-src="this.imgUrl"></image>
  40. <view v-else style="background:rgb(223 215 215 / 63%);font-size:22rpx;line-height:40rpx;margin-top:20rpx;padding:0 20px;display:inline-block;border-radius:10rpx">请上传 + </view>
  41. </view>
  42. </view>
  43. <view class="form-item margin-top">
  44. <view class="title">
  45. <text class="necessary">*</text>
  46. 巡检描述:
  47. </view>
  48. <textarea maxlength="-1" @input="textareaAInput" placeholder="" v-model="msg"></textarea>
  49. </view>
  50. <view class="btn-area submitBottomBtn padding-lr-sm">
  51. <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
  52. </view>
  53. </form>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. noClick: true,
  61. imgList: [],
  62. msg: '',
  63. id: '',
  64. img: '',
  65. imgUrl: '',
  66. reportName: '',
  67. radioOne: 0,
  68. zb_id: 0
  69. }
  70. },
  71. onLoad: function(option) {
  72. this.id = option.id;
  73. this.zb_id = option.zb_id
  74. },
  75. mounted() {
  76. // 创建附件上传
  77. // var _self = this;
  78. // var input = document.createElement('input'); //创建元素
  79. // input.type = 'file' //添加file类型
  80. // input.onchange = (event) => {
  81. // _self.upFile(input, event)
  82. // }
  83. // this.$refs.input.$el.appendChild(input)
  84. },
  85. methods: {
  86. radioChange(e) {
  87. console.log('type:' + e.detail.value);
  88. this.radioOne = e.detail.value;
  89. },
  90. goCamera() {
  91. const that = this;
  92. uni.chooseImage({
  93. count: 1, // 最多可以选择的图片张数
  94. sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
  95. sourceType: ['camera','album'],
  96. success: function(res) {
  97. console.log(res);
  98. that.imgUrl = res.tempFilePaths[0];
  99. const { tempFilePaths, tempFiles } = res
  100. // var tempFilePaths = res.tempFilePaths[0];
  101. alert(tempFilePaths)
  102. alert(tempFiles)
  103. // setTimeout(function(){
  104. // uni.uploadFile({
  105. // url: that.$BASE_URL + 'Inspection/setUpload',
  106. // filePath: tempFilePaths,
  107. // name: 'file',
  108. // // formData: {
  109. // // 'user': 'test'
  110. // // },
  111. // success: (uploadFileRes) => {
  112. // console.log('uploadFileRes')
  113. // that.img = JSON.parse(uploadFileRes.data).img_url;
  114. // alert(1)
  115. // alert(uploadFileRes.data)
  116. // alert(that.img)
  117. // }
  118. // });
  119. // },2000)
  120. }
  121. })
  122. },
  123. // upFile(input, event) {
  124. // var _self = this;
  125. // uni.uploadFile({
  126. // url:this.$BASE_URL+'Inspection/setUpload',
  127. // files: [{
  128. // file: input.files[0],
  129. // uri: event.srcElement.value
  130. // }],
  131. // success: (uploadFileRes) => {
  132. // var data = JSON.parse(uploadFileRes.data)
  133. // this.img = data.img_url;
  134. // alert(this.img)
  135. // },
  136. // fail: (err) => {
  137. // console.log(err)
  138. // }
  139. // });
  140. // },
  141. addSubmit() {
  142. if (!this.reportName.replace(/^\s*/g, '')) {
  143. uni.showToast({
  144. title: "请输入上报名称",
  145. icon: "none"
  146. });
  147. return
  148. }
  149. if (!this.img) {
  150. uni.showToast({
  151. title: "请上传图片",
  152. icon: "none"
  153. });
  154. return
  155. }
  156. if (!this.msg.replace(/^\s*/g, '')) {
  157. uni.showToast({
  158. title: "请输入巡检描述",
  159. icon: "none"
  160. });
  161. return
  162. }
  163. this.powerSubmitRes({
  164. "zb_id": this.zb_id,
  165. "spot_id": this.id,
  166. "report_name": this.reportName,
  167. "spot_abnormal": this.radioOne,
  168. "img": this.img,
  169. "dwsb_remarks": this.msg,
  170. })
  171. },
  172. async powerSubmitRes(params = {}) {
  173. const res = await this.$myRequest({
  174. url: 'Inspection/setInspection',
  175. data: params
  176. })
  177. if (res.data.flag) {
  178. uni.showToast({
  179. title: "提交成功",
  180. });
  181. setTimeout(() => {
  182. uni.navigateTo({
  183. url: '/pages/xunJian/planInnerList/planInnerList?id=' + this.zb_id,
  184. });
  185. }, 1000);
  186. }
  187. },
  188. textareaAInput(e) {
  189. this.textareaAValue = e.detail.value
  190. },
  191. }
  192. }
  193. </script>
  194. <style lang="scss">
  195. .unload-box {
  196. width: calc(100% - 200rpx)
  197. }
  198. .textarea {
  199. width: calc(100% - 200rpx)
  200. }
  201. </style>