You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

452 lines
16 KiB

<template>
<div>
<!-- 工地巡查 -->
<dialogShow :title="title" :is-show.sync="isShow" :width="width">
<template v-slot:content>
<!-- 在建工地 -->
<el-form :model="form" :rules="rules" ref="form" label-position="right"
:label-width="labelwidth">
<el-row>
<el-col :span="12">
<el-form-item label="所属道路" prop="road_id">
<el-select class="width100" v-model="roadName" filterable remote @change="chooseRoad"
:disabled="roaddisabled" reserve-keyword placeholder="请输入关键词查找道路信息" clearable @focus="remoteRoad"
:remote-method="remoteMethod" :loading="roadloading">
<el-option v-for="item in roadsList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="工地名称" prop="name">
<el-select v-model="form.name" allow-create filterable @change="buildchange" class="width100"
placeholder="请选择工地或新建工地">
<el-option v-for="item in buildList" :key="item.id" :label="item.name" :value="item">
</el-option>
</el-select>
<!-- <el-input disabled="" v-model="form.name" placeholder="工地名称" autocomplete="off"></el-input> -->
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="所在位置" prop="address">
<avue-input-map :params="mapparams" placeholder="请选择地图" v-model="mapform"></avue-input-map>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="经度" prop="longitude">
<el-input disabled="" v-model="form.longitude" placeholder="经度" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="纬度" prop="address">
<el-input disabled="" v-model="form.latitude" placeholder="纬度" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="工地编号" prop="number">
<el-input v-model="form.number" disabled placeholder="工地编号" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="建设单位" prop="build_unit">
<el-input v-model="form.build_unit" placeholder="请填写建设单位" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="施工单位" prop="carry_unit">
<el-input v-model="form.carry_unit" placeholder="请填写施工单位" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="工地类型" prop="type">
<el-select class="width100" v-model="form.type" placeholder="请选择">
<el-option v-for="item in siteType" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="工地状态" prop="status">
<el-radio v-model="form.status" v-for="item in siteStatus" :label="item.id">{{item.value}}
</el-radio>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="联系人" prop="link_name">
<el-input v-model="form.link_name" placeholder="请填写联系人" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="联系号码" prop="link_mobile">
<el-input v-model="form.link_mobile" placeholder="请填写联系号码" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="form.remark" placeholder="备注" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="现场照片" prop="files_list">
<el-upload class="upload-demo" multiple drag action="/api/admin/upload-file"
list-type="picture-card" :file-list="filesList" ref="pictureUpload" :auto-upload="true"
:data="uploadOther" :on-error="handleError"
:on-success="function(responsose,file,fileList) {return handlesuccess(responsose,file,fileList,1)}">
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{file}">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
<span class="el-upload-list__item-actions">
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
<i class="el-icon-zoom-in"></i>
</span>
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="是否违法" prop="is_law">
<el-radio-group v-model="form.is_law">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.is_law==1">
<el-form-item label="违规内容" prop="break_id">
<el-select class="width100" v-model="form.break_id" placeholder="请选择违规内容">
<el-option v-for="item in siteLaw" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.is_law==1">
<el-form-item label="描述" prop="content">
<el-input type="textarea" v-model="form.content" placeholder="备注" autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<template v-slot:footerbtn>
<el-button type="primary" v-preventReClick @click="submitForm('form')">保存</el-button>
</template>
</dialogShow>
<div>
<el-dialog class="common-dialog" :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
</div>
</div>
</template>
<script>
import {
get,
storebuilding,
savebuilding,
getbuilding
4 years ago
} from '../../../../api/rain/inspection.js'
import {
getToken
} from '@/utils/auth'
import {
getparameteritem
} from '../../../../api/system/dictionary.js'
import {
listroad
} from '../../../../api/basic/road.js'
import AvueMap from 'avue-plugin-map'
import dialogShow from '@/components/dialogShow'
export default {
components: {
dialogShow,
AvueMap
},
data() {
return {
formType: "showform", // 审核:auditform 办结 endform 查看 showform
title: "在建工地巡查",
width: "60%",
labelwidth: "120px",
isShow: false,
infoId: "",
dialogImageUrl: "",
dialogVisible: false,
disabled: false,
uploadOther: {
token: ""
},
mapparams: {
zoom: 11,
},
mapform: [],
roadsList: [],
roadName: "",
roaddisabled: false,
roadloading: false,
filesList: [],
buildList:[],
siteType: [],
siteLaw: [],
siteStatus: [{
id: 1,
value: "在建"
}, {
id: 2,
value: "完工"
}],
form: {
status:0
},
rules: {
name:[{
required: true,
message: '请填写工地名称',
trigger: 'blur',
}],
link_name:[{
required: true,
message: '请填写联系人',
trigger: 'blur',
}],
build_unit:[{
required: true,
message: '请填写建设单位',
trigger: 'blur',
}],
carry_unit:[{
required: true,
message: '请填写施工单位',
trigger: 'blur',
}],
type:[{
required: true,
message: '请选择工地类型',
trigger: 'blur',
}],
link_mobile:[{
// required: true,
message: '请填写联系号码',
trigger: 'blur',
},{ pattern: /^1[3456789]\d{9}$/,
message: '手机号码格式不正确',
trigger: 'blur' ,
}],
}
}
},
watch: {
infoId(val) {
this.infoId = val
}
},
created() {
this.initload()
},
methods: {
4 years ago
initload() {
this.uploadOther.token = getToken()
getparameteritem('siteType').then(res => {
this.siteType = res.detail
})
getparameteritem('siteLaw').then(res => {
this.siteLaw = res.detail
})
getbuilding().then(res => {
this.buildList = res
})
},
getSiteInfo(id) {
this.resetForm()
if (id) {
var that = this;
that.form = {}
get(id).then(res => {
let result = Object.assign(that.form, res);
that.form = result.building_site_info;
that.roaddisabled = true
that.roadName = result.building_site_info.road ? result.building_site_info.road.name : ""
let building_site = result.building_site_info.building_site
that.form.building_site_id = building_site.id
that.form.address = building_site.address
that.form.latitude = building_site.latitude
that.form.longitude = building_site.longitude
that.form.name = building_site.name
that.form.number = building_site.number
that.form.remark = building_site.remark
that.form.status = building_site.status
that.form.build_unit = building_site.build_unit
that.form.carry_unit = building_site.carry_unit
that.form.type = parseInt(building_site.type)
that.form.link_name = building_site.link_name
that.form.link_mobile = building_site.link_mobile
that.form.building_site_id = building_site.id
that.form.building_site_content_id = result.building_site_content_id;
that.mapform = [building_site.longitude, building_site.latitude, building_site.address]
let site_files = [];
for (var mod of result.building_site_info.building_site_content_files) {
let m = Object.assign({}, mod);
m.url = mod.files.url;
m.id = mod.files.id;
m.photoType = "before";
site_files.push(m);
}
that.filesList = site_files;
}).catch(error => {
//reject(error)
})
}
},
submitForm(formName) {
var that = this;
var listUrlbefore = []
for (var m of this.filesList) {
if (m.response)
listUrlbefore.push({
"upload_id": m.response.id
});
else
listUrlbefore.push({
"upload_id": m.id
});
}
that.form.files_list = listUrlbefore
console.log('build',that.form)
// return
this.$refs[formName].validate((valid) => {
if (valid) {
if (that.infoId) {
savebuilding(that.form).then(response => {
this.$Message.success('操作成功');
this.$emit("auditSuccess")
that.isShow = false;
}).catch(error => {
//reject(error)
})
} else {
storebuilding(that.form).then(response => {
this.$Message.success('操作成功');
this.$emit("auditSuccess")
that.isShow = false;
}).catch(error => {
//reject(error)
})
}
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
var that = this
that.filesList = []
that.roadName = ""
that.roaddisabled = false
that.mapform = ['', '', '']
this.form={
is_law:0,
status:1
}
},
chooseRoad(val) {
this.form.road_id = val
},
remoteRoad() {
this.roadsList = []
},
remoteMethod(query) {
if (query != '') {
this.roadloading = true
listroad({
name: query
}).then(res => {
this.roadloading = false
this.roadsList = res.data
})
} else {
this.roadsList = []
}
},
buildchange(val) {
if (Object.prototype.toString.call(val) != '[object Object]') {
this.mapform = ['', '', ''];
this.$refs['form'].resetFields();
this.form.name = val
this.form.type = ""
this.form.status = 0
let timeNumber = new Date().getTime()
this.form.number = timeNumber
}
if (Object.prototype.toString.call(val) === '[object Object]') {
console.log(val)
this.mapform = [val.longitude, val.latitude, val.address]
this.form.longitude = val.longitude
this.form.latitude = val.latitude
this.form.address = val.address
this.form.number = val.number
this.form.type = parseInt(val.type)
this.form.status = val.status
this.form.remark = val.remark
this.form.building_site_id = val.id
this.form.name = val.name
this.form.build_unit = val.build_unit
this.form.carry_unit = val.carry_unit
this.form.link_name = val.link_name
this.form.link_mobile = val.link_mobile
}
//判断对象
},
handleRemove(file) {
for (var i = 0; i < this.filesList.length; i++) {
if (this.filesList[i].url == file.url) {
this.filesList.splice(i, 1)
}
}
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
handlesuccess(response, file, fileList, index) {
if (index == 1) {
file.photoType = "before"
this.filesList = fileList;
// this.form.files_list = listUrl;
}
this.$message({
message: '上传成功',
type: 'success'
});
},
handleError(err, file, fileList) {
this.$message.error('上传失败,重新上传');
}
}
}
</script>
<style>
</style>