streetCzfpczl.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="uni-container">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
  4. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="100%" labelAlign="left">
  5. <view class="juli-bottom">
  6. <u-form-item label="检查出租房屋 (处)" prop="jcczfw">
  7. <u-input v-model="formData.jcczfw" placeholder="请输入" :disabled="isview" />
  8. </u-form-item>
  9. <u-form-item label="发现隐患 (处)" prop="fxyh">
  10. <u-input v-model="formData.fxyh" placeholder="请输入" :disabled="isview" />
  11. </u-form-item>
  12. <u-form-item label="整改隐患((处)" prop="zgyh">
  13. <u-input v-model="formData.zgyh" placeholder="请输入" :disabled="isview" />
  14. </u-form-item>
  15. <u-form-item label="发现违规群租房(处)" prop="fxwgqzf">
  16. <u-input v-model="formData.fxwgqzf" placeholder="请输入" :disabled="isview" />
  17. </u-form-item>
  18. <u-form-item label="整改违规群租房(处)" prop="zgwgqzf">
  19. <u-input v-model="formData.zgwgqzf" placeholder="请输入" :disabled="isview" />
  20. </u-form-item>
  21. <picker mode="date" :value="dateTime" @change="bindDateChange" :disabled="isview">
  22. <view class="datatime-street">
  23. <u-form-item label="填报日期" prop="reporttime" :required="true">
  24. <u-input v-model="formData.reporttime" placeholder="选择日期" class="add-date"
  25. :disabled="isview" />
  26. </u-form-item>
  27. </view>
  28. </picker>
  29. <view>
  30. <view class="paizhao">现场照片</view>
  31. <view class="paizhao-posit" v-if="!isview">
  32. <view class="">
  33. <image :src="photograph" @click="photoUpload" class="tiantupian-photo"></image>
  34. <uni-load-more v-show="loading" status="loading" :content-text="contentText" />
  35. <!-- <span v-show="loading" class="photo-loading">上传照片中...</span> -->
  36. </view>
  37. <view class="">
  38. 拍照上传
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="formData.streetRepPicsDOList" class="show-photo">
  43. <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
  44. <view class="show-photo-main">
  45. <view class="show-photo-main-img">
  46. <image :src="items.url" class="show-photo-main-img-item">
  47. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
  48. v-if="!isview">
  49. </u-icon>
  50. </view>
  51. <view class="">
  52. <view>
  53. 图片名称
  54. </view>
  55. <view class="img-name">
  56. <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </u--form>
  64. </view>
  65. <view class="sub-botn heigthButton">
  66. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  67. color="#4CB2B6" text="确认修改" style="width:200px">
  68. </u-button>
  69. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  70. color="#4CB2B6" text="确认新增" style="width:200px">
  71. </u-button>
  72. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  73. color="#4CB2B6" text="返回" style="width:200px">
  74. </u-button>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. createCzfpczl,
  81. getIdCzfpczl,
  82. updateCzfpczl
  83. }
  84. from '@/api/fire_inspetItem/index';
  85. import {
  86. takePhotos,
  87. NumericRule
  88. } from '@/utils/common.js';
  89. import config from '@/config'
  90. const baseUrlImg = config.baseUrlImg
  91. export default {
  92. data() {
  93. return {
  94. contentText: {
  95. contentrefresh: '上传照片中',
  96. },
  97. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  98. dateTime: '',
  99. formData: {
  100. jcczfw: '',
  101. fxyh: '',
  102. zgyh: '',
  103. fxwgqzf: '',
  104. zgwgqzf: '',
  105. reporttime: '',
  106. streetRepPicsDOList: []
  107. },
  108. rules: {
  109. jcczfw: NumericRule(),
  110. fxyh: NumericRule(),
  111. zgyh: NumericRule(),
  112. fxwgqzf: NumericRule(),
  113. zgwgqzf: NumericRule(),
  114. reporttime: [{
  115. required: true,
  116. message: '请输入日期',
  117. trigger: ['change', 'blur'],
  118. }],
  119. },
  120. isedit: false, //编辑
  121. isview: false, //查看
  122. screenHeight: this.$screenHeight,
  123. wheight: '',
  124. loading: false
  125. }
  126. },
  127. mounted() {
  128. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  129. this.wheight = data.height
  130. }).exec()
  131. },
  132. onReady() {
  133. this.$refs.customForm.setRules(this.rules);
  134. },
  135. watch: {
  136. loading: {
  137. handler(newLength, oldLength) {
  138. this.$modal.isLoadingModel(this.loading)
  139. },
  140. immediate: true
  141. }
  142. },
  143. onLoad(option) {
  144. if (option.editData) {
  145. this.isedit = true
  146. this.parentId = option.editData
  147. this.getIdData()
  148. // this.formData = JSON.parse(option.editData)
  149. } else if (option.viewData) {
  150. this.isview = true
  151. this.parentId = option.viewData
  152. this.getIdData()
  153. // this.formData = JSON.parse(option.viewData)
  154. }
  155. },
  156. methods: {
  157. getIdData() {
  158. getIdCzfpczl({
  159. id: this.parentId
  160. }).then(response => {
  161. this.formData = response.data
  162. console.log('sdfff');
  163. console.log(response, 'responsesssss')
  164. })
  165. },
  166. //拍照
  167. closeImage(val, index) {
  168. this.formData.streetRepPicsDOList.splice(index, 1)
  169. },
  170. photoUpload() {
  171. // this.loading = true
  172. takePhotos(this)
  173. },
  174. bindDateChange(e) {
  175. this.formData.reporttime = e.detail.value
  176. },
  177. submit(ref) {
  178. this.$refs[ref].validate().then(res => {
  179. const formList = this.formData
  180. Object.keys(formList).forEach(key => {
  181. formList[key] = formList[key] === '' ? 0 : formList[key];
  182. });
  183. formList.streetRepPicsDOList.forEach((item) => {
  184. // 删除除了feildname和url以外的多余字段
  185. Object.keys(item).forEach((key) => {
  186. if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
  187. delete item[key];
  188. }
  189. });
  190. // 如果feildname为空,赋值为默认名称
  191. if (!item.feildname) {
  192. item.feildname = '默认名称';
  193. }
  194. if (this.isedit && !item.repid) {
  195. item.repid = this.parentId
  196. }
  197. });
  198. console.log(formList, 'this.formData');
  199. if (this.isedit) {
  200. updateCzfpczl(JSON.stringify(this.formData)).then(res => {
  201. this.$modal.msg('修改成功')
  202. this.isedit = false
  203. setTimeout(() => {
  204. uni.navigateBack()
  205. }, 400)
  206. })
  207. } else if (this.isview) {
  208. this.isview = false
  209. uni.navigateBack()
  210. } else {
  211. createCzfpczl(JSON.stringify(this.formData)).then(res => {
  212. this.$modal.msg('新增成功')
  213. setTimeout(() => {
  214. uni.navigateBack()
  215. }, 400)
  216. })
  217. }
  218. }).catch(err => {
  219. console.log(err);
  220. })
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. body {
  227. background-color: #f5f7f9;
  228. }
  229. page {
  230. background-color: #f5f7f9 !important;
  231. }
  232. .uni-container {
  233. height: 100vh;
  234. background-color: #f5f7f9 !important;
  235. }
  236. /deep/.uni-card {
  237. position: relative;
  238. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  239. border-radius: 30rpx;
  240. }
  241. .example {
  242. overflow-y: auto;
  243. }
  244. </style>