streetXfxcjypxyl.vue 7.6 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="jlxczd">
  7. <u-input v-model="formData.jlxczd" placeholder="请输入" :disabled="isview" />
  8. </u-form-item>
  9. <u-form-item label="“敲门行动”入户宣传 (户)" prop="qmxdrhxc">
  10. <u-input v-model="formData.qmxdrhxc" placeholder="请输入" :disabled="isview" />
  11. </u-form-item>
  12. <u-form-item label="开展消火栓、灭火器等操作培训 (人次)" prop="kzxhsmhqdczpx">
  13. <u-input v-model="formData.kzxhsmhqdczpx" placeholder="请输入" :disabled="isview" />
  14. </u-form-item>
  15. <u-form-item label="组织村(居)民开展集中消防宣传培训或警示教育 (场次)" prop="zzcjmkzjzxfxc">
  16. <u-input v-model="formData.zzcjmkzjzxfxc" placeholder="请输入" :disabled="isview" />
  17. </u-form-item>
  18. <u-form-item label="组织灭火及疏散逃生演练 (场次)" prop="zzmhjsstsyl">
  19. <u-input v-model="formData.zzmhjsstsyl" placeholder="请输入" :disabled="isview" />
  20. </u-form-item>
  21. <u-form-item label="设点面向群众开展普遍性消防宣传 (场次)" prop="sdmxqzkzpbxxfxc">
  22. <u-input v-model="formData.sdmxqzkzpbxxfxc" placeholder="请输入" :disabled="isview" />
  23. </u-form-item>
  24. <u-form-item label="悬挂消防宣传标语 (幅)" prop="xgxfxcby">
  25. <u-input v-model="formData.xgxfxcby" placeholder="请输入" :disabled="isview" />
  26. </u-form-item>
  27. <u-form-item label="利用户外视频开展消防宣传 (个点位)" prop="lyhwspkzxfxc">
  28. <u-input v-model="formData.lyhwspkzxfxc" placeholder="请输入" :disabled="isview" />
  29. </u-form-item>
  30. <picker mode="date" :value="dateTime" @change="bindDateChange" :disabled="isview">
  31. <view class="datatime-street">
  32. <u-form-item label="填报日期" prop="reporttime" :required="true">
  33. <u-input v-model="formData.reporttime" placeholder="选择日期" class="add-date"
  34. :disabled="isview" />
  35. </u-form-item>
  36. </view>
  37. </picker>
  38. <view>
  39. <view class="paizhao">现场照片</view>
  40. <view class="paizhao-posit" v-if="!isview">
  41. <image :src="photograph" @click="photoUpload" class="tiantupian-photo"></image>
  42. <view class="">
  43. 拍照上传
  44. </view>
  45. </view>
  46. </view>
  47. <view v-if="formData.streetRepPicsDOList" class="show-photo">
  48. <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
  49. <view class="show-photo-main">
  50. <view class="show-photo-main-img">
  51. <image :src="items.url" class="show-photo-main-img-item">
  52. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
  53. v-if="!isview">
  54. </u-icon>
  55. </view>
  56. <view class="">
  57. <view>
  58. 图片名称
  59. </view>
  60. <view class="img-name">
  61. <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </u--form>
  69. </view>
  70. <view class="sub-botn heigthButton">
  71. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  72. color="#4CB2B6" text="确认修改" style="width:200px">
  73. </u-button>
  74. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  75. color="#4CB2B6" text="确认新增" style="width:200px">
  76. </u-button>
  77. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  78. color="#4CB2B6" text="返回" style="width:200px">
  79. </u-button>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. createXfxcjypxyl,
  86. getIdXfxcjypxyl,
  87. updateXfxcjypxyl
  88. }
  89. from '@/api/fire_inspetItem/index';
  90. import {
  91. takePhotos,
  92. NumericRule
  93. } from '@/utils/common.js';
  94. import config from '@/config'
  95. const baseUrlImg = config.baseUrlImg
  96. export default {
  97. data() {
  98. return {
  99. screenHeight: this.$screenHeight,
  100. wheight: '',
  101. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  102. dateTime: '',
  103. formData: {
  104. jlxczd: '',
  105. qmxdrhxc: '',
  106. kzxhsmhqdczpx: '',
  107. zzcjmkzjzxfxc: '',
  108. zzmhjsstsyl: '',
  109. sdmxqzkzpbxxfxc: '',
  110. xgxfxcby: '',
  111. lyhwspkzxfxc: '',
  112. reporttime: '',
  113. streetRepPicsDOList: []
  114. },
  115. rules: {
  116. jlxczd: NumericRule(),
  117. qmxdrhxc: NumericRule(),
  118. kzxhsmhqdczpx: NumericRule(),
  119. zzcjmkzjzxfxc: NumericRule(),
  120. zzmhjsstsyl: NumericRule(),
  121. sdmxqzkzpbxxfxc: NumericRule(),
  122. xgxfxcby: NumericRule(),
  123. lyhwspkzxfxc: NumericRule(),
  124. reporttime: [{
  125. required: true,
  126. message: '请输入日期',
  127. trigger: ['change', 'blur'],
  128. }],
  129. },
  130. isedit: false, //编辑
  131. isview: false, //查看
  132. }
  133. },
  134. onReady() {
  135. this.$refs.customForm.setRules(this.rules);
  136. },
  137. mounted() {
  138. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  139. this.wheight = data.height
  140. }).exec()
  141. },
  142. onLoad(option) {
  143. if (option.editData) {
  144. this.isedit = true
  145. this.parentId = option.editData
  146. this.getIdData()
  147. // this.formData = JSON.parse(option.editData)
  148. } else if (option.viewData) {
  149. this.isview = true
  150. this.parentId = option.viewData
  151. this.getIdData()
  152. // this.formData = JSON.parse(option.viewData)
  153. }
  154. },
  155. methods: {
  156. getIdData() {
  157. getIdXfxcjypxyl({
  158. id: this.parentId
  159. }).then(response => {
  160. this.formData = response.data
  161. console.log(response, 'response')
  162. })
  163. },
  164. //拍照
  165. closeImage(val, index) {
  166. this.formData.streetRepPicsDOList.splice(index, 1)
  167. },
  168. photoUpload() {
  169. takePhotos(this)
  170. },
  171. bindDateChange(e) {
  172. this.formData.reporttime = e.detail.value
  173. },
  174. submit(ref) {
  175. this.$refs[ref].validate().then(res => {
  176. const formList = this.formData
  177. Object.keys(formList).forEach(key => {
  178. formList[key] = formList[key] === '' ? 0 : formList[key];
  179. });
  180. formList.streetRepPicsDOList.forEach((item) => {
  181. // 删除除了feildname和url以外的多余字段
  182. Object.keys(item).forEach((key) => {
  183. if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
  184. delete item[key];
  185. }
  186. });
  187. // 如果feildname为空,赋值为默认名称
  188. if (!item.feildname) {
  189. item.feildname = '默认名称';
  190. }
  191. });
  192. console.log(formList, 'this.formData');
  193. if (this.isedit) {
  194. updateXfxcjypxyl(JSON.stringify(this.formData)).then(res => {
  195. this.$modal.msg('修改成功')
  196. this.isedit = false
  197. setTimeout(() => {
  198. uni.navigateBack()
  199. }, 400)
  200. })
  201. } else if (this.isview) {
  202. this.isview = false
  203. uni.navigateBack()
  204. } else {
  205. createXfxcjypxyl(JSON.stringify(this.formData)).then(res => {
  206. this.$modal.msg('新增成功')
  207. setTimeout(() => {
  208. uni.navigateBack()
  209. }, 400)
  210. })
  211. }
  212. }).catch(err => {
  213. console.log(err);
  214. })
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. body {
  221. background-color: #f5f7f9;
  222. }
  223. page {
  224. background-color: #f5f7f9 !important;
  225. }
  226. .uni-container {
  227. height: 100vh;
  228. background-color: #f5f7f9 !important;
  229. }
  230. /deep/.uni-card {
  231. position: relative;
  232. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  233. border-radius: 30rpx;
  234. }
  235. .example {
  236. overflow-y: auto;
  237. }
  238. </style>