streetHypczl.vue 7.7 KB

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