streetXfsssbpczl.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. <uni-load-more v-show="loading" status="loading" :content-text="contentText" />
  187. </view>
  188. </view>
  189. <view v-if="formData.streetRepPicsDOList" class="show-photo">
  190. <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
  191. <view class="show-photo-main">
  192. <view class="show-photo-main-img">
  193. <image :src="items.url" class="show-photo-main-img-item">
  194. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
  195. v-if="!isview">
  196. </u-icon>
  197. </view>
  198. <view class="">
  199. <view>
  200. 图片名称
  201. </view>
  202. <view class="img-name">
  203. <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. </view>
  210. </u--form>
  211. </view>
  212. <view class="sub-botn heigthButton">
  213. <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
  214. color="#4CB2B6" text="确认修改" style="width:200px">
  215. </u-button>
  216. <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
  217. color="#4CB2B6" text="确认新增" style="width:200px">
  218. </u-button>
  219. <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
  220. color="#4CB2B6" text="返回" style="width:200px">
  221. </u-button>
  222. </view>
  223. </view>
  224. </template>
  225. <script>
  226. import {
  227. createXfsssbpczl,
  228. getIdXfsssbpczl,
  229. updateXfsssbpczl
  230. }
  231. from '@/api/fire_inspetItem/index';
  232. import {
  233. takePhotos,
  234. NumericRule
  235. } from '@/utils/common.js';
  236. import config from '@/config'
  237. const baseUrlImg = config.baseUrlImg
  238. export default {
  239. data() {
  240. return {
  241. contentText: {
  242. contentrefresh: '上传照片中',
  243. },
  244. screenHeight: this.$screenHeight,
  245. wheight: '',
  246. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  247. dateTime: '',
  248. formData: {
  249. szxhsXz: '',
  250. szxhsYy: '',
  251. jzswxhsXz: '',
  252. jzswxhsYy: '',
  253. xfscYy: '',
  254. xfscXz: '',
  255. mhqYy: '',
  256. mhqGhwh: '',
  257. yjzmdYy: '',
  258. yjzmdGhwh: '',
  259. sszsbzYy: '',
  260. sszsbzGhwh: '',
  261. wxxfzYy: '',
  262. wxxfzXz: '',
  263. xfclYy: '',
  264. xfclXz: '',
  265. zdmhssYy: '',
  266. zdmhssGhwh: '',
  267. qtXz: '',
  268. reporttime: '',
  269. streetRepPicsDOList: []
  270. },
  271. rules: {
  272. szxhsXz: NumericRule(),
  273. szxhsYy: NumericRule(),
  274. jzswxhsXz: NumericRule(),
  275. jzswxhsYy: NumericRule(),
  276. xfscYy: NumericRule(),
  277. xfscXz: NumericRule(),
  278. mhqYy: NumericRule(),
  279. mhqGhwh: NumericRule(),
  280. yjzmdYy: NumericRule(),
  281. yjzmdGhwh: NumericRule(),
  282. sszsbzYy: NumericRule(),
  283. sszsbzGhwh: NumericRule(),
  284. wxxfzYy: NumericRule(),
  285. wxxfzXz: NumericRule(),
  286. xfclYy: NumericRule(),
  287. xfclXz: NumericRule(),
  288. zdmhssYy: NumericRule(),
  289. zdmhssGhwh: NumericRule(),
  290. qtXz: NumericRule(),
  291. reporttime: [{
  292. required: true,
  293. message: '请输入日期',
  294. trigger: ['change', 'blur'],
  295. }],
  296. },
  297. isedit: false, //编辑
  298. isview: false, //查看
  299. loading: false
  300. }
  301. },
  302. onReady() {
  303. this.$refs.customForm.setRules(this.rules);
  304. },
  305. mounted() {
  306. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  307. this.wheight = data.height
  308. }).exec()
  309. },
  310. onLoad(option) {
  311. if (option.editData) {
  312. this.isedit = true
  313. this.parentId = option.editData
  314. this.getIdData()
  315. // this.formData = JSON.parse(option.editData)
  316. } else if (option.viewData) {
  317. this.isview = true
  318. this.parentId = option.viewData
  319. this.getIdData()
  320. // this.formData = JSON.parse(option.viewData)
  321. }
  322. },
  323. methods: {
  324. getIdData() {
  325. getIdXfsssbpczl({
  326. id: this.parentId
  327. }).then(response => {
  328. this.formData = response.data
  329. })
  330. },
  331. //拍照
  332. closeImage(val, index) {
  333. this.formData.streetRepPicsDOList.splice(index, 1)
  334. },
  335. photoUpload() {
  336. takePhotos(this)
  337. },
  338. bindDateChange(e) {
  339. this.dateTime = e.detail.value
  340. this.formData.reporttime = e.detail.value
  341. },
  342. submit(ref) {
  343. this.$refs[ref].validate().then(res => {
  344. const formList = this.formData
  345. Object.keys(formList).forEach(key => {
  346. formList[key] = formList[key] === '' ? 0 : formList[key];
  347. });
  348. formList.streetRepPicsDOList.forEach((item) => {
  349. // 删除除了feildname和url以外的多余字段
  350. Object.keys(item).forEach((key) => {
  351. if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
  352. delete item[key];
  353. }
  354. });
  355. // 如果feildname为空,赋值为默认名称
  356. if (!item.feildname) {
  357. item.feildname = '默认名称';
  358. }
  359. if (this.isedit && !item.repid) {
  360. item.repid = this.parentId
  361. }
  362. });
  363. if (this.isedit) {
  364. updateXfsssbpczl(JSON.stringify(this.formData)).then(res => {
  365. this.$modal.msg('修改成功')
  366. this.isedit = false
  367. setTimeout(() => {
  368. uni.navigateBack()
  369. }, 400)
  370. })
  371. } else if (this.isview) {
  372. this.isview = false
  373. uni.navigateBack()
  374. } else {
  375. createXfsssbpczl(JSON.stringify(this.formData)).then(res => {
  376. this.$modal.msg('新增成功')
  377. setTimeout(() => {
  378. uni.navigateBack()
  379. }, 400)
  380. })
  381. }
  382. }).catch(err => {
  383. })
  384. }
  385. }
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. body {
  390. background-color: #f5f7f9;
  391. }
  392. page {
  393. background-color: #f5f7f9 !important;
  394. }
  395. .uni-container {
  396. height: 100vh;
  397. background-color: #f5f7f9 !important;
  398. }
  399. /deep/.uni-card {
  400. position: relative;
  401. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
  402. border-radius: 30rpx;
  403. }
  404. /deep/ .uni-row {
  405. margin-top: 70rpx;
  406. }
  407. /deep/ .u-form-item__body__left {
  408. width: auto !important
  409. }
  410. .demo-uni-row {
  411. // margin-top: 70rpx;
  412. // /deep/.u-form-item {
  413. // display: flex;
  414. // }
  415. /deep/.u-form-item__body {
  416. flex-direction: row !important;
  417. }
  418. /deep/ .u-form-item__body__right {
  419. width: 230rpx !important;
  420. }
  421. // /deep/.u-border {
  422. // border: none !important;
  423. // border-bottom: 1px solid #E5E5E5 !important;
  424. // }
  425. // /deep/ .u-form-item__body__right__message {
  426. // margin-left: 20rpx !important
  427. // }
  428. }
  429. .julis-bottom {
  430. padding-bottom: 100px;
  431. /deep/ .u-form-item__body__left__content__label {
  432. color: #383838 !important;
  433. }
  434. /deep/ .u-form-item__body__right__message {
  435. margin-left: 20rpx !important
  436. }
  437. }
  438. .xf-title {
  439. /deep/ .u-form-item__body__left.data-v-5e7216f1 {
  440. width: auto !important
  441. }
  442. /deep/.u-border {
  443. border: none !important;
  444. border-bottom: 1px solid #E5E5E5 !important;
  445. }
  446. }
  447. .example {
  448. overflow-y: auto;
  449. }
  450. </style>