controlReportAdd.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="appWrapper">
  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="supervision_title" required>
  11. <!-- <select name="" id="" filterable clearable v-model="supervision_title">
  12. <option value="">请选择</option>
  13. <option :value=item.supervision_name v-for="item in titleListData">{{ item.supervision_name}}</option>
  14. </select> -->
  15. </view>
  16. <view class="form-item">
  17. <view class="title"><text class="necessary">*</text>所属站点:</view>
  18. <select name="" id="" filterable clearable v-model="site_id">
  19. <option value="">请选择</option>
  20. <option :value=item.id v-for="item in siteListData">{{ item.site_name}}</option>
  21. </select>
  22. </view>
  23. <view class="form-item">
  24. <view class="title"><text class="necessary">*</text>监察内容:</view>
  25. <textarea maxlength="-1" width="250" v-model="supervision_content"></textarea>
  26. </view>
  27. <view class="form-item">
  28. <view class="title"><text class="necessary">*</text>上传图片:</view>
  29. <view style="width:500rpx">
  30. <!-- <uni-group title="只选择图片">
  31. <uni-file-picker limit="1"></uni-file-picker>
  32. </uni-group> -->
  33. <view ref="input" class="input">
  34. </view>
  35. <!-- <view class="cu-form-group" style="padding:0">
  36. <view class="grid col-4 grid-square flex-sub">
  37. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
  38. :data-url="imgList[index]">
  39. <image :src="imgList[index]" mode="aspectFill"></image>
  40. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  41. <text class='cuIcon-close'></text>
  42. </view>
  43. </view>
  44. <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
  45. <text class='cuIcon-cameraadd'></text>
  46. </view>
  47. </view>
  48. </view> -->
  49. </view>
  50. </view>
  51. <br>
  52. <view class="form-item">
  53. <view style="color:#4074E7;border-bottom:1px solid #4074E7" @tap="goArchivePage()">现场档案</view>
  54. </view>
  55. <view class="btn-area submitBottomBtn padding-lr-sm">
  56. <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
  57. </view>
  58. </form>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. noClick:true,
  66. imgList: [],
  67. supervision_title: '',
  68. site_id: '',
  69. supervision_content: '',
  70. msg:'',
  71. img:'',
  72. titleListData: [],
  73. siteListData: [],
  74. }
  75. },
  76. onLoad: function(option) {
  77. this.getSiteList();
  78. },
  79. mounted(){
  80. // 创建附件上传
  81. var _self = this;
  82. var input = document.createElement('input');//创建元素
  83. input.type = 'file'//添加file类型
  84. input.onchange = (event) => {
  85. _self.upFile(input, event)
  86. }
  87. this.$refs.input.$el.appendChild(input)
  88. },
  89. methods: {
  90. goArchivePage(){
  91. uni.navigateTo({
  92. url: '/pages/siteArchive/siteArchive',
  93. });
  94. },
  95. upFile(input, event) {
  96. var _self = this;
  97. uni.uploadFile({
  98. url: 'https://wx.ewoogi.com/wx/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
  99. files: [
  100. {
  101. file: input.files[0],
  102. uri: event.srcElement.value
  103. }
  104. ],
  105. success: (uploadFileRes) => {
  106. var data=JSON.parse(uploadFileRes.data)
  107. // alert('上传成功')
  108. // alert(data.img_url)
  109. // console.log('data')
  110. // console.log(data.img_url)
  111. // console.log('uploadFileRes')
  112. this.img=data.img_url
  113. },
  114. fail: (err) => {
  115. // alert('上传失败')
  116. console.log(err)
  117. }
  118. });
  119. },
  120. //新增提交
  121. async addSubmit() {
  122. if (!this.supervision_title.replace(/^\s*/g,'')) {
  123. uni.showToast({
  124. title: "请输入监察标题",
  125. icon: "none"
  126. });
  127. return
  128. }
  129. if (!this.site_id) {
  130. uni.showToast({
  131. title: "请选择站点",
  132. icon: "none"
  133. });
  134. return
  135. }
  136. if (!this.supervision_content.replace(/^\s*/g,'')) {
  137. uni.showToast({
  138. title: "请输入监察内容",
  139. icon: "none"
  140. });
  141. return
  142. }
  143. if (!this.img) {
  144. uni.showToast({
  145. title: "请上传图片",
  146. icon: "none"
  147. });
  148. return
  149. }
  150. // if (!this.msg ) {
  151. // uni.showToast({
  152. // title: "请上传图片",
  153. // icon: "none"
  154. // });
  155. // return
  156. // }
  157. let res = await this.addReport({
  158. "supervision_title": this.supervision_title,
  159. "site_id": this.site_id,
  160. "supervision_content": this.supervision_content,
  161. // "img":this.imgList[0]
  162. "img_url":this.img
  163. })
  164. if (!res.data.flag) {
  165. uni.showToast({
  166. title: "添加失败",
  167. icon: "none"
  168. });
  169. } else {
  170. uni.showToast({
  171. title: "添加成功",
  172. });
  173. }
  174. setTimeout(() => {
  175. uni.navigateTo({
  176. url: '/pages/siteArchive/controlReport/controlReport',
  177. });
  178. }, 1000);
  179. },
  180. addReport(params = {}) {
  181. return this.$myRequest({
  182. url: 'MonitoringReporting/addMonitoringReporting',
  183. data: params
  184. })
  185. },
  186. //站带下拉数据请求
  187. async getSiteList(params = {}) {
  188. const res = await this.$myRequest({
  189. url: 'BlackoutPlan/getSiteBox',
  190. showLoading: true,
  191. data: params
  192. })
  193. this.siteListData = res.data.data
  194. },
  195. ChooseImage() {
  196. uni.chooseImage({
  197. count: 4, //默认9
  198. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  199. sourceType: ['album'], //从相册选择
  200. success: (res) => {
  201. if (this.imgList.length != 0) {
  202. this.imgList = this.imgList.concat(res.tempFilePaths)
  203. } else {
  204. this.imgList = res.tempFilePaths
  205. }
  206. }
  207. });
  208. },
  209. ViewImage(e) {
  210. uni.previewImage({
  211. urls: this.imgList,
  212. current: e.currentTarget.dataset.url
  213. });
  214. },
  215. DelImg(e) {
  216. uni.showModal({
  217. title: '删除',
  218. content: '确定要删除此图片吗?',
  219. cancelText: '取消',
  220. confirmText: '确定',
  221. success: res => {
  222. if (res.confirm) {
  223. this.imgList.splice(e.currentTarget.dataset.index, 1)
  224. }
  225. }
  226. })
  227. },
  228. submit() {
  229. uni.navigateTo({
  230. url: '/pages/accountManage/success/success',
  231. });
  232. },
  233. }
  234. }
  235. </script>
  236. <style lang="scss">
  237. select {
  238. background-size: 6%;
  239. }
  240. </style>