streetXfxcjypxyl.vue 7.9 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="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. <uni-load-more v-show="loading" status="loading" :content-text="contentText" />
  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">
  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. createXfxcjypxyl,
  87. getIdXfxcjypxyl,
  88. updateXfxcjypxyl
  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. contentText: {
  101. contentrefresh: '上传照片中',
  102. },
  103. screenHeight: this.$screenHeight,
  104. wheight: '',
  105. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  106. dateTime: '',
  107. formData: {
  108. jlxczd: '',
  109. qmxdrhxc: '',
  110. kzxhsmhqdczpx: '',
  111. zzcjmkzjzxfxc: '',
  112. zzmhjsstsyl: '',
  113. sdmxqzkzpbxxfxc: '',
  114. xgxfxcby: '',
  115. lyhwspkzxfxc: '',
  116. reporttime: '',
  117. streetRepPicsDOList: []
  118. },
  119. rules: {
  120. jlxczd: NumericRule(),
  121. qmxdrhxc: NumericRule(),
  122. kzxhsmhqdczpx: NumericRule(),
  123. zzcjmkzjzxfxc: NumericRule(),
  124. zzmhjsstsyl: NumericRule(),
  125. sdmxqzkzpbxxfxc: NumericRule(),
  126. xgxfxcby: NumericRule(),
  127. lyhwspkzxfxc: NumericRule(),
  128. reporttime: [{
  129. required: true,
  130. message: '请输入日期',
  131. trigger: ['change', 'blur'],
  132. }],
  133. },
  134. isedit: false, //编辑
  135. isview: false, //查看
  136. loading: false
  137. }
  138. },
  139. onReady() {
  140. this.$refs.customForm.setRules(this.rules);
  141. },
  142. mounted() {
  143. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  144. this.wheight = data.height
  145. }).exec()
  146. },
  147. onLoad(option) {
  148. if (option.editData) {
  149. this.isedit = true
  150. this.parentId = option.editData
  151. this.getIdData()
  152. // this.formData = JSON.parse(option.editData)
  153. } else if (option.viewData) {
  154. this.isview = true
  155. this.parentId = option.viewData
  156. this.getIdData()
  157. // this.formData = JSON.parse(option.viewData)
  158. }
  159. },
  160. methods: {
  161. getIdData() {
  162. getIdXfxcjypxyl({
  163. id: this.parentId
  164. }).then(response => {
  165. this.formData = response.data
  166. console.log(response, 'response')
  167. })
  168. },
  169. //拍照
  170. closeImage(val, index) {
  171. this.formData.streetRepPicsDOList.splice(index, 1)
  172. },
  173. photoUpload() {
  174. takePhotos(this)
  175. },
  176. bindDateChange(e) {
  177. this.formData.reporttime = e.detail.value
  178. },
  179. submit(ref) {
  180. this.$refs[ref].validate().then(res => {
  181. const formList = this.formData
  182. Object.keys(formList).forEach(key => {
  183. formList[key] = formList[key] === '' ? 0 : formList[key];
  184. });
  185. formList.streetRepPicsDOList.forEach((item) => {
  186. // 删除除了feildname和url以外的多余字段
  187. Object.keys(item).forEach((key) => {
  188. if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
  189. delete item[key];
  190. }
  191. });
  192. // 如果feildname为空,赋值为默认名称
  193. if (!item.feildname) {
  194. item.feildname = '默认名称';
  195. }
  196. if (this.isedit && !item.repid) {
  197. item.repid = this.parentId
  198. }
  199. });
  200. console.log(formList, 'this.formData');
  201. if (this.isedit) {
  202. updateXfxcjypxyl(JSON.stringify(this.formData)).then(res => {
  203. this.$modal.msg('修改成功')
  204. this.isedit = false
  205. setTimeout(() => {
  206. uni.navigateBack()
  207. }, 400)
  208. })
  209. } else if (this.isview) {
  210. this.isview = false
  211. uni.navigateBack()
  212. } else {
  213. createXfxcjypxyl(JSON.stringify(this.formData)).then(res => {
  214. this.$modal.msg('新增成功')
  215. setTimeout(() => {
  216. uni.navigateBack()
  217. }, 400)
  218. })
  219. }
  220. }).catch(err => {
  221. console.log(err);
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. body {
  229. background-color: #f5f7f9;
  230. }
  231. page {
  232. background-color: #f5f7f9 !important;
  233. }
  234. .uni-container {
  235. height: 100vh;
  236. background-color: #f5f7f9 !important;
  237. }
  238. /deep/.uni-card {
  239. position: relative;
  240. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  241. border-radius: 30rpx;
  242. }
  243. .example {
  244. overflow-y: auto;
  245. }
  246. </style>