Files
foton-laws-system-front/src/components/advancedQuery/index.vue
T
2021-05-25 20:02:41 +08:00

1161 lines
39 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--高级查询组件-->
<template>
<div>
<el-dialog
:visible.sync="temp_app"
width="850px"
title="高级检索"
@close="closeIsAdvancedSearch"
class="advance-dialog"
:close-on-click-modal="false"
:close-on-press-escape="false"
>
<el-form ref="advancedSearch" class="advance-dialog-form">
<template v-for="(item, index) in advancedSearch">
<el-form-item :key="index" >
<el-select v-model="advancedSearch[index].one" class="advanced-one" :class="{'advanced-class': index === 0}">
<el-option value="AND" label="且(AND"></el-option>
<el-option value="OR" label="或(OR"></el-option>
<!-- <el-option value="NOT" label="NOT"></el-option>-->
</el-select>
<el-select filterable v-model="advancedSearch[index].two" class="advanced-two" @change="twoSelectChange(advancedSearch[index].two, index)">
<el-option
v-for="item2 in twoOptions"
:key="item2.value"
:value="item2"
:label="item2.label"
:disabled="item2.disabled"
></el-option>
</el-select>
<el-select v-model="advancedSearch[index].four" class="advanced-one">
<el-option value="等于" label="等于"></el-option>
<el-option value="不等于" label="不等于"></el-option>
<el-option value="包含" label="包含"></el-option>
</el-select>
<!--下拉单选-->
<template v-if="!item.two.type || item.two.type === 'SEL_OPTION'">
<!--单选部门-->
<template v-if="item.two.selVal === 'ORGLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择部门"
readonly
@click.native="handleVisibleDept(index, false)"
/>
</template>
<!--单选人员-->
<template v-else-if="item.two.selVal === 'USERLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-autocomplete
clearable
@clear="setBlur"
v-model="advancedSearch[index].three"
class="advanced-three"
placeholder="请选择人员"
:fetch-suggestions="querySearchAsync"
@select="handleSelect($event,index)"
:trigger-on-focus="false"
/>
</template>
<!--单选角色-->
<template v-else-if="item.two.selVal === 'ROLELIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择"
readonly
@click.native="handleVisibleRole(index, false, item.two.label)"
/>
</template>
<!--正常下拉框-->
<template v-else>
<el-select filterable v-model="advancedSearch[index].three" class="advanced-three">
<el-option
v-for="item2 in advancedSearch[index].threeOptions"
:key="item2.value"
:value="item2.value"
:label="item2.label"
></el-option>
</el-select>
</template>
</template>
<!--下拉多选-->
<template v-else-if="item.two.type === 'SEL_OPTS'">
<!--多选部门-->
<template v-if="item.two.selVal === 'ORGLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择部门"
readonly
@click.native="handleVisibleDept(index, true)"
/>
</template>
<!--多选人-->
<template v-else-if="item.two.selVal === 'USERLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<!-- <el-input-->
<!-- v-model="advancedSearch[index].threeName"-->
<!-- class="advanced-three"-->
<!-- placeholder="请选择人员"-->
<!-- readonly-->
<!-- @click.native="handleVisibleUser(index, true)"-->
<!-- />-->
<el-autocomplete
clearable
@clear="setBlur"
v-model="advancedSearch[index].three"
class="advanced-three"
placeholder="请选择人员"
:fetch-suggestions="querySearchAsync"
@select="handleSelect($event,index)"
:trigger-on-focus="false"
/>
</template>
<!--多选角色-->
<template v-else-if="item.two.selVal === 'ROLELIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择"
readonly
@click.native="handleVisibleRole(index, true, item.two.label)"
/>
</template>
<!--SVPPS-->
<template v-else-if="item.two.value === 'SVPPS'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择SVPPS"
readonly
@click.native="handleVisibleSVPPS(index)"
/>
</template>
<template v-else>
<el-select v-model="advancedSearch[index].three" class="advanced-three">
<el-option
v-for="item2 in advancedSearch[index].threeOptions"
:key="item2.value"
:value="item2.value"
:label="item2.label"
multiline
></el-option>
</el-select>
</template>
</template>
<!--日期区间 DATE_PICKER-->
<template v-else-if="item.two.type === 'DATE_PIC_OPTS' || item.two.type === 'DATE_PICKER'">
<el-date-picker
class="advanced-three"
v-model="advancedSearch[index].three"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
unlink-panels
>
</el-date-picker>
</template>
<!--input 输入框-->
<template v-else>
<el-input
class="advanced-three"
v-model="advancedSearch[index].three"
clearable>
</el-input>
</template>
<el-button
class="advancedSearch-btn"
v-if="index === advancedSearch.length - 1"
@click="addAdvancedSearch"
icon="el-icon-plus"
></el-button>
<el-button
class="advancedSearch-btn-reduce"
v-if="advancedSearch.length > 1"
icon="el-icon-minus"
@click="removeAdvancedSearch(index)"
></el-button>
</el-form-item>
</template>
</el-form>
<div slot="footer">
<el-button type="primary" round class="common-button-primary" @click="getDomesticStandardTableBtn">高级检索</el-button>
<el-button round class="common-button-default" @click="clearAllSearch">重置</el-button>
</div>
</el-dialog>
<!--搜索中心-高级检索-->
<div class="query-box" v-if="isShow">
<el-form ref="advancedSearch" class="advance-dialog-form">
<template v-for="(item, index) in advancedSearch">
<el-form-item :key="index" >
<el-select v-model="advancedSearch[index].one" class="advanced-one" :class="{'advanced-class': index === 0}">
<el-option value="AND" label="且(AND"></el-option>
<el-option value="OR" label="或(OR"></el-option>
<!-- <el-option value="NOT" label="NOT"></el-option>-->
</el-select>
<el-select filterable v-model="advancedSearch[index].two" class="advanced-two" @change="twoSelectChange(advancedSearch[index].two, index)">
<el-option
v-for="item2 in twoOptions"
:key="item2.value"
:value="item2"
:label="item2.label"
:disabled="item2.disabled"
></el-option>
</el-select>
<el-select v-model="advancedSearch[index].four" class="advanced-one">
<el-option value="等于" label="等于"></el-option>
<el-option value="不等于" label="不等于"></el-option>
<el-option value="包含" label="包含"></el-option>
</el-select>
<!--下拉单选-->
<template v-if="!item.two.type || item.two.type === 'SEL_OPTION'">
<!--单选部门-->
<template v-if="item.two.selVal === 'ORGLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择部门"
readonly
@click.native="handleVisibleDept(index, false)"
/>
</template>
<!--单选人员-->
<template v-else-if="item.two.selVal === 'USERLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<!-- <el-input-->
<!-- v-model="advancedSearch[index].threeName"-->
<!-- class="advanced-three"-->
<!-- placeholder="请选择人员"-->
<!-- readonly-->
<!-- @click.native="handleVisibleUser(index, false)"-->
<!-- />-->
<el-autocomplete
clearable
@clear="setBlur"
v-model="advancedSearch[index].three"
class="advanced-three"
placeholder="请选择人员"
:fetch-suggestions="querySearchAsync"
@select="handleSelect($event,index)"
:trigger-on-focus="false"
/>
</template>
<!--单选角色-->
<template v-else-if="item.two.selVal === 'ROLELIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择"
readonly
@click.native="handleVisibleRole(index, false, item.two.label)"
/>
</template>
<!--正常下拉框-->
<template v-else>
<el-select filterable v-model="advancedSearch[index].three" class="advanced-three">
<el-option
v-for="item2 in advancedSearch[index].threeOptions"
:key="item2.value"
:value="item2.value"
:label="item2.label"
></el-option>
</el-select>
</template>
</template>
<!--下拉多选-->
<template v-else-if="item.two.type === 'SEL_OPTS'">
<!--多选部门-->
<template v-if="item.two.selVal === 'ORGLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择部门"
readonly
@click.native="handleVisibleDept(index, true)"
/>
</template>
<!--多选人-->
<template v-else-if="item.two.selVal === 'USERLIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<!-- <el-input-->
<!-- v-model="advancedSearch[index].threeName"-->
<!-- class="advanced-three"-->
<!-- placeholder="请选择人员"-->
<!-- readonly-->
<!-- @click.native="handleVisibleUser(index, true)"-->
<!-- />-->
<el-autocomplete
clearable
@clear="setBlur"
v-model="advancedSearch[index].three"
class="advanced-three"
placeholder="请选择人员"
:fetch-suggestions="querySearchAsync"
@select="handleSelect($event,index)"
:trigger-on-focus="false"
/>
</template>
<!--多选角色-->
<template v-else-if="item.two.selVal === 'ROLELIST'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择"
readonly
@click.native="handleVisibleRole(index, true, item.two.label)"
/>
</template>
<!--SVPPS-->
<template v-else-if="item.two.value === 'SVPPS'">
<input v-model="advancedSearch[index].three" type="hidden" />
<el-input
v-model="advancedSearch[index].threeName"
class="advanced-three"
placeholder="请选择SVPPS"
readonly
@click.native="handleVisibleSVPPS(index)"
/>
</template>
<template v-else>
<el-select filterable v-model="advancedSearch[index].three" class="advanced-three">
<el-option
v-for="item2 in advancedSearch[index].threeOptions"
:key="item2.value"
:value="item2.value"
:label="item2.label"
multiline
></el-option>
</el-select>
</template>
</template>
<!--日期区间-->
<template v-else-if="item.two.type === 'DATE_PIC_OPTS' || item.two.type === 'DATE_PICKER'">
<el-date-picker
class="advanced-three"
v-model="advancedSearch[index].three"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
unlink-panels
>
</el-date-picker>
</template>
<!--input 输入框-->
<template v-else>
<el-input
class="advanced-three"
v-model="advancedSearch[index].three"
clearable>
</el-input>
</template>
<el-button
class="advancedSearch-btn"
v-if="index === advancedSearch.length - 1"
@click="addAdvancedSearch"
icon="el-icon-plus"
></el-button>
<el-button
class="advancedSearch-btn-reduce"
v-if="advancedSearch.length > 1"
icon="el-icon-minus"
@click="removeAdvancedSearch(index)"
></el-button>
</el-form-item>
</template>
</el-form>
<div class="search-condition-btn">
<el-button type="primary" round class="common-button-primary" @click="getDomesticStandardTableBtn">查询</el-button>
<el-button round class="common-button-default" @click="clearAllSearch">重置</el-button>
</div>
</div>
<!-- 组织机构树 -->
<el-drawer
title="组织结构"
:visible.sync="isTreeDrawer"
@opened="drawerOpen"
>
<div :class="{'demo-drawer-content': checkEnable}">
<laws-tree
v-if="checkType === 'dept' && isTreeDrawer"
:zNodes="depNode"
deptSelect
:checkEnable="checkEnable"
treeDivId="deptTreeOrg"
@treeDblClick="(treeId, treeNode) => treeDbOrgTree(treeId, treeNode)"
@treeOnCheck="(checkedList) => treeOnDeptCheck(checkedList)"
:editable="false"
:check-id-list="checkIdList"
:chkboxType="{ 'Y': '', 'N': '' }"
ref="deptTreeOrg"
class="ztree" style="overflow: auto">
</laws-tree>
<dept-tree
v-if="checkType === 'person' && isTreeDrawer"
treeDivId="roleTree"
ref="roleTree"
allDept
showUser
:checkEnable="checkEnable"
:editable="false"
@treeDblClick="(treeId, treeNode) => treeDbRoleTree(treeId, treeNode)"
@treeOnCheck="(checkedList) => treeOnRoleCheck(checkedList)"
style="overflow: auto">
</dept-tree>
</div>
<div class="demo-drawer-footer" v-if="checkEnable">
<el-button type="primary" round class="common-button-primary" icon="el-icon-check" @click="isTreeOk">确定</el-button>
<el-button round class="common-button-default" icon="el-icon-close" @click="isTreeDrawer = false">取消</el-button>
</div>
</el-drawer>
<!--SVPPS抽屉-->
<el-drawer
title="SVPPS"
:visible.sync="isSVPPSDrawer"
:wrapper-closable="false"
size="350px"
append-to-body
class="org-tree"
@opened="drawerOpen"
>
<div class="demo-drawer-content">
<laws-tree
v-if="isSVPPSDrawer"
:zNodes="SVPPSZNodes"
check-enable
treeDivId="SVPPSID"
@treeOnCheck="handleOnCheck"
:editable="false"
:checkIdList="checkIdList"
:chkboxType="{ 'Y': '', 'N': '' }"
ref="SVPPSID"
:loading="svppsLoading"
class="ztree" style="height: 100%;overflow: auto"
/>
</div>
<div class="demo-drawer-footer">
<el-button
round
class="common-button-primary"
icon="el-icon-check"
type="primary"
@click="handleTreeDrawerConfirm">确定
</el-button>
<el-button
round
class="common-button-default"
icon="el-icon-close"
@click="handleTreeDrawerCancel">取消</el-button>
</div>
</el-drawer>
<!--角色抽屉-->
<el-drawer
title="选择角色"
:visible.sync="isRoleDrawer"
:wrapper-closable="false"
size="350px"
append-to-body
@opened="drawerOpen"
>
<div class="demo-drawer-content">
<div class="search-area" v-if="label !== 'FO' || label !== '项目评估角色'">
<div class="left">
<el-form inline class="label-input-form" >
<el-form-item label="角色组" class="search-item">
<el-select
v-model="roleHierarchy"
filterable
@change="roleHierarchyChange"
clearable
>
<el-option
v-for="item in roleHierarchyOption"
:key="item.id"
:value="item.id"
:label="item.name"
></el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</div>
<laws-tree
v-if="isRoleDrawer"
ref="roleTree"
:zNodes="roleZNodes"
treeDivId="roleTree"
:editable="false"
expandFirst
:chkboxType="{ 'Y': '', 'N': '' }"
:check-enable="checkEnable"
:onlyChecked="checkEnable"
deptSelect
:checkIdList="checkIdList"
:loading="loading"
@treeOnCheck="handleRoleTreeOnCheck"
@treeDblClick="(treeId, treeNode) => treeDbRoleTree(treeId, treeNode)"
></laws-tree>
</div>
<div class="demo-drawer-footer" v-if="checkEnable">
<el-button
round
class="common-button-primary"
icon="el-icon-check"
type="primary"
@click="handleRoleTreeDrawerConfirm">确定
</el-button>
<el-button
round
class="common-button-default"
icon="el-icon-close"
@click="handleTreeDrawerCancel">取消</el-button>
</div>
</el-drawer>
</div>
</template>
<script>
export default {
name: '',
props: {
// 显示状态
isAdvancedSearch: {
type: Boolean,
default: false
},
twoOptions: {
type: Array,
default: function () {
return []
}
},
threeOptions: {
type: Array,
default: function () {
return []
}
},
isShow: {
type: Boolean,
default: false
},
selectIndexType: {
type: String,
default: 'INLAND_STAND'
},
activeName: {
type: String,
default: 'first'
}
},
data () {
return {
temp_app: false,
advancedSearch: [
{
one: 'AND',
two: {},
three: '',
threeName: '',
four: '包含',
threeOptions: [],
userId:''
}
],
checkType: null,
isTreeDrawer: false,
isSVPPSDrawer: false, // SVPPS抽屉
SVPPSZNodes: [],
checkIdList: [],
svppsLoading: false,
depNode: [],
checkEnable: false,
advancedSearchIndex: null,
treeDeptNameList: [],
treeDeptIdList: [],
treeRoleNameList: [],
treeRoleIdList: [],
isRoleDrawer: false, // 角色抽屉
roleHierarchy: '',
roleHierarchyOption: [],
roleZNodes: [],
loading: false,
label: '', // 验证是否是FO和项目评估角色
restaurants:[],
timeout: null
}
},
methods: {
// 组件关闭事件
closeIsAdvancedSearch () {
this.temp_app = false
},
twoSelectChange (val, index) {
this.$emit('twoSelectChange', val.value, val)
// 清空填写的数据
this.$set(this.advancedSearch[index], 'three', '')
this.$set(this.advancedSearch[index], 'threeName', '')
this.twoOptions.map(item => {
item.disabled = false
})
// 选中之后置灰,不可重复选择
this.advancedSearch.map(item => {
this.twoOptions.map((items, index) => {
if (item.two.value === items.value) {
items.disabled = true
}
})
})
this.$nextTick(() => {
this.advancedSearch[index].threeOptions = this.threeOptions
})
},
// 点击高级检索 + 号按钮
addAdvancedSearch () {
this.advancedSearch.push(
{
one: 'AND',
two: {},
three: '',
threeName: '',
four: '包含',
threeOptions: []
}
)
},
// 点击高级检索 - 号事件
removeAdvancedSearch (index) {
this.advancedSearch.splice(index, 1)
this.twoOptions.map(item => {
item.disabled = false
})
// 选中之后置灰,不可重复选择
this.advancedSearch.map(item => {
this.twoOptions.map((items, index) => {
if (item.two.value === items.value) {
items.disabled = true
}
})
})
},
// 点击高级检索按钮
getDomesticStandardTableBtn () {
let advancedSearch = []
this.advancedSearch.map((item, index) => {
// delete item.threeOptions
if (item.two.type === 'DATE_PIC_OPTS' || item.two.type === 'DATE_PICKER') {
advancedSearch.push({
connect: index === 0 ? '' : item.one,
field: item.two.value,
type: item.four === '等于' ? '=' : item.four === '不等于' ? '!=' : 'like',
timeSt: item.three[0] ? this.$moment(item.three[0]).format('YYYY-MM-DD') : '',
timeEd: item.three[1] ? this.$moment(item.three[1]).format('YYYY-MM-DD') : ''
})
} else if(item.two.type ==='SEL_OPTION'|| item.two.type ==='SEL_OPTS'){
if (item.two.selVal === 'USERLIST'){
if (!item.userId){
this.$message({
message: '请选择人员',
type: 'warning'
})
return
}
advancedSearch.push({
connect: index === 0 ? '' : item.one,
field: item.two.value,
type: item.four === '等于' ? '=' : item.four === '不等于' ? '!=' : 'like',
value: item.userId ? item.userId : item.three ? '1111111111111111111111111' : ''
})
} else {
advancedSearch.push({
connect: index === 0 ? '' : item.one,
field: item.two.value,
type: item.four === '等于' ? '=' : item.four === '不等于' ? '!=' : 'like',
value: item.three === ' ' ? '' : item.three
})
}
} else {
advancedSearch.push({
connect: index === 0 ? '' : item.one,
field: item.two.value,
type: item.four === '等于' ? '=' : item.four === '不等于' ? '!=' : 'like',
value: item.three
})
}
})
this.$emit('getDomesticStandardTableBtn', advancedSearch, this.temp_app)
this.temp_app = false
},
// 重置事件
clearAllSearch () {
this.advancedSearch = [
{
one: 'AND',
two: {},
three: '',
threeName: '',
four: '包含',
threeOptions: []
}
]
this.twoOptions.map(item => {
item.disabled = false
})
},
// 打开选择部门drawer
handleVisibleDept (index, checked) {
this.advancedSearchIndex = index
this.checkEnable = checked
this.checkType = 'dept'
this.isTreeDrawer = true
},
// 打开选择人员drawer
handleVisibleUser (index, checked) {
// this.advancedSearchIndex = index
// this.checkEnable = checked
// this.checkType = 'person'
// this.isTreeDrawer = true
// this.restaurants =
},
// 打开选择SVPPS抽屉
handleVisibleSVPPS (index) {
this.advancedSearchIndex = index
this.isSVPPSDrawer = true
},
// 打开选择角色抽屉
handleVisibleRole (index, checked, label) {
this.advancedSearchIndex = index
this.checkEnable = checked
this.label = label
if (label === '项目评估角色') {
this.getDeptChild().then(treeNodeList => {
this.getUserByRole('', '', 'FO,VSE,工程师', treeNodeList)
})
} else if (label === 'FO') {
this.getDeptChild().then(treeNodeList => {
this.getUserByRole('', '', 'FO', treeNodeList)
})
} else {
this.getDeptChild().then(treeNodeList => {
this.getUserByRole('', '', '', treeNodeList)
})
}
this.isRoleDrawer = true
},
// 部门树双击事件
treeDbOrgTree (treeId, treeNode) {
this.advancedSearch[this.advancedSearchIndex].three = treeNode.id
this.advancedSearch[this.advancedSearchIndex].threeName = treeNode.oldname || treeNode.name
this.isTreeDrawer = false
this.checkEnable = false
},
// 部门选择事件
treeOnDeptCheck (checkedList) {
this.treeDeptNameList = []
this.treeDeptIdList = []
checkedList.map((item, index) => {
this.treeDeptNameList.push(item.oldname || item.name)
this.treeDeptIdList.push(item.id)
})
},
// 人员树 角色树 双击事件
treeDbRoleTree (treeId, treeNode) {
this.advancedSearch[this.advancedSearchIndex].three = treeNode.id
this.advancedSearch[this.advancedSearchIndex].threeName = treeNode.name
this.isTreeDrawer = false
this.isRoleDrawer = false
this.checkEnable = false
},
// 人员选择事件
treeOnRoleCheck (checkedList) {
this.treeRoleNameList = []
this.treeRoleIdList = []
checkedList.map((item, index) => {
if (!item.isParent) {
this.treeRoleNameList.push(item.name)
this.treeRoleIdList.push(item.id)
}
})
},
// 点击确定赋值部门和人员
isTreeOk () {
if (this.checkType === 'dept') {
this.advancedSearch[this.advancedSearchIndex].threeName = this.treeDeptNameList.join(',')
this.advancedSearch[this.advancedSearchIndex].three = this.treeDeptIdList.join(',')
} else if (this.checkType === 'person') {
this.advancedSearch[this.advancedSearchIndex].threeName = this.treeRoleNameList.join(',')
this.advancedSearch[this.advancedSearchIndex].three = this.treeRoleIdList.join(',')
}
this.isTreeDrawer = false
this.checkEnable = false
},
// 请求部门结构树
getOrgTreeSource () {
this.$http.get('sys/org/getTree', {
orgType: 'DEPART'
}, {_this: this},
res => {
if (res.ok) {
let treeNode = []
res.data.map((item, index) => {
let treeItem = {}
for (let key in item) {
if (key === 'orgName') {
treeItem.name = item[key]
treeItem.icon = 'static/images/dept.png'
} else {
treeItem[key] = item[key]
treeItem.icon = 'static/images/dept.png'
}
}
treeNode[index] = treeItem
})
this.depNode = treeNode
}
})
},
// 选择SVPPS事件
handleOnCheck (treeCheckNode) {
this.treeCheckNode = treeCheckNode
},
// 选择SVPPS确定事件
handleTreeDrawerConfirm () {
const checkedList = []
const checkedNameList = []
if (this.treeCheckNode.length > 0) {
this.treeCheckNode.map(item => {
// if (item.pId) {
checkedList.push(item.id)
checkedNameList.push(item.svppsCode)
// }
})
this.advancedSearch[this.advancedSearchIndex].threeName = checkedNameList.join(',')
this.advancedSearch[this.advancedSearchIndex].three = checkedList.join(',')
}
this.isSVPPSDrawer = false
},
// 选择SVPPS取消事件
handleTreeDrawerCancel () {
this.isSVPPSDrawer = false
this.isRoleDrawer = false
},
// 赋值回显事件
drawerOpen () {
this.checkIdList = this.advancedSearch[this.advancedSearchIndex].three ? this.advancedSearch[this.advancedSearchIndex].three.split(',') : []
},
// 请求SVPPS
getSvpps () {
this.svppsLoading = true
this.$http.get('/lawss/otSvpps/selectThree', {}, {
_this: this
}, res => {
this.svppsLoading = false
if (res.ok) {
let treeNode = []
res.data.map((item, index) => {
let treeItem = {
name: item.svppsCode + ' ' + item.svppsCnName + ' ' + item.svppsEnName,
pId: item.pid,
id: item.id,
svppsCode: item.svppsCode,
snum: item.snum,
fnum: item.fnum,
tnum: item.tnum
}
treeNode[index] = treeItem
})
this.SVPPSZNodes = treeNode
}
})
},
// 角色选择事件
handleRoleTreeOnCheck (treeCheckNode) {
this.treeCheckNode = treeCheckNode
},
// 选择角色确定事件
handleRoleTreeDrawerConfirm () {
const checkedList = []
const checkedNameList = []
this.treeCheckNode.map(item => {
checkedList.push(item.id)
checkedNameList.push(item.oldname || item.name)
})
this.advancedSearch[this.advancedSearchIndex].threeName = checkedNameList.join(',')
this.advancedSearch[this.advancedSearchIndex].three = checkedList.join(',')
this.isRoleDrawer = false
},
// 角色组change查询角色树
roleHierarchyChange (val) {
this.getDeptChild().then(treeNodeList => {
this.getUserByRole('', val, '', treeNodeList)
})
},
// 获取选中的部门下子子部门
getDeptChild () {
return new Promise((resolve, reject) => {
this.$http.get('sys/org/getChildDept', {
orgId: ''
}, {
_this: this
}, res => {
if (res.ok) {
// 获取组织与人员完毕,开始组装树结构
let zNodes = []
let treeNodeList = res.data
for (let i = 0; i < treeNodeList.length; i++) {
let zObj = {}
zObj.id = treeNodeList[i].id
zObj.pId = treeNodeList[i].pId
// 该节点为机构
zObj.name = treeNodeList[i].orgName
zObj.icon = 'static/images/dept.png'
zObj.isParent = true
zObj.shotName = treeNodeList[i].shotName
zObj.remarks = treeNodeList[i].remarks
zObj.iconSkin = 'org-dept'
zNodes[i] = zObj
}
resolve(res.data)
}
}, e => {
reject(e)
})
})
},
// 查询指定角色树
getUserByRole (orgId, roleHierarchy, roleHierarchyName, treeNodeList) {
this.loading = true
this.$http.get('sys/role/getRoleByOrgId', {
orgId,
roleHierarchy,
roleHierarchyName,
type: 0
}, {
_this: this
}, res => {
this.loading = false
if (res.ok) {
for (let i = 0; i < res.data.length; i++) {
let obj = {}
for (let key in res.data[i]) {
if (key === 'usid') {
obj.id = res.data[i][key]
} else if (key === 'orgId') {
obj.pId = res.data[i][key]
} else {
obj[key] = res.data[i][key]
}
}
treeNodeList.push(obj)
}
// 获取组织与人员完毕,开始组装树结构
let zNodes = []
for (let i = 0; i < treeNodeList.length; i++) {
let zObj = {}
// 该节点为角色
if (!treeNodeList[i].orgName) {
zObj.id = treeNodeList[i].id
zObj.pId = treeNodeList[i].dyOrgId
zObj.name = treeNodeList[i].name
zObj.icon = 'static/images/user.png'
zObj.iconSkin = 'org-user'
zObj.shotName = treeNodeList[i].shotName
zObj.remarks = treeNodeList[i].remarks
} else {
// 该节点为机构
zObj.id = treeNodeList[i].id
zObj.pId = treeNodeList[i].pId
zObj.name = treeNodeList[i].orgName
zObj.oldname = treeNodeList[i].orgName
zObj.icon = 'static/images/dept.png'
zObj.iconSkin = 'org-dept'
zObj.isParent = true
zObj.isChecked = true
}
if (zObj.pId === null && !zObj.isParent) {
zObj.pId = ''
zObj.orgName = '未分配人员'
}
zNodes[i] = zObj
}
this.roleZNodes = zNodes
}
}, e => {
this.loading = false
})
},
// 查询角色组
getRoleGroup () {
this.$http.get('sys/role/getRoleGroup', {}, {
_this: this
}, res => {
if (res.ok) {
this.roleHierarchyOption = res.data
}
})
},
/**
* @Description:
* @author zmf
* @date 2021/3/22
*/
setBlur() {
// 法规维护人清空后再次输入不搜索问题解决方法
document.activeElement.blur()
},
querySearchAsync(queryString, cb) {
let restaurants = this.restaurants;
let results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
cb(results);
}, 3000 * Math.random());
},
createStateFilter(queryString) {
return (state) => {
return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
};
},
handleSelect(item,index) {
this.advancedSearch[index].userId = item.id
// return item.id
}
},
watch: {
isAdvancedSearch (val) {
this.temp_app = val
},
temp_app (val) {
this.$emit('update:isAdvancedSearch', val)
},
selectIndexType (val) {
this.advancedSearch = [
{
one: 'AND',
two: {},
three: '',
threeName: '',
four: '包含',
threeOptions: []
}
]
},
activeName(val) {
this.$refs['advancedSearch'].resetFields()
}
},
mounted () {
this.getOrgTreeSource()
this.getSvpps()
// this.getUserByRole()
this.getRoleGroup()
this.$http.get('sys/user/getUser', {
page: 1,
pageSize: 999999
}, {_this: this},
res => {
if (res.ok) {
let array = res.data
let temp = []
array.forEach(item=>{
temp.push({
value: item.email ? item.uname + ' '+ item.email : item.uname,
id: item.usid
})
})
this.restaurants = temp
}
})
},
destroyed () {
this.restaurants = []
clearTimeout(this.timeout)
}
}
</script>
<style lang="less" scoped>
.advanced-class{
visibility: hidden;
}
.advanced-one{
width: 115px;
}
.advancedSearch-btn{
padding: 12px 12px;
color: #ffffff;
background: #409EFF;
border: none;
}
.advancedSearch-btn-reduce{
padding: 12px 12px;
color: #999;
background: #fff;
border: 1px solid #DCDFE6;
}
.advance-dialog {
.advance-dialog-form{
.el-date-editor, .advanced-three{
width: 247px;
}
.el-date-editor{
/deep/& > span{
width: auto;
}
}
}
}
button.el-button.advancedSearch-btn-reduce.el-button--default{
margin-left: 0;
}
.query-box{
width: 850px;
.advance-dialog-form{
.advanced-class{
visibility: hidden;
}
.advanced-one{
width: 115px;
}
.advancedSearch-btn{
padding: 12px 12px;
color: #ffffff;
background: #409EFF;
border: none;
}
.advancedSearch-btn-reduce{
padding: 12px 12px;
color: #999;
background: #fff;
border: 1px solid #DCDFE6;
}
.el-date-editor, .advanced-three{
width: 247px;
}
.el-date-editor{
/deep/& > span{
width: auto;
}
}
}
.search-condition-btn{
text-align: right;
}
}
</style>