streetHypczl.vue 7.5 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="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. </view>
  47. </view>
  48. <view v-if="formData.streetRepPicsDOList" class="show-photo">
  49. <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
  50. <view class="show-photo-main">
  51. <view class="show-photo-main-img">
  52. <image :src="items.url" class="show-photo-main-img-item">
  53. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
  54. v-if="!isview">
  55. </u-icon>
  56. </view>
  57. <view class="">
  58. <view>
  59. 图片名称
  60. </view>
  61. <view class="img-name-street">
  62. <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </u--form>
  70. </view>
  71. <view class="sub-botn heigthButton">
  72. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  73. color="#4CB2B6" text="确认修改" style="width:200px">
  74. </u-button>
  75. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  76. color="#4CB2B6" text="确认新增" style="width:200px">
  77. </u-button>
  78. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  79. color="#4CB2B6" text="返回" style="width:200px">
  80. </u-button>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. createHypczl,
  87. getIdHypczl,
  88. updateHypczl
  89. }
  90. from '@/api/fire_inspetItem/index';
  91. import {
  92. takePhotos,
  93. NumericRule
  94. } from '@/utils/common.js';
  95. import config from '@/config'
  96. const baseUrlImg = config.baseUrlImg
  97. export default {
  98. data() {
  99. return {
  100. screenHeight: this.$screenHeight,
  101. wheight: '',
  102. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  103. dateTime: '',
  104. formData: {
  105. jcdwhcs: '',
  106. zfjnjlddggbwfxszjs: '',
  107. hywykrwbcaqjl: '',
  108. ythqnhkwbctf: '',
  109. yhlr: '',
  110. hjqgddymhwqlzbkrwhcqfhcs: '',
  111. wfjlywyh: '',
  112. reporttime: '',
  113. streetRepPicsDOList: []
  114. },
  115. rules: {
  116. jcdwhcs: NumericRule(),
  117. zfjnjlddggbwfxszjs: NumericRule(),
  118. hywykrwbcaqjl: NumericRule(),
  119. ythqnhkwbctf: NumericRule(),
  120. yhlr: NumericRule(),
  121. hjqgddymhwqlzbkrwhcqfhcs: NumericRule(),
  122. wfjlywyh: NumericRule(),
  123. reporttime: [{
  124. required: true,
  125. message: '请输入日期',
  126. trigger: ['change', 'blur'],
  127. }],
  128. },
  129. isedit: false, //编辑
  130. isview: false, //查看
  131. }
  132. },
  133. onReady() {
  134. this.$refs.customForm.setRules(this.rules);
  135. },
  136. mounted() {
  137. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  138. this.wheight = data.height
  139. }).exec()
  140. },
  141. onLoad(option) {
  142. if (option.editData) {
  143. this.isedit = true
  144. this.parentId = option.editData
  145. this.getIdData()
  146. // this.formData = JSON.parse(option.editData)
  147. } else if (option.viewData) {
  148. this.isview = true
  149. this.parentId = option.viewData
  150. this.getIdData()
  151. // this.formData = JSON.parse(option.viewData)
  152. }
  153. },
  154. methods: {
  155. getIdData() {
  156. getIdHypczl({
  157. id: this.parentId
  158. }).then(response => {
  159. this.formData = response.data
  160. console.log(response, 'response')
  161. })
  162. },
  163. //拍照
  164. closeImage(val, index) {
  165. this.formData.streetRepPicsDOList.splice(index, 1)
  166. },
  167. photoUpload() {
  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. updateHypczl(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. createHypczl(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>