controlReportAdd.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. <select name="" id="" filterable clearable v-model="supervision_title">
  11. <option value="">请选择</option>
  12. <option :value=item.supervision_name v-for="item in titleListData">{{ item.supervision_name}}</option>
  13. </select>
  14. </view>
  15. <view class="form-item">
  16. <view class="title"><text class="necessary">*</text>所属站点:</view>
  17. <select name="" id="" filterable clearable v-model="site_id">
  18. <option value="">请选择</option>
  19. <option :value=item.site_name v-for="item in siteListData">{{ item.site_name}}</option>
  20. </select>
  21. </view>
  22. <view class="form-item">
  23. <view class="title"><text class="necessary">*</text>监察内容:</view>
  24. <textarea maxlength="-1" width="250" v-model="supervision_content"></textarea>
  25. </view>
  26. <view class="form-item">
  27. <view class="title"><text class="necessary">*</text>上传图片:</view>
  28. <view style="width:500rpx">
  29. <view class="cu-form-group" style="padding:0">
  30. <view class="grid col-4 grid-square flex-sub">
  31. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
  32. <image :src="imgList[index]" mode="aspectFill"></image>
  33. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  34. <text class='cuIcon-close'></text>
  35. </view>
  36. </view>
  37. <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
  38. <text class='cuIcon-cameraadd'></text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="btn-area submitBottomBtn padding-lr-sm">
  45. <button class="bg-blue round margin-top" @click="addSubmit()">提 交 </button>
  46. </view>
  47. </form>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. imgList: [],
  55. supervision_title:'',
  56. site_id:'',
  57. supervision_content:'',
  58. titleListData:[],
  59. siteListData:[]
  60. }
  61. },
  62. onLoad: function(option) {
  63. this.getTitleList();
  64. this.getSiteList()
  65. },
  66. methods: {
  67. //新增提交
  68. async addSubmit() {
  69. if (!this.supervision_title) {
  70. uni.showToast({
  71. title: "请选择监察标题",
  72. icon: "none"
  73. });
  74. return
  75. }
  76. if (!this.site_id) {
  77. uni.showToast({
  78. title: "请选择站点",
  79. icon: "none"
  80. });
  81. return
  82. }
  83. if (!this.supervision_content) {
  84. uni.showToast({
  85. title: "请输入监察内容",
  86. icon: "none"
  87. });
  88. return
  89. }
  90. if (!this.imgList.length>0) {
  91. uni.showToast({
  92. title: "请上传图片",
  93. icon: "none"
  94. });
  95. return
  96. }
  97. let res = await this.addReport({
  98. "supervision_title": this.supervision_title,
  99. "site_id": this.site_id,
  100. "supervision_content": this.supervision_content,
  101. "img":'ss'
  102. })
  103. if (!res.data.flag) {
  104. uni.showToast({
  105. title: "添加失败",
  106. icon: "none"
  107. });
  108. } else {
  109. uni.showToast({
  110. title: "添加成功",
  111. });
  112. }
  113. setTimeout(() => {
  114. uni.navigateTo({
  115. url: '/pages/authManage/authManage',
  116. });
  117. }, 1000);
  118. },
  119. addReport(params = {}) {
  120. return this.$myRequest({
  121. url: 'MonitoringReporting/addMonitoringReporting',
  122. data: params
  123. })
  124. },
  125. //监察标题下拉数据请求
  126. async getTitleList(params = {}) {
  127. const res = await this.$myRequest({
  128. url: 'Archives/getsupervisionBox',
  129. showLoading: true,
  130. data: params
  131. })
  132. this.titleListData = res.data.data
  133. },
  134. //站带下拉数据请求
  135. async getSiteList(params = {}) {
  136. const res = await this.$myRequest({
  137. url: 'BlackoutPlan/getSiteBox',
  138. showLoading: true,
  139. data: params
  140. })
  141. this.siteListData = res.data.data
  142. },
  143. ChooseImage() {
  144. uni.chooseImage({
  145. count: 4, //默认9
  146. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  147. sourceType: ['album'], //从相册选择
  148. success: (res) => {
  149. if (this.imgList.length != 0) {
  150. this.imgList = this.imgList.concat(res.tempFilePaths)
  151. } else {
  152. this.imgList = res.tempFilePaths
  153. }
  154. }
  155. });
  156. },
  157. ViewImage(e) {
  158. uni.previewImage({
  159. urls: this.imgList,
  160. current: e.currentTarget.dataset.url
  161. });
  162. },
  163. DelImg(e) {
  164. uni.showModal({
  165. title: '删除',
  166. content: '确定要删除此图片吗?',
  167. cancelText: '取消',
  168. confirmText: '确定',
  169. success: res => {
  170. if (res.confirm) {
  171. this.imgList.splice(e.currentTarget.dataset.index, 1)
  172. }
  173. }
  174. })
  175. },
  176. submit() {
  177. uni.navigateTo({
  178. url: '/pages/accountManage/success/success',
  179. });
  180. },
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. select {
  186. background-size: 6%;
  187. }
  188. </style>