planDetail.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 class="cu-form-group">
  41. <view class="grid col-4 grid-square flex-sub">
  42. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
  43. :data-url="imgList[index]">
  44. <image :src="imgList[index]" mode="aspectFill"></image>
  45. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  46. <text class='cuIcon-close'></text>
  47. </view>
  48. </view>
  49. <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
  50. <text class='cuIcon-cameraadd'></text>
  51. </view>
  52. </view>
  53. </view> -->
  54. </view>
  55. </view>
  56. <view class="form-item margin-top">
  57. <view class="title">
  58. <text class="necessary">*</text>
  59. 巡检描述:
  60. </view>
  61. <textarea maxlength="-1" @input="textareaAInput" placeholder="" v-model="msg" width="250"></textarea>
  62. </view>
  63. <view class="btn-area submitBottomBtn padding-lr-sm">
  64. <button class="bg-blue round margin-top" @click="addSubmit">提 交 </button>
  65. </view>
  66. </form>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. imgList: [],
  74. msg: '',
  75. id: '',
  76. reportName: '',
  77. radioOne: 0,
  78. }
  79. },
  80. onLoad: function(option) {
  81. this.id = option.id;
  82. },
  83. mounted() {
  84. // 创建附件上传
  85. var _self = this;
  86. var input = document.createElement('input'); //创建元素
  87. input.type = 'file' //添加file类型
  88. input.onchange = (event) => {
  89. _self.upFile(input, event)
  90. }
  91. this.$refs.input.$el.appendChild(input)
  92. },
  93. methods: {
  94. radioChange(e) {
  95. console.log('type:' + e.detail.value);
  96. this.radioOne = e.detail.value;
  97. },
  98. upFile(input, event) {
  99. var _self = this;
  100. uni.uploadFile({
  101. url: 'https://wx.ewoogi.com/wx/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
  102. files: [{
  103. file: input.files[0],
  104. uri: event.srcElement.value
  105. }],
  106. success: (uploadFileRes) => {
  107. var data = JSON.parse(uploadFileRes.data)
  108. this.img = data.img_url;
  109. console.log(this.img)
  110. },
  111. fail: (err) => {
  112. console.log(err)
  113. }
  114. });
  115. },
  116. addSubmit() {
  117. if (!this.reportName) {
  118. uni.showToast({
  119. title: "请输入上报名称",
  120. icon: "none"
  121. });
  122. return
  123. }
  124. if (!this.msg) {
  125. uni.showToast({
  126. title: "请输入巡检描述",
  127. icon: "none"
  128. });
  129. return
  130. }
  131. if (!this.img) {
  132. uni.showToast({
  133. title: "请上传图片",
  134. icon: "none"
  135. });
  136. return
  137. }
  138. this.powerSubmitRes({
  139. // "zb_id": this.getData.id, ??????
  140. "zb_id":'6172484',
  141. "spot_id": this.id,
  142. "report_name": this.reportName,
  143. "spot_abnormal": this.radioOne,
  144. "img": this.img,
  145. "dwsb_remarks": this.msg,
  146. })
  147. },
  148. async powerSubmitRes(params = {}) {
  149. const res = await this.$myRequest({
  150. url: 'Inspection/setInspection',
  151. data: params
  152. })
  153. if (res.data.flag) {
  154. uni.showToast({
  155. title: "提交成功",
  156. });
  157. setTimeout(() => {
  158. uni.navigateTo({
  159. url: '/pages/inspectList/processList/processList?type=' + this.type,
  160. });
  161. }, 1000);
  162. }
  163. },
  164. ChooseImage() {
  165. uni.chooseImage({
  166. count: 4, //默认9
  167. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  168. sourceType: ['album'], //从相册选择
  169. success: (res) => {
  170. if (this.imgList.length != 0) {
  171. this.imgList = this.imgList.concat(res.tempFilePaths)
  172. } else {
  173. this.imgList = res.tempFilePaths
  174. }
  175. }
  176. });
  177. },
  178. ViewImage(e) {
  179. uni.previewImage({
  180. urls: this.imgList,
  181. current: e.currentTarget.dataset.url
  182. });
  183. },
  184. DelImg(e) {
  185. uni.showModal({
  186. title: '删除',
  187. content: '确定要删除此图片吗?',
  188. cancelText: '取消',
  189. confirmText: '确定',
  190. success: res => {
  191. if (res.confirm) {
  192. this.imgList.splice(e.currentTarget.dataset.index, 1)
  193. }
  194. }
  195. })
  196. },
  197. textareaAInput(e) {
  198. this.textareaAValue = e.detail.value
  199. },
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. </style>