2 changed files with 223 additions and 203 deletions
@ -1,270 +1,258 @@ |
|||||||
<template> |
<template> |
||||||
<div class="flex gap"> |
<div class="flex gap"> |
||||||
<el-tag type="info" effect="plain" closable v-for="(item, index) in modelValue" :key="item" @close="handleRemove(index)">{{ item.name }}</el-tag> |
<el-tag type="info" effect="plain" closable v-for="(item, index) in modelValue" :key="item" |
||||||
<el-button size="small" type="primary" plain @click="show = true"> |
@close="handleRemove(index)">{{ item.name }} |
||||||
<template #icon> |
</el-tag> |
||||||
<icon name="el-icon-Plus" /> |
<el-button size="small" type="primary" plain @click="show = true"> |
||||||
</template> |
<template #icon> |
||||||
</el-button> |
<icon name="el-icon-Plus"/> |
||||||
</div> |
</template> |
||||||
<el-dialog title="选择警员" v-model="show" width="60vw" top="5vh"> |
</el-button> |
||||||
<div style="min-height: 70vh"> |
</div> |
||||||
<el-row :gutter="20"> |
<el-dialog title="选择警员" v-model="show" width="60vw" top="5vh"> |
||||||
<el-col :span="6"> |
<div style="min-height: 70vh"> |
||||||
<el-scrollbar max-height="70vh"> |
<el-row :gutter="20"> |
||||||
<el-tree |
<el-col :span="6"> |
||||||
:data="treeData" |
<el-scrollbar max-height="70vh"> |
||||||
:props="{ label: 'shortName', value: 'id' }" |
<el-tree |
||||||
:default-expanded-keys="['12630']" |
:data="treeData" |
||||||
node-key="id" |
:props="{ label: 'shortName', value: 'id' }" |
||||||
@node-click="handleSelectDepart" |
:default-expanded-keys="['12630']" |
||||||
/> |
node-key="id" |
||||||
</el-scrollbar> |
@node-click="handleSelectDepart" |
||||||
</el-col> |
/> |
||||||
<el-col :span="18"> |
</el-scrollbar> |
||||||
<header class="flex between mb-20"> |
</el-col> |
||||||
<el-form class="flex gap wrap"> |
<el-col :span="18"> |
||||||
<el-input |
<header class="flex between mb-20"> |
||||||
placeholder="警员姓名" |
<el-form class="flex gap wrap"> |
||||||
v-model="query.name" |
<el-input |
||||||
clearable |
placeholder="警员姓名" |
||||||
style="width: 190px" |
v-model="query.name" |
||||||
/> |
clearable |
||||||
<el-input |
style="width: 190px" |
||||||
placeholder="请输入" |
/> |
||||||
v-model="query.empNo" |
<el-input |
||||||
clearable |
placeholder="请输入" |
||||||
style="width: 190px" |
v-model="query.empNo" |
||||||
/> |
clearable |
||||||
<el-input |
style="width: 190px" |
||||||
placeholder="身份证号码" |
/> |
||||||
v-model="query.idCode" |
<el-input |
||||||
clearable |
placeholder="身份证号码" |
||||||
style="width: 190px" |
v-model="query.idCode" |
||||||
/> |
clearable |
||||||
</el-form> |
style="width: 190px" |
||||||
<el-button type="primary" @click="getList">查询</el-button> |
/> |
||||||
</header> |
</el-form> |
||||||
<div class="table-container"> |
<el-button type="primary" @click="getList">查询</el-button> |
||||||
<el-table |
</header> |
||||||
ref="ableRef" |
<div class="table-container"> |
||||||
:data="polices" |
<el-table |
||||||
row-key="id" |
ref="ableRef" |
||||||
max-height="890px" |
:data="polices" |
||||||
@selection-change="selectionChange" |
row-key="id" |
||||||
v-loading="loading" |
max-height="890px" |
||||||
> |
v-loading="loading" |
||||||
<el-table-column type="selection" width="55" /> |
> |
||||||
<el-table-column |
<el-table-column width="55"> |
||||||
label="姓名" |
<template #default="{row}"> |
||||||
prop="name" |
<el-checkbox |
||||||
width="90" |
v-model="row.isCheck" @change="changeCheck(row)" size="large" /> |
||||||
/> |
</template> |
||||||
<el-table-column |
</el-table-column> |
||||||
label="警号" |
<el-table-column |
||||||
prop="empNo" |
label="姓名" |
||||||
width="100" |
prop="name" |
||||||
show-overflow-tooltip |
width="90" |
||||||
/> |
/> |
||||||
<el-table-column |
<el-table-column |
||||||
label="人员属性" |
label="警号" |
||||||
width="120" |
prop="empNo" |
||||||
align="center" |
width="100" |
||||||
> |
show-overflow-tooltip |
||||||
<template #default="{ row }"> |
/> |
||||||
|
<el-table-column |
||||||
|
label="人员属性" |
||||||
|
width="120" |
||||||
|
align="center" |
||||||
|
> |
||||||
|
<template #default="{ row }"> |
||||||
<span>{{ |
<span>{{ |
||||||
getDictLable( |
getDictLable( |
||||||
dict.personType, |
dict.personType, |
||||||
row.personType |
row.personType |
||||||
) |
) |
||||||
}}</span> |
}}</span> |
||||||
</template> |
</template> |
||||||
</el-table-column> |
</el-table-column> |
||||||
<el-table-column |
<el-table-column |
||||||
label="职位" |
label="职位" |
||||||
width="120" |
width="120" |
||||||
align="center" |
align="center" |
||||||
> |
> |
||||||
<template #default="{ row }"> |
<template #default="{ row }"> |
||||||
<span v-if="row.position"> |
<span v-if="row.position"> |
||||||
<span v-if="row.level === 0" |
<span v-if="row.level === 0" |
||||||
>局领导{{ row.position }}</span |
>局领导{{ row.position }}</span |
||||||
> |
> |
||||||
<span v-if="row.level === 2" |
<span v-if="row.level === 2" |
||||||
>二级机构{{ row.position }}</span |
>二级机构{{ row.position }}</span |
||||||
> |
> |
||||||
<span v-if="row.level === 3" |
<span v-if="row.level === 3" |
||||||
>三机机构{{ row.position }}</span |
>三机机构{{ row.position }}</span |
||||||
> |
> |
||||||
<span v-if="row.level === 4" |
<span v-if="row.level === 4" |
||||||
>四机机构{{ row.position }}</span |
>四机机构{{ row.position }}</span |
||||||
> |
> |
||||||
</span> |
</span> |
||||||
</template> |
</template> |
||||||
</el-table-column> |
</el-table-column> |
||||||
<el-table-column |
<el-table-column |
||||||
label="机构名称" |
label="机构名称" |
||||||
prop="departShortName" |
prop="departShortName" |
||||||
width="200" |
width="200" |
||||||
/> |
/> |
||||||
</el-table> |
</el-table> |
||||||
</div> |
</div> |
||||||
<div class="flex end mt-8"> |
<div class="flex end mt-8"> |
||||||
<el-pagination |
<el-pagination |
||||||
@size-change="getList" |
@size-change="getList" |
||||||
@current-change="getList" |
@current-change="getList" |
||||||
:page-sizes="[10, 20]" |
:page-sizes="[10, 20]" |
||||||
v-model:page-size="query.size" |
v-model:page-size="query.size" |
||||||
v-model:current-page="query.current" |
v-model:current-page="query.current" |
||||||
layout="total, sizes, prev, pager, next" |
layout="total, sizes, prev, pager, next" |
||||||
:total="total" |
:total="total" |
||||||
> |
> |
||||||
</el-pagination> |
</el-pagination> |
||||||
</div> |
</div> |
||||||
<div class="flex gap mt-10 wrap v-center"> |
<div class="flex gap mt-10 wrap v-center"> |
||||||
<span>已选警员:</span> |
<span>已选 {{checkPolices.length}} 员警员:</span> |
||||||
<el-tag |
<el-tag |
||||||
v-for="(item, index) in checkPolices" |
v-for="(item, index) in checkPolices" |
||||||
:key="item" |
:key="item" |
||||||
closable |
closable |
||||||
@close="handleRemove(index)" |
@close="handleRemove(index)" |
||||||
>{{ item.name }}</el-tag |
>{{ item.name }} |
||||||
> |
</el-tag |
||||||
</div> |
> |
||||||
</el-col> |
</div> |
||||||
</el-row> |
</el-col> |
||||||
</div> |
</el-row> |
||||||
<footer class="flex end"> |
</div> |
||||||
<el-button @click="show = false">取消</el-button> |
<footer class="flex end"> |
||||||
<el-button type="primary" @click="submit">确定</el-button> |
<el-button @click="show = false">取消</el-button> |
||||||
</footer> |
<el-button type="primary" @click="submit">确定</el-button> |
||||||
</el-dialog> |
</footer> |
||||||
|
</el-dialog> |
||||||
</template> |
</template> |
||||||
<script setup> |
<script setup> |
||||||
import { departTreeList } from "@/api/system/depart"; |
import {departTreeList} from "@/api/system/depart"; |
||||||
import { listPolice } from "@/api/system/police"; |
import {listPolice} from "@/api/system/police"; |
||||||
import useCatchStore from "@/stores/modules/catch"; |
import useCatchStore from "@/stores/modules/catch"; |
||||||
import { getDictLable } from "@/utils/util"; |
import {getDictLable} from "@/utils/util"; |
||||||
|
|
||||||
const catchSotre = useCatchStore(); |
const catchSotre = useCatchStore(); |
||||||
const dict = catchSotre.getDicts(["personType"]); |
const dict = catchSotre.getDicts(["personType"]); |
||||||
|
|
||||||
const props = defineProps({ |
const props = defineProps({ |
||||||
modelValue: { |
modelValue: { |
||||||
type: Array, |
type: Array, |
||||||
default: [] |
default: [] |
||||||
}, |
}, |
||||||
departId: { |
departId: { |
||||||
type: String |
type: String |
||||||
} |
} |
||||||
}); |
}); |
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']) |
const emit = defineEmits(['update:modelValue']) |
||||||
|
|
||||||
const show = ref(false); |
const show = ref(false); |
||||||
const query = ref({ |
const query = ref({ |
||||||
current:1, |
current: 1, |
||||||
departBranch: true |
departBranch: true |
||||||
|
|
||||||
}); |
}); |
||||||
watch(() => props.departId, (val) => { |
watch(() => props.departId, (val) => { |
||||||
query.value.departId = val; |
query.value.departId = val; |
||||||
getList() |
getList() |
||||||
}) |
}) |
||||||
const total = ref(0); |
const total = ref(0); |
||||||
const ableRef =ref(null) |
const ableRef = ref(null) |
||||||
const treeData = catchSotre.getDepartsAll(); |
const treeData = catchSotre.getDepartsAll(); |
||||||
const polices = ref([]); |
const polices = ref([]); |
||||||
const loading = ref(false) |
const loading = ref(false) |
||||||
|
|
||||||
function getList() { |
function getList() { |
||||||
loading.value = true |
loading.value = true |
||||||
listPolice(query.value).then((data) => { |
listPolice(query.value).then((data) => { |
||||||
polices.value = data.records; |
polices.value = data.records; |
||||||
console.log('polices',polices) |
setCheckFun(data.records) |
||||||
setCheckFun(data.records) |
total.value = data.total; |
||||||
total.value = data.total; |
loading.value = false |
||||||
loading.value = false |
}); |
||||||
}); |
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
const setCheckFun =(row)=>{ |
const setCheckFun = (row) => { |
||||||
|
let keyValue = checkPolices.value.map(s=>s.empNo); |
||||||
row.forEach((s)=>{ |
row.forEach((s) => { |
||||||
let data =checkPolices.value.find(x=>{ |
if(keyValue.indexOf(s.empNo) >= 0){ |
||||||
return JSON.stringify(x) === JSON.stringify({ |
s.isCheck=true; |
||||||
name: s.name, |
}else{ |
||||||
empNo: s.empNo, |
s.isCheck=false; |
||||||
idCode: s.idCode |
|
||||||
}) |
|
||||||
}); |
|
||||||
if(data){ |
|
||||||
nextTick(()=>{ |
|
||||||
ableRef.value.toggleRowSelection(s, true); |
|
||||||
}) |
|
||||||
} |
} |
||||||
}) |
}) |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
const checkPolices = ref([]); |
const checkPolices = ref([]); |
||||||
const checkPolicesMap =ref([]) |
|
||||||
function selectionChange(selectionRows) { |
|
||||||
if( checkPolicesMap.value['key'+query.value.current]){ |
|
||||||
let data = checkPolicesMap.value['key'+query.value.current]; |
|
||||||
checkPolicesMap.value['key'+query.value.current]=getCheckData(data,selectionRows); |
|
||||||
}else{ |
|
||||||
checkPolicesMap.value['key'+query.value.current] =getCheckData([],selectionRows); |
|
||||||
} |
|
||||||
checkPolices.value=[] |
|
||||||
for (let key in checkPolicesMap.value){ |
|
||||||
checkPolices.value=checkPolices.value.concat(checkPolicesMap.value[key]) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
const getCheckData = (data,selectionRows) =>{ |
const changeCheck = (row)=>{ |
||||||
selectionRows.forEach(item => { |
let checkIndex =checkPolices.value.map(s=>s.empNo); |
||||||
if (data.findIndex(o => o.empNo === item.empNo) === -1) { |
if(row.isCheck){ |
||||||
data.push({ |
checkPolices.value.push({ |
||||||
name: item.name, |
name: row.name, |
||||||
empNo: item.empNo, |
empNo: row.empNo, |
||||||
idCode: item.idCode |
idCode: row.idCode |
||||||
}) |
}); |
||||||
} |
}else{ |
||||||
}) |
checkPolices.value.splice(checkIndex.indexOf(row.empNo),1) |
||||||
data.forEach((s,i)=>{ |
|
||||||
if (selectionRows.findIndex(o => o.empNo === s.empNo) === -1){ |
|
||||||
data.splice(i,1) |
|
||||||
} |
} |
||||||
}) |
|
||||||
return data; |
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function handleSelectDepart(node) { |
function handleSelectDepart(node) { |
||||||
query.value.departId = node.id; |
query.value.departId = node.id; |
||||||
getList(); |
getList(); |
||||||
} |
} |
||||||
|
|
||||||
function handleRemove(index) { |
function handleRemove(index) { |
||||||
checkPolices.value.splice(index, 1) |
console.log(index) |
||||||
emit('update:modelValue', checkPolices.value) |
polices.value.forEach(s=>{ |
||||||
|
if(s.empNo == checkPolices.value[index].empNo){ |
||||||
|
s.isCheck =false |
||||||
|
} |
||||||
|
}) |
||||||
|
checkPolices.value.splice(index, 1) |
||||||
|
|
||||||
|
emit('update:modelValue', checkPolices.value) |
||||||
} |
} |
||||||
|
|
||||||
function submit() { |
function submit() { |
||||||
emit('update:modelValue', checkPolices.value) |
emit('update:modelValue', checkPolices.value) |
||||||
show.value = false |
show.value = false |
||||||
} |
} |
||||||
|
|
||||||
onMounted(() => { |
onMounted(() => { |
||||||
getList(); |
getList(); |
||||||
}); |
}); |
||||||
</script> |
</script> |
||||||
<style lang="scss"> |
<style lang="scss"> |
||||||
.el-tree-node.is-current > .el-tree-node__content { |
.el-tree-node.is-current > .el-tree-node__content { |
||||||
background-color: #e8e9f3; |
background-color: #e8e9f3; |
||||||
} |
} |
||||||
</style> |
</style> |
||||||
|
|||||||
Loading…
Reference in new issue