streetXfsssbpczl.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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="julis-bottom">
  6. <uni-card class="xf-title">
  7. <view class="main-showdow-streetXf">
  8. 市政消火栓 (个)
  9. </view>
  10. <uni-row class="demo-uni-row">
  11. <uni-col :span="11" style="margin-right:40rpx">
  12. <u-form-item label="原有:" prop="szxhsXz">
  13. <u-input v-model="formData.szxhsXz" :disabled="isview" />
  14. </u-form-item>
  15. </uni-col>
  16. <uni-col :span="11">
  17. <u-form-item label="新增:" prop="szxhsYy">
  18. <u-input v-model="formData.szxhsYy" :disabled="isview" />
  19. </u-form-item>
  20. </uni-col>
  21. </uni-row>
  22. </uni-card>
  23. <uni-card class="xf-title">
  24. <view class="main-showdow-streetXf">
  25. 建筑室外消火栓 (个)
  26. </view>
  27. <uni-row class="demo-uni-row">
  28. <uni-col :span="11" style="margin-right:40rpx">
  29. <u-form-item label="新增:" prop="jzswxhsXz">
  30. <u-input v-model="formData.jzswxhsXz" :disabled="isview" />
  31. </u-form-item>
  32. </uni-col>
  33. <uni-col :span="11">
  34. <u-form-item label="维护:" prop="jzswxhsYy">
  35. <u-input v-model="formData.jzswxhsYy" :disabled="isview" />
  36. </u-form-item>
  37. </uni-col>
  38. </uni-row>
  39. </uni-card>
  40. <uni-card class="xf-title">
  41. <view class="main-showdow-streetXf">
  42. 消防水池 (个)
  43. </view>
  44. <uni-row class="demo-uni-row">
  45. <uni-col :span="11" style="margin-right:40rpx">
  46. <u-form-item label="原有:" prop="xfscYy">
  47. <u-input v-model="formData.xfscYy" :disabled="isview" />
  48. </u-form-item>
  49. </uni-col>
  50. <uni-col :span="11">
  51. <u-form-item label="新增:" prop="xfscXz">
  52. <u-input v-model="formData.xfscXz" :disabled="isview" />
  53. </u-form-item>
  54. </uni-col>
  55. </uni-row>
  56. </uni-card>
  57. <uni-card class="xf-title">
  58. <view class="main-showdow-streetXf">
  59. 灭火器 (个)
  60. </view>
  61. <uni-row class="demo-uni-row">
  62. <uni-col :span="10" style="margin-right:40rpx">
  63. <u-form-item label="新增:" prop="mhqYy">
  64. <u-input v-model="formData.mhqYy" :disabled="isview" />
  65. </u-form-item>
  66. </uni-col>
  67. <uni-col :span="12">
  68. <u-form-item label="更换维护:" prop="mhqGhwh">
  69. <u-input v-model="formData.mhqGhwh" :disabled="isview" />
  70. </u-form-item>
  71. </uni-col>
  72. </uni-row>
  73. </uni-card>
  74. <uni-card class="xf-title">
  75. <view class="main-showdow-streetXf">
  76. 应急照明灯具 (个)
  77. </view>
  78. <uni-row class="demo-uni-row">
  79. <uni-col :span="10" style="margin-right:40rpx">
  80. <u-form-item label="新增:" prop="yjzmdYy">
  81. <u-input v-model="formData.yjzmdYy" :disabled="isview" />
  82. </u-form-item>
  83. </uni-col>
  84. <uni-col :span="12">
  85. <u-form-item label="更换维护:" prop="yjzmdGhwh">
  86. <u-input v-model="formData.yjzmdGhwh" :disabled="isview" />
  87. </u-form-item>
  88. </uni-col>
  89. </uni-row>
  90. </uni-card>
  91. <uni-card class="xf-title">
  92. <view class="main-showdow-streetXf">
  93. 疏散指示标志 (个)
  94. </view>
  95. <uni-row class="demo-uni-row">
  96. <uni-col :span="10" style="margin-right:40rpx">
  97. <u-form-item label="新增:" prop="sszsbzYy">
  98. <u-input v-model="formData.sszsbzYy" :disabled="isview" />
  99. </u-form-item>
  100. </uni-col>
  101. <uni-col :span="12">
  102. <u-form-item label="更换维护:" prop="sszsbzGhwh">
  103. <u-input v-model="formData.sszsbzGhwh" :disabled="isview" />
  104. </u-form-item>
  105. </uni-col>
  106. </uni-row>
  107. </uni-card>
  108. <uni-card class="xf-title">
  109. <view class="main-showdow-streetXf">
  110. 微型消防站 (个)
  111. </view>
  112. <uni-row class="demo-uni-row">
  113. <uni-col :span="11" style="margin-right:40rpx">
  114. <u-form-item label="原有:" prop="wxxfzYy">
  115. <u-input v-model="formData.wxxfzYy" :disabled="isview" />
  116. </u-form-item>
  117. </uni-col>
  118. <uni-col :span="11">
  119. <u-form-item label="新增:" prop="wxxfzXz">
  120. <u-input v-model="formData.wxxfzXz" :disabled="isview" />
  121. </u-form-item>
  122. </uni-col>
  123. </uni-row>
  124. </uni-card>
  125. <uni-card class="xf-title">
  126. <view class="main-showdow-streetXf">
  127. 消防车辆 (台)
  128. </view>
  129. <uni-row class="demo-uni-row">
  130. <uni-col :span="10" style="margin-right:40rpx">
  131. <u-form-item label="原有:" prop="xfclYy">
  132. <u-input v-model="formData.xfclYy" :disabled="isview" />
  133. </u-form-item>
  134. </uni-col>
  135. <uni-col :span="12">
  136. <u-form-item label="新增:" prop="xfclXz">
  137. <u-input v-model="formData.xfclXz" :disabled="isview" />
  138. </u-form-item>
  139. </uni-col>
  140. </uni-row>
  141. </uni-card>
  142. <uni-card class="xf-title">
  143. <view class="main-showdow-streetXf">
  144. 自动灭火设施(自动报警、自动喷淋、防排烟等) (套)
  145. </view>
  146. <uni-row class="demo-uni-row">
  147. <uni-col :span="10" style="margin-right:40rpx">
  148. <u-form-item label="新增:" prop="zdmhssYy">
  149. <u-input v-model="formData.zdmhssYy" :disabled="isview" />
  150. </u-form-item>
  151. </uni-col>
  152. <uni-col :span="12">
  153. <u-form-item label="更换维护:" prop="zdmhssGhwh">
  154. <u-input v-model="formData.zdmhssGhwh" :disabled="isview" />
  155. </u-form-item>
  156. </uni-col>
  157. </uni-row>
  158. </uni-card>
  159. <uni-card class="xf-title">
  160. <view class="main-showdow-streetXf">
  161. 其他(如手抬消防泵等)
  162. </view>
  163. <uni-row class="demo-uni-row">
  164. <uni-col :span="10" style="margin-right:40rpx">
  165. <u-form-item label="新增:" prop="qtXz">
  166. <u-input v-model="formData.qtXz" :disabled="isview" />
  167. </u-form-item>
  168. </uni-col>
  169. </uni-row>
  170. </uni-card>
  171. <picker mode="date" :value="dateTime" @change="bindDateChange" :disabled="isview">
  172. <view class="datatime-street">
  173. <u-form-item label="填报日期" prop="reporttime" :required="true">
  174. <u-input v-model="formData.reporttime" placeholder="选择日期" class="add-date"
  175. :disabled="isview" />
  176. </u-form-item>
  177. </view>
  178. </picker>
  179. <view>
  180. <view class="paizhao" style="color:#383838 !important">现场照片</view>
  181. <view class="paizhao-posit" v-if="!isview">
  182. <image :src="photograph" @click="photoUpload" class="tiantupian-photo"></image>
  183. <view class="">
  184. 拍照上传
  185. </view>
  186. </view>
  187. </view>
  188. <view v-if="formData.streetRepPicsDOList" class="show-photo">
  189. <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
  190. <view class="show-photo-main">
  191. <view class="show-photo-main-img">
  192. <image :src="items.url" class="show-photo-main-img-item">
  193. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
  194. v-if="!isview">
  195. </u-icon>
  196. </view>
  197. <view class="">
  198. <view>
  199. 图片名称
  200. </view>
  201. <view class="img-name">
  202. <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
  203. </view>
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. </u--form>
  210. </view>
  211. <view class="sub-botn heigthButton">
  212. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  213. color="#4CB2B6" text="确认修改" style="width:200px">
  214. </u-button>
  215. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  216. color="#4CB2B6" text="确认新增" style="width:200px">
  217. </u-button>
  218. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  219. color="#4CB2B6" text="返回" style="width:200px">
  220. </u-button>
  221. </view>
  222. </view>
  223. </template>
  224. <script>
  225. import {
  226. createXfsssbpczl,
  227. getIdXfsssbpczl,
  228. updateXfsssbpczl
  229. }
  230. from '@/api/fire_inspetItem/index';
  231. import {
  232. takePhotos,
  233. NumericRule
  234. } from '@/utils/common.js';
  235. import config from '@/config'
  236. const baseUrlImg = config.baseUrlImg
  237. export default {
  238. data() {
  239. return {
  240. screenHeight: this.$screenHeight,
  241. wheight: '',
  242. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  243. dateTime: '',
  244. formData: {
  245. szxhsXz: '',
  246. szxhsYy: '',
  247. jzswxhsXz: '',
  248. jzswxhsYy: '',
  249. xfscYy: '',
  250. xfscXz: '',
  251. mhqYy: '',
  252. mhqGhwh: '',
  253. yjzmdYy: '',
  254. yjzmdGhwh: '',
  255. sszsbzYy: '',
  256. sszsbzGhwh: '',
  257. wxxfzYy: '',
  258. wxxfzXz: '',
  259. xfclYy: '',
  260. xfclXz: '',
  261. zdmhssYy: '',
  262. zdmhssGhwh: '',
  263. qtXz: '',
  264. reporttime: '',
  265. streetRepPicsDOList: []
  266. },
  267. rules: {
  268. szxhsXz: NumericRule(),
  269. szxhsYy: NumericRule(),
  270. jzswxhsXz: NumericRule(),
  271. jzswxhsYy: NumericRule(),
  272. xfscYy: NumericRule(),
  273. xfscXz: NumericRule(),
  274. mhqYy: NumericRule(),
  275. mhqGhwh: NumericRule(),
  276. yjzmdYy: NumericRule(),
  277. yjzmdGhwh: NumericRule(),
  278. sszsbzYy: NumericRule(),
  279. sszsbzGhwh: NumericRule(),
  280. wxxfzYy: NumericRule(),
  281. wxxfzXz: NumericRule(),
  282. xfclYy: NumericRule(),
  283. xfclXz: NumericRule(),
  284. zdmhssYy: NumericRule(),
  285. zdmhssGhwh: NumericRule(),
  286. qtXz: NumericRule(),
  287. reporttime: [{
  288. required: true,
  289. message: '请输入日期',
  290. trigger: ['change', 'blur'],
  291. }],
  292. },
  293. isedit: false, //编辑
  294. isview: false, //查看
  295. }
  296. },
  297. onReady() {
  298. this.$refs.customForm.setRules(this.rules);
  299. },
  300. mounted() {
  301. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  302. this.wheight = data.height
  303. }).exec()
  304. },
  305. onLoad(option) {
  306. if (option.editData) {
  307. this.isedit = true
  308. this.parentId = option.editData
  309. this.getIdData()
  310. // this.formData = JSON.parse(option.editData)
  311. } else if (option.viewData) {
  312. this.isview = true
  313. this.parentId = option.viewData
  314. this.getIdData()
  315. // this.formData = JSON.parse(option.viewData)
  316. }
  317. },
  318. methods: {
  319. getIdData() {
  320. getIdXfsssbpczl({
  321. id: this.parentId
  322. }).then(response => {
  323. this.formData = response.data
  324. console.log(response, 'response')
  325. })
  326. },
  327. //拍照
  328. closeImage(val, index) {
  329. this.formData.streetRepPicsDOList.splice(index, 1)
  330. },
  331. photoUpload() {
  332. takePhotos(this)
  333. },
  334. bindDateChange(e) {
  335. this.dateTime = e.detail.value
  336. this.formData.reporttime = e.detail.value
  337. },
  338. submit(ref) {
  339. this.$refs[ref].validate().then(res => {
  340. const formList = this.formData
  341. Object.keys(formList).forEach(key => {
  342. formList[key] = formList[key] === '' ? 0 : formList[key];
  343. });
  344. formList.streetRepPicsDOList.forEach((item) => {
  345. // 删除除了feildname和url以外的多余字段
  346. Object.keys(item).forEach((key) => {
  347. if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
  348. delete item[key];
  349. }
  350. });
  351. // 如果feildname为空,赋值为默认名称
  352. if (!item.feildname) {
  353. item.feildname = '默认名称';
  354. }
  355. });
  356. console.log(formList, 'this.formData');
  357. if (this.isedit) {
  358. updateXfsssbpczl(JSON.stringify(this.formData)).then(res => {
  359. this.$modal.msg('修改成功')
  360. this.isedit = false
  361. setTimeout(() => {
  362. uni.navigateBack()
  363. }, 400)
  364. })
  365. } else if (this.isview) {
  366. this.isview = false
  367. uni.navigateBack()
  368. } else {
  369. createXfsssbpczl(JSON.stringify(this.formData)).then(res => {
  370. this.$modal.msg('新增成功')
  371. setTimeout(() => {
  372. uni.navigateBack()
  373. }, 400)
  374. })
  375. }
  376. }).catch(err => {
  377. console.log(err);
  378. })
  379. }
  380. }
  381. }
  382. </script>
  383. <style lang="scss" scoped>
  384. body {
  385. background-color: #f5f7f9;
  386. }
  387. page {
  388. background-color: #f5f7f9 !important;
  389. }
  390. .uni-container {
  391. height: 100vh;
  392. background-color: #f5f7f9 !important;
  393. }
  394. /deep/.uni-card {
  395. position: relative;
  396. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  397. border-radius: 30rpx;
  398. }
  399. /deep/ .uni-row {
  400. margin-top: 70rpx;
  401. }
  402. /deep/ .u-form-item__body__left {
  403. width: auto !important
  404. }
  405. .demo-uni-row {
  406. // margin-top: 70rpx;
  407. // /deep/.u-form-item {
  408. // display: flex;
  409. // }
  410. /deep/.u-form-item__body {
  411. flex-direction: row !important;
  412. }
  413. /deep/ .u-form-item__body__right {
  414. width: 230rpx !important;
  415. }
  416. // /deep/.u-border {
  417. // border: none !important;
  418. // border-bottom: 1px solid #E5E5E5 !important;
  419. // }
  420. // /deep/ .u-form-item__body__right__message {
  421. // margin-left: 20rpx !important
  422. // }
  423. }
  424. .julis-bottom {
  425. padding-bottom: 100px;
  426. /deep/ .u-form-item__body__left__content__label {
  427. color: #383838 !important;
  428. }
  429. /deep/ .u-form-item__body__right__message {
  430. margin-left: 20rpx !important
  431. }
  432. }
  433. .xf-title {
  434. /deep/ .u-form-item__body__left.data-v-5e7216f1 {
  435. width: auto !important
  436. }
  437. /deep/.u-border {
  438. border: none !important;
  439. border-bottom: 1px solid #E5E5E5 !important;
  440. }
  441. }
  442. .example {
  443. overflow-y: auto;
  444. }
  445. </style>