123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <view class="uni-container">
- <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
- <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="100%" labelAlign="left">
- <view class="juli-bottom">
- <u-form-item label="检查出租房屋 (处)" prop="jcczfw">
- <u-input v-model="formData.jcczfw" placeholder="请输入" :disabled="isview" />
- </u-form-item>
- <u-form-item label="发现隐患 (处)" prop="fxyh">
- <u-input v-model="formData.fxyh" placeholder="请输入" :disabled="isview" />
- </u-form-item>
- <u-form-item label="整改隐患((处)" prop="zgyh">
- <u-input v-model="formData.zgyh" placeholder="请输入" :disabled="isview" />
- </u-form-item>
- <u-form-item label="发现违规群租房(处)" prop="fxwgqzf">
- <u-input v-model="formData.fxwgqzf" placeholder="请输入" :disabled="isview" />
- </u-form-item>
- <u-form-item label="整改违规群租房(处)" prop="zgwgqzf">
- <u-input v-model="formData.zgwgqzf" placeholder="请输入" :disabled="isview" />
- </u-form-item>
- <picker mode="date" :value="dateTime" @change="bindDateChange" :disabled="isview">
- <view class="datatime-street">
- <u-form-item label="填报日期" prop="reporttime" :required="true">
- <u-input v-model="formData.reporttime" placeholder="选择日期" class="add-date"
- :disabled="isview" />
- </u-form-item>
- </view>
- </picker>
- <view>
- <view class="paizhao">现场照片</view>
- <view class="paizhao-posit" v-if="!isview">
- <view class="">
- <image :src="photograph" @click="photoUpload" class="tiantupian-photo"></image>
- <uni-load-more v-show="loading" status="loading" :content-text="contentText" />
- <!-- <span v-show="loading" class="photo-loading">上传照片中...</span> -->
- </view>
- <view class="">
- 拍照上传
- </view>
- </view>
- </view>
- <view v-if="formData.streetRepPicsDOList" class="show-photo">
- <view v-for="(items,indexs) in formData.streetRepPicsDOList" :key="indexs">
- <view class="show-photo-main">
- <view class="show-photo-main-img">
- <image :src="items.url" class="show-photo-main-img-item">
- <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(items,indexs)"
- v-if="!isview">
- </u-icon>
- </view>
- <view class="">
- <view>
- 图片名称
- </view>
- <view class="img-name">
- <u-input v-model="items.feildname" placeholder="请输入图片名称" :disabled="isview" />
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </u--form>
- </view>
- <view class="sub-botn heigthButton">
- <u-button v-if="isedit" @click="submit('customForm')" type="primary" shape="circle" size="large"
- color="#4CB2B6" text="确认修改" style="width:200px">
- </u-button>
- <u-button v-else-if="!formData.id" @click="submit('customForm')" type="primary" shape="circle" size="large"
- color="#4CB2B6" text="确认新增" style="width:200px">
- </u-button>
- <u-button v-else-if="isview" @click="submit('customForm')" type="primary" shape="circle" size="large"
- color="#4CB2B6" text="返回" style="width:200px">
- </u-button>
- </view>
- </view>
- </template>
- <script>
- import {
- createCzfpczl,
- getIdCzfpczl,
- updateCzfpczl
- }
- from '@/api/fire_inspetItem/index';
- import {
- takePhotos,
- NumericRule
- } from '@/utils/common.js';
- import config from '@/config'
- const baseUrlImg = config.baseUrlImg
- export default {
- data() {
- return {
- contentText: {
- contentrefresh: '上传照片中',
- },
- photograph: `${baseUrlImg}/checkActive/photograph.png`,
- dateTime: '',
- formData: {
- jcczfw: '',
- fxyh: '',
- zgyh: '',
- fxwgqzf: '',
- zgwgqzf: '',
- reporttime: '',
- streetRepPicsDOList: []
- },
- rules: {
- jcczfw: NumericRule(),
- fxyh: NumericRule(),
- zgyh: NumericRule(),
- fxwgqzf: NumericRule(),
- zgwgqzf: NumericRule(),
- reporttime: [{
- required: true,
- message: '请输入日期',
- trigger: ['change', 'blur'],
- }],
- },
- isedit: false, //编辑
- isview: false, //查看
- screenHeight: this.$screenHeight,
- wheight: '',
- loading: false
- }
- },
- mounted() {
- uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
- this.wheight = data.height
- }).exec()
- },
- onReady() {
- this.$refs.customForm.setRules(this.rules);
- },
- watch: {
- loading: {
- handler(newLength, oldLength) {
- this.$modal.isLoadingModel(this.loading)
- },
- immediate: true
- }
- },
- onLoad(option) {
- if (option.editData) {
- this.isedit = true
- this.parentId = option.editData
- this.getIdData()
- // this.formData = JSON.parse(option.editData)
- } else if (option.viewData) {
- this.isview = true
- this.parentId = option.viewData
- this.getIdData()
- // this.formData = JSON.parse(option.viewData)
- }
- },
- methods: {
- getIdData() {
- getIdCzfpczl({
- id: this.parentId
- }).then(response => {
- this.formData = response.data
- console.log('sdfff');
- console.log(response, 'responsesssss')
- })
- },
- //拍照
- closeImage(val, index) {
- this.formData.streetRepPicsDOList.splice(index, 1)
- },
- photoUpload() {
- // this.loading = true
- takePhotos(this)
- },
- bindDateChange(e) {
- this.formData.reporttime = e.detail.value
- },
- submit(ref) {
- this.$refs[ref].validate().then(res => {
- const formList = this.formData
- Object.keys(formList).forEach(key => {
- formList[key] = formList[key] === '' ? 0 : formList[key];
- });
- formList.streetRepPicsDOList.forEach((item) => {
- // 删除除了feildname和url以外的多余字段
- Object.keys(item).forEach((key) => {
- if (key !== 'feildname' && key !== 'url' && key !== 'repid') {
- delete item[key];
- }
- });
- // 如果feildname为空,赋值为默认名称
- if (!item.feildname) {
- item.feildname = '默认名称';
- }
- if (this.isedit && !item.repid) {
- item.repid = this.parentId
- }
- });
- console.log(formList, 'this.formData');
- if (this.isedit) {
- updateCzfpczl(JSON.stringify(this.formData)).then(res => {
- this.$modal.msg('修改成功')
- this.isedit = false
- setTimeout(() => {
- uni.navigateBack()
- }, 400)
- })
- } else if (this.isview) {
- this.isview = false
- uni.navigateBack()
- } else {
- createCzfpczl(JSON.stringify(this.formData)).then(res => {
- this.$modal.msg('新增成功')
- setTimeout(() => {
- uni.navigateBack()
- }, 400)
- })
- }
- }).catch(err => {
- console.log(err);
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- body {
- background-color: #f5f7f9;
- }
- page {
- background-color: #f5f7f9 !important;
- }
- .uni-container {
- height: 100vh;
- background-color: #f5f7f9 !important;
- }
- /deep/.uni-card {
- position: relative;
- box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.15);
- border-radius: 30rpx;
- }
- .example {
- overflow-y: auto;
- }
- </style>
|