7 changed files with 1736 additions and 569 deletions
@ -0,0 +1,414 @@ |
|||
<template> |
|||
<el-dialog title="提示" :visible.sync="dialogVisible" width="1370px" :before-close="handleCancle"> |
|||
<span slot="title"> |
|||
<span v-if="pageType == 'add'">新增</span> |
|||
<span v-if="pageType == 'edit'">修改</span> |
|||
<span v-if="pageType == 'view'">查看</span> |
|||
</span> |
|||
<div> |
|||
<div class="dialog-h-content scroll-h"> |
|||
<el-form :inline="true" :model="formData" ref="form" :rules="dataRule" :label-width="'90px'" v-if="pageType != 'view'"> |
|||
<el-row> |
|||
<el-col :span="6"> |
|||
<el-form-item label="设备名称" prop="equipmentName"> |
|||
<el-input v-model="formData.equipmentName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="设备编号" prop="equipmentNum"> |
|||
<el-input v-model="formData.equipmentNum" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="负责人" prop="principalName"> |
|||
<el-input v-model="formData.principalName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="联系电话" prop="contactNum"> |
|||
<el-input v-model="formData.contactNum" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="所处位置" prop="location" style="display: block"> |
|||
<el-select |
|||
v-model="formData.location" |
|||
:disabled="disabled" |
|||
filterable |
|||
remote |
|||
:reserve-keyword="true" |
|||
placeholder="请输入关键词" |
|||
:remote-method="remoteMethod" |
|||
:loading="loading" |
|||
> |
|||
<el-option |
|||
v-for="(item, index) in searchOptions" |
|||
@click.native="handleClickKey(index)" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value" |
|||
></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<div id="app_event" class="div_map"></div> |
|||
</el-form> |
|||
<el-form :inline="false" :model="formData" ref="form" :label-width="'90px'" v-if="pageType == 'view'"> |
|||
<el-row> |
|||
<el-col :span="6"> |
|||
<el-form-item label="设备名称" prop="equipmentName">{{ formData.equipmentName }}</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="设备编号" prop="equipmentNum">{{ formData.equipmentNum }}</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="负责人" prop="principalName">{{ formData.principalName }}</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="联系电话" prop="contactNum">{{ formData.contactNum }}</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="场所地址" prop="location" style="display: block">{{ formData.location }}</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<div id="app_event" class="div_map"></div> |
|||
</el-form> |
|||
</div> |
|||
<div class="div_btn" v-if="pageType != 'view'"> |
|||
<el-button size="small" @click="handleCancle">取 消</el-button> |
|||
<!-- <el-button size="small" @click="resetData" v-if="pageType != 'view'">重置</el-button> --> |
|||
<el-button size="small" type="primary" :disabled="btnDisable" @click="handleComfirm">确 定</el-button> |
|||
</div> |
|||
<div class="recordBox"><record :disabled="disabled" :formType="pageType" :id="detailId" :info="{ agencyId: agencyId }"></record></div> |
|||
</div> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button @click="handleCancle" size="small">关 闭</el-button> |
|||
<!-- <el-button type="primary" @click="handleComfirm">确 定</el-button> --> |
|||
</span> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import { isMobile } from '@/utils/validate'; |
|||
import { mapGetters } from 'vuex'; |
|||
import { Loading } from 'element-ui'; // 引入Loading服务 |
|||
import { requestPost, requestGet } from '@/js/dai/request'; |
|||
import daiMap from '@/utils/dai-map'; |
|||
import nextTick from 'dai-js/tools/nextTick'; |
|||
import record from './record'; |
|||
let loading; // 加载动画 |
|||
let map; |
|||
var search; |
|||
var markers; |
|||
var infoWindowList; |
|||
var geocoder; // 新建一个正逆地址解析类 |
|||
|
|||
export default { |
|||
props: { |
|||
dialogVisible: { |
|||
type: Boolean, |
|||
default: '' |
|||
}, |
|||
defaultData: { |
|||
type: Object, |
|||
default: null |
|||
}, |
|||
pageType: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
detailId: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
detailData: { |
|||
type: Object, |
|||
default: null |
|||
}, |
|||
disabled: { |
|||
type: Boolean, |
|||
default: false |
|||
} |
|||
}, |
|||
|
|||
data() { |
|||
let checkMObile = (rule, value, callback) => { |
|||
if (value === '') { |
|||
callback(new Error('请输入联系电话')); |
|||
} else { |
|||
if (!isMobile(value)) { |
|||
callback(new Error('联系电话格式不正确')); |
|||
} |
|||
callback(); |
|||
} |
|||
}; |
|||
return { |
|||
btnDisable: false, |
|||
user: '', |
|||
agencyId: '', |
|||
gridList: [], //所属网格list--场所区域 |
|||
placeTypeList: [], //场所类型 |
|||
resultArray: [{ value: '0', label: '合格' }, { value: '1', label: '不合格' }], |
|||
equipmentCategoryCodeArray: [], |
|||
list: {}, |
|||
formData: { |
|||
equipmentName: '', |
|||
equipmentCategoryCode: '', |
|||
principalName: '', |
|||
location: '', |
|||
contactNum: '' |
|||
}, |
|||
dataRule: { |
|||
equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'bulr' }], |
|||
equipmentNum: [{ required: true, message: '设备编号不能为空', trigger: 'bulr' }], |
|||
principalName: [{ required: true, message: '负责人不能为空', trigger: 'bulr' }], |
|||
contactNum: [{ required: true, message: '联系电话不能为空', trigger: 'blur' }], |
|||
location: [{ required: true, message: '所处位置不能为空', trigger: 'blur' }] |
|||
}, |
|||
//地图 |
|||
loading: false, |
|||
searchValue: '', |
|||
searchOptions: [] |
|||
}; |
|||
}, |
|||
watch: {}, |
|||
components: { record }, |
|||
created() {}, |
|||
async mounted() { |
|||
console.log('detailId', this.detailId); |
|||
this.user = this.$store.state.user; |
|||
this.agencyId = this.user.agencyId; |
|||
this.startLoading(); |
|||
this.loadCategory(); |
|||
// this.loadGrid(); |
|||
// this.loadplaceType(); |
|||
if (this.pageType != 'add') { |
|||
this.getDetail(); |
|||
} else { |
|||
this.initMap(); |
|||
} |
|||
await this.endLoading(); |
|||
this.endLoading(); |
|||
}, |
|||
|
|||
methods: { |
|||
async loadCategory() { |
|||
const url = '/sys/dict/data/dictlist'; |
|||
|
|||
let params = { |
|||
dictType: 'safety_equipment_category' |
|||
}; |
|||
|
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.equipmentCategoryCodeArray = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
async loadGrid() { |
|||
const url = '/gov/org/customergrid/gridoption'; |
|||
let params = { |
|||
agencyId: this.agencyId, |
|||
purpose: 'query' |
|||
}; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.gridList = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
//场所类型 |
|||
async loadplaceType() { |
|||
const url = '/gov/org/coverage/dict-select-list/enterprise_patrol'; |
|||
let params = { |
|||
// agencyId: this.agencyId, |
|||
// purpose: 'query' |
|||
}; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.placeTypeList = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
async getDetail() { |
|||
const url = `/actual/base/monitoringEquipment/detail/${this.detailId}`; |
|||
const { data, code, msg } = await requestPost(url); |
|||
if (code === 0) { |
|||
console.log('详情数据', data); |
|||
this.formData = { ...data }; |
|||
this.initMap(); |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
|
|||
handleComfirm() { |
|||
this.save(); |
|||
}, |
|||
async handleAdd() { |
|||
// this.btnDisable = true; |
|||
// setTimeout(() => { |
|||
// this.btnDisable = false; |
|||
// }, 10000); |
|||
// nextTick(1000); |
|||
// const form = new Promise((resolve, reject) => { |
|||
// this.$refs['form'].validate(valid => { |
|||
// if (valid) resolve(); |
|||
// }); |
|||
// }); |
|||
// const form1 = new Promise((resolve, reject) => { |
|||
// this.$refs['form1'].validate(valid => { |
|||
// if (valid) resolve(); |
|||
// }); |
|||
// }); |
|||
// Promise.all([form1, form]) |
|||
// .then(() => { |
|||
// this.addFuwu(); |
|||
// }) |
|||
// .catch(() => { |
|||
// app.util.validateRule(messageObj); |
|||
// this.btnDisable = false; |
|||
// }); |
|||
}, |
|||
|
|||
async save() { |
|||
console.log('this.formData', this.formData); |
|||
var url = ''; |
|||
var params = {}; |
|||
if (this.pageType == 'add') { |
|||
url = '/actual/base/monitoringEquipment/save'; |
|||
} else { |
|||
url = '/actual/base/monitoringEquipment/update'; |
|||
} |
|||
params = { ...this.formData }; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.$message.success('操作成功'); |
|||
this.detailId=data |
|||
// this.handleCancle(); |
|||
} else if (code >= 8000) { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
handleCancle() { |
|||
this.resetData(); |
|||
this.$emit('handleClose'); |
|||
}, |
|||
resetData() { |
|||
this.$refs.form.resetFields(); |
|||
}, |
|||
// 开启加载动画 |
|||
startLoading() { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}); |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading() { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close(); |
|||
} |
|||
}, // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|||
initMap() { |
|||
let { latitude, longitude } = this.$store.state.user; |
|||
|
|||
if (this.formData.latitude && this.formData.longitude) { |
|||
latitude = this.formData.latitude; |
|||
longitude = this.formData.longitude; |
|||
} |
|||
if (!latitude || latitude == '' || latitude == '0') { |
|||
latitude = 39.9088810666821; |
|||
longitude = 116.39743841556731; |
|||
} |
|||
|
|||
this.$nextTick(() => { |
|||
map = new daiMap( |
|||
document.getElementById('app_event'), |
|||
{ latitude, longitude }, |
|||
{ |
|||
zoom: 16.2, // 设置地图缩放级别 |
|||
pitch: 43.5, // 设置俯仰角 |
|||
rotation: 45 // 设置地图旋转角度 |
|||
} |
|||
); |
|||
// 监听地图平移结束 |
|||
map.on('dragend', e => { |
|||
if (!this.disabled) { |
|||
this.handleMoveCenter(e); |
|||
} |
|||
}); |
|||
|
|||
map.setCenter(latitude, longitude); |
|||
if (this.formData.latitude) { |
|||
map.setMarker(latitude, longitude); |
|||
} |
|||
}); |
|||
}, |
|||
async handleMoveCenter() { |
|||
//修改地图中心点 |
|||
const { lat, lng } = map.getCenter(); |
|||
this.formData.latitude = lat; |
|||
this.formData.longitude = lng; |
|||
map.setMarker(lat, lng); |
|||
|
|||
let { msg, data } = await map.getAddress(lat, lng); |
|||
if (msg == 'success') { |
|||
this.formData.location = data.address; |
|||
this.searchValue = data.address; |
|||
this.searchOptions = []; |
|||
} |
|||
}, |
|||
async remoteMethod(query) { |
|||
if (query !== '') { |
|||
this.loading = true; |
|||
const { msg, data } = await map.searchNearby(query); |
|||
this.loading = false; |
|||
this.resultList = []; |
|||
|
|||
if (msg == 'success' && data.resultList && data.resultList.length > 0) { |
|||
if (data.resultList && data.resultList.length > 0) { |
|||
this.resultList = data.resultList; |
|||
this.searchOptions = this.resultList.map(item => { |
|||
return { value: `${item.id}`, label: `${item.address + item.name}` }; |
|||
}); |
|||
} |
|||
} else { |
|||
this.searchOptions = [ |
|||
{ |
|||
value: '0', |
|||
label: '未检索到结果' |
|||
} |
|||
]; |
|||
} |
|||
} else { |
|||
this.searchOptions = []; |
|||
} |
|||
}, |
|||
handleClickKey(index) { |
|||
let selPosition = this.resultList[index]; |
|||
let lonlat = selPosition.lonlat.split(' '); |
|||
map.setCenter(lonlat[1], lonlat[0]); |
|||
map.setMarker(lonlat[1], lonlat[0]); |
|||
this.formData.latitude = lonlat[1]; |
|||
this.formData.longitude = lonlat[0]; |
|||
this.formData.location = selPosition.address + selPosition.name; |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
@import '@/assets/scss/modules/management/form-main.scss'; |
|||
@import '@/assets/scss/modules/management/form.scss'; |
|||
@import '@/assets/scss/modules/visual/a_customize.scss'; |
|||
.el-dialog__body { |
|||
padding: 30px 80px; |
|||
} |
|||
</style> |
@ -0,0 +1,204 @@ |
|||
<template> |
|||
<div> |
|||
<base-page |
|||
:searchParams="searchParams" |
|||
:tableParams="tableParams" |
|||
:tableUrl="tableUrl" |
|||
:addUrl="addUrl" |
|||
:editUrl="editUrl" |
|||
:delUrl="delUrl" |
|||
:infoUrl="infoUrl" |
|||
:editAuth="editAuth" |
|||
:delAuth="delAuth" |
|||
:exportUrl="exportUrl" |
|||
:qrCodeExportUrl="qrCodeExportUrl" |
|||
:importUrl="importUrl" |
|||
:mubanUrl="mubanUrl" |
|||
:editParams="editParams" |
|||
:editElseRules="editElseRules" |
|||
:editFixedParams="editFixedParams" |
|||
:editParamsDiv="5" |
|||
:editBtnName="(item) => (!item.latitude ? '待完善' : '修改')" |
|||
:formBtnFixed="false" |
|||
idName="id" |
|||
> |
|||
<template v-slot:editBottomSup="{ id, formType, info }"> |
|||
<record |
|||
:formType="formType" |
|||
:id="id" |
|||
:info="info" |
|||
></record> |
|||
</template> |
|||
</base-page> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import basePage from "@/views/modules/cpts/base2/index"; |
|||
import record from "./cpts/record"; |
|||
|
|||
export default { |
|||
components: { basePage, record }, |
|||
props: {}, |
|||
|
|||
data() { |
|||
return { |
|||
searchParams: [ |
|||
{ field: "设备名称", keyName: "equipmentName", type: "input" }, |
|||
{ field: "设备编号", keyName: "equipmentNum", type: "input" }, |
|||
{ field: "负责人", keyName: "principalName", type: "input" }, |
|||
{ field: "所处位置", keyName: "location", type: "input" }, |
|||
{ |
|||
field: "检查时间", |
|||
keyName: "latestInspectTime", |
|||
type: "date", |
|||
}, |
|||
{ |
|||
field: "检查结果", |
|||
keyName: "latestInspectResult", |
|||
type: "select", |
|||
optionUrl: "", |
|||
optionUrlParams: {}, |
|||
optionList: [ |
|||
{ |
|||
value: "0", |
|||
label: "异常", |
|||
}, |
|||
{ |
|||
value: "1", |
|||
label: "正常", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
|
|||
tableParams: [ |
|||
{ field: "序号", keyName: "", type: "no" }, |
|||
{ field: "设备名称", keyName: "equipmentName", type: "text" }, |
|||
{ field: "设备编号", keyName: "equipmentNum", type: "text" }, |
|||
{ field: "所处位置", keyName: "location", type: "text" }, |
|||
{ |
|||
field: "负责人", |
|||
keyName: "principalName", |
|||
type: "text", |
|||
}, |
|||
{ field: "联系电话", keyName: "contactNum", type: "text" }, |
|||
{ |
|||
field: "最新检查时间", |
|||
keyName: "latestInspectTime", |
|||
type: "text", |
|||
}, |
|||
{ |
|||
field: "最新结果", |
|||
keyName: "latestInspectResultName", |
|||
type: "text", |
|||
}, |
|||
], |
|||
tableUrl: "/actual/base/monitoringEquipment/page", |
|||
mubanUrl: "/actual/base/monitoringEquipment/downloadTemplate", |
|||
importUrl: "/actual/base/monitoringEquipment/import", |
|||
exportUrl: "/actual/base/monitoringEquipment/export", |
|||
qrCodeExportUrl: "", |
|||
|
|||
addUrl: "/actual/base/monitoringEquipment/save", |
|||
editUrl: "/actual/base/monitoringEquipment/update", |
|||
infoUrl: "/actual/base/monitoringEquipment/detail/", |
|||
delUrl: "/actual/base/monitoringEquipment/delete", |
|||
|
|||
editAuth(item) { |
|||
return item.agencyId == this.$store.state.user.agencyId; |
|||
}, |
|||
delAuth(item) { |
|||
return item.agencyId == this.$store.state.user.agencyId; |
|||
}, |
|||
|
|||
editParams: [ |
|||
[ |
|||
{ |
|||
field: "设备名称", |
|||
keyName: "equipmentName", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "设备名称不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "设备编号", |
|||
keyName: "equipmentNum", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "设备编号不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "负责人", |
|||
keyName: "principalName", |
|||
type: "input", |
|||
|
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "负责人不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "联系电话", |
|||
keyName: "contactNum", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "联系电话不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "所处位置", |
|||
keyName: "location", |
|||
type: "address", |
|||
maxlength: 50, |
|||
supKeys: ["longitude", "latitude"], |
|||
supValues: ["", ""], |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "所处位置不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
], |
|||
editFixedParams: { |
|||
agencyId: this.$store.state.user.agencyId, |
|||
}, |
|||
editElseRules: { |
|||
longitude: { |
|||
type: "number", |
|||
required: true, |
|||
message: "请拖动地图选择坐标点", |
|||
}, |
|||
}, |
|||
}; |
|||
}, |
|||
computed: {}, |
|||
watch: {}, |
|||
|
|||
async mounted() {}, |
|||
|
|||
methods: {}, |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped></style> |
@ -1,204 +1,492 @@ |
|||
<template> |
|||
<div class="g-main"> |
|||
<div> |
|||
<base-page |
|||
:searchParams="searchParams" |
|||
:tableParams="tableParams" |
|||
:tableUrl="tableUrl" |
|||
:addUrl="addUrl" |
|||
:editUrl="editUrl" |
|||
:delUrl="delUrl" |
|||
:infoUrl="infoUrl" |
|||
:editAuth="editAuth" |
|||
:delAuth="delAuth" |
|||
:exportUrl="exportUrl" |
|||
:qrCodeExportUrl="qrCodeExportUrl" |
|||
:importUrl="importUrl" |
|||
:mubanUrl="mubanUrl" |
|||
:editParams="editParams" |
|||
:editElseRules="editElseRules" |
|||
:editFixedParams="editFixedParams" |
|||
:editParamsDiv="5" |
|||
:editBtnName="(item) => (!item.latitude ? '待完善' : '修改')" |
|||
:formBtnFixed="false" |
|||
idName="id" |
|||
<div class="m-search"> |
|||
<el-form :inline="true" :model="formData" ref="ref_searchform" :label-width="'100px'"> |
|||
<div> |
|||
<el-form-item label="设备名称" prop="equipmentName"> |
|||
<el-input v-model="formData.equipmentName" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="设备编号" prop="equipmentNum"> |
|||
<el-input v-model="formData.equipmentNum" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="所处位置" prop="location"> |
|||
<el-input v-model="formData.location" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="负责人" prop="principalName"> |
|||
<el-input v-model="formData.principalName" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="检查时间" prop="latestInspectTime"> |
|||
|
|||
<el-date-picker v-model="formData.latestInspectTime" type="date" class="input-width" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="检查结果" prop="latestInspectResult"> |
|||
<el-select v-model="formData.latestInspectResult" placeholder="请选择" size="small" clearable class="u-item-width-normal"> |
|||
<el-option v-for="item in resultArray" :key="item.value" :label="item.label" :value="item.value"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-row> |
|||
<el-col :span="24" align="right"> |
|||
<el-button style="margin-left: 30px" size="small" type="primary " @click="handleSearch">查询</el-button> |
|||
<el-button style="margin-left: 10px" size="small" class="diy-button--white" @click="resetSearch">重置</el-button> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</el-form> |
|||
</div> |
|||
<div class="m-table"> |
|||
<div class="div_btn"> |
|||
<el-button size="small" type="primary " @click="handleAdd({}, 'add')">新增</el-button> |
|||
<el-button class="diy-button--white" size="small" @click="handleExportModule('room')">下载导入模板</el-button> |
|||
<el-upload |
|||
:headers="$getElUploadHeaders()" |
|||
ref="upload" |
|||
class="upload-btn" |
|||
action="uploadUlr" |
|||
:limit="1" |
|||
:accept="'.xls,.xlsx'" |
|||
:with-credentials="true" |
|||
:show-file-list="false" |
|||
:auto-upload="true" |
|||
:on-progress="handleProgress" |
|||
:on-success="handleExcelSuccess" |
|||
:before-upload="beforeExcelUpload" |
|||
:http-request="uploadHttpRequest" |
|||
style="display: inline-block;margin:0px 10px" |
|||
> |
|||
<el-button size="small" class="diy-button--white" :loading="importLoading">导入</el-button> |
|||
</el-upload> |
|||
|
|||
<el-button @click="handleExport" class="diy-button--white" size="small">导出</el-button> |
|||
</div> |
|||
<el-table :data="tableData" border class="m-table-item" style="width: 100%" @selection-change="handleSelectionChange" :height="maxTableHeight"> |
|||
<!-- <el-table-column label="" fixed="left" type="selection" align="center" width="50" /> --> |
|||
<el-table-column label="序号" fixed="left" type="index" align="center" width="50" /> |
|||
<el-table-column prop="equipmentName" align="center" label="设备名称" :show-overflow-tooltip="true"></el-table-column> |
|||
<el-table-column prop="equipmentNum" align="center" label="设备编号"></el-table-column> |
|||
|
|||
<el-table-column prop="location" label="所处位置" min-width="140" align="center" :show-overflow-tooltip="true" /> |
|||
<el-table-column prop="principalName" align="center" label="负责人" :show-overflow-tooltip="true"></el-table-column> |
|||
<el-table-column prop="contactNum" align="center" :show-overflow-tooltip="true" label="联系电话"></el-table-column> |
|||
<el-table-column prop="latestInspectTime" align="center" label="最新检查时间" :show-overflow-tooltip="true"></el-table-column> |
|||
<el-table-column prop="latestInspectResultName" align="center" label="最新结果" :show-overflow-tooltip="true"></el-table-column> |
|||
<el-table-column fixed="right" label="操作" align="center" width="200"> |
|||
<template slot-scope="scope"> |
|||
<el-button @click="handleAdd(scope.row, 'view')" type="text" size="small">查看</el-button> |
|||
|
|||
<el-button |
|||
v-if="scope.row.latitude && agencyId == scope.row.agencyId" |
|||
style="margin-right: 10px" |
|||
@click="handleAdd(scope.row, 'edit')" |
|||
size="small" |
|||
type="text" |
|||
> |
|||
编辑 |
|||
</el-button> |
|||
<el-button |
|||
v-if="!scope.row.latitude && agencyId == scope.row.agencyId" |
|||
style="margin-right: 10px" |
|||
@click="handleAdd(scope.row, 'edit')" |
|||
size="small" |
|||
type="text" |
|||
> |
|||
<template v-slot:editBottomSup="{ id, formType, info }"> |
|||
<record |
|||
:formType="formType" |
|||
:id="id" |
|||
:info="info" |
|||
></record> |
|||
待完善 |
|||
</el-button> |
|||
<el-button @click="handleDel(scope.row)" v-if="agencyId == scope.row.agencyId" type="text" size="small" class="">删除</el-button> |
|||
</template> |
|||
</base-page> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<div> |
|||
<el-pagination |
|||
@size-change="handleSizeChange" |
|||
@current-change="handleCurrentChange" |
|||
:current-page.sync="pageNo" |
|||
:page-sizes="[20, 50, 100, 200]" |
|||
:page-size="parseInt(pageSize)" |
|||
layout="sizes, prev, pager, next, total" |
|||
:total="total" |
|||
></el-pagination> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<addForm |
|||
v-if="dialogVisible" |
|||
:dialogVisible="dialogVisible" |
|||
:pageType="pageType" |
|||
:disabled="disabled" |
|||
:detailId="detailId" |
|||
:detailData="detailData" |
|||
@handleClose="handleClose" |
|||
@handleOk="handleOk" |
|||
@dialogOk="handleEditSuccess" |
|||
/> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import basePage from "@/views/modules/cpts/base2/index"; |
|||
import record from "./cpts/record"; |
|||
import { requestPost } from '@/js/dai/request'; |
|||
import nextTick from 'dai-js/tools/nextTick'; |
|||
import { mapGetters } from 'vuex'; |
|||
import addForm from './addForm.vue'; |
|||
import axios from 'axios'; |
|||
|
|||
export default { |
|||
components: { basePage, record }, |
|||
props: {}, |
|||
|
|||
data() { |
|||
return { |
|||
searchParams: [ |
|||
{ field: "设备名称", keyName: "equipmentName", type: "input" }, |
|||
{ field: "设备编号", keyName: "equipmentNum", type: "input" }, |
|||
{ field: "负责人", keyName: "principalName", type: "input" }, |
|||
{ field: "所处位置", keyName: "location", type: "input" }, |
|||
{ |
|||
field: "检查时间", |
|||
keyName: "latestInspectTime", |
|||
type: "date", |
|||
}, |
|||
{ |
|||
field: "检查结果", |
|||
keyName: "latestInspectResult", |
|||
type: "select", |
|||
optionUrl: "", |
|||
optionUrlParams: {}, |
|||
optionList: [ |
|||
{ |
|||
value: "0", |
|||
label: "异常", |
|||
}, |
|||
{ |
|||
value: "1", |
|||
label: "正常", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
|
|||
tableParams: [ |
|||
{ field: "序号", keyName: "", type: "no" }, |
|||
{ field: "设备名称", keyName: "equipmentName", type: "text" }, |
|||
{ field: "设备编号", keyName: "equipmentNum", type: "text" }, |
|||
{ field: "所处位置", keyName: "location", type: "text" }, |
|||
{ |
|||
field: "负责人", |
|||
keyName: "principalName", |
|||
type: "text", |
|||
}, |
|||
{ field: "联系电话", keyName: "contactNum", type: "text" }, |
|||
{ |
|||
field: "最新检查时间", |
|||
keyName: "latestInspectTime", |
|||
type: "text", |
|||
}, |
|||
{ |
|||
field: "最新结果", |
|||
keyName: "latestInspectResultName", |
|||
type: "text", |
|||
}, |
|||
], |
|||
tableUrl: "/actual/base/monitoringEquipment/page", |
|||
mubanUrl: "/actual/base/monitoringEquipment/downloadTemplate", |
|||
importUrl: "/actual/base/monitoringEquipment/import", |
|||
exportUrl: "/actual/base/monitoringEquipment/export", |
|||
qrCodeExportUrl: "", |
|||
|
|||
addUrl: "/actual/base/monitoringEquipment/save", |
|||
editUrl: "/actual/base/monitoringEquipment/update", |
|||
infoUrl: "/actual/base/monitoringEquipment/detail/", |
|||
delUrl: "/actual/base/monitoringEquipment/delete", |
|||
|
|||
editAuth(item) { |
|||
return item.agencyId == this.$store.state.user.agencyId; |
|||
dialogVisible: false, |
|||
importLoading: false, |
|||
disabled: false, |
|||
user: '', |
|||
agencyId: '', |
|||
formData: { |
|||
equipmentName: '', |
|||
equipmentCategoryCode: '', |
|||
principalName: '', |
|||
contactNum: '', |
|||
address: '' |
|||
}, |
|||
pageType: 'list', // 列表list 新增add 处理dispose 详情info |
|||
gridList: [], //所属网格list--场所区域 |
|||
placeTypeList: [], //场所类型 |
|||
tableData: [], |
|||
resultArray: [{ value: '1', label: '合格' }, { value: '0', label: '不合格' }], |
|||
equipmentCategoryCodeArray: [], |
|||
pageNo: 1, |
|||
pageSize: window.localStorage.getItem('pageSize') || 20, |
|||
total: 1, |
|||
detailId: '', |
|||
detailData: {}, |
|||
multipleSelection: [], |
|||
rowObj: {} |
|||
}; |
|||
}, |
|||
components: { addForm }, |
|||
created() {}, |
|||
computed: { |
|||
maxTableHeight() { |
|||
return this.$store.state.inIframe ? this.clientHeight - 410 + this.iframeHeigh : this.clientHeight - 410; |
|||
}, |
|||
...mapGetters(['clientHeight', 'iframeHeight']) |
|||
}, |
|||
watch: {}, |
|||
mounted() { |
|||
this.user = this.$store.state.user; |
|||
this.agencyId = this.user.agencyId; |
|||
this.loadGrid(); |
|||
this.loadplaceType(); |
|||
this.loadCategory(); |
|||
this.getTableData(); |
|||
}, |
|||
delAuth(item) { |
|||
return item.agencyId == this.$store.state.user.agencyId; |
|||
methods: { |
|||
handleSelectionChange(val) { |
|||
this.multipleSelection = []; |
|||
val.forEach(element => { |
|||
this.multipleSelection.push(element.icEventId); |
|||
}); |
|||
}, |
|||
handleSearch(val) { |
|||
console.log(this.formData); |
|||
this.pageNo = 1; |
|||
this.getTableData(); |
|||
}, |
|||
async loadGrid() { |
|||
const url = '/gov/org/customergrid/gridoption'; |
|||
let params = { |
|||
agencyId: this.agencyId, |
|||
purpose: 'query' |
|||
}; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.gridList = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
//场所类型 |
|||
async loadplaceType() { |
|||
const url = '/gov/org/coverage/dict-select-list/enterprise_patrol'; |
|||
let params = { |
|||
// agencyId: this.agencyId, |
|||
// purpose: 'query' |
|||
}; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.placeTypeList = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
//设备类型 |
|||
async loadCategory() { |
|||
const url = '/sys/dict/data/dictlist'; |
|||
|
|||
editParams: [ |
|||
[ |
|||
{ |
|||
field: "设备名称", |
|||
keyName: "equipmentName", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "设备名称不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "设备编号", |
|||
keyName: "equipmentNum", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "设备编号不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "负责人", |
|||
keyName: "principalName", |
|||
type: "input", |
|||
let params = { |
|||
dictType: 'safety_equipment_category' |
|||
}; |
|||
|
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "负责人不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "联系电话", |
|||
keyName: "contactNum", |
|||
type: "input", |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "联系电话不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
field: "所处位置", |
|||
keyName: "location", |
|||
type: "address", |
|||
maxlength: 50, |
|||
supKeys: ["longitude", "latitude"], |
|||
supValues: ["", ""], |
|||
rules: [ |
|||
{ |
|||
required: true, |
|||
message: "所处位置不能为空", |
|||
trigger: "blur", |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
], |
|||
editFixedParams: { |
|||
agencyId: this.$store.state.user.agencyId, |
|||
}, |
|||
editElseRules: { |
|||
longitude: { |
|||
type: "number", |
|||
required: true, |
|||
message: "请拖动地图选择坐标点", |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.equipmentCategoryCodeArray = data; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
async handleImport() { |
|||
// 导入 |
|||
}, |
|||
async handleExport() { |
|||
// 导出 |
|||
const url = '/actual/base/monitoringEquipment/export'; |
|||
const { pageSize, pageNo, formData } = this; |
|||
axios({ |
|||
url: window.SITE_CONFIG['apiURL'] + url, |
|||
method: 'post', |
|||
data: { |
|||
pageSize, |
|||
pageNo, |
|||
...formData |
|||
}, |
|||
responseType: 'blob' |
|||
}) |
|||
.then(res => { |
|||
let fileName = window.decodeURI(res.headers['content-disposition'].split(';')[1].split('=')[1]); |
|||
console.log('filename', fileName); |
|||
let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }); |
|||
var url = window.URL.createObjectURL(blob); |
|||
var aLink = document.createElement('a'); |
|||
aLink.style.display = 'none'; |
|||
aLink.href = url; |
|||
aLink.setAttribute('download', fileName); |
|||
document.body.appendChild(aLink); |
|||
aLink.click(); |
|||
document.body.removeChild(aLink); //下载完成移除元素 |
|||
window.URL.revokeObjectURL(url); //释放掉blob对象 |
|||
}) |
|||
.catch(err => { |
|||
console.log('获取导出情失败', err); |
|||
return this.$message.error('网络错误'); |
|||
}); |
|||
}, |
|||
handleAdd(row, type) { |
|||
if (row.id) { |
|||
this.detailId = row.id; |
|||
} |
|||
this.pageType = type; |
|||
if (type == 'view') { |
|||
this.disabled = true; |
|||
} else { |
|||
this.disabled = false; |
|||
} |
|||
this.dialogVisible = true; |
|||
}, |
|||
handleClose() { |
|||
this.dialogVisible = false; |
|||
this.pageType = 'list'; |
|||
this.detailId = ''; |
|||
this.getTableData(); |
|||
}, |
|||
handleOk() { |
|||
this.pageType = 'list'; |
|||
this.detailId = ''; |
|||
this.pageNo = 1; |
|||
this.getTableData(); |
|||
}, |
|||
handleEditSuccess() { |
|||
this.handleClose(); |
|||
this.getTableData(); |
|||
}, |
|||
async handleDel(rowData) { |
|||
let message = '确认删除?'; |
|||
this.$confirm(message, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}) |
|||
.then(() => { |
|||
this.del(rowData.id); |
|||
}) |
|||
.catch(err => {}); |
|||
}, |
|||
async del(id) { |
|||
const url = `/actual/base/monitoringEquipment/delete`; |
|||
let idsArr = [id]; |
|||
const { data, code, msg } = await requestPost(url, idsArr); |
|||
if (code === 0) { |
|||
this.$message.success('删除成功!'); |
|||
this.getTableData(); |
|||
} else { |
|||
this.$message.error('操作失败!'); |
|||
} |
|||
}, |
|||
async getTableData() { |
|||
const url = '/actual/base/monitoringEquipment/page'; |
|||
// const url = 'http://yapi.elinkservice.cn/mock/330/actual/base/enterprise/list'; |
|||
const { pageSize, pageNo, formData } = this; |
|||
const { data, code, msg } = await requestPost(url, { |
|||
pageSize, |
|||
pageNo, |
|||
...formData |
|||
}); |
|||
if (code === 0) { |
|||
this.total = data.total || 0; |
|||
this.tableData = data.list |
|||
? data.list.map(item => { |
|||
return item; |
|||
}) |
|||
: []; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
handleSizeChange(val) { |
|||
this.pageSize = val; |
|||
window.localStorage.setItem('pageSize', val); |
|||
this.getTableData(); |
|||
}, |
|||
handleCurrentChange(val) { |
|||
this.pageNo = val; |
|||
this.getTableData(); |
|||
}, |
|||
resetSearch() { |
|||
this.formData = { |
|||
equipmentName: '', |
|||
equipmentCategoryCode: '', |
|||
principalName: '', |
|||
contactNum: '', |
|||
address: '' |
|||
}; |
|||
this.pageNo = 1; |
|||
this.getTableData(); |
|||
}, |
|||
async handleExportModule() { |
|||
let url = '/actual/base/monitoringEquipment/downloadTemplate'; |
|||
let params = {}; |
|||
await this.$http({ |
|||
method: 'POST', |
|||
url, |
|||
responseType: 'blob', |
|||
data: params |
|||
}) |
|||
.then(res => { |
|||
// this.download(res.data, title + '.xls') |
|||
if (res.headers['content-disposition']) { |
|||
let fileName = window.decodeURI(res.headers['content-disposition'].split(';')[1].split('=')[1]); |
|||
console.log('filename', fileName); |
|||
let blob = new Blob([res.data], { |
|||
type: 'application/vnd.ms-excel' |
|||
}); |
|||
var url = window.URL.createObjectURL(blob); |
|||
var aLink = document.createElement('a'); |
|||
aLink.style.display = 'none'; |
|||
aLink.href = url; |
|||
aLink.setAttribute('download', fileName); |
|||
document.body.appendChild(aLink); |
|||
aLink.click(); |
|||
document.body.removeChild(aLink); //下载完成移除元素 |
|||
window.URL.revokeObjectURL(url); //释放掉blob对象 |
|||
} else this.$message.error('下载失败'); |
|||
}) |
|||
.catch(err => { |
|||
console.log('err', err); |
|||
return this.$message.error('网络错误'); |
|||
}); |
|||
}, |
|||
handleExcelSuccess(res, file) { |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
console.log('resss---ppp', res); |
|||
} else { |
|||
this.$message.error(res.msg); |
|||
} |
|||
}, |
|||
handleProgress(event, file, fileList) { |
|||
console.log('percentage', file.percentage); |
|||
}, |
|||
computed: {}, |
|||
watch: {}, |
|||
|
|||
async mounted() {}, |
|||
beforeExcelUpload(file) { |
|||
console.log('file', file); |
|||
const isType = file.type === 'application/vnd.ms-excel'; |
|||
const isTypeComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|||
const fileType = isType || isTypeComputer; |
|||
const isLt1M = file.size / 1024 / 1024 < 10; |
|||
if (!fileType) { |
|||
this.$message.error('上传文件只能是xls/xlsx格式!'); |
|||
} |
|||
|
|||
methods: {}, |
|||
if (!isLt1M) { |
|||
this.$message.error('上传文件大小不能超过 10MB!'); |
|||
} |
|||
return fileType && isLt1M; |
|||
}, |
|||
|
|||
async uploadHttpRequest(file) { |
|||
this.importLoading = true; |
|||
this.importBtnTitle = '正在上传中...'; |
|||
this.$message({ |
|||
showClose: true, |
|||
dangerouslyUseHTMLString: true, |
|||
message: "导入中,请到系统管理-<a id='clickA' style='cursor: pointer;'>导入记录</a>中查看进度", |
|||
duration: 3000 |
|||
}); |
|||
let than = this; |
|||
document.getElementById('clickA').addEventListener('click', function() { |
|||
than.$router.replace('/main/importRecord-index'); |
|||
}); |
|||
const formData = new FormData(); //FormData对象,添加参数只能通过append('key', value)的形式添加 |
|||
formData.append('file', file.file); //添加文件对象 |
|||
formData.append('code', ''); //添加文件对象 |
|||
await this.$http |
|||
.post('/actual/base/monitoringEquipment/import', formData) |
|||
.then(res => { |
|||
console.log('res-up', res); |
|||
if (res.data.code == 0 && res.data.msg == 'success') { |
|||
console.log(res.data.data); |
|||
const data = res.data.data; |
|||
|
|||
this.dataList = [ |
|||
...Object.keys(data.option.exist).map(k => { |
|||
return { |
|||
index: k, |
|||
srcField: data.option.exist[k], |
|||
exist: true, |
|||
field: data.option.exist[k] |
|||
}; |
|||
}), |
|||
...Object.keys(data.option.notExist).map(k => { |
|||
return { |
|||
index: k, |
|||
srcField: data.option.notExist[k], |
|||
exist: false, |
|||
field: '' |
|||
}; |
|||
}) |
|||
]; |
|||
this.importOption = data.option; |
|||
this.importCode = data.code; |
|||
this.fileData = file; |
|||
} else this.$message.error(res.data.msg); |
|||
}) |
|||
.catch(err => { |
|||
console.log('失败', err); |
|||
file.onError(); //上传失败的文件会从文件列表中删除 |
|||
// this.$message.error('导入失败') |
|||
}); |
|||
this.importLoading = false; |
|||
this.importBtnTitle = '导入'; |
|||
this.$refs.upload.clearFiles(); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped></style> |
|||
<style lang="scss" scoped> |
|||
@import '@/assets/scss/modules/management/list-main.scss'; |
|||
.m-search { |
|||
.u-item-width-normal { |
|||
width: 200px; |
|||
} |
|||
} |
|||
</style> |
|||
|
@ -0,0 +1,448 @@ |
|||
<template> |
|||
<div class="m-record"> |
|||
<h3>检查记录</h3> |
|||
<div> |
|||
<!-- <div class="u-table-btn1 mt10" v-if="formType != 'view'"> |
|||
<el-button size="small" class="diy-button--blue" :disabled="btnDisabled || disabled" @click="handleAdd">新增</el-button> |
|||
</div> --> |
|||
<div class="m-table-item"> |
|||
<el-table :data="tableData" class="resi-table" row-key="id" border style="width: 100%"> |
|||
<el-table-column label="序号" type="index" align="center" width="50"></el-table-column> |
|||
|
|||
<el-table-column prop="inspectTime" label="检查时间" align="center" width="200px"> |
|||
<template slot-scope="scope"> |
|||
<el-date-picker |
|||
v-if="scope.row.isEdit" |
|||
v-model="scope.row.inspectTime" |
|||
type="date" |
|||
class="input-width" |
|||
value-format="yyyy-MM-dd" |
|||
placeholder="选择日期" |
|||
></el-date-picker> |
|||
<div v-else class="div-content">{{ scope.row.inspectTime }}</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="inspectStaffId" label="检查人员" align="center" width="200px"> |
|||
<template slot-scope="scope"> |
|||
<el-select |
|||
v-if="scope.row.isEdit" |
|||
v-model="scope.row.inspectStaffId" |
|||
placeholder="请选择" |
|||
class="input-width" |
|||
@change="handleChangeStaff(scope.row)" |
|||
clearable |
|||
> |
|||
<el-option v-for="subItem in optionStaff" :key="subItem.value" :label="subItem.label" :value="subItem.value"></el-option> |
|||
</el-select> |
|||
<div v-else class="div-content">{{ scope.row.inspectStaffName }}</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="inspectStaffMobile" label="联系电话" align="center" width="200px"> |
|||
<template slot-scope="scope"> |
|||
<el-input |
|||
v-if="scope.row.isEdit" |
|||
type="number" |
|||
v-model="scope.row.inspectStaffMobile" |
|||
placeholder="请输入" |
|||
class="input-width" |
|||
clearable |
|||
disabled |
|||
></el-input> |
|||
<div v-else class="div-content">{{ scope.row.inspectStaffMobile }}</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="inspectResult" label="检查结果" align="center" width="200px"> |
|||
<template slot-scope="scope"> |
|||
<el-select v-if="scope.row.isEdit" v-model="scope.row.inspectResult" placeholder="请选择" class="input-width" size="small" clearable> |
|||
<el-option v-for="subItem in optionResult" :key="subItem.value" :label="subItem.label" :value="subItem.value"></el-option> |
|||
</el-select> |
|||
<div v-else class="div-content">{{ scope.row.inspectResult == 1 ? '正常' : '异常' }}</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<!-- <el-table-column |
|||
prop="detailed" |
|||
label="隐患明细" |
|||
align="center" |
|||
width="200px" |
|||
> |
|||
<template slot-scope="scope"> |
|||
<el-input |
|||
v-if="scope.row.isEdit" |
|||
type="text" |
|||
v-model="scope.row.detailed" |
|||
placeholder="请输入" |
|||
class="input-width" |
|||
maxlength="500" |
|||
clearable |
|||
></el-input> |
|||
<div v-else class="div-content"> |
|||
{{ scope.row.detailed }} |
|||
</div> |
|||
</template> |
|||
</el-table-column> --> |
|||
|
|||
<el-table-column prop="imgList" label="图片列表" align="center" width="150px"> |
|||
<template slot-scope="scope"> |
|||
<div v-if="scope.row.isEdit"> |
|||
<el-upload |
|||
:headers="$getElUploadHeaders()" |
|||
class="avatar-uploader" |
|||
:action="uploadUrl" |
|||
:data="{ customerId: customerId }" |
|||
:show-file-list="true" |
|||
:limit="3" |
|||
:file-list="scope.row.imgShowList" |
|||
:on-success="res => handleImgSuccess(res, scope.row)" |
|||
:on-remove="res => handleImgRemove(res, scope.row)" |
|||
list-type="picture" |
|||
:before-upload="beforeImgUpload" |
|||
> |
|||
<i class="el-icon-plus avatar-uploader-icon"></i> |
|||
最多三张图片 |
|||
</el-upload> |
|||
</div> |
|||
|
|||
<div v-else class="div-content"> |
|||
<el-image |
|||
v-if="scope.row.imgList.length > 0" |
|||
style="width: 100px; height: 50px" |
|||
:src="scope.row.imgList[0]" |
|||
fit="cover" |
|||
:preview-src-list="scope.row.imgList" |
|||
></el-image> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="nextInspectTime" label="拟复查时间" align="center" width="200px"> |
|||
<template slot-scope="scope"> |
|||
<el-date-picker |
|||
v-if="scope.row.isEdit" |
|||
v-model="scope.row.nextInspectTime" |
|||
type="date" |
|||
class="input-width" |
|||
value-format="yyyy-MM-dd" |
|||
placeholder="选择日期" |
|||
></el-date-picker> |
|||
<div v-else class="div-content">{{ scope.row.nextInspectTime }}</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column v-if="!disabled" fixed="right" label="操作" align="center" width="120"> |
|||
<template slot-scope="scope"> |
|||
<template v-if="scope.row.isEdit"> |
|||
<el-button @click="handleEdit(scope.row)" type="text" size="small" class="btn-color-edit">保存</el-button> |
|||
<el-button @click="handleChange(scope.row, 'cancle')" type="text" size="small" class="btn-color-edit">取消</el-button> |
|||
</template> |
|||
<template v-else> |
|||
<el-button v-if="formType == 'edit'" @click="handleChange(scope.row, 'edit')" type="text" size="small" :disabled="disabled" class="btn-color-edit"> |
|||
修改 |
|||
</el-button> |
|||
<el-popconfirm v-if="formType == 'edit'" title="删除之后无法恢复,确认删除?" @onConfirm="del(scope.row)" @confirm="del(scope.row)"> |
|||
<el-button slot="reference" type="text" size="small" class="btn-color-del" style="margin-left: 10px">删除</el-button> |
|||
</el-popconfirm> |
|||
</template> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { requestPost, requestGet } from '@/js/dai/request'; |
|||
export default { |
|||
props: { |
|||
id: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
info: { |
|||
type: Object, |
|||
default: () => ({}) |
|||
}, |
|||
disabled: { |
|||
type: Boolean, |
|||
default: false |
|||
}, |
|||
formType: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
source: { |
|||
//展示来源:manage 管理平台 visiual 可视化平台 |
|||
type: String, |
|||
default: 'manage' |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
uploadUrl: window.SITE_CONFIG['apiURL'] + '/oss/file/uploadqrcodeV2', |
|||
customerId: localStorage.getItem('customerId'), |
|||
|
|||
btnDisabled: false, |
|||
btnType: 'cancle', |
|||
isEdit: false, |
|||
tableData: [], |
|||
tempRow: {}, |
|||
|
|||
optionResult: [ |
|||
{ |
|||
label: '异常', |
|||
value: '0' |
|||
}, |
|||
{ |
|||
label: '正常', |
|||
value: '1' |
|||
} |
|||
], |
|||
optionStaff: [ |
|||
// { |
|||
// label: "人名", |
|||
// value: "inspectStaffId", |
|||
// }, |
|||
] |
|||
}; |
|||
}, |
|||
|
|||
computed: { |
|||
allowOperate() { |
|||
const { |
|||
info: { agencyId } |
|||
} = this; |
|||
return agencyId && agencyId == this.$store.state.user.agencyId; |
|||
} |
|||
}, |
|||
watch: { |
|||
id: { |
|||
handler(val) { |
|||
console.log('val------points', val); |
|||
if (val.length > 0) { |
|||
this.btnDisabled = false; |
|||
this.getList(); |
|||
} else this.btnDisabled = true; |
|||
}, |
|||
immediate: true |
|||
} |
|||
}, |
|||
|
|||
created() { |
|||
console.log('id', this.id); |
|||
this.getOptionStaff(); |
|||
if (this.id) { |
|||
this.getList(); |
|||
} else { |
|||
this.handleAdd(); |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
beforeImgUpload(file) { |
|||
console.log(file); |
|||
const isLt1M = file.size / 1024 / 1024 < 10; |
|||
const srcType = file.type; |
|||
const format = file.name.split('.').pop(); |
|||
|
|||
if (!isLt1M) { |
|||
this.$message.error('上传文件大小不能超过 10MB!'); |
|||
return false; |
|||
} |
|||
if (srcType.indexOf('image') == -1) { |
|||
this.$message.error('仅限图片格式'); |
|||
return false; |
|||
} |
|||
return true; |
|||
}, |
|||
|
|||
handleImgSuccess(res, row) { |
|||
console.log('handleImgSuccess', res); |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
row.imgList.push(res.data.url); |
|||
this.computeImgShowList(row); |
|||
} else { |
|||
this.$message.error(res.msg); |
|||
} |
|||
}, |
|||
|
|||
computeImgShowList(row) { |
|||
row.imgShowList = row.imgList.map(url => { |
|||
return { name: '', url }; |
|||
}); |
|||
}, |
|||
|
|||
handleImgRemove(file, row) { |
|||
console.log('handleImgRemove', file); |
|||
let url = file.url || file.response.data.url; |
|||
if (url) { |
|||
row.imgList = row.imgList.filter(item => item !== url); |
|||
this.computeImgShowList(row); |
|||
} |
|||
}, |
|||
|
|||
getRowClass({ rowIndex, columnIndex }) { |
|||
if (rowIndex === 0) { |
|||
return 'background: #2195fe; color: #fff;'; |
|||
} |
|||
}, |
|||
|
|||
handleChange(row, type) { |
|||
console.log('type----', type); |
|||
if (type == 'cancle') { |
|||
row = { ...this.tempRow }; |
|||
row.isEdit = false; |
|||
if (this.btnType == 'add') this.tableData.pop(); |
|||
this.getList(); |
|||
console.log('row----', row); |
|||
} else { |
|||
this.tempRow = { ...row }; |
|||
row.isEdit = true; |
|||
} |
|||
this.btnType = type; |
|||
this.isEdit = !this.isEdit; |
|||
}, |
|||
|
|||
handleChangeStaff(row) { |
|||
const { inspectStaffId } = row; |
|||
const { optionStaff } = this; |
|||
let item = optionStaff.find(item => item.value == inspectStaffId); |
|||
if (item) { |
|||
row.inspectStaffName = item.name; |
|||
row.inspectStaffMobile = item.mobile; |
|||
} |
|||
}, |
|||
|
|||
async getOptionStaff() { |
|||
let url = `/data/aggregator/org/staff-select-list/${this.$store.state.user.agencyId}`; |
|||
const { data, code, msg } = await requestPost(url, {}); |
|||
|
|||
if (code === 0) { |
|||
this.optionStaff = data || []; |
|||
} else { |
|||
this.$message.error('请求工作人员数据失败!'); |
|||
} |
|||
}, |
|||
|
|||
async handleEdit(row) { |
|||
if (row.result == '0' && row.reviewTime == '') { |
|||
this.$message.error('拟复查时间不能为空'); |
|||
} else { |
|||
if (this.id) { |
|||
console.log('有id'); |
|||
if (this.btnType == 'add') this.save(row); |
|||
else this.edit(row); |
|||
} else { |
|||
this.$message.error('请先保存上方信息'); |
|||
} |
|||
} |
|||
}, |
|||
|
|||
handleAdd() { |
|||
this.btnType = 'add'; |
|||
this.isEdit = true; |
|||
|
|||
const item = { |
|||
isEdit: true, |
|||
// id: this.id, |
|||
inspectTime: '', |
|||
inspectStaffId: '', |
|||
inspectStaffName: '', |
|||
inspectStaffMobile: '', |
|||
inspectResult: '', |
|||
imgList: [], |
|||
nextInspectTime: '' |
|||
}; |
|||
this.computeImgShowList(item); |
|||
this.tableData.push(item); |
|||
}, |
|||
|
|||
async save(row) { |
|||
console.log(row, this.id); |
|||
const params = { |
|||
equipmentId: this.id, |
|||
...row |
|||
}; |
|||
const url = `/actual/base/monitoringEquipmentInspectRecord/save`; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.$message.success('保存成功'); |
|||
row.isEdit = false; |
|||
this.isEdit = false; |
|||
this.btnType = 'cancle'; |
|||
this.getList(); |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
|
|||
async edit(row) { |
|||
console.log(row, this.id); |
|||
const params = { |
|||
...row |
|||
}; |
|||
const url = `/actual/base/monitoringEquipmentInspectRecord/update`; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
if (code === 0) { |
|||
this.$message.success('保存成功'); |
|||
row.isEdit = false; |
|||
this.isEdit = false; |
|||
this.getList(); |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
|
|||
async del(row) { |
|||
let arr = [row.id]; |
|||
const url = `/actual/base/monitoringEquipmentInspectRecord/delete`; |
|||
const { data, code, msg } = await requestPost(url, arr); |
|||
|
|||
if (code === 0) { |
|||
this.$message.success('删除成功'); |
|||
this.getList(); |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
|
|||
async getList() { |
|||
const params = { |
|||
equipmentId: this.id, |
|||
pageNo: 1, |
|||
pageSize: 10000 |
|||
}; |
|||
const url = `/actual/base/monitoringEquipmentInspectRecord/page`; |
|||
const { data, code, msg } = await requestPost(url, params); |
|||
|
|||
if (code === 0) { |
|||
this.tableData = data.list.map(item => { |
|||
this.computeImgShowList(item); |
|||
return { |
|||
...item, |
|||
isEdit: false |
|||
}; |
|||
}); |
|||
this.handleAdd(); |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
@import '@/assets/scss/buttonstyle.scss'; |
|||
@import '@/assets/scss/modules/management/list-main.scss'; |
|||
|
|||
.mt10 { |
|||
margin-bottom: 10px; |
|||
} |
|||
.input-width { |
|||
width: 170px; |
|||
} |
|||
</style> |
Loading…
Reference in new issue