streetCzfpczl.vue 6.9 KB

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