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. zb_id:0
  79. }
  80. },
  81. onLoad: function(option) {
  82. this.id = option.id;
  83. this.zb_id=option.zb_id
  84. },
  85. mounted() {
  86. // 创建附件上传
  87. var _self = this;
  88. var input = document.createElement('input'); //创建元素
  89. input.type = 'file' //添加file类型
  90. input.onchange = (event) => {
  91. _self.upFile(input, event)
  92. }
  93. this.$refs.input.$el.appendChild(input)
  94. },
  95. methods: {
  96. radioChange(e) {
  97. console.log('type:' + e.detail.value);
  98. this.radioOne = e.detail.value;
  99. },
  100. upFile(input, event) {
  101. var _self = this;
  102. uni.uploadFile({
  103. url: 'https://qhome.usky.cn/USKYZHAF/USKYZHAF.php/Home/Inspection/setUpload',
  104. files: [{
  105. file: input.files[0],
  106. uri: event.srcElement.value
  107. }],
  108. success: (uploadFileRes) => {
  109. var data = JSON.parse(uploadFileRes.data)
  110. this.img = data.img_url;
  111. console.log(this.img)
  112. },
  113. fail: (err) => {
  114. console.log(err)
  115. }
  116. });
  117. },
  118. addSubmit() {
  119. if (!this.reportName) {
  120. uni.showToast({
  121. title: "请输入上报名称",
  122. icon: "none"
  123. });
  124. return
  125. }
  126. if (!this.msg) {
  127. uni.showToast({
  128. title: "请输入巡检描述",
  129. icon: "none"
  130. });
  131. return
  132. }
  133. if (!this.img) {
  134. uni.showToast({
  135. title: "请上传图片",
  136. icon: "none"
  137. });
  138. return
  139. }
  140. this.powerSubmitRes({
  141. "zb_id": this.zb_id,
  142. // "zb_id":600,
  143. "spot_id": this.id,
  144. "report_name": this.reportName,
  145. "spot_abnormal": this.radioOne,
  146. "img": this.img,
  147. "dwsb_remarks": this.msg,
  148. })
  149. },
  150. async powerSubmitRes(params = {}) {
  151. const res = await this.$myRequest({
  152. url: 'Inspection/setInspection',
  153. data: params
  154. })
  155. if (res.data.flag) {
  156. uni.showToast({
  157. title: "提交成功",
  158. });
  159. setTimeout(() => {
  160. uni.navigateTo({
  161. url: '/pages/xunJian/planInnerList/planInnerList?id=' + this.id,
  162. });
  163. }, 1000);
  164. }
  165. },
  166. ChooseImage() {
  167. uni.chooseImage({
  168. count: 4, //默认9
  169. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  170. sourceType: ['album'], //从相册选择
  171. success: (res) => {
  172. if (this.imgList.length != 0) {
  173. this.imgList = this.imgList.concat(res.tempFilePaths)
  174. } else {
  175. this.imgList = res.tempFilePaths
  176. }
  177. }
  178. });
  179. },
  180. ViewImage(e) {
  181. uni.previewImage({
  182. urls: this.imgList,
  183. current: e.currentTarget.dataset.url
  184. });
  185. },
  186. DelImg(e) {
  187. uni.showModal({
  188. title: '删除',
  189. content: '确定要删除此图片吗?',
  190. cancelText: '取消',
  191. confirmText: '确定',
  192. success: res => {
  193. if (res.confirm) {
  194. this.imgList.splice(e.currentTarget.dataset.index, 1)
  195. }
  196. }
  197. })
  198. },
  199. textareaAInput(e) {
  200. this.textareaAValue = e.detail.value
  201. },
  202. }
  203. }
  204. </script>
  205. <style lang="scss">
  206. </style>