7 changed files with 344 additions and 24 deletions
@ -0,0 +1,143 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '180px' : '120px'"> |
|||
<el-form-item label="监测点名称" prop="testingPointName"> |
|||
<el-input v-model="dataForm.testingPointName" placeholder="监测点名称" maxlength="100" show-word-limit></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="监测点介绍"> |
|||
<el-input type="textarea" autosize placeholder="请输入内容" v-model="dataForm.introduce" maxlength="200"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="负责人" prop="contacts"> |
|||
<el-input v-model="dataForm.contacts" placeholder="负责人" maxlength="50" show-word-limit></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="联系电话" prop="tel"> |
|||
<el-input v-model="dataForm.tel" placeholder="联系电话" maxlength="20" show-word-limit></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="经度" prop="longitude"> |
|||
<el-input v-model="dataForm.longitude" :disabled = "true" placeholder="经度"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="纬度" prop="latitude"> |
|||
<el-input v-model="dataForm.latitude" :disabled = "true" placeholder="纬度"></el-input> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="mapSelectHandle(2)">地图选择</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
<map-select v-if="mapSelectVisible" |
|||
ref="mapSelect" |
|||
v-on:position="position"></map-select> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
import MapSelect from '../sys/map-select' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '', |
|||
testingPointName: '', |
|||
address: '', |
|||
longitude: '', |
|||
latitude: '', |
|||
contacts: '', |
|||
tel: '', |
|||
introduce: '' |
|||
}, |
|||
mapSelectVisible: false |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
testingPointName: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
address: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
longitude: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
latitude: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
contacts: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
tel: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.dataForm.introduce = '' |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 地图相关 |
|||
position (position) { |
|||
this.dataForm.address = position.address |
|||
this.dataForm.latitude = position.latitude |
|||
this.dataForm.longitude = position.longitude |
|||
this.mapSelectVisible = false |
|||
}, |
|||
mapSelectHandle (type) { |
|||
this.mapSelectVisible = true |
|||
this.$nextTick(() => { |
|||
this.$refs.mapSelect.init(type, 200) |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/custom/testingpoint/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/custom/testingpoint/', this.dataForm).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$message({ |
|||
message: this.$t('prompt.success'), |
|||
type: 'success', |
|||
duration: 500, |
|||
onClose: () => { |
|||
this.visible = false |
|||
this.$emit('refreshDataList') |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
}, |
|||
components: { |
|||
MapSelect |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,70 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" title="详情" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" ref="dataForm" :label-width="$i18n.locale === 'en-US' ? '180px' : '120px'"> |
|||
<el-form-item label="监测点名称"> |
|||
<div>{{dataForm.testingPointName}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="监测点介绍"> |
|||
<div>{{dataForm.introduce}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="负责人"> |
|||
<div>{{dataForm.contacts}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="联系电话"> |
|||
<div>{{dataForm.tel}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="监测点位置"> |
|||
<div>{{dataForm.address}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="经度"> |
|||
<div>{{dataForm.longitude}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="纬度"> |
|||
<div>{{dataForm.latitude}}</div> |
|||
</el-form-item> |
|||
<el-form-item label="检测人数"> |
|||
<div>{{dataForm.testNum}}</div> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false" |
|||
type="primary">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '' |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/custom/testingpoint/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
}).catch(() => {}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,82 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-custom__testingpoint}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item> |
|||
<el-input v-model="dataForm.testingPointName" placeholder="按监测点名称模糊查询" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button v-if="$hasPermission('custom:testingpoint:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> |
|||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> |
|||
<el-table-column prop="testingPointName" label="监测点名称" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="address" label="位置" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="contacts" label="负责人" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="tel" label="联系电话" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="testNum" label="检测人数" header-align="center" align="center"></el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="text" size="small" @click="detailQuery(scope.row.id)">详情</el-button> |
|||
<el-button v-if="$hasPermission('custom:testingpoint:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> |
|||
<el-button v-if="$hasPermission('custom:testingpoint:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<el-pagination |
|||
:current-page="page" |
|||
:page-sizes="[10, 20, 50, 100]" |
|||
:page-size="limit" |
|||
:total="total" |
|||
layout="total, sizes, prev, pager, next, jumper" |
|||
@size-change="pageSizeChangeHandle" |
|||
@current-change="pageCurrentChangeHandle"> |
|||
</el-pagination> |
|||
<!-- 弹窗, 新增 / 修改 --> |
|||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> |
|||
<!-- 弹窗, 详情 --> |
|||
<detail v-if="detailVisible" ref="detail"></detail> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './testingpoint-add-or-update' |
|||
import Detail from './testingpoint-detail' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/custom/testingpoint/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/custom/testingpoint', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '' |
|||
}, |
|||
detailVisible: false |
|||
} |
|||
}, |
|||
methods: { |
|||
// 跳转到详情页 |
|||
detailQuery (id) { |
|||
this.detailVisible = true |
|||
this.$nextTick(() => { |
|||
this.$refs.detail.dataForm.id = id |
|||
this.$refs.detail.init() |
|||
}) |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate, |
|||
Detail |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue