Files
dvcp_v2_webapp/packages/grid/AppGridBlock/components/list.vue

483 lines
13 KiB
Vue
Raw Normal View History

2021-12-14 18:36:19 +08:00
<template>
2022-06-13 09:39:19 +08:00
<section class="app-grid-block">
2021-12-14 18:36:19 +08:00
<ai-list>
<template slot="title">
<ai-title title="网格区块" :isShowBottomBorder="true"></ai-title>
</template>
<template slot="left">
2022-06-13 09:39:19 +08:00
<ai-tree-menu title="网格层级" @search="v=> $refs.tree.filter(v)">
2021-12-14 18:36:19 +08:00
<el-tree
2022-06-13 09:39:19 +08:00
:data="treeObj.treeList"
:props="treeObj.defaultProps"
@node-click="handleNodeClick"
node-key="id"
ref="tree"
2022-08-30 10:37:09 +08:00
:expand-on-click-node="false"
:defaultExpandedKeys="treeObj.defaultExpandedKeys"
2022-06-13 09:39:19 +08:00
:filter-node-method="filterNode"
highlight-current>
<template slot-scope="{node,data}">
<div v-text="node.label"/>
</template>
</el-tree>
2021-12-14 18:36:19 +08:00
</ai-tree-menu>
</template>
<template slot="content">
<ai-search-bar>
<template slot="left">
<el-date-picker
2022-06-13 09:39:19 +08:00
v-model="searchObj.createTimeStr"
type="date"
@change="(page.current = 1), getList()"
value-format="yyyy-MM-dd"
size="small"
placeholder="创建时间"
2021-12-14 18:36:19 +08:00
>
</el-date-picker>
</template>
<template slot="right">
<el-input
2022-06-13 09:39:19 +08:00
v-model="searchObj.girdName"
size="small"
placeholder="输入网格名称"
@keyup.enter.native="(page.current = 1), getList()"
clearable
@clear="(searchObj.girdName = '', page.current = 1), getList()"
suffix-icon="iconfont iconSearch"
2021-12-14 18:36:19 +08:00
/>
</template>
</ai-search-bar>
<ai-search-bar bottomBorder>
<template slot="left">
<el-button
2022-06-13 09:39:19 +08:00
type="primary"
icon="iconfont iconAdd"
@click="(isEdit = false), toAdd()"
>新增
2021-12-14 18:36:19 +08:00
</el-button>
<el-button
2022-06-13 09:39:19 +08:00
icon="iconfont iconDelete"
@click="deleteById(ids.join(','))"
:disabled="!Boolean(ids.length)"
2021-12-14 18:36:19 +08:00
>
删除
</el-button>
<ai-import
2022-06-13 09:39:19 +08:00
ref="import"
title="导入"
name="网格区块"
url="/app/appgirdinfo/downloadGirdInfo"
importUrl="/app/appgirdinfo/importGirdInfo"
suffixName="xlsx"
:customCliker="true"
:instance="instance"
2021-12-14 18:36:19 +08:00
>
<template slot="tips">
<p>
如果表格中已经存在数据则会被本次导入的数据覆盖不存在数据系统将生成新的标准记录
</p>
</template>
<el-button size="small" icon="iconfont iconImport"
2022-06-13 09:39:19 +08:00
>导入
</el-button
2021-12-14 18:36:19 +08:00
>
</ai-import>
2023-04-19 14:10:00 +08:00
<el-button type="primary" v-if="!treeObj.treeList.length" @click="init">初始化</el-button>
2021-12-14 18:36:19 +08:00
</template>
</ai-search-bar>
2023-11-03 10:30:32 +08:00
<el-tabs v-model="currIndex" @tab-click="tabChange">
<el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label"></el-tab-pane>
</el-tabs>
2021-12-14 18:36:19 +08:00
<ai-table
2023-04-19 14:10:00 +08:00
class="mt10"
:tableData="tableData"
:col-configs="colConfigs"
:total="page.total"
ref="aitableex"
:current.sync="page.current"
:size.sync="page.size"
@selection-change="v=>ids=v.map((e) => e.id)"
@getList="getList()"
:dict="dict">
2022-06-13 09:39:19 +08:00
<el-table-column label="网格成员" slot="user" align="center" width="160">
<template slot-scope="{ row }">
<el-button type="text" @click="showGridMembers(row)">{{ row.girdMemberNumber || 0 }}</el-button>
</template>
2021-12-14 18:36:19 +08:00
</el-table-column>
<el-table-column
2022-06-13 09:39:19 +08:00
label="操作"
slot="options"
align="center"
fixed="right"
width="160">
2022-01-13 10:11:04 +08:00
<template slot-scope="{ row }">
2022-06-13 09:39:19 +08:00
<el-button type="text" @click="showEdit(row.id)">编辑</el-button>
<map-plotting :value="row.points" @change="v=>confirm(row,v)"/>
<el-button type="text" @click="deleteById(row.id)">删除</el-button>
2021-12-14 18:36:19 +08:00
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
2022-06-13 09:39:19 +08:00
<ai-dialog :title="`${gridInfo.girdName}网格成员`" :visible.sync="dialog" customFooter @closed="gridInfo={}"
width="700px">
<ai-table :tableData="gridInfo.tableData" :colConfigs="gridMemberColConfigs" :dict="dict"
:isShowPagination="false" :show-header="false"/>
<template #footer>
<el-button @click="dialog=false">关闭</el-button>
</template>
2021-12-14 18:36:19 +08:00
</ai-dialog>
2022-06-13 09:39:19 +08:00
</section>
2021-12-14 18:36:19 +08:00
</template>
<script>
2022-06-13 09:39:19 +08:00
import MapPlotting from "./mapPlotting";
2021-12-14 18:36:19 +08:00
export default {
2022-01-24 17:03:05 +08:00
name: "List",
2022-06-13 09:39:19 +08:00
components: {MapPlotting},
2021-12-14 18:36:19 +08:00
label: "网格区块",
props: {
instance: Function,
dict: Object,
permissions: Function,
},
data() {
return {
treeObj: {
treeList: [],
defaultProps: {
2022-08-24 17:56:05 +08:00
children: "children",
2021-12-14 18:36:19 +08:00
label: "girdName",
},
defaultExpandedKeys: [],
},
filterText: "",
page: {
current: 1,
size: 10,
total: 0,
},
searchObj: {
createTimeStr: "",
girdName: "",
},
tableData: [],
info: {},
ids: [],
showMap: false,
map: "",
polyEditor: "",
editRow: {},
searchAddress: "",
mouseTool: "",
placeSearch: "",
path: [],
overlays: [],
isEdit: false,
fileList: [],
2022-06-13 09:39:19 +08:00
dialog: false,
gridInfo: {},
gridMemberColConfigs: [
{prop: "name"},
2023-01-09 09:36:10 +08:00
{prop: "checkType", format: v => v === '1' ? '网格员' : '网格长'}
2023-11-03 10:30:32 +08:00
],
currIndex: 0,
tabs: [{label: '子网格'}, {label: '协同部门'}],
2021-12-14 18:36:19 +08:00
};
},
created() {
this.getTreeList();
this.getList();
2022-06-13 09:39:19 +08:00
this.dict.load("girdType", "isLastLevel", "plottingStatus", "girdMemberType");
2021-12-14 18:36:19 +08:00
},
computed: {
colConfigs() {
return [
2022-06-13 09:39:19 +08:00
{type: 'selection'},
{prop: "girdName", align: "left", label: "网格名称",},
{slot: 'user'},
{prop: "plottingStatus", align: "center", label: "标绘状态", dict: "plottingStatus"},
{prop: "createTime", align: "center", label: "创建时间"},
{slot: "options"}
2021-12-14 18:36:19 +08:00
];
},
2022-06-13 09:39:19 +08:00
isTopGrid() {
return this.info.id == this.treeObj.treeList?.[0]?.id
}
2021-12-14 18:36:19 +08:00
},
methods: {
2023-11-03 10:30:32 +08:00
tabChange() {
this.page.current = 1
this.getList()
},
2021-12-14 18:36:19 +08:00
handleNodeClick(val) {
2022-06-13 09:39:19 +08:00
this.info = this.$copy(val);
2021-12-14 18:36:19 +08:00
this.getList();
},
getTreeList() {
2023-11-03 10:30:32 +08:00
this.instance.post(`/app/appgirdinfo/listAll4`).then((res) => {
2022-06-13 09:39:19 +08:00
if (res?.data) {
2022-08-24 17:56:05 +08:00
this.treeObj.treeList = res.data.filter(e => !e.parentGirdId)
const parentGirdId = this.treeObj.treeList[0].id
2023-05-06 15:03:34 +08:00
this.treeObj.treeList.map(p => this.addChild(p, res.data.sort((a, b)=>{ return a.girdCode - b.girdCode}).map(v => {
2022-08-24 17:56:05 +08:00
if (v.id === parentGirdId) {
2022-08-30 10:37:09 +08:00
this.treeObj.defaultExpandedKeys.push(v.id)
2022-08-24 17:56:05 +08:00
}
return {
...v
}
}), {
parent: 'parentGirdId'
}))
2022-08-30 10:37:09 +08:00
this.$nextTick(() => {
this.info = this.treeObj.treeList[0]
this.$refs.tree.setCurrentKey(parentGirdId)
})
2022-06-13 09:39:19 +08:00
}
});
2021-12-14 18:36:19 +08:00
},
2023-04-19 14:10:00 +08:00
init () {
this.instance.post("/app/appgirdinfo/initByCorpAreaId").then((res) => {
if (res?.code == 0) {
this.getTreeList();
this.$message.success("网格初始化成功!");
this.getList();
}
})
},
2021-12-14 18:36:19 +08:00
filterNode(value, data) {
if (!value) return true;
return data.girdName.indexOf(value) !== -1;
},
deleteById(ids) {
2022-06-13 09:39:19 +08:00
ids && this.$confirm("删除网格后,会清除网格内网格员的责任家庭信息,如有下级网格,会同步删除下级网格所有数据!", {
type: "error",
}).then(() => {
this.instance.post("/app/appgirdinfo/delete", null, {params: {ids}}).then((res) => {
if (res?.code == 0) {
this.$message.success("删除成功!");
this.getList();
this.getTreeList();
}
});
}).catch(() => 0);
2021-12-14 18:36:19 +08:00
},
deleteTree(ids) {
2022-06-13 09:39:19 +08:00
ids && this.$confirm("是否要删除该网格区块?", {
type: "error",
}).then(() => {
this.instance.post("/app/appgirdinfo/delete", null, {
params: {ids}
}).then((res) => {
if (res?.code == 0) {
this.$message.success("删除成功!");
this.getTreeList();
2021-12-14 18:36:19 +08:00
}
});
2022-06-13 09:39:19 +08:00
}).catch(() => 0);
},
getList() {
2023-11-03 10:30:32 +08:00
var url = this.currIndex == 1 ? `/app/appgirdinfo/listCoordination` : `/app/appgirdinfo/list?isCoordination=0`
this.instance.post(url, null, {
2022-06-13 09:39:19 +08:00
params: {
...this.searchObj,
...this.page,
parentGirdId: this.isTopGrid ? '' : this.info.id,
},
}).then((res) => {
if (res?.data) {
this.tableData = res.data.records;
this.page.total = res.data.total;
}
});
2021-12-14 18:36:19 +08:00
},
handleSelectionChange(val) {
this.ids = [];
val.map((e) => {
this.ids.push(e.id);
});
},
//添加二级网格
addTwoLevel() {
2022-06-13 09:39:19 +08:00
this.info = {...this.treeObj.treeList[0]};
2021-12-14 18:36:19 +08:00
this.toAdd()
},
toAdd() {
2022-06-13 09:39:19 +08:00
let {id: parentGirdId, girdName: parentGirdName} = this.info
2023-11-06 15:27:54 +08:00
var coordinationId = this.info.parentGirdId
var coordinationName = this.info.parentGirdName
2022-06-13 09:39:19 +08:00
this.$router.push({
2023-11-06 15:27:54 +08:00
hash: "#add", query: {parentGirdId, parentGirdName, coordinationId, coordinationName, currIndex: this.currIndex}
2021-12-14 18:36:19 +08:00
})
},
goBack() {
this.isAdd = false;
this.$nextTick(() => {
this.getList();
this.getTreeList();
});
},
2022-06-13 09:39:19 +08:00
showEdit(id) {
this.$router.push({hash: "#add", query: {id}})
2021-12-14 18:36:19 +08:00
},
//map搜索
2022-06-13 09:39:19 +08:00
confirm(row, points) {
2022-08-19 11:12:07 +08:00
this.instance.post(`/app/appgirdinfo/updateCoordinate`, {...row, points}).then((res) => {
2022-06-13 09:39:19 +08:00
if (res.code == 0) {
this.$message.success("提交成功!")
this.getList();
}
2021-12-14 18:36:19 +08:00
});
},
resetSearch() {
Object.keys(this.searchObj).map((e) => {
this.searchObj[e] = "";
});
this.getList();
},
2022-06-13 09:39:19 +08:00
showGridMembers(row) {
if (row.girdMemberNumber > 0) {
this.gridInfo = this.$copy(row)
this.instance.post("/app/appgirdmemberinfo/listByGirdIdByThree", null, {
params: {girdId: row.id}
}).then(res => {
if (res?.data) {
this.gridInfo.tableData = res.data
this.dialog = true
}
})
} else this.$message.warning("当前网格无成员")
}
2021-12-14 18:36:19 +08:00
},
};
</script>
<style lang="scss" scoped>
.app-grid-block {
width: 100%;
height: 100%;
2022-06-13 09:39:19 +08:00
2022-12-01 09:35:20 +08:00
:deep( .el-tree ){
2022-01-18 16:09:37 +08:00
background: transparent;
.el-tree-node__expand-icon.is-leaf {
2022-06-13 09:39:19 +08:00
color: transparent !important;
2022-01-18 16:09:37 +08:00
}
.el-tree-node__content > .el-tree-node__expand-icon {
padding: 4px;
}
.el-tree-node__content {
height: 32px;
}
.el-tree__empty-text {
color: #222;
font-size: 14px;
}
.el-tree-node__children .el-tree-node__content {
height: 32px;
}
.el-tree-node__content:hover {
background: #E8EFFF;
color: #222222;
border-radius: 2px;
}
.is-current > .el-tree-node__content {
2022-06-13 09:39:19 +08:00
color: #fff !important;
2022-01-18 16:09:37 +08:00
&:hover {
background: #2266FF;
color: #fff;
}
background: #2266FF;
2022-06-13 09:39:19 +08:00
.el-tooltip {
2022-01-18 16:09:37 +08:00
color: #fff;
}
}
}
2021-12-14 18:36:19 +08:00
2022-06-13 09:39:19 +08:00
.flex-box {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
& > div {
display: flex;
}
}
2021-12-14 18:36:19 +08:00
.mt10 {
padding: 8px 0;
}
2022-12-01 09:35:20 +08:00
:deep(.fullscreenMap ){
2022-06-13 09:39:19 +08:00
.el-dialog {
display: flex;
flex-direction: column;
2021-12-14 18:36:19 +08:00
2022-06-13 09:39:19 +08:00
.el-dialog__body {
padding: 0;
flex: 1;
min-height: 0;
2021-12-14 18:36:19 +08:00
2022-06-13 09:39:19 +08:00
.ai-dialog__content {
max-height: unset !important;
padding-bottom: 0;
height: 100%;
2021-12-14 18:36:19 +08:00
2022-06-13 09:39:19 +08:00
.ai-dialog__content--wrapper {
padding-right: 0 !important;
}
}
}
2021-12-14 18:36:19 +08:00
}
}
2022-12-01 09:35:20 +08:00
:deep( .treePanel ){
2021-12-14 18:36:19 +08:00
display: flex;
flex-direction: column;
.el-tree {
min-height: 0;
flex: 1;
}
footer {
width: 100%;
height: 32px;
background-color: #fff;
display: flex;
align-items: center;
span {
width: 33.33%;
text-align: center;
cursor: pointer;
}
.el-button {
width: 33.33%;
}
}
}
}
</style>