planDetail.vue 5.2 KB

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