selectPositions.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <el-cascader
  3. ref="cascader"
  4. v-model="selection"
  5. :options="options"
  6. :props="props"
  7. collapse-tags
  8. class="cascader"
  9. :clearable="false"
  10. />
  11. </template>
  12. <script>
  13. import TreeUtils from '@/utils/tree'
  14. export default {
  15. props: {
  16. filterGroup: {
  17. type: Boolean,
  18. default: false
  19. }
  20. },
  21. data() {
  22. const { level } = this.$store.getters
  23. return {
  24. level,
  25. props: {
  26. children: 'children',
  27. label: 'positionName',
  28. value: 'positionId',
  29. multiple: false,
  30. expandTrigger: 'hover',
  31. checkStrictly: true,
  32. emitPath: false
  33. },
  34. options: [],
  35. selection: '',
  36. selectionDept: {},
  37. filterDept: []
  38. }
  39. },
  40. watch: {
  41. selection(val) {
  42. if (!val) {
  43. return
  44. }
  45. this.$emit('handleFunc', {
  46. selection: this.selection,
  47. selectionDept: this.selectionDept,
  48. filterDept: this.filterDept
  49. })
  50. }
  51. },
  52. mounted() {
  53. this.getPositionList()
  54. },
  55. methods: {
  56. // 获取本账户所在的部门
  57. getPositionList() {
  58. // 直接获取store部门数据,无需调用接口
  59. // this.$common.request('query', {
  60. // key: 'empManageBoard0',
  61. // params: [this.level.first]
  62. // }).then(({ state, variables: { data } }) => {
  63. const {
  64. deptList = [],
  65. mainPosition,
  66. position
  67. } = this.$store.getters || {}
  68. const mainPos = mainPosition ? mainPosition.id : position.split(',')[0]
  69. this.selection = mainPos
  70. this.selectionDept = deptList.find((i) => i.positionId === mainPos)
  71. const deptEntity = deptList.filter((i) => i.depth >= 3)
  72. const filterLetter = [
  73. '综合',
  74. '质量',
  75. '科研',
  76. '教学',
  77. '医疗',
  78. '样品',
  79. '助理',
  80. '急诊'
  81. ]
  82. this.filterDept = this.filterGroup
  83. ? deptEntity.filter(
  84. (d) => !filterLetter.some((i) => d.positionName.includes(i))
  85. )
  86. : deptEntity
  87. this.options = this.toTree(this.filterDept)
  88. console.log(mainPosition, position, 'this.optionsthis.options')
  89. },
  90. toTree(data) {
  91. return TreeUtils.transformToTreeFormat(data, {
  92. idKey: 'positionId',
  93. pIdKey: 'parentId',
  94. childrenKey: 'children'
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="less" scoped>
  101. /deep/ .el-tag--info {
  102. color: #fcfcfc;
  103. background-color: #00083e;
  104. }
  105. /deep/.el-input__inner {
  106. background-color: #00083e;
  107. border: 1px solid #4ea5d6;
  108. color: #fff;
  109. }
  110. </style>