streetCzfpczl.vue 6.8 KB

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