6 changed files with 3724 additions and 0 deletions
@ -0,0 +1,694 @@ |
|||
<template> |
|||
<div class="div_main"> |
|||
<div class="div_search"> |
|||
<el-form :inline="true" |
|||
:model="formData" |
|||
ref="ref_searchform" |
|||
:label-width="'100px'"> |
|||
<div> |
|||
<el-form-item label="所属网格" |
|||
prop="gridId"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="单位名称" |
|||
prop="unitName"> |
|||
<el-input v-model="formData.unitName" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.serviceMatter" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in serviceList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
</div> |
|||
<div> |
|||
<el-form-item label="分类" |
|||
prop="type"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in typeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact"> |
|||
<el-input v-model="formData.contact" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile"> |
|||
<el-input v-model="formData.contactMobile" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-button style="margin-left:10px" |
|||
type="primary" |
|||
size="small" |
|||
@click="handleSearch">查询</el-button> |
|||
<el-button style="margin-left:10px" |
|||
type="yellow" |
|||
size="small" |
|||
@click="resetSearch">重置</el-button> |
|||
</div> |
|||
</el-form> |
|||
</div> |
|||
<div class="div_table"> |
|||
<div class="div_btn"> |
|||
<el-button style="float:left" |
|||
type="green" |
|||
size="small" |
|||
@click="handleAdd">新增</el-button> |
|||
<el-upload ref="upload" |
|||
:multiple='false' |
|||
:show-file-list='false' |
|||
:before-upload="beforeUpload" |
|||
action="" |
|||
accept=".xls,.xlsx" |
|||
:limit="1" |
|||
:on-exceed="handleExceed" |
|||
:http-request="uploadFile"> |
|||
<el-button style="margin-left:10px" |
|||
size="small" |
|||
type="red">导入</el-button> |
|||
|
|||
<el-button style="float:left" |
|||
type="yellow" |
|||
size="small" |
|||
@click="handleExport">导出</el-button> |
|||
|
|||
</el-upload> |
|||
|
|||
</div> |
|||
|
|||
<el-table class="table" |
|||
:data="tableData" |
|||
border |
|||
:height="tableHeight" |
|||
v-loading="tableLoading" |
|||
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}" |
|||
style="width: 100%"> |
|||
<el-table-column label="序号" |
|||
header-align="center" |
|||
align="center" |
|||
type="index" |
|||
width="50"></el-table-column> |
|||
<el-table-column prop="gridName" |
|||
header-align="center" |
|||
align="center" |
|||
label="所属网格" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="unitName" |
|||
header-align="center" |
|||
align="center" |
|||
label="单位名称" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="type" |
|||
header-align="center" |
|||
align="center" |
|||
label="分类" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="serviceMatter" |
|||
header-align="center" |
|||
align="center" |
|||
label="服务事项" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="contact" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系人" |
|||
width="100"> |
|||
</el-table-column> |
|||
<el-table-column prop="contactMobile" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系电话" |
|||
width="110"> |
|||
</el-table-column> |
|||
<el-table-column prop="memberCount" |
|||
header-align="center" |
|||
align="center" |
|||
label="在职党员数" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="satisfaction" |
|||
header-align="center" |
|||
align="center" |
|||
label="群众满意度" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="remark" |
|||
header-align="center" |
|||
align="center" |
|||
label="备注" |
|||
:show-overflow-tooltip="true" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column label="操作" |
|||
fixed="right" |
|||
width="140" |
|||
header-align="center" |
|||
align="center" |
|||
class="operate"> |
|||
<template slot-scope="scope"> |
|||
|
|||
<el-button type="text" |
|||
style="color:#1C6AFD;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDetail(scope.row)">查看</el-button> |
|||
<el-button type="text" |
|||
style="color:#00A7A9;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleEdit(scope.row)">修改</el-button> |
|||
|
|||
<el-button type="text" |
|||
style="color:#D51010;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDelete(scope.row)">删除</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<div> |
|||
<el-pagination @size-change="handleSizeChange" |
|||
@current-change="handleCurrentChange" |
|||
:current-page.sync="pageNo" |
|||
:page-sizes="[10, 20, 50]" |
|||
:page-size="pageSize" |
|||
layout="sizes, prev, pager, next, total" |
|||
:total="total"> |
|||
</el-pagination> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- 修改弹出框 --> |
|||
<el-dialog :visible.sync="formShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
:title="formTitle" |
|||
width="850px" |
|||
top="5vh" |
|||
@closed="diaClose"> |
|||
<units-form ref="ref_form" |
|||
:gridList="gridList" |
|||
:serviceList="serviceList" |
|||
:typeList="typeList" |
|||
@dialogCancle="addFormCancle" |
|||
@dialogOk="addFormOk"></units-form> |
|||
</el-dialog> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
|
|||
import unitsForm from './unitsForm' |
|||
|
|||
import { requestPost } from "@/js/dai/request"; |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
loading: false, |
|||
total: 0, |
|||
pageSize: 10, |
|||
pageNo: 0, |
|||
tableLoading: false, |
|||
agencyId: '', |
|||
gridList: [],//所属网格list |
|||
unitList: [],//单位list |
|||
serviceList: [ |
|||
{ |
|||
id: "1", |
|||
name: '积极配合社区安全巡查员进行场所消防、安全等方面的检查。' |
|||
}, |
|||
{ |
|||
id: "2", |
|||
name: '积极配合' |
|||
}, |
|||
{ |
|||
id: "3", |
|||
name: '积极配合社区安全巡查员进行' |
|||
}, |
|||
{ |
|||
id: "4", |
|||
name: '积极配合社区安全巡查员进行场所消防、安全等方面的检查。并具备安全意识及设备设施' |
|||
}, |
|||
],//服务list |
|||
typeList: [],//分类list |
|||
|
|||
unitId: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
}, |
|||
|
|||
tableData: [], |
|||
|
|||
//form相关 |
|||
formShow: false, |
|||
formTitle: '新增单位', |
|||
|
|||
files: "", |
|||
fileName: "", |
|||
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import' |
|||
|
|||
} |
|||
}, |
|||
components: { |
|||
unitsForm |
|||
}, |
|||
async created () { |
|||
|
|||
}, |
|||
async mounted () { |
|||
//获取服务事项 |
|||
await this.loadService() |
|||
|
|||
//获取分类 |
|||
await this.loadType() |
|||
|
|||
const { user } = this.$store.state |
|||
this.agencyId = user.agencyId |
|||
//获取网格下拉框数据 |
|||
await this.loadGrid() |
|||
|
|||
await this.loadTable() |
|||
}, |
|||
|
|||
methods: { |
|||
handleSearch () { |
|||
this.loadTable() |
|||
}, |
|||
|
|||
async loadGrid () { |
|||
const url = "/gov/org/customergrid/gridoption" |
|||
|
|||
let params = { |
|||
agencyId: this.agencyId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.gridList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
//获取服务事项下拉框 |
|||
async loadService () { |
|||
// const url = "/heart/icresidemanddict/subcodelist" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icresidemanddict/subcodelist" |
|||
|
|||
let params = { |
|||
parentCategoryCode: '1010' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.serviceList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
//获取分类 |
|||
async loadType () { |
|||
const url = "/sys/dict/data/dictlist" |
|||
|
|||
let params = { |
|||
dictType: 'party_unit_type' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.typeList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
async loadTable () { |
|||
this.tableLoading = true |
|||
|
|||
// const url = "/heart/icpartyunit/list" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/list" |
|||
let params = { |
|||
pageSize: this.pageSize, |
|||
pageNo: this.pageNo, |
|||
agencyId: this.agencyId, |
|||
...this.formData |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.total = data.total |
|||
this.tableData = data.list |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
this.tableLoading = false |
|||
}, |
|||
|
|||
|
|||
|
|||
diaClose () { |
|||
this.$refs.ref_form.resetData() |
|||
this.formShow = false |
|||
}, |
|||
|
|||
handleDetail (row) { |
|||
this.formTitle = '详情' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('detail', row.id) |
|||
}) |
|||
}, |
|||
|
|||
handleAdd () { |
|||
this.formTitle = '新增' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('add', null) |
|||
}) |
|||
}, |
|||
|
|||
handleEdit (row) { |
|||
this.formTitle = '修改' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('edit', row.id) |
|||
}) |
|||
}, |
|||
|
|||
addFormCancle () { |
|||
this.formShow = false |
|||
}, |
|||
addFormOk () { |
|||
this.formShow = false |
|||
this.loadTable() |
|||
|
|||
}, |
|||
|
|||
async handleDelete (row) { |
|||
|
|||
this.$confirm("确认删除?", "提示", { |
|||
confirmButtonText: "确定", |
|||
cancelButtonText: "取消", |
|||
type: "warning" |
|||
}) |
|||
.then(() => { |
|||
this.deleteUnit(row) |
|||
}) |
|||
.catch(err => { |
|||
if (err == "cancel") { |
|||
|
|||
} |
|||
|
|||
}); |
|||
}, |
|||
|
|||
async deleteUnit (row) { |
|||
// const url = "/heart/icpartyunit/delete" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/delete" |
|||
|
|||
let params = { |
|||
id: row.id |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "删除成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
//重置搜索条件 |
|||
resetSearch () { |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
} |
|||
}, |
|||
|
|||
//导出表格 |
|||
async handleExport () { |
|||
let title = '联建单位列表' |
|||
|
|||
|
|||
const url = "/partyunit/export" |
|||
let params = { |
|||
ownerName: this.ownerName, |
|||
ownerPhone: this.ownerPhone, |
|||
level: this.agencyObj.level, |
|||
id: this.agencyObj.id |
|||
} |
|||
|
|||
app.ajax.exportFilePost( |
|||
url, |
|||
params, |
|||
(data, rspMsg) => { |
|||
|
|||
this.download(data, title + '.xls') |
|||
}, |
|||
(rspMsg, data) => { |
|||
this.$message.error(rspMsg); |
|||
} |
|||
); |
|||
|
|||
}, |
|||
|
|||
// 下载文件 |
|||
download (data, fileName) { |
|||
if (!data) { |
|||
return |
|||
} |
|||
|
|||
var csvData = new Blob([data]) |
|||
|
|||
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|||
window.navigator.msSaveOrOpenBlob(csvData, fileName); |
|||
} |
|||
// for Non-IE (chrome, firefox etc.) |
|||
else { |
|||
var a = document.createElement('a'); |
|||
document.body.appendChild(a); |
|||
a.style = 'display: none'; |
|||
var url = window.URL.createObjectURL(csvData); |
|||
a.href = url; |
|||
a.download = fileName; |
|||
a.click(); |
|||
a.remove(); |
|||
window.URL.revokeObjectURL(url); |
|||
} |
|||
|
|||
}, |
|||
|
|||
// 上传文件之前的钩子 |
|||
beforeUpload (file) { |
|||
this.files = file; |
|||
|
|||
const isText = file.type === 'application/vnd.ms-excel' |
|||
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|||
|
|||
if (!isText && !isTextComputer) { |
|||
this.$message.error('请选择正确格式的文件') |
|||
return false |
|||
} else { |
|||
this.fileName = file.name; |
|||
return true |
|||
} |
|||
|
|||
}, |
|||
// 上传文件个数超过定义的数量 |
|||
handleExceed (files, fileList) { |
|||
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|||
}, |
|||
|
|||
async uploadFile () { |
|||
this.loading = true |
|||
|
|||
if (this.fileName == "") { |
|||
this.$message.warning('请选择要上传的文件!') |
|||
return false |
|||
} |
|||
|
|||
//清空上传列表 |
|||
this.$refs['upload'].clearFiles() |
|||
|
|||
var url = '/partyunit/import' |
|||
let fileFormData = new FormData(); |
|||
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|||
|
|||
const { data, code, msg } = await requestPost(url, fileFormData) |
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "导入成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
|
|||
}, |
|||
|
|||
handleSizeChange (val) { |
|||
this.pageSize = val |
|||
this.pageNo = 1 |
|||
this.loadTable() |
|||
}, |
|||
handleCurrentChange (val) { |
|||
this.pageNo = val |
|||
this.loadTable() |
|||
}, |
|||
|
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
tableHeight () { |
|||
|
|||
return (this.clientHeight - 460) |
|||
|
|||
}, |
|||
rowHeight () { |
|||
return (this.clientHeight - 200) + 'px' |
|||
}, |
|||
...mapGetters(['clientHeight']) |
|||
}, |
|||
watch: { |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss" scoped > |
|||
@import "@/assets/scss/buttonstyle.scss"; |
|||
|
|||
.div_main { |
|||
width: 100%; |
|||
} |
|||
|
|||
.div_search { |
|||
background: #ffffff; |
|||
border-radius: 4px; |
|||
padding: 35px 20px; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
} |
|||
|
|||
.item_width_1 { |
|||
width: 260px; |
|||
} |
|||
|
|||
.div_table { |
|||
background: #ffffff; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
border-radius: 4px; |
|||
margin-top: 20px; |
|||
padding: 23px 30px 10px; |
|||
|
|||
.table { |
|||
margin-top: 20px; |
|||
} |
|||
} |
|||
|
|||
.div_btn { |
|||
} |
|||
|
|||
.el-row { |
|||
/* margin-bottom: 20px; */ |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
margin-top: 10px; |
|||
margin-right: 50px; |
|||
} |
|||
</style> |
@ -0,0 +1,553 @@ |
|||
<template> |
|||
<div> |
|||
<div> |
|||
<div> |
|||
<el-form ref="ref_form" |
|||
:inline="true" |
|||
:model="formData" |
|||
:rules="dataRule" |
|||
:disabled="formType === 'detail'" |
|||
class="form"> |
|||
|
|||
<el-form-item label="所属网格" |
|||
prop="gridId" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="单位名称" |
|||
prop="unitName" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
maxlength="50" |
|||
show-word-limit |
|||
placeholder="请输入单位名称" |
|||
v-model="formData.unitName"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="分类" |
|||
prop="type" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
filterable |
|||
clearable> |
|||
<el-option v-for="item in typeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-checkbox-group class="item_width_1" |
|||
style="display:flex;flex-wrap:wrap" |
|||
v-model="formData.serviceMatter"> |
|||
<el-checkbox v-for="item in serviceList" |
|||
:key="item.value" |
|||
:label="item.value">{{item.label}}</el-checkbox> |
|||
|
|||
</el-checkbox-group> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人姓名" |
|||
v-model="formData.contact"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人电话" |
|||
v-model="formData.contactMobile"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="在职党员" |
|||
style="display: block" |
|||
prop="memberCount" |
|||
label-width="150px"> |
|||
<el-input-number class="item_width_1" |
|||
v-model="formData.memberCount" |
|||
:min="1" |
|||
label="单元数"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="备注" |
|||
prop="remark" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
type="textarea" |
|||
maxlength="500" |
|||
show-word-limit |
|||
:rows="3" |
|||
placeholder="请输入备注,不超过500字" |
|||
v-model="formData.remark"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="位置坐标" |
|||
prop="longitude" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<div style="width:500px"> |
|||
|
|||
<div class="div_map"> |
|||
<div id="app"> |
|||
|
|||
</div> |
|||
<div class="div_searchmap"> |
|||
<el-input class="item_width_4" |
|||
maxlength="50" |
|||
size="mini" |
|||
placeholder="请输入关键字" |
|||
v-model="keyWords"> |
|||
</el-input> |
|||
<el-button style="margin-left: 10px" |
|||
type="primary" |
|||
size="mini" |
|||
@click="handleSearchMap">查询</el-button> |
|||
</div> |
|||
</div> |
|||
|
|||
<div style="margin-top: 10px"> |
|||
<span>经度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入经度" |
|||
v-model="formData.longitude"> |
|||
</el-input> |
|||
<span style="margin-left: 20px">纬度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入纬度" |
|||
v-model="formData.latitude"> |
|||
</el-input> |
|||
</div> |
|||
</div> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="地理位置" |
|||
prop="address" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
|
|||
<el-input class="item_width_1" |
|||
v-model="formData.address"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
</el-form> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="div_btn"> |
|||
<el-button @click="handleCancle">取 消</el-button> |
|||
<el-button v-if="formType != 'detail'" |
|||
type="primary" |
|||
:disabled="btnDisable" |
|||
@click="handleComfirm">确 定</el-button> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
import { requestPost } from '@/js/dai/request' |
|||
|
|||
|
|||
|
|||
var map |
|||
var search |
|||
var markers |
|||
var infoWindowList |
|||
var geocoder // 新建一个正逆地址解析类 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
formType: 'add', //表单操作类型 add新增,edit编辑,detail详情 |
|||
|
|||
btnDisable: false, |
|||
|
|||
unitId: '', |
|||
keyWords: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: 36.0722275, //经度 |
|||
latitude: 120.38945519 //纬度 |
|||
}, |
|||
|
|||
} |
|||
}, |
|||
components: {}, |
|||
mounted () { |
|||
this.initMap() |
|||
}, |
|||
|
|||
methods: { |
|||
|
|||
async initForm (type, unitId) { |
|||
this.$refs.ref_form.resetFields(); |
|||
|
|||
// debugger |
|||
// map.setCenter(new TMap.LatLng(agencyObj.latitude, agencyObj.longitude)) |
|||
|
|||
this.formType = type |
|||
if (unitId) { |
|||
this.unitId = unitId |
|||
this.formData.id = unitId |
|||
await this.loadFormData() |
|||
} |
|||
|
|||
}, |
|||
|
|||
//加载组织 |
|||
async loadFormData () { |
|||
// const url = '/heart/icpartyunit/detail' |
|||
const url = 'http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/detail' |
|||
let params = { |
|||
id: this.unitId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.formData = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
|
|||
|
|||
async handleComfirm () { |
|||
|
|||
this.btnDisable = true |
|||
setTimeout(() => { |
|||
this.btnDisable = false |
|||
}, 10000) |
|||
this.$refs['ref_form'].validate((valid, messageObj) => { |
|||
if (!valid) { |
|||
app.util.validateRule(messageObj) |
|||
this.btnDisable = false |
|||
} else { |
|||
this.addUnit() |
|||
} |
|||
|
|||
}) |
|||
|
|||
|
|||
}, |
|||
async addUnit () { |
|||
// const regPhone = /^1(3|4|5|6|7|8|9)\d{9}$/; //手机号码 |
|||
// if (regPhone.test(this.formData.contactMobile) === false) { |
|||
// this.btnDisable = false |
|||
// this.$message({ |
|||
// type: 'warning', |
|||
// message: '请输入正确的手机号码' |
|||
// }) |
|||
// return false; |
|||
// } |
|||
|
|||
// let url = '/heart/icpartyunit/save' |
|||
let url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/save" |
|||
// if (this.formType === 'edit') { |
|||
// this.formData.id = this.unitId |
|||
// } |
|||
|
|||
const { data, code, msg } = await requestPost(url, this.formData) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '新增联建单位成功' |
|||
}) |
|||
this.resetData() |
|||
this.$emit('dialogOk') |
|||
this.btnDisable = false |
|||
} else { |
|||
this.btnDisable = false |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
handleCancle () { |
|||
|
|||
this.resetData() |
|||
this.$emit('dialogCancle') |
|||
|
|||
}, |
|||
|
|||
// 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|||
initMap () { |
|||
// 定义地图中心点坐标 |
|||
var center = new window.TMap.LatLng(36.0722275, 120.38945519) |
|||
// 定义map变量,调用 TMap.Map() 构造函数创建地图 |
|||
map = new window.TMap.Map(document.getElementById('app'), { |
|||
center: center, // 设置地图中心点坐标 |
|||
zoom: 17.2, // 设置地图缩放级别 |
|||
pitch: 43.5, // 设置俯仰角 |
|||
rotation: 45 // 设置地图旋转角度 |
|||
}) |
|||
|
|||
search = new window.TMap.service.Search({ pageSize: 10 }) |
|||
// 新建一个地点搜索类 |
|||
markers = new TMap.MultiMarker({ |
|||
map: map, |
|||
geometries: [] |
|||
}) |
|||
infoWindowList = Array(10) |
|||
|
|||
geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|||
|
|||
// 监听地图平移结束 |
|||
map.on('panend', () => { |
|||
this.handleMoveCenter() |
|||
}) |
|||
this.handleMoveCenter() |
|||
this.convert() |
|||
}, |
|||
|
|||
setMarker (lat, lng) { |
|||
markers.setGeometries([]) |
|||
markers.add([ |
|||
{ |
|||
id: '4', |
|||
styleId: 'marker', |
|||
position: new TMap.LatLng(lat, lng), |
|||
properties: { |
|||
title: 'marker4' |
|||
} |
|||
} |
|||
]) |
|||
}, |
|||
|
|||
handleSearchMap () { |
|||
infoWindowList.forEach((infoWindow) => { |
|||
infoWindow.close() |
|||
}) |
|||
infoWindowList.length = 0 |
|||
markers.setGeometries([]) |
|||
// 在地图显示范围内以给定的关键字搜索地点 |
|||
search |
|||
.searchRectangle({ |
|||
keyword: this.keyWords, |
|||
bounds: map.getBounds() |
|||
}) |
|||
.then((result) => { |
|||
let { data } = result |
|||
if (Array.isArray(data) && data.length > 0) { |
|||
const { |
|||
location: { lat, lng } |
|||
} = data[0] |
|||
|
|||
|
|||
map.setCenter(new TMap.LatLng(lat, lng)) |
|||
this.setMarker(lat, lng) |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.convert() |
|||
} else { |
|||
this.$message.error('未检索到相关位置坐标') |
|||
} |
|||
}) |
|||
}, |
|||
|
|||
handleMoveCenter () { |
|||
//修改地图中心点 |
|||
const center = map.getCenter() |
|||
const lat = center.getLat() |
|||
const lng = center.getLng() |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.setMarker(lat, lng) |
|||
this.convert(lat, lng) |
|||
}, |
|||
|
|||
convert (lat, lng) { |
|||
markers.setGeometries([]); |
|||
// var input = document.getElementById('location').value.split(','); |
|||
let location |
|||
if (lat && lng) { |
|||
location = new TMap.LatLng(lat, lng); |
|||
} else { |
|||
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude); |
|||
} |
|||
|
|||
// map.setCenter(location); |
|||
markers.updateGeometries([ |
|||
{ |
|||
id: 'main', // 点标注数据数组 |
|||
position: location, |
|||
}, |
|||
]); |
|||
geocoder |
|||
.getAddress({ location: location }) // 将给定的坐标位置转换为地址 |
|||
.then((result) => { |
|||
this.formData.address = result.result.address |
|||
// 显示搜索到的地址 |
|||
}); |
|||
}, |
|||
|
|||
|
|||
resetData () { |
|||
this.unitId = '' |
|||
this.keyWords = '' |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: '', //经度 |
|||
latitude: '' //纬度 |
|||
} |
|||
}, |
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
gridId: [ |
|||
{ required: true, message: '所属网格不能为空', trigger: 'blur' } |
|||
], |
|||
unitName: [ |
|||
{ required: true, message: '单位名称不能为空', trigger: 'blur' }, |
|||
], |
|||
type: [ |
|||
{ required: true, message: '分类不能为空', trigger: 'blur' } |
|||
], |
|||
|
|||
contact: [ |
|||
{ required: true, message: '联系人不能为空', trigger: 'blur' } |
|||
], |
|||
contactMobile: [ |
|||
{ required: true, message: '联系电话不能为空', trigger: 'blur' } |
|||
], |
|||
memberCount: [ |
|||
{ required: true, message: '在职党员数不能为空', trigger: 'blur' } |
|||
], |
|||
address: [ |
|||
{ required: true, message: '详细地址不能为空', trigger: 'blur' } |
|||
], |
|||
longitude: [ |
|||
{ required: true, message: '坐标不能为空', trigger: 'blur' } |
|||
] |
|||
} |
|||
}, |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
gridList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
typeList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
serviceList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.item_width_1 { |
|||
width: 500px; |
|||
} |
|||
.item_width_2 { |
|||
width: 400px; |
|||
} |
|||
.item_width_3 { |
|||
margin-left: 10px; |
|||
width: 200px; |
|||
} |
|||
.item_width_4 { |
|||
width: 200px; |
|||
} |
|||
|
|||
.div_map { |
|||
position: relative; |
|||
} |
|||
.div_searchmap { |
|||
z-index: 5000; |
|||
position: absolute; |
|||
top: 5px; |
|||
left: 5px; |
|||
} |
|||
|
|||
.div_btn { |
|||
display: flex; |
|||
justify-content: flex-end; |
|||
} |
|||
.el-tabs { |
|||
margin: 0 20px; |
|||
} |
|||
.el-upload__tip { |
|||
color: rgb(155, 155, 155); |
|||
margin: 0; |
|||
} |
|||
.form { |
|||
margin-top: 30px; |
|||
} |
|||
</style> |
|||
|
|||
<style lang=scss> |
|||
.el-dialog__body { |
|||
padding: 0 10px 20px !important; |
|||
} |
|||
</style> |
@ -0,0 +1,677 @@ |
|||
<template> |
|||
<div class="div_main"> |
|||
<div class="div_search"> |
|||
<el-form :inline="true" |
|||
:model="formData" |
|||
ref="ref_searchform" |
|||
:label-width="'100px'"> |
|||
<div> |
|||
<el-form-item label="所属网格" |
|||
prop="gridId"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="单位名称" |
|||
prop="unitName"> |
|||
<el-input v-model="formData.unitName" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.serviceMatter" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in scaleList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
</div> |
|||
<div> |
|||
<el-form-item label="分类" |
|||
prop="type"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in placeTypeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact"> |
|||
<el-input v-model="formData.contact" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile"> |
|||
<el-input v-model="formData.contactMobile" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-button style="margin-left:10px" |
|||
type="primary" |
|||
size="small" |
|||
@click="handleSearch">查询</el-button> |
|||
<el-button style="margin-left:10px" |
|||
type="yellow" |
|||
size="small" |
|||
@click="resetSearch">重置</el-button> |
|||
</div> |
|||
</el-form> |
|||
</div> |
|||
<div class="div_table"> |
|||
<div class="div_btn"> |
|||
<el-button style="float:left" |
|||
type="green" |
|||
size="small" |
|||
@click="handleAdd">新增</el-button> |
|||
<el-upload ref="upload" |
|||
:multiple='false' |
|||
:show-file-list='false' |
|||
:before-upload="beforeUpload" |
|||
action="" |
|||
accept=".xls,.xlsx" |
|||
:limit="1" |
|||
:on-exceed="handleExceed" |
|||
:http-request="uploadFile"> |
|||
<el-button style="margin-left:10px" |
|||
size="small" |
|||
type="red">导入</el-button> |
|||
|
|||
<el-button style="float:left" |
|||
type="yellow" |
|||
size="small" |
|||
@click="handleExport">导出</el-button> |
|||
|
|||
</el-upload> |
|||
|
|||
</div> |
|||
|
|||
<el-table class="table" |
|||
:data="tableData" |
|||
border |
|||
:height="tableHeight" |
|||
v-loading="tableLoading" |
|||
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}" |
|||
style="width: 100%"> |
|||
<el-table-column label="序号" |
|||
header-align="center" |
|||
align="center" |
|||
type="index" |
|||
width="50"></el-table-column> |
|||
<el-table-column prop="gridName" |
|||
header-align="center" |
|||
align="center" |
|||
label="所属网格" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="unitName" |
|||
header-align="center" |
|||
align="center" |
|||
label="单位名称" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="type" |
|||
header-align="center" |
|||
align="center" |
|||
label="分类" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="serviceMatter" |
|||
header-align="center" |
|||
align="center" |
|||
label="服务事项" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="contact" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系人" |
|||
width="100"> |
|||
</el-table-column> |
|||
<el-table-column prop="contactMobile" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系电话" |
|||
width="110"> |
|||
</el-table-column> |
|||
<el-table-column prop="memberCount" |
|||
header-align="center" |
|||
align="center" |
|||
label="在职党员数" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="satisfaction" |
|||
header-align="center" |
|||
align="center" |
|||
label="群众满意度" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="remark" |
|||
header-align="center" |
|||
align="center" |
|||
label="备注" |
|||
:show-overflow-tooltip="true" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column label="操作" |
|||
fixed="right" |
|||
width="140" |
|||
header-align="center" |
|||
align="center" |
|||
class="operate"> |
|||
<template slot-scope="scope"> |
|||
|
|||
<el-button type="text" |
|||
style="color:#1C6AFD;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDetail(scope.row)">查看</el-button> |
|||
<el-button type="text" |
|||
style="color:#00A7A9;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleEdit(scope.row)">修改</el-button> |
|||
|
|||
<el-button type="text" |
|||
style="color:#D51010;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDelete(scope.row)">删除</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<div> |
|||
<el-pagination @size-change="handleSizeChange" |
|||
@current-change="handleCurrentChange" |
|||
:current-page.sync="pageNo" |
|||
:page-sizes="[10, 20, 50]" |
|||
:page-size="pageSize" |
|||
layout="sizes, prev, pager, next, total" |
|||
:total="total"> |
|||
</el-pagination> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- 修改弹出框 --> |
|||
<el-dialog :visible.sync="formShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
:title="formTitle" |
|||
width="850px" |
|||
top="5vh" |
|||
@closed="diaClose"> |
|||
<places-form ref="ref_form" |
|||
:gridList="gridList" |
|||
:scaleList="scaleList" |
|||
:placeTypeList="placeTypeList" |
|||
@dialogCancle="addFormCancle" |
|||
@dialogOk="addFormOk"></places-form> |
|||
</el-dialog> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
|
|||
import placesForm from './placesForm' |
|||
|
|||
import { requestPost } from "@/js/dai/request"; |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
loading: false, |
|||
total: 0, |
|||
pageSize: 10, |
|||
pageNo: 0, |
|||
tableLoading: false, |
|||
|
|||
agencyId: '', |
|||
gridList: [],//所属网格list--场所区域 |
|||
scaleList: [],//规模list |
|||
placeTypeList: [],//场所类型list |
|||
|
|||
unitId: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
}, |
|||
|
|||
tableData: [], |
|||
|
|||
//form相关 |
|||
formShow: false, |
|||
formTitle: '新增单位', |
|||
|
|||
files: "", |
|||
fileName: "", |
|||
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import' |
|||
|
|||
} |
|||
}, |
|||
components: { |
|||
placesForm |
|||
}, |
|||
async created () { |
|||
|
|||
}, |
|||
async mounted () { |
|||
//获取服务事项 |
|||
await this.loadService() |
|||
|
|||
//获取分类 |
|||
await this.loadType() |
|||
|
|||
const { user } = this.$store.state |
|||
this.agencyId = user.agencyId |
|||
//获取网格下拉框数据 |
|||
await this.loadGrid() |
|||
|
|||
await this.loadTable() |
|||
}, |
|||
|
|||
methods: { |
|||
handleSearch () { |
|||
this.loadTable() |
|||
}, |
|||
|
|||
async loadGrid () { |
|||
const url = "/gov/org/customergrid/gridoption" |
|||
|
|||
let params = { |
|||
agencyId: this.agencyId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.gridList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
//获取服务事项下拉框 |
|||
async loadService () { |
|||
// const url = "/heart/icresidemanddict/subcodelist" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icresidemanddict/subcodelist" |
|||
|
|||
let params = { |
|||
parentCategoryCode: '1010' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.scaleList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
//获取分类 |
|||
async loadType () { |
|||
const url = "/sys/dict/data/dictlist" |
|||
|
|||
let params = { |
|||
dictType: 'party_unit_type' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.placeTypeList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
async loadTable () { |
|||
this.tableLoading = true |
|||
|
|||
// const url = "/heart/icpartyunit/list" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/list" |
|||
let params = { |
|||
pageSize: this.pageSize, |
|||
pageNo: this.pageNo, |
|||
agencyId: this.agencyId, |
|||
...this.formData |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.total = data.total |
|||
this.tableData = data.list |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
this.tableLoading = false |
|||
}, |
|||
|
|||
|
|||
|
|||
diaClose () { |
|||
this.$refs.ref_form.resetData() |
|||
this.formShow = false |
|||
}, |
|||
|
|||
handleDetail (row) { |
|||
this.formTitle = '详情' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('detail', row.id) |
|||
}) |
|||
}, |
|||
|
|||
handleAdd () { |
|||
this.formTitle = '新增' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('add', null) |
|||
}) |
|||
}, |
|||
|
|||
handleEdit (row) { |
|||
this.formTitle = '修改' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('edit', row.id) |
|||
}) |
|||
}, |
|||
|
|||
addFormCancle () { |
|||
this.formShow = false |
|||
}, |
|||
addFormOk () { |
|||
this.formShow = false |
|||
this.loadTable() |
|||
|
|||
}, |
|||
|
|||
async handleDelete (row) { |
|||
|
|||
this.$confirm("确认删除?", "提示", { |
|||
confirmButtonText: "确定", |
|||
cancelButtonText: "取消", |
|||
type: "warning" |
|||
}) |
|||
.then(() => { |
|||
this.deleteUnit(row) |
|||
}) |
|||
.catch(err => { |
|||
if (err == "cancel") { |
|||
|
|||
} |
|||
|
|||
}); |
|||
}, |
|||
|
|||
async deleteUnit (row) { |
|||
// const url = "/heart/icpartyunit/delete" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/delete" |
|||
|
|||
let params = { |
|||
id: row.id |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "删除成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
//重置搜索条件 |
|||
resetSearch () { |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
} |
|||
}, |
|||
|
|||
//导出表格 |
|||
async handleExport () { |
|||
let title = '联建单位列表' |
|||
|
|||
|
|||
const url = "/partyunit/export" |
|||
let params = { |
|||
ownerName: this.ownerName, |
|||
ownerPhone: this.ownerPhone, |
|||
level: this.agencyObj.level, |
|||
id: this.agencyObj.id |
|||
} |
|||
|
|||
app.ajax.exportFilePost( |
|||
url, |
|||
params, |
|||
(data, rspMsg) => { |
|||
|
|||
this.download(data, title + '.xls') |
|||
}, |
|||
(rspMsg, data) => { |
|||
this.$message.error(rspMsg); |
|||
} |
|||
); |
|||
|
|||
}, |
|||
|
|||
// 下载文件 |
|||
download (data, fileName) { |
|||
if (!data) { |
|||
return |
|||
} |
|||
|
|||
var csvData = new Blob([data]) |
|||
|
|||
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|||
window.navigator.msSaveOrOpenBlob(csvData, fileName); |
|||
} |
|||
// for Non-IE (chrome, firefox etc.) |
|||
else { |
|||
var a = document.createElement('a'); |
|||
document.body.appendChild(a); |
|||
a.style = 'display: none'; |
|||
var url = window.URL.createObjectURL(csvData); |
|||
a.href = url; |
|||
a.download = fileName; |
|||
a.click(); |
|||
a.remove(); |
|||
window.URL.revokeObjectURL(url); |
|||
} |
|||
|
|||
}, |
|||
|
|||
// 上传文件之前的钩子 |
|||
beforeUpload (file) { |
|||
this.files = file; |
|||
|
|||
const isText = file.type === 'application/vnd.ms-excel' |
|||
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|||
|
|||
if (!isText && !isTextComputer) { |
|||
this.$message.error('请选择正确格式的文件') |
|||
return false |
|||
} else { |
|||
this.fileName = file.name; |
|||
return true |
|||
} |
|||
|
|||
}, |
|||
// 上传文件个数超过定义的数量 |
|||
handleExceed (files, fileList) { |
|||
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|||
}, |
|||
|
|||
async uploadFile () { |
|||
this.loading = true |
|||
|
|||
if (this.fileName == "") { |
|||
this.$message.warning('请选择要上传的文件!') |
|||
return false |
|||
} |
|||
|
|||
//清空上传列表 |
|||
this.$refs['upload'].clearFiles() |
|||
|
|||
var url = '/partyunit/import' |
|||
let fileFormData = new FormData(); |
|||
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|||
|
|||
const { data, code, msg } = await requestPost(url, fileFormData) |
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "导入成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
|
|||
}, |
|||
|
|||
handleSizeChange (val) { |
|||
this.pageSize = val |
|||
this.pageNo = 1 |
|||
this.loadTable() |
|||
}, |
|||
handleCurrentChange (val) { |
|||
this.pageNo = val |
|||
this.loadTable() |
|||
}, |
|||
|
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
tableHeight () { |
|||
|
|||
return (this.clientHeight - 460) |
|||
|
|||
}, |
|||
rowHeight () { |
|||
return (this.clientHeight - 200) + 'px' |
|||
}, |
|||
...mapGetters(['clientHeight']) |
|||
}, |
|||
watch: { |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss" scoped > |
|||
@import "@/assets/scss/buttonstyle.scss"; |
|||
|
|||
.div_main { |
|||
width: 100%; |
|||
} |
|||
|
|||
.div_search { |
|||
background: #ffffff; |
|||
border-radius: 4px; |
|||
padding: 35px 20px; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
} |
|||
|
|||
.item_width_1 { |
|||
width: 260px; |
|||
} |
|||
|
|||
.div_table { |
|||
background: #ffffff; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
border-radius: 4px; |
|||
margin-top: 20px; |
|||
padding: 23px 30px 10px; |
|||
|
|||
.table { |
|||
margin-top: 20px; |
|||
} |
|||
} |
|||
|
|||
.div_btn { |
|||
} |
|||
|
|||
.el-row { |
|||
/* margin-bottom: 20px; */ |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
margin-top: 10px; |
|||
margin-right: 50px; |
|||
} |
|||
</style> |
@ -0,0 +1,553 @@ |
|||
<template> |
|||
<div> |
|||
<div> |
|||
<div> |
|||
<el-form ref="ref_form" |
|||
:inline="true" |
|||
:model="formData" |
|||
:rules="dataRule" |
|||
:disabled="formType === 'detail'" |
|||
class="form"> |
|||
|
|||
<el-form-item label="所属网格" |
|||
prop="gridId" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="单位名称" |
|||
prop="unitName" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
maxlength="50" |
|||
show-word-limit |
|||
placeholder="请输入单位名称" |
|||
v-model="formData.unitName"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="分类" |
|||
prop="type" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
filterable |
|||
clearable> |
|||
<el-option v-for="item in typeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-checkbox-group class="item_width_1" |
|||
style="display:flex;flex-wrap:wrap" |
|||
v-model="formData.serviceMatter"> |
|||
<el-checkbox v-for="item in serviceList" |
|||
:key="item.value" |
|||
:label="item.value">{{item.label}}</el-checkbox> |
|||
|
|||
</el-checkbox-group> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人姓名" |
|||
v-model="formData.contact"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人电话" |
|||
v-model="formData.contactMobile"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="在职党员" |
|||
style="display: block" |
|||
prop="memberCount" |
|||
label-width="150px"> |
|||
<el-input-number class="item_width_1" |
|||
v-model="formData.memberCount" |
|||
:min="1" |
|||
label="单元数"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="备注" |
|||
prop="remark" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
type="textarea" |
|||
maxlength="500" |
|||
show-word-limit |
|||
:rows="3" |
|||
placeholder="请输入备注,不超过500字" |
|||
v-model="formData.remark"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="位置坐标" |
|||
prop="longitude" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<div style="width:500px"> |
|||
|
|||
<div class="div_map"> |
|||
<div id="app"> |
|||
|
|||
</div> |
|||
<div class="div_searchmap"> |
|||
<el-input class="item_width_4" |
|||
maxlength="50" |
|||
size="mini" |
|||
placeholder="请输入关键字" |
|||
v-model="keyWords"> |
|||
</el-input> |
|||
<el-button style="margin-left: 10px" |
|||
type="primary" |
|||
size="mini" |
|||
@click="handleSearchMap">查询</el-button> |
|||
</div> |
|||
</div> |
|||
|
|||
<div style="margin-top: 10px"> |
|||
<span>经度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入经度" |
|||
v-model="formData.longitude"> |
|||
</el-input> |
|||
<span style="margin-left: 20px">纬度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入纬度" |
|||
v-model="formData.latitude"> |
|||
</el-input> |
|||
</div> |
|||
</div> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="地理位置" |
|||
prop="address" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
|
|||
<el-input class="item_width_1" |
|||
v-model="formData.address"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
</el-form> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="div_btn"> |
|||
<el-button @click="handleCancle">取 消</el-button> |
|||
<el-button v-if="formType != 'detail'" |
|||
type="primary" |
|||
:disabled="btnDisable" |
|||
@click="handleComfirm">确 定</el-button> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
import { requestPost } from '@/js/dai/request' |
|||
|
|||
|
|||
|
|||
var map |
|||
var search |
|||
var markers |
|||
var infoWindowList |
|||
var geocoder // 新建一个正逆地址解析类 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
formType: 'add', //表单操作类型 add新增,edit编辑,detail详情 |
|||
|
|||
btnDisable: false, |
|||
|
|||
unitId: '', |
|||
keyWords: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: 36.0722275, //经度 |
|||
latitude: 120.38945519 //纬度 |
|||
}, |
|||
|
|||
} |
|||
}, |
|||
components: {}, |
|||
mounted () { |
|||
this.initMap() |
|||
}, |
|||
|
|||
methods: { |
|||
|
|||
async initForm (type, unitId) { |
|||
this.$refs.ref_form.resetFields(); |
|||
|
|||
// debugger |
|||
// map.setCenter(new TMap.LatLng(agencyObj.latitude, agencyObj.longitude)) |
|||
|
|||
this.formType = type |
|||
if (unitId) { |
|||
this.unitId = unitId |
|||
this.formData.id = unitId |
|||
await this.loadFormData() |
|||
} |
|||
|
|||
}, |
|||
|
|||
//加载组织 |
|||
async loadFormData () { |
|||
// const url = '/heart/icpartyunit/detail' |
|||
const url = 'http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/detail' |
|||
let params = { |
|||
id: this.unitId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.formData = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
|
|||
|
|||
async handleComfirm () { |
|||
|
|||
this.btnDisable = true |
|||
setTimeout(() => { |
|||
this.btnDisable = false |
|||
}, 10000) |
|||
this.$refs['ref_form'].validate((valid, messageObj) => { |
|||
if (!valid) { |
|||
app.util.validateRule(messageObj) |
|||
this.btnDisable = false |
|||
} else { |
|||
this.addUnit() |
|||
} |
|||
|
|||
}) |
|||
|
|||
|
|||
}, |
|||
async addUnit () { |
|||
// const regPhone = /^1(3|4|5|6|7|8|9)\d{9}$/; //手机号码 |
|||
// if (regPhone.test(this.formData.contactMobile) === false) { |
|||
// this.btnDisable = false |
|||
// this.$message({ |
|||
// type: 'warning', |
|||
// message: '请输入正确的手机号码' |
|||
// }) |
|||
// return false; |
|||
// } |
|||
|
|||
// let url = '/heart/icpartyunit/save' |
|||
let url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/save" |
|||
// if (this.formType === 'edit') { |
|||
// this.formData.id = this.unitId |
|||
// } |
|||
|
|||
const { data, code, msg } = await requestPost(url, this.formData) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '新增联建单位成功' |
|||
}) |
|||
this.resetData() |
|||
this.$emit('dialogOk') |
|||
this.btnDisable = false |
|||
} else { |
|||
this.btnDisable = false |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
handleCancle () { |
|||
|
|||
this.resetData() |
|||
this.$emit('dialogCancle') |
|||
|
|||
}, |
|||
|
|||
// 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|||
initMap () { |
|||
// 定义地图中心点坐标 |
|||
var center = new window.TMap.LatLng(36.0722275, 120.38945519) |
|||
// 定义map变量,调用 TMap.Map() 构造函数创建地图 |
|||
map = new window.TMap.Map(document.getElementById('app'), { |
|||
center: center, // 设置地图中心点坐标 |
|||
zoom: 17.2, // 设置地图缩放级别 |
|||
pitch: 43.5, // 设置俯仰角 |
|||
rotation: 45 // 设置地图旋转角度 |
|||
}) |
|||
|
|||
search = new window.TMap.service.Search({ pageSize: 10 }) |
|||
// 新建一个地点搜索类 |
|||
markers = new TMap.MultiMarker({ |
|||
map: map, |
|||
geometries: [] |
|||
}) |
|||
infoWindowList = Array(10) |
|||
|
|||
geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|||
|
|||
// 监听地图平移结束 |
|||
map.on('panend', () => { |
|||
this.handleMoveCenter() |
|||
}) |
|||
this.handleMoveCenter() |
|||
this.convert() |
|||
}, |
|||
|
|||
setMarker (lat, lng) { |
|||
markers.setGeometries([]) |
|||
markers.add([ |
|||
{ |
|||
id: '4', |
|||
styleId: 'marker', |
|||
position: new TMap.LatLng(lat, lng), |
|||
properties: { |
|||
title: 'marker4' |
|||
} |
|||
} |
|||
]) |
|||
}, |
|||
|
|||
handleSearchMap () { |
|||
infoWindowList.forEach((infoWindow) => { |
|||
infoWindow.close() |
|||
}) |
|||
infoWindowList.length = 0 |
|||
markers.setGeometries([]) |
|||
// 在地图显示范围内以给定的关键字搜索地点 |
|||
search |
|||
.searchRectangle({ |
|||
keyword: this.keyWords, |
|||
bounds: map.getBounds() |
|||
}) |
|||
.then((result) => { |
|||
let { data } = result |
|||
if (Array.isArray(data) && data.length > 0) { |
|||
const { |
|||
location: { lat, lng } |
|||
} = data[0] |
|||
|
|||
|
|||
map.setCenter(new TMap.LatLng(lat, lng)) |
|||
this.setMarker(lat, lng) |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.convert() |
|||
} else { |
|||
this.$message.error('未检索到相关位置坐标') |
|||
} |
|||
}) |
|||
}, |
|||
|
|||
handleMoveCenter () { |
|||
//修改地图中心点 |
|||
const center = map.getCenter() |
|||
const lat = center.getLat() |
|||
const lng = center.getLng() |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.setMarker(lat, lng) |
|||
this.convert(lat, lng) |
|||
}, |
|||
|
|||
convert (lat, lng) { |
|||
markers.setGeometries([]); |
|||
// var input = document.getElementById('location').value.split(','); |
|||
let location |
|||
if (lat && lng) { |
|||
location = new TMap.LatLng(lat, lng); |
|||
} else { |
|||
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude); |
|||
} |
|||
|
|||
// map.setCenter(location); |
|||
markers.updateGeometries([ |
|||
{ |
|||
id: 'main', // 点标注数据数组 |
|||
position: location, |
|||
}, |
|||
]); |
|||
geocoder |
|||
.getAddress({ location: location }) // 将给定的坐标位置转换为地址 |
|||
.then((result) => { |
|||
this.formData.address = result.result.address |
|||
// 显示搜索到的地址 |
|||
}); |
|||
}, |
|||
|
|||
|
|||
resetData () { |
|||
this.unitId = '' |
|||
this.keyWords = '' |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: '', //经度 |
|||
latitude: '' //纬度 |
|||
} |
|||
}, |
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
gridId: [ |
|||
{ required: true, message: '所属网格不能为空', trigger: 'blur' } |
|||
], |
|||
unitName: [ |
|||
{ required: true, message: '单位名称不能为空', trigger: 'blur' }, |
|||
], |
|||
type: [ |
|||
{ required: true, message: '分类不能为空', trigger: 'blur' } |
|||
], |
|||
|
|||
contact: [ |
|||
{ required: true, message: '联系人不能为空', trigger: 'blur' } |
|||
], |
|||
contactMobile: [ |
|||
{ required: true, message: '联系电话不能为空', trigger: 'blur' } |
|||
], |
|||
memberCount: [ |
|||
{ required: true, message: '在职党员数不能为空', trigger: 'blur' } |
|||
], |
|||
address: [ |
|||
{ required: true, message: '详细地址不能为空', trigger: 'blur' } |
|||
], |
|||
longitude: [ |
|||
{ required: true, message: '坐标不能为空', trigger: 'blur' } |
|||
] |
|||
} |
|||
}, |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
gridList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
typeList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
serviceList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.item_width_1 { |
|||
width: 500px; |
|||
} |
|||
.item_width_2 { |
|||
width: 400px; |
|||
} |
|||
.item_width_3 { |
|||
margin-left: 10px; |
|||
width: 200px; |
|||
} |
|||
.item_width_4 { |
|||
width: 200px; |
|||
} |
|||
|
|||
.div_map { |
|||
position: relative; |
|||
} |
|||
.div_searchmap { |
|||
z-index: 5000; |
|||
position: absolute; |
|||
top: 5px; |
|||
left: 5px; |
|||
} |
|||
|
|||
.div_btn { |
|||
display: flex; |
|||
justify-content: flex-end; |
|||
} |
|||
.el-tabs { |
|||
margin: 0 20px; |
|||
} |
|||
.el-upload__tip { |
|||
color: rgb(155, 155, 155); |
|||
margin: 0; |
|||
} |
|||
.form { |
|||
margin-top: 30px; |
|||
} |
|||
</style> |
|||
|
|||
<style lang=scss> |
|||
.el-dialog__body { |
|||
padding: 0 10px 20px !important; |
|||
} |
|||
</style> |
@ -0,0 +1,694 @@ |
|||
<template> |
|||
<div class="div_main"> |
|||
<div class="div_search"> |
|||
<el-form :inline="true" |
|||
:model="formData" |
|||
ref="ref_searchform" |
|||
:label-width="'100px'"> |
|||
<div> |
|||
<el-form-item label="所属网格" |
|||
prop="gridId"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="单位名称" |
|||
prop="unitName"> |
|||
<el-input v-model="formData.unitName" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.serviceMatter" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in serviceList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
</div> |
|||
<div> |
|||
<el-form-item label="分类" |
|||
prop="type"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
clearable> |
|||
<el-option v-for="item in typeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact"> |
|||
<el-input v-model="formData.contact" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile"> |
|||
<el-input v-model="formData.contactMobile" |
|||
class="item_width_1" |
|||
size="small" |
|||
clearable |
|||
placeholder="请输入内容"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
|
|||
<el-button style="margin-left:10px" |
|||
type="primary" |
|||
size="small" |
|||
@click="handleSearch">查询</el-button> |
|||
<el-button style="margin-left:10px" |
|||
type="yellow" |
|||
size="small" |
|||
@click="resetSearch">重置</el-button> |
|||
</div> |
|||
</el-form> |
|||
</div> |
|||
<div class="div_table"> |
|||
<div class="div_btn"> |
|||
<el-button style="float:left" |
|||
type="green" |
|||
size="small" |
|||
@click="handleAdd">新增</el-button> |
|||
<el-upload ref="upload" |
|||
:multiple='false' |
|||
:show-file-list='false' |
|||
:before-upload="beforeUpload" |
|||
action="" |
|||
accept=".xls,.xlsx" |
|||
:limit="1" |
|||
:on-exceed="handleExceed" |
|||
:http-request="uploadFile"> |
|||
<el-button style="margin-left:10px" |
|||
size="small" |
|||
type="red">导入</el-button> |
|||
|
|||
<el-button style="float:left" |
|||
type="yellow" |
|||
size="small" |
|||
@click="handleExport">导出</el-button> |
|||
|
|||
</el-upload> |
|||
|
|||
</div> |
|||
|
|||
<el-table class="table" |
|||
:data="tableData" |
|||
border |
|||
:height="tableHeight" |
|||
v-loading="tableLoading" |
|||
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}" |
|||
style="width: 100%"> |
|||
<el-table-column label="序号" |
|||
header-align="center" |
|||
align="center" |
|||
type="index" |
|||
width="50"></el-table-column> |
|||
<el-table-column prop="gridName" |
|||
header-align="center" |
|||
align="center" |
|||
label="所属网格" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="unitName" |
|||
header-align="center" |
|||
align="center" |
|||
label="单位名称" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="type" |
|||
header-align="center" |
|||
align="center" |
|||
label="分类" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="serviceMatter" |
|||
header-align="center" |
|||
align="center" |
|||
label="服务事项" |
|||
width="180"> |
|||
</el-table-column> |
|||
<el-table-column prop="contact" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系人" |
|||
width="100"> |
|||
</el-table-column> |
|||
<el-table-column prop="contactMobile" |
|||
header-align="center" |
|||
align="center" |
|||
label="联系电话" |
|||
width="110"> |
|||
</el-table-column> |
|||
<el-table-column prop="memberCount" |
|||
header-align="center" |
|||
align="center" |
|||
label="在职党员数" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="satisfaction" |
|||
header-align="center" |
|||
align="center" |
|||
label="群众满意度" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column prop="remark" |
|||
header-align="center" |
|||
align="center" |
|||
label="备注" |
|||
:show-overflow-tooltip="true" |
|||
width="150"> |
|||
</el-table-column> |
|||
<el-table-column label="操作" |
|||
fixed="right" |
|||
width="140" |
|||
header-align="center" |
|||
align="center" |
|||
class="operate"> |
|||
<template slot-scope="scope"> |
|||
|
|||
<el-button type="text" |
|||
style="color:#1C6AFD;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDetail(scope.row)">查看</el-button> |
|||
<el-button type="text" |
|||
style="color:#00A7A9;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleEdit(scope.row)">修改</el-button> |
|||
|
|||
<el-button type="text" |
|||
style="color:#D51010;text-decoration: underline;" |
|||
size="small" |
|||
@click="handleDelete(scope.row)">删除</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<div> |
|||
<el-pagination @size-change="handleSizeChange" |
|||
@current-change="handleCurrentChange" |
|||
:current-page.sync="pageNo" |
|||
:page-sizes="[10, 20, 50]" |
|||
:page-size="pageSize" |
|||
layout="sizes, prev, pager, next, total" |
|||
:total="total"> |
|||
</el-pagination> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- 修改弹出框 --> |
|||
<el-dialog :visible.sync="formShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
:title="formTitle" |
|||
width="850px" |
|||
top="5vh" |
|||
@closed="diaClose"> |
|||
<units-form ref="ref_form" |
|||
:gridList="gridList" |
|||
:serviceList="serviceList" |
|||
:typeList="typeList" |
|||
@dialogCancle="addFormCancle" |
|||
@dialogOk="addFormOk"></units-form> |
|||
</el-dialog> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
|
|||
import unitsForm from './unitsForm' |
|||
|
|||
import { requestPost } from "@/js/dai/request"; |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
loading: false, |
|||
total: 0, |
|||
pageSize: 10, |
|||
pageNo: 0, |
|||
tableLoading: false, |
|||
agencyId: '', |
|||
gridList: [],//所属网格list |
|||
unitList: [],//单位list |
|||
serviceList: [ |
|||
{ |
|||
id: "1", |
|||
name: '积极配合社区安全巡查员进行场所消防、安全等方面的检查。' |
|||
}, |
|||
{ |
|||
id: "2", |
|||
name: '积极配合' |
|||
}, |
|||
{ |
|||
id: "3", |
|||
name: '积极配合社区安全巡查员进行' |
|||
}, |
|||
{ |
|||
id: "4", |
|||
name: '积极配合社区安全巡查员进行场所消防、安全等方面的检查。并具备安全意识及设备设施' |
|||
}, |
|||
],//服务list |
|||
typeList: [],//分类list |
|||
|
|||
unitId: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
}, |
|||
|
|||
tableData: [], |
|||
|
|||
//form相关 |
|||
formShow: false, |
|||
formTitle: '新增单位', |
|||
|
|||
files: "", |
|||
fileName: "", |
|||
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import' |
|||
|
|||
} |
|||
}, |
|||
components: { |
|||
unitsForm |
|||
}, |
|||
async created () { |
|||
|
|||
}, |
|||
async mounted () { |
|||
//获取服务事项 |
|||
await this.loadService() |
|||
|
|||
//获取分类 |
|||
await this.loadType() |
|||
|
|||
const { user } = this.$store.state |
|||
this.agencyId = user.agencyId |
|||
//获取网格下拉框数据 |
|||
await this.loadGrid() |
|||
|
|||
await this.loadTable() |
|||
}, |
|||
|
|||
methods: { |
|||
handleSearch () { |
|||
this.loadTable() |
|||
}, |
|||
|
|||
async loadGrid () { |
|||
const url = "/gov/org/customergrid/gridoption" |
|||
|
|||
let params = { |
|||
agencyId: this.agencyId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.gridList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
//获取服务事项下拉框 |
|||
async loadService () { |
|||
// const url = "/heart/icresidemanddict/subcodelist" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icresidemanddict/subcodelist" |
|||
|
|||
let params = { |
|||
parentCategoryCode: '1010' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.serviceList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
//获取分类 |
|||
async loadType () { |
|||
const url = "/sys/dict/data/dictlist" |
|||
|
|||
let params = { |
|||
dictType: 'party_unit_type' |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.typeList = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
async loadTable () { |
|||
this.tableLoading = true |
|||
|
|||
// const url = "/heart/icpartyunit/list" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/list" |
|||
let params = { |
|||
pageSize: this.pageSize, |
|||
pageNo: this.pageNo, |
|||
agencyId: this.agencyId, |
|||
...this.formData |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.total = data.total |
|||
this.tableData = data.list |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
this.tableLoading = false |
|||
}, |
|||
|
|||
|
|||
|
|||
diaClose () { |
|||
this.$refs.ref_form.resetData() |
|||
this.formShow = false |
|||
}, |
|||
|
|||
handleDetail (row) { |
|||
this.formTitle = '详情' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('detail', row.id) |
|||
}) |
|||
}, |
|||
|
|||
handleAdd () { |
|||
this.formTitle = '新增' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('add', null) |
|||
}) |
|||
}, |
|||
|
|||
handleEdit (row) { |
|||
this.formTitle = '修改' |
|||
this.formShow = true |
|||
this.$nextTick(() => { |
|||
this.$refs.ref_form.initForm('edit', row.id) |
|||
}) |
|||
}, |
|||
|
|||
addFormCancle () { |
|||
this.formShow = false |
|||
}, |
|||
addFormOk () { |
|||
this.formShow = false |
|||
this.loadTable() |
|||
|
|||
}, |
|||
|
|||
async handleDelete (row) { |
|||
|
|||
this.$confirm("确认删除?", "提示", { |
|||
confirmButtonText: "确定", |
|||
cancelButtonText: "取消", |
|||
type: "warning" |
|||
}) |
|||
.then(() => { |
|||
this.deleteUnit(row) |
|||
}) |
|||
.catch(err => { |
|||
if (err == "cancel") { |
|||
|
|||
} |
|||
|
|||
}); |
|||
}, |
|||
|
|||
async deleteUnit (row) { |
|||
// const url = "/heart/icpartyunit/delete" |
|||
const url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/delete" |
|||
|
|||
let params = { |
|||
id: row.id |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "删除成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
//重置搜索条件 |
|||
resetSearch () { |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: '', |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '' |
|||
} |
|||
}, |
|||
|
|||
//导出表格 |
|||
async handleExport () { |
|||
let title = '联建单位列表' |
|||
|
|||
|
|||
const url = "/partyunit/export" |
|||
let params = { |
|||
ownerName: this.ownerName, |
|||
ownerPhone: this.ownerPhone, |
|||
level: this.agencyObj.level, |
|||
id: this.agencyObj.id |
|||
} |
|||
|
|||
app.ajax.exportFilePost( |
|||
url, |
|||
params, |
|||
(data, rspMsg) => { |
|||
|
|||
this.download(data, title + '.xls') |
|||
}, |
|||
(rspMsg, data) => { |
|||
this.$message.error(rspMsg); |
|||
} |
|||
); |
|||
|
|||
}, |
|||
|
|||
// 下载文件 |
|||
download (data, fileName) { |
|||
if (!data) { |
|||
return |
|||
} |
|||
|
|||
var csvData = new Blob([data]) |
|||
|
|||
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|||
window.navigator.msSaveOrOpenBlob(csvData, fileName); |
|||
} |
|||
// for Non-IE (chrome, firefox etc.) |
|||
else { |
|||
var a = document.createElement('a'); |
|||
document.body.appendChild(a); |
|||
a.style = 'display: none'; |
|||
var url = window.URL.createObjectURL(csvData); |
|||
a.href = url; |
|||
a.download = fileName; |
|||
a.click(); |
|||
a.remove(); |
|||
window.URL.revokeObjectURL(url); |
|||
} |
|||
|
|||
}, |
|||
|
|||
// 上传文件之前的钩子 |
|||
beforeUpload (file) { |
|||
this.files = file; |
|||
|
|||
const isText = file.type === 'application/vnd.ms-excel' |
|||
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|||
|
|||
if (!isText && !isTextComputer) { |
|||
this.$message.error('请选择正确格式的文件') |
|||
return false |
|||
} else { |
|||
this.fileName = file.name; |
|||
return true |
|||
} |
|||
|
|||
}, |
|||
// 上传文件个数超过定义的数量 |
|||
handleExceed (files, fileList) { |
|||
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|||
}, |
|||
|
|||
async uploadFile () { |
|||
this.loading = true |
|||
|
|||
if (this.fileName == "") { |
|||
this.$message.warning('请选择要上传的文件!') |
|||
return false |
|||
} |
|||
|
|||
//清空上传列表 |
|||
this.$refs['upload'].clearFiles() |
|||
|
|||
var url = '/partyunit/import' |
|||
let fileFormData = new FormData(); |
|||
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|||
|
|||
const { data, code, msg } = await requestPost(url, fileFormData) |
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: "success", |
|||
message: "导入成功" |
|||
}); |
|||
|
|||
this.loadTable() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
|
|||
}, |
|||
|
|||
handleSizeChange (val) { |
|||
this.pageSize = val |
|||
this.pageNo = 1 |
|||
this.loadTable() |
|||
}, |
|||
handleCurrentChange (val) { |
|||
this.pageNo = val |
|||
this.loadTable() |
|||
}, |
|||
|
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
tableHeight () { |
|||
|
|||
return (this.clientHeight - 460) |
|||
|
|||
}, |
|||
rowHeight () { |
|||
return (this.clientHeight - 200) + 'px' |
|||
}, |
|||
...mapGetters(['clientHeight']) |
|||
}, |
|||
watch: { |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss" scoped > |
|||
@import "@/assets/scss/buttonstyle.scss"; |
|||
|
|||
.div_main { |
|||
width: 100%; |
|||
} |
|||
|
|||
.div_search { |
|||
background: #ffffff; |
|||
border-radius: 4px; |
|||
padding: 35px 20px; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
} |
|||
|
|||
.item_width_1 { |
|||
width: 260px; |
|||
} |
|||
|
|||
.div_table { |
|||
background: #ffffff; |
|||
box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1); |
|||
border-radius: 4px; |
|||
margin-top: 20px; |
|||
padding: 23px 30px 10px; |
|||
|
|||
.table { |
|||
margin-top: 20px; |
|||
} |
|||
} |
|||
|
|||
.div_btn { |
|||
} |
|||
|
|||
.el-row { |
|||
/* margin-bottom: 20px; */ |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
margin-top: 10px; |
|||
margin-right: 50px; |
|||
} |
|||
</style> |
@ -0,0 +1,553 @@ |
|||
<template> |
|||
<div> |
|||
<div> |
|||
<div> |
|||
<el-form ref="ref_form" |
|||
:inline="true" |
|||
:model="formData" |
|||
:rules="dataRule" |
|||
:disabled="formType === 'detail'" |
|||
class="form"> |
|||
|
|||
<el-form-item label="所属网格" |
|||
prop="gridId" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.gridId" |
|||
placeholder="全部" |
|||
clearable> |
|||
<el-option v-for="item in gridList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="单位名称" |
|||
prop="unitName" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
maxlength="50" |
|||
show-word-limit |
|||
placeholder="请输入单位名称" |
|||
v-model="formData.unitName"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="分类" |
|||
prop="type" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-select class="item_width_1" |
|||
v-model="formData.type" |
|||
placeholder="请选择" |
|||
filterable |
|||
clearable> |
|||
<el-option v-for="item in typeList" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="服务事项" |
|||
prop="serviceMatter" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-checkbox-group class="item_width_1" |
|||
style="display:flex;flex-wrap:wrap" |
|||
v-model="formData.serviceMatter"> |
|||
<el-checkbox v-for="item in serviceList" |
|||
:key="item.value" |
|||
:label="item.value">{{item.label}}</el-checkbox> |
|||
|
|||
</el-checkbox-group> |
|||
|
|||
</el-form-item> |
|||
<el-form-item label="联系人" |
|||
prop="contact" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人姓名" |
|||
v-model="formData.contact"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="联系电话" |
|||
prop="contactMobile" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
placeholder="请输入联系人电话" |
|||
v-model="formData.contactMobile"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="在职党员" |
|||
style="display: block" |
|||
prop="memberCount" |
|||
label-width="150px"> |
|||
<el-input-number class="item_width_1" |
|||
v-model="formData.memberCount" |
|||
:min="1" |
|||
label="单元数"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="备注" |
|||
prop="remark" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<el-input class="item_width_1" |
|||
type="textarea" |
|||
maxlength="500" |
|||
show-word-limit |
|||
:rows="3" |
|||
placeholder="请输入备注,不超过500字" |
|||
v-model="formData.remark"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="位置坐标" |
|||
prop="longitude" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
<div style="width:500px"> |
|||
|
|||
<div class="div_map"> |
|||
<div id="app"> |
|||
|
|||
</div> |
|||
<div class="div_searchmap"> |
|||
<el-input class="item_width_4" |
|||
maxlength="50" |
|||
size="mini" |
|||
placeholder="请输入关键字" |
|||
v-model="keyWords"> |
|||
</el-input> |
|||
<el-button style="margin-left: 10px" |
|||
type="primary" |
|||
size="mini" |
|||
@click="handleSearchMap">查询</el-button> |
|||
</div> |
|||
</div> |
|||
|
|||
<div style="margin-top: 10px"> |
|||
<span>经度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入经度" |
|||
v-model="formData.longitude"> |
|||
</el-input> |
|||
<span style="margin-left: 20px">纬度</span> |
|||
<el-input class="item_width_3" |
|||
maxlength="50" |
|||
placeholder="请输入纬度" |
|||
v-model="formData.latitude"> |
|||
</el-input> |
|||
</div> |
|||
</div> |
|||
</el-form-item> |
|||
|
|||
<el-form-item label="地理位置" |
|||
prop="address" |
|||
label-width="150px" |
|||
style="display: block"> |
|||
|
|||
<el-input class="item_width_1" |
|||
v-model="formData.address"> |
|||
</el-input> |
|||
|
|||
</el-form-item> |
|||
</el-form> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="div_btn"> |
|||
<el-button @click="handleCancle">取 消</el-button> |
|||
<el-button v-if="formType != 'detail'" |
|||
type="primary" |
|||
:disabled="btnDisable" |
|||
@click="handleComfirm">确 定</el-button> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapGetters } from 'vuex' |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
import { requestPost } from '@/js/dai/request' |
|||
|
|||
|
|||
|
|||
var map |
|||
var search |
|||
var markers |
|||
var infoWindowList |
|||
var geocoder // 新建一个正逆地址解析类 |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data () { |
|||
return { |
|||
formType: 'add', //表单操作类型 add新增,edit编辑,detail详情 |
|||
|
|||
btnDisable: false, |
|||
|
|||
unitId: '', |
|||
keyWords: '', |
|||
formData: { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: 36.0722275, //经度 |
|||
latitude: 120.38945519 //纬度 |
|||
}, |
|||
|
|||
} |
|||
}, |
|||
components: {}, |
|||
mounted () { |
|||
this.initMap() |
|||
}, |
|||
|
|||
methods: { |
|||
|
|||
async initForm (type, unitId) { |
|||
this.$refs.ref_form.resetFields(); |
|||
|
|||
// debugger |
|||
// map.setCenter(new TMap.LatLng(agencyObj.latitude, agencyObj.longitude)) |
|||
|
|||
this.formType = type |
|||
if (unitId) { |
|||
this.unitId = unitId |
|||
this.formData.id = unitId |
|||
await this.loadFormData() |
|||
} |
|||
|
|||
}, |
|||
|
|||
//加载组织 |
|||
async loadFormData () { |
|||
// const url = '/heart/icpartyunit/detail' |
|||
const url = 'http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/detail' |
|||
let params = { |
|||
id: this.unitId |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, params) |
|||
|
|||
if (code === 0) { |
|||
this.formData = data |
|||
|
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
|
|||
|
|||
async handleComfirm () { |
|||
|
|||
this.btnDisable = true |
|||
setTimeout(() => { |
|||
this.btnDisable = false |
|||
}, 10000) |
|||
this.$refs['ref_form'].validate((valid, messageObj) => { |
|||
if (!valid) { |
|||
app.util.validateRule(messageObj) |
|||
this.btnDisable = false |
|||
} else { |
|||
this.addUnit() |
|||
} |
|||
|
|||
}) |
|||
|
|||
|
|||
}, |
|||
async addUnit () { |
|||
// const regPhone = /^1(3|4|5|6|7|8|9)\d{9}$/; //手机号码 |
|||
// if (regPhone.test(this.formData.contactMobile) === false) { |
|||
// this.btnDisable = false |
|||
// this.$message({ |
|||
// type: 'warning', |
|||
// message: '请输入正确的手机号码' |
|||
// }) |
|||
// return false; |
|||
// } |
|||
|
|||
// let url = '/heart/icpartyunit/save' |
|||
let url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyunit/save" |
|||
// if (this.formType === 'edit') { |
|||
// this.formData.id = this.unitId |
|||
// } |
|||
|
|||
const { data, code, msg } = await requestPost(url, this.formData) |
|||
|
|||
if (code === 0) { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '新增联建单位成功' |
|||
}) |
|||
this.resetData() |
|||
this.$emit('dialogOk') |
|||
this.btnDisable = false |
|||
} else { |
|||
this.btnDisable = false |
|||
this.$message.error(msg) |
|||
} |
|||
|
|||
}, |
|||
|
|||
handleCancle () { |
|||
|
|||
this.resetData() |
|||
this.$emit('dialogCancle') |
|||
|
|||
}, |
|||
|
|||
// 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|||
initMap () { |
|||
// 定义地图中心点坐标 |
|||
var center = new window.TMap.LatLng(36.0722275, 120.38945519) |
|||
// 定义map变量,调用 TMap.Map() 构造函数创建地图 |
|||
map = new window.TMap.Map(document.getElementById('app'), { |
|||
center: center, // 设置地图中心点坐标 |
|||
zoom: 17.2, // 设置地图缩放级别 |
|||
pitch: 43.5, // 设置俯仰角 |
|||
rotation: 45 // 设置地图旋转角度 |
|||
}) |
|||
|
|||
search = new window.TMap.service.Search({ pageSize: 10 }) |
|||
// 新建一个地点搜索类 |
|||
markers = new TMap.MultiMarker({ |
|||
map: map, |
|||
geometries: [] |
|||
}) |
|||
infoWindowList = Array(10) |
|||
|
|||
geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|||
|
|||
// 监听地图平移结束 |
|||
map.on('panend', () => { |
|||
this.handleMoveCenter() |
|||
}) |
|||
this.handleMoveCenter() |
|||
this.convert() |
|||
}, |
|||
|
|||
setMarker (lat, lng) { |
|||
markers.setGeometries([]) |
|||
markers.add([ |
|||
{ |
|||
id: '4', |
|||
styleId: 'marker', |
|||
position: new TMap.LatLng(lat, lng), |
|||
properties: { |
|||
title: 'marker4' |
|||
} |
|||
} |
|||
]) |
|||
}, |
|||
|
|||
handleSearchMap () { |
|||
infoWindowList.forEach((infoWindow) => { |
|||
infoWindow.close() |
|||
}) |
|||
infoWindowList.length = 0 |
|||
markers.setGeometries([]) |
|||
// 在地图显示范围内以给定的关键字搜索地点 |
|||
search |
|||
.searchRectangle({ |
|||
keyword: this.keyWords, |
|||
bounds: map.getBounds() |
|||
}) |
|||
.then((result) => { |
|||
let { data } = result |
|||
if (Array.isArray(data) && data.length > 0) { |
|||
const { |
|||
location: { lat, lng } |
|||
} = data[0] |
|||
|
|||
|
|||
map.setCenter(new TMap.LatLng(lat, lng)) |
|||
this.setMarker(lat, lng) |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.convert() |
|||
} else { |
|||
this.$message.error('未检索到相关位置坐标') |
|||
} |
|||
}) |
|||
}, |
|||
|
|||
handleMoveCenter () { |
|||
//修改地图中心点 |
|||
const center = map.getCenter() |
|||
const lat = center.getLat() |
|||
const lng = center.getLng() |
|||
this.formData.latitude = lat |
|||
this.formData.longitude = lng |
|||
this.setMarker(lat, lng) |
|||
this.convert(lat, lng) |
|||
}, |
|||
|
|||
convert (lat, lng) { |
|||
markers.setGeometries([]); |
|||
// var input = document.getElementById('location').value.split(','); |
|||
let location |
|||
if (lat && lng) { |
|||
location = new TMap.LatLng(lat, lng); |
|||
} else { |
|||
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude); |
|||
} |
|||
|
|||
// map.setCenter(location); |
|||
markers.updateGeometries([ |
|||
{ |
|||
id: 'main', // 点标注数据数组 |
|||
position: location, |
|||
}, |
|||
]); |
|||
geocoder |
|||
.getAddress({ location: location }) // 将给定的坐标位置转换为地址 |
|||
.then((result) => { |
|||
this.formData.address = result.result.address |
|||
// 显示搜索到的地址 |
|||
}); |
|||
}, |
|||
|
|||
|
|||
resetData () { |
|||
this.unitId = '' |
|||
this.keyWords = '' |
|||
this.formData = { |
|||
gridId: '', |
|||
unitName: '', |
|||
serviceMatter: [], |
|||
type: '', |
|||
contact: '', |
|||
contactMobile: '', |
|||
memberCount: 0, |
|||
remark: '', //备注【最大500字】 |
|||
address: '', //详细地址 |
|||
longitude: '', //经度 |
|||
latitude: '' //纬度 |
|||
} |
|||
}, |
|||
// 开启加载动画 |
|||
startLoading () { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading () { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
gridId: [ |
|||
{ required: true, message: '所属网格不能为空', trigger: 'blur' } |
|||
], |
|||
unitName: [ |
|||
{ required: true, message: '单位名称不能为空', trigger: 'blur' }, |
|||
], |
|||
type: [ |
|||
{ required: true, message: '分类不能为空', trigger: 'blur' } |
|||
], |
|||
|
|||
contact: [ |
|||
{ required: true, message: '联系人不能为空', trigger: 'blur' } |
|||
], |
|||
contactMobile: [ |
|||
{ required: true, message: '联系电话不能为空', trigger: 'blur' } |
|||
], |
|||
memberCount: [ |
|||
{ required: true, message: '在职党员数不能为空', trigger: 'blur' } |
|||
], |
|||
address: [ |
|||
{ required: true, message: '详细地址不能为空', trigger: 'blur' } |
|||
], |
|||
longitude: [ |
|||
{ required: true, message: '坐标不能为空', trigger: 'blur' } |
|||
] |
|||
} |
|||
}, |
|||
|
|||
}, |
|||
props: { |
|||
|
|||
gridList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
typeList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
serviceList: { |
|||
type: Array, |
|||
default: [] |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.item_width_1 { |
|||
width: 500px; |
|||
} |
|||
.item_width_2 { |
|||
width: 400px; |
|||
} |
|||
.item_width_3 { |
|||
margin-left: 10px; |
|||
width: 200px; |
|||
} |
|||
.item_width_4 { |
|||
width: 200px; |
|||
} |
|||
|
|||
.div_map { |
|||
position: relative; |
|||
} |
|||
.div_searchmap { |
|||
z-index: 5000; |
|||
position: absolute; |
|||
top: 5px; |
|||
left: 5px; |
|||
} |
|||
|
|||
.div_btn { |
|||
display: flex; |
|||
justify-content: flex-end; |
|||
} |
|||
.el-tabs { |
|||
margin: 0 20px; |
|||
} |
|||
.el-upload__tip { |
|||
color: rgb(155, 155, 155); |
|||
margin: 0; |
|||
} |
|||
.form { |
|||
margin-top: 30px; |
|||
} |
|||
</style> |
|||
|
|||
<style lang=scss> |
|||
.el-dialog__body { |
|||
padding: 0 10px 20px !important; |
|||
} |
|||
</style> |
Loading…
Reference in new issue