You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
594 lines
16 KiB
594 lines
16 KiB
<template>
|
|
<el-dialog :visible="visible"
|
|
:title="'新增党组织'"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="true"
|
|
@close="handleDlgClose">
|
|
<el-form class="form"
|
|
:model="dataForm"
|
|
:rules="dataRule"
|
|
ref="dataForm"
|
|
@keyup.enter.native=""
|
|
:label-width="$i18n.locale === 'en-US' ? '120px' : '100px'">
|
|
|
|
<el-form-item prop="partyOrgLevel"
|
|
label="党组织类型">
|
|
<el-select v-model="dataForm.partyOrgLevel"
|
|
@change="handlePartyOrgLevelSelected"
|
|
clearable
|
|
placeholder="请选择">
|
|
<el-option
|
|
v-for="level in partyOrgLevels"
|
|
:key="level.levelCode"
|
|
:label="level.levelName"
|
|
:value="level.levelCode">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="partyOrgPid"
|
|
label="上级党组织">
|
|
<el-select v-model="dataForm.partyOrgPid"
|
|
@change="handleParentPartyOrgSelected"
|
|
clearable
|
|
placeholder="请选择">
|
|
<el-option
|
|
v-for="org in parentPartyOrgs"
|
|
:key="org.id"
|
|
:label="org.partyOrgName"
|
|
:value="org.id">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="orgId"
|
|
label="行政组织"
|
|
v-show="xingzhengSelectorVisible">
|
|
<el-select v-model="dataForm.orgId"
|
|
@change="handleXingzhengOrgSelected"
|
|
value-key="orgId"
|
|
clearable
|
|
placeholder="请选择">
|
|
<el-option
|
|
v-for="org in xingzhengOrgs"
|
|
:key="org.orgId"
|
|
:label="org.orgName"
|
|
:value="org.orgId">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="principalId"
|
|
label="负责人">
|
|
<el-select v-model="dataForm.principalId"
|
|
@change=""
|
|
clearable
|
|
placeholder="请选择">
|
|
<el-option
|
|
v-for="principal in principals"
|
|
:key="principal.principalId"
|
|
:label="principal.principalName"
|
|
:value="principal.principalId">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="partyOrgName"
|
|
label="党组织名称">
|
|
<el-input v-model="dataForm.partyOrgName"
|
|
placeholder="请输入党组织名称"
|
|
style="width: 300px"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="description" label="党组织介绍">
|
|
<el-input
|
|
type="textarea"
|
|
:rows="2"
|
|
placeholder="请输入党组织介绍"
|
|
v-model="dataForm.description">
|
|
</el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="地图位置"
|
|
prop="longitude"
|
|
style="display: block">
|
|
<div style="width: 500px">
|
|
<el-select v-model="searchValue"
|
|
filterable
|
|
style="width: 500px"
|
|
remote
|
|
:reserve-keyword="true"
|
|
placeholder="请输入位置关键词"
|
|
:remote-method="searchOnMap"
|
|
:loading="mapLoading">
|
|
<el-option v-for="(item,index) in mapSearchResultList"
|
|
@click.native="handleMapSearchResultSelected(index)"
|
|
:key="index"
|
|
:label="item.label"
|
|
:value="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
<div id="partyOrgMap"
|
|
class="div_map"></div>
|
|
</div>
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
<template slot="footer">
|
|
<el-button @click="handleDlgClose">取消</el-button>
|
|
<el-button type="primary" @click="handleSubmitCreate">确定</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
<script>
|
|
var map
|
|
var search
|
|
var markers
|
|
var infoWindowList
|
|
var geocoder // 新建一个正逆地址解析类
|
|
import debounce from 'lodash/debounce'
|
|
import { requestGet, requestPost } from "@/js/dai/request";
|
|
import { EpmetResultResolver } from '@/js/epmet-result-resolver'
|
|
import { number } from 'echarts'
|
|
import daiMap from "@/utils/dai-map";
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
operation: 'create', // 新建createNew ;新建下级createSubOrg
|
|
dataForm: this.initForm(),
|
|
// 党组织类型下拉框
|
|
partyOrgLevels: [],
|
|
// 父级党组织
|
|
parentPartyOrgs: [],
|
|
|
|
// 行政组织列表
|
|
xingzhengOrgs: [],
|
|
principals: [], // 负责人列表
|
|
xingzhengSelectorVisible: true, // 行政组织是否可见
|
|
|
|
// 地图
|
|
searchValue: '',
|
|
mapLoading: false, // 地图加载
|
|
mapSearchResultList: [], // 地图搜索结果列表
|
|
epmetResultResolver: null, // epmet请求结果解析器
|
|
visible: false,
|
|
}
|
|
},
|
|
mounted () {
|
|
this.epmetResultResolver = new EpmetResultResolver(this);
|
|
},
|
|
methods: {
|
|
/**
|
|
* 初始化
|
|
* @param parentPartyOrgLevel 非必填,父党组织级别的level,在添加下级党组织的时候传递,否则为空
|
|
* @param parentPartyOrgId 非必填,父党组织级别的ID,在添加下级党组织的时候传递,否则为空
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async init (operation, parentPartyOrgLevel, parentPartyOrgId) {
|
|
if (operation) {
|
|
this.operation = operation;
|
|
}
|
|
|
|
this.visible = true;
|
|
|
|
// 加载党组织级别下拉框
|
|
this.loadPartyOrgLevels(parentPartyOrgLevel);
|
|
|
|
// 如果传递了党组织id,operation=createSubOrg,新增下级,
|
|
if (operation === 'createSubOrg' && parentPartyOrgId) {
|
|
|
|
// async异步函数的返回值,如果是正常值或者是对象,则需要通过then()指定回调函数来获取返回值
|
|
await this.getPartyOrgDetail(parentPartyOrgId).then(resp => {
|
|
this.parentPartyOrgs.push(resp);
|
|
this.dataForm.partyOrgPid = parentPartyOrgId;
|
|
|
|
});
|
|
}
|
|
|
|
// 初始化地图
|
|
let { latitude, longitude } = this.$store.state.user;
|
|
|
|
this.$nextTick(() => {
|
|
if(!map){
|
|
this.initMap(latitude, longitude);
|
|
|
|
}else{
|
|
map.setCenter(latitude, longitude);
|
|
map.setMarker(latitude, longitude);
|
|
}
|
|
})
|
|
},
|
|
|
|
// 初始化地图
|
|
initMap (latitude, longitude) {
|
|
let d = document.getElementById("partyOrgMap");
|
|
console.log("地图div:" + d);
|
|
map = new daiMap(
|
|
document.getElementById("partyOrgMap"),
|
|
{ latitude, longitude },
|
|
{
|
|
zoom: 16.2, // 设置地图缩放级别
|
|
pitch: 43.5, // 设置俯仰角
|
|
rotation: 45, // 设置地图旋转角度
|
|
}
|
|
);
|
|
|
|
// 监听地图平移结束事件
|
|
map.on("dragend", (e) => {
|
|
this.handleMoveCenter(e);
|
|
});
|
|
|
|
// 设置地图默认经纬度中心店和标记
|
|
map.setCenter(latitude, longitude);
|
|
map.setMarker(latitude, longitude);
|
|
},
|
|
|
|
/**
|
|
* 重置
|
|
*/
|
|
initForm() {
|
|
this.partyOrgLevels = [];
|
|
this.parentPartyOrgs = [];
|
|
this.principals = [];
|
|
this.xingzhengOrgs = [];
|
|
this.searchValue = null;
|
|
|
|
return {
|
|
partyOrgPid: null,
|
|
partyOrgName: null,
|
|
partyOrgLevel: null,
|
|
principalId: null,
|
|
orgId: null, // 行政组织id
|
|
description: null,
|
|
longitude: null,
|
|
latitude: null,
|
|
address: null
|
|
};
|
|
},
|
|
|
|
// 加载党组织类型下拉框
|
|
async loadPartyOrgLevels(parentPartyOrgLevel) {
|
|
let url = "/actual/base/party/org/listPartyOrgLevels";
|
|
let rst = await requestGet(url, {
|
|
parentPartyOrgLevel: parentPartyOrgLevel
|
|
});
|
|
|
|
this.epmetResultResolver
|
|
.success((data) => {
|
|
this.partyOrgLevels = data;
|
|
})
|
|
.parse(rst);
|
|
},
|
|
|
|
/**
|
|
* 加载上级党组织
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async loadParentPartyOrgs(partyOrgLevel) {
|
|
let url = "/actual/base/party/org/listParentPartyOrg";
|
|
let rst = await requestGet(url, {
|
|
partyOrgLevel: partyOrgLevel
|
|
})
|
|
|
|
this.parentPartyOrgs = [];
|
|
this.principals = [];
|
|
this.xingzhengOrgs = [];
|
|
|
|
this.dataForm.partyOrgPid = null;
|
|
this.dataForm.principalId = null;
|
|
this.dataForm.orgId = null;
|
|
|
|
this.epmetResultResolver.success((data) => {
|
|
this.parentPartyOrgs = data;
|
|
}).parse(rst);
|
|
},
|
|
|
|
/**
|
|
* 党组织级别选中事件
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async handlePartyOrgLevelSelected() {
|
|
this.dataForm.orgId = null;
|
|
|
|
// 加载上级党组织。只在新增的时候加载,新增下级的时候,不加载,init函数中已经固定了上级党组织
|
|
if (this.operation === 'createNew') {
|
|
this.loadParentPartyOrgs(this.dataForm.partyOrgLevel);
|
|
}
|
|
|
|
// 如果是新增下级组织,那么在选了level之后,要加载行政组织
|
|
if (this.operation === 'createSubOrg') {
|
|
this.loadXingzhengOrgs();
|
|
}
|
|
|
|
// 级别为党总支及以下,则隐藏行政组织下拉框
|
|
if (this.dataForm.partyOrgLevel >= 6) {
|
|
this.xingzhengSelectorVisible = false;
|
|
} else {
|
|
this.xingzhengSelectorVisible = true;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 上级党组织选中事件,
|
|
* 加载下级行政组织
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async handleParentPartyOrgSelected() {
|
|
if (!this.dataForm.partyOrgLevel || !this.dataForm.partyOrgPid) {
|
|
return;
|
|
}
|
|
|
|
await this.loadXingzhengOrgs();
|
|
|
|
// if (this.dataForm.partyOrgPid === '0') {
|
|
// // 根级党组织
|
|
// this.dataForm.orgId = this.xingzhengOrgs[0].orgId;
|
|
// }
|
|
},
|
|
|
|
/**
|
|
* 加载候选人选项列表
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async handleXingzhengOrgSelected() {
|
|
if (!this.dataForm.orgId) {
|
|
return;
|
|
}
|
|
|
|
this.loadPrincipals();
|
|
},
|
|
|
|
/**
|
|
* 加载负责人
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async loadPrincipals() {
|
|
let url = "/actual/base/party/org/listPrincipal";
|
|
let rst = await requestGet(url, {
|
|
orgId: this.dataForm.orgId,
|
|
partyOrgLevel: this.dataForm.partyOrgLevel
|
|
});
|
|
|
|
this.epmetResultResolver
|
|
.success((data) => {
|
|
this.principals = data;
|
|
})
|
|
.parse(rst);
|
|
},
|
|
|
|
/**
|
|
* 对话框关闭事件
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async handleDlgClose() {
|
|
this.visible = false;
|
|
this.$emit("update:visiable", false);
|
|
this.initForm();
|
|
this.$refs.dataForm.resetFields();
|
|
this.xingzhengSelectorVisible = true;
|
|
},
|
|
|
|
/**
|
|
* 提交表单事件
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async handleSubmitCreate() {
|
|
|
|
this.$refs.dataForm.validate((success) => {
|
|
if (success) {
|
|
this.submitCreatePartyOrg();
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 执行提交
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async submitCreatePartyOrg() {
|
|
let url = "/actual/base/party/org/create";
|
|
|
|
let params = {
|
|
...this.dataForm
|
|
}
|
|
|
|
let rst = await requestPost(url, params)
|
|
|
|
this.epmetResultResolver
|
|
.success((data) => {
|
|
this.$message.success("提交成功");
|
|
this.handleDlgClose(); // 关闭对话框
|
|
this.$emit("refreshTree")
|
|
})
|
|
.parse(rst);
|
|
},
|
|
|
|
// 地图搜索
|
|
async searchOnMap (query) {
|
|
|
|
if (query !== '') {
|
|
this.mapLoading = true;
|
|
|
|
const { msg, data } = await map.searchNearby(query);
|
|
this.mapLoading = false;
|
|
this.mapSearchResultList = []
|
|
|
|
if (msg == "success" && data.resultList && data.resultList.length > 0) {
|
|
|
|
// this.mapSearchResultList = data.resultList
|
|
this.mapSearchResultList = data.resultList.map(item => {
|
|
return { value: `${item.id}`, label: `${item.address + item.name}`,location:item.location };
|
|
});
|
|
} else {
|
|
this.mapSearchResultList = [
|
|
{
|
|
value: '0',
|
|
label: '未检索到结果'
|
|
}
|
|
]
|
|
}
|
|
} else {
|
|
this.mapSearchResultList = [];
|
|
}
|
|
},
|
|
|
|
// 地图中心点移动
|
|
async handleMoveCenter () {
|
|
//修改地图中心点
|
|
const { lat, lng } = map.getCenter();
|
|
this.dataForm.latitude = lat;
|
|
this.dataForm.longitude = lng;
|
|
map.setMarker(lat, lng);
|
|
|
|
let { msg, data } = await map.getAddress(lat, lng);
|
|
if (msg == "success") {
|
|
this.dataForm.address = data.address
|
|
this.searchValue = data.address
|
|
this.mapSearchResultList = []
|
|
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 地图文本搜索,选中
|
|
* @param index
|
|
*/
|
|
handleMapSearchResultSelected (index) {
|
|
console.log(index)
|
|
console.log(this.mapSearchResultList);;
|
|
let selPosition = this.mapSearchResultList[index]
|
|
let {lat,lng} = selPosition.location
|
|
map.setCenter(lat, lng);
|
|
map.setMarker(lat, lng);
|
|
this.dataForm.latitude = lat;
|
|
this.dataForm.longitude = lng;
|
|
console.log(selPosition);
|
|
this.dataForm.address = selPosition.label
|
|
},
|
|
|
|
/**
|
|
* 党组织详情
|
|
* @param partyOrgId
|
|
* @returns {Promise<*>}
|
|
*/
|
|
async getPartyOrgDetail(partyOrgId) {
|
|
let url = "/actual/base/party/org/brief";
|
|
|
|
let params = {
|
|
id: partyOrgId
|
|
}
|
|
|
|
let rst = await requestGet(url, params)
|
|
|
|
let partyOrgDetail;
|
|
this.epmetResultResolver
|
|
.success((data) => {
|
|
partyOrgDetail = data;
|
|
})
|
|
.parse(rst);
|
|
return partyOrgDetail;
|
|
},
|
|
|
|
/**
|
|
* 加载行政组织
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async loadXingzhengOrgs() {
|
|
let url = "/actual/base/party/org/listXingZhengOrgs";
|
|
let rst = await requestGet(url, {
|
|
partyOrgPid: this.dataForm.partyOrgPid,
|
|
partyOrgLevel: this.dataForm.partyOrgLevel
|
|
});
|
|
|
|
this.epmetResultResolver
|
|
.success((data) => {
|
|
this.xingzhengOrgs = data;
|
|
|
|
// 1:省委,2:市委,3:区委,4:党工委,5:党委,6:党总支,7:党支部,8:楼院党小组
|
|
// 如果是 >=6 ,那么他们对应的行政组织,就是上级党组织对应的行政组织,自动选中即可
|
|
this.$nextTick(() => {
|
|
if (data && data.length > 0 && (this.dataForm.partyOrgLevel >= 6 || this.dataForm.partyOrgPid === '0')) {
|
|
this.dataForm.orgId = this.xingzhengOrgs[0].orgId;
|
|
|
|
// 自动选择了行政组织,然后自动加载负责人列表
|
|
this.loadPrincipals();
|
|
}
|
|
})
|
|
})
|
|
.parse(rst);
|
|
}
|
|
|
|
},
|
|
computed: {
|
|
dataRule () {
|
|
return {
|
|
partyOrgLevel: [
|
|
{ required: true, message: '请选择党组织类型', trigger: 'blur' },
|
|
],
|
|
partyOrgPid: [
|
|
{ required: true, message: '请选择上级党组织', trigger: 'blur' },
|
|
],
|
|
partyOrgName: [
|
|
{ required: true, message: '党组织名称不能为空', trigger: 'blur' },
|
|
],
|
|
orgId: [
|
|
{ required: true, message: '行政组织不能为空', trigger: 'blur' },
|
|
],
|
|
principalId: [
|
|
{ required: true, message: '请选择负责人', trigger: 'blur' },
|
|
],
|
|
longitude: [
|
|
{ required: true, message: '请选择地图位置', trigger: 'blur' },
|
|
],
|
|
}
|
|
},
|
|
},
|
|
props: {
|
|
// visible: {
|
|
// defult: false,
|
|
// type: Boolean
|
|
// }
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import "@/assets/scss/modules/visual/communityManageForm.scss";
|
|
</style>
|
|
<style lang="scss" scoped>
|
|
.item_width_1 {
|
|
width: 560px;
|
|
|
|
/deep/ .tox .tox-dialog {
|
|
z-index: 20000;
|
|
}
|
|
}
|
|
|
|
.div_map {
|
|
position: relative;
|
|
}
|
|
|
|
.div_searchmap {
|
|
z-index: 5000;
|
|
position: absolute;
|
|
top: 5px;
|
|
left: 5px;
|
|
}
|
|
|
|
.tinymce_view {
|
|
height: 400px;
|
|
overflow: auto;
|
|
}
|
|
|
|
.text_p {
|
|
margin: 0;
|
|
padding: 0 10px;
|
|
border: 1px solid #d9d9d9;
|
|
border-radius: 5px;
|
|
|
|
> p {
|
|
margin: 0;
|
|
}
|
|
}
|
|
</style>
|
|
|