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.

453 lines
13 KiB

3 years ago
<template>
<div>
3 years ago
<xy-dialog ref="dialog" :is-show.sync="isShow" type="form" :title="type === 'add' ? '新增检查' : '编辑检查'" :form="form"
3 years ago
:rules="rules" @submit="submit">
<template v-slot:mission_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
2 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>任务专题
3 years ago
</div>
<div class="xy-table-item-content">
3 years ago
<el-select v-model="form.mission_id" filterable clearable placeholder="请选择任务专题" style="width: 400px;">
3 years ago
<el-option v-for="item in unitList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:date>
<div class="xy-table-item">
<div class="xy-table-item-label">
3 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>检查日期
3 years ago
</div>
<div class="xy-table-item-content">
3 years ago
<el-date-picker style="width: 400px;" v-model="form.date" format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm" type="datetime"
3 years ago
placeholder="选择检查日期">
3 years ago
</el-date-picker>
</div>
</div>
</template>
3 years ago
<template v-slot:siteName>
3 years ago
<div class="xy-table-item">
<div class="xy-table-item-label">
3 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>检查地点
3 years ago
</div>
<div class="xy-table-item-content">
3 years ago
<el-select @change="changeSite" v-model="form.siteName" filterable clearable placeholder="请选择检查地点" style="width: 400px;">
3 years ago
<el-option v-for="item in siteList" :key="-1" label="选择地图位置" :value="-1">
</el-option>
3 years ago
<el-option v-for="item in siteList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:ask_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>问题类型
</div>
<div class="xy-table-item-content">
3 years ago
<el-select v-model="form.ask_id" filterable clearable placeholder="请选择问题类型" style="width: 400px;">
3 years ago
<el-option v-for="item in askList" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
2 years ago
</template>
<template v-slot:ask_department>
<div class="xy-table-item">
<div class="xy-table-item-label">
2 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>建议科室
2 years ago
</div>
<div class="xy-table-item-content">
2 years ago
<el-input v-model="form.ask_department" type='text' placeholder="请输入建议科室" clearable
2 years ago
style="width: 400px;"></el-input>
</div>
</div>
3 years ago
</template>
<template v-slot:ask_introduce>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>问题描述
</div>
<div class="xy-table-item-content">
<el-input v-model="form.ask_introduce" :rows='5' type='textarea' placeholder="请输入问题描述" clearable
3 years ago
style="width: 400px;"></el-input>
3 years ago
</div>
</div>
</template>
<template v-slot:tips>
<div class="xy-table-item">
<div class="xy-table-item-label">
3 years ago
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>整改建议
3 years ago
</div>
<div class="xy-table-item-content">
<el-input v-model="form.tips" :rows='5' type='textarea' placeholder="请输入整改建议" clearable
3 years ago
style="width: 400px;"></el-input>
3 years ago
</div>
</div>
3 years ago
</template>
2 years ago
3 years ago
<template v-slot:file_ids>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>附件
</div>
<div class="xy-table-item-content">
<el-upload :action="action" class='upload-demo' list-type="picture-card" :file-list="pictureList"
ref="pictureUpload" style="width:600px" :auto-upload="true" :data="uploadOther"
:on-preview="handlePictureCardPreview" :on-success="handlesuccess" :on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</div>
3 years ago
</template>
</xy-dialog>
<el-dialog :visible.sync="showPic">
<img width="100%" :src="showPicUrl" alt="">
3 years ago
</el-dialog>
<avue-input-map ref="maps" :params="mapparams" placeholder="请选择地图" v-model="mapform"></avue-input-map>
3 years ago
</div>
</template>
<script>
import {
Message
} from 'element-ui'
import {
getparameteritem
} from "@/api/system/dictionary.js";
import {
save,
get
} from "@/api/task/patrol.js";
import {
listunit
} from "@/api/task/unit.js";
import {
listaddress
} from '@/api/address'
import {
listdept
} from "@/api/system/department.js"
import {
listCommonuser
} from "@/api/common.js"
import {
getToken
} from '@/utils/auth'
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
id: '',
uploadOther: {
token: ""
},
action: `${process.env.VUE_APP_BASE_API}api/admin/upload-file`,
pictureList: [],
showPic: false,
showPicUrl: '',
unitList: [],
siteList: [],
3 years ago
askList: [],
3 years ago
mission_id:'',
mapparams: {
zoom: 11,
},
mapform: [],
3 years ago
form: {
mission_id: '',
date: '',
site_id: '',
3 years ago
siteName:'',
address:'',
lat:'',
lon:'',
2 years ago
ask_id: '',
ask_department:'',
3 years ago
ask_introduce: '',
3 years ago
tips: '',
file_ids: [],
3 years ago
},
rules: {
2 years ago
// mission_id: [{
// required: true,
// message: '请选择任务专题'
// }],
3 years ago
date: [{
3 years ago
required: true,
3 years ago
message: '请选择检查日期'
3 years ago
}],
3 years ago
siteName: [{
3 years ago
required: true,
3 years ago
message: '请选择检查地点'
3 years ago
}],
3 years ago
ask_id: [{
3 years ago
required: true,
3 years ago
message: '请选择问题类型'
}],
ask_introduce: [{
required: true,
message: '请输入问题描述'
3 years ago
}]
}
}
},
created() {
this.uploadOther.token = getToken();
this.getUnit()
this.getAddress()
this.getAsk()
// this.loadDeptOptions()
// this.loadUser()
},
methods: {
// 获取 专项任务
async getUnit() {
const res = await listunit({
page: 1,
page_size: 9999
2 years ago
})
3 years ago
this.unitList = res.data
3 years ago
},
changeSite(e){
console.log(e)
3 years ago
if(e==-1){
this.form.site_id = ''
this.form.address = ''
this.form.lat = ''
this.form.lon = ''
this.form.siteName = ''
this.$refs.maps.box = true
}else{
this.siteList.map(item=>{
if(item.id==e){
this.form.site_id = item.id
this.form.address = item.address
this.form.lat = item.lat
this.form.lon = item.lon
this.form.siteName = item.name
}
})
}
3 years ago
},
async getAddress() {
const res = await listaddress({
page: 1,
page_size: 9999
})
this.siteList = res.data
},
async getAsk(label) {
const res = await getparameteritem('askList')
this.askList = res.detail
},
handleRemove(file, fileList) {
this.pictureList = fileList
},
handlesuccess(response, file, fileList) {
this.pictureList = fileList
},
handlePictureCardPreview(file) {
this.showPicUrl = file.url;
this.showPic = true;
},
async getDetail() {
const res = await get(this.id)
this.form = {
mission_id: res?.mission_id,
date: res?.date,
3 years ago
site_id: res?.site_id,
siteName:'',
address:res?.address,
lat:res?.lat,
lon:res?.lon,
2 years ago
ask_id: res?.ask_id,
ask_department:res?.ask_department,
3 years ago
ask_introduce: res?.ask_introduce,
3 years ago
tips: res?.tips,
file_ids: res?.file_ids,
3 years ago
}
3 years ago
this.mapform = [res.lon, res.lat, res.address]
3 years ago
for (var f of res.files) {
this.pictureList.push({
id: f.id,
url: f.url,
name: f.original_name
})
}
// res.guide_upload ? this.guidePictureList.push(res.guide_upload) : ''
},
submit() {
let _files = []
if (this.pictureList.length > 0) {
for (var h of this.pictureList) {
if (h.response) {
_files.push(h.response.id)
} else {
_files.push(h.id)
}
}
this.form.file_ids = _files
} else {
this.form.file_ids = []
}
console.log(this.form)
// return
if (this.type === 'add') {
save({
...this.form
}).then(res => {
Message({
type: 'success',
3 years ago
message: '新增检查成功'
3 years ago
})
this.isShow = false
this.$emit('refresh')
})
return
}
if (this.type === 'editor') {
save({
id: this.id,
...this.form
}).then(res => {
Message({
type: 'success',
3 years ago
message: '编辑检查成功'
3 years ago
})
this.isShow = false
this.$emit('refresh')
})
}
},
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
2 years ago
}
if(this.type==='add'){
for(var k of this.unitList){
console.log("adddd",k.name)
if(k.name=='日常巡查'){
this.form.mission_id = k.id
}
}
3 years ago
}
} else {
this.id = ''
3 years ago
this.pictureList = []
3 years ago
this.mission_id = ''
2 years ago
this.mapform=[]
3 years ago
this.$refs['dialog'].reset()
}
3 years ago
},
mission_id(newval){
console.log("newval",newval)
if(newval){
this.form.mission_id = this.mission_id
}
3 years ago
},
mapform(newVal, oldVal) {
this.form.lon = newVal[0];
this.form.lat = newVal[1];
this.form.address = newVal[2];
this.form.siteName = newVal[2]
3 years ago
}
}
}
</script>
<style scoped lang="scss">
3 years ago
// .xy-table-item-label {
// width: 160px;
3 years ago
// }
2 years ago
::v-deep .ask_department{
flex-basis: 100%;
}
2 years ago
::v-deep .avue-input-map{
display: none;
}
3 years ago
::v-deep .site_id,::v-deep .address,::v-deep .lat,::v-deep .lon{
display: none;
}
3 years ago
.img__delete {
transform: scale(0.8, 0.8);
position: absolute;
top: 4px;
right: 4px;
}
::v-deep .avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
::v-deep .avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
::v-deep .el-upload--picture-card {
font-size: 28px;
color: #8c939d;
3 years ago
width: 146px !important;
height: 146px !important;
line-height: 146px !important;
3 years ago
text-align: center;
}
::v-deep .avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
3 years ago
width: 146px !important;
height: 146px !important;
line-height: 146px !important;
3 years ago
text-align: center;
}
::v-deep .avatar {
width: 80px !important;
display: block;
border-radius: 6px;
}
3 years ago
// ::v-deep .xy-table-item-label {
// width: 160px !important;
// }
3 years ago
::v-deep .el-date-editor .el-range-separator {
width: auto !important;
}
::v-deep .el-input-number .el-input__inner {
text-align: left !important;
}
.searchCompanys {
display: flex;
justify-content: space-between;
margin-bottom: 16px;
.el-input {
width: 80%
}
}
</style>