| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <el-cascader
- ref="cascader"
- v-model="selection"
- :options="options"
- :props="props"
- collapse-tags
- class="cascader"
- :clearable="false"
- />
- </template>
- <script>
- import TreeUtils from '@/utils/tree'
- export default {
- props: {
- filterGroup: {
- type: Boolean,
- default: false
- }
- },
- data() {
- const { level } = this.$store.getters
- return {
- level,
- props: {
- children: 'children',
- label: 'positionName',
- value: 'positionId',
- multiple: false,
- expandTrigger: 'hover',
- checkStrictly: true,
- emitPath: false
- },
- options: [],
- selection: '',
- selectionDept: {},
- filterDept: []
- }
- },
- watch: {
- selection(val) {
- if (!val) {
- return
- }
- this.$emit('handleFunc', {
- selection: this.selection,
- selectionDept: this.selectionDept,
- filterDept: this.filterDept
- })
- }
- },
- mounted() {
- this.getPositionList()
- },
- methods: {
- // 获取本账户所在的部门
- getPositionList() {
- // 直接获取store部门数据,无需调用接口
- // this.$common.request('query', {
- // key: 'empManageBoard0',
- // params: [this.level.first]
- // }).then(({ state, variables: { data } }) => {
- const {
- deptList = [],
- mainPosition,
- position
- } = this.$store.getters || {}
- const mainPos = mainPosition ? mainPosition.id : position.split(',')[0]
- this.selection = mainPos
- this.selectionDept = deptList.find((i) => i.positionId === mainPos)
- const deptEntity = deptList.filter((i) => i.depth >= 3)
- const filterLetter = [
- '综合',
- '质量',
- '科研',
- '教学',
- '医疗',
- '样品',
- '助理',
- '急诊'
- ]
- this.filterDept = this.filterGroup
- ? deptEntity.filter(
- (d) => !filterLetter.some((i) => d.positionName.includes(i))
- )
- : deptEntity
- this.options = this.toTree(this.filterDept)
- console.log(mainPosition, position, 'this.optionsthis.options')
- },
- toTree(data) {
- return TreeUtils.transformToTreeFormat(data, {
- idKey: 'positionId',
- pIdKey: 'parentId',
- childrenKey: 'children'
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- /deep/ .el-tag--info {
- color: #fcfcfc;
- background-color: #00083e;
- }
- /deep/.el-input__inner {
- background-color: #00083e;
- border: 1px solid #4ea5d6;
- color: #fff;
- }
- </style>
|