index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <m-card noTitle class="py-5">
  3. <center class="pb-3">
  4. <div class="text">请选择{{ label }}进行比较: </div>
  5. <v-autocomplete
  6. v-model="candidate"
  7. class="select my-3 input-width-xl"
  8. :label="`候选${label}`"
  9. :placeholder="`候选${label}`"
  10. :items="candidateItems"
  11. hide-details
  12. clearable
  13. outlined
  14. dense
  15. :item-value="r => r"
  16. />
  17. <span>VS</span>
  18. <v-autocomplete
  19. v-model="comparison"
  20. class="select my-3 input-width-xl"
  21. :label="`候选${label}`"
  22. :placeholder="`候选${label}`"
  23. :items="comparisonItems"
  24. hide-details
  25. clearable
  26. outlined
  27. dense
  28. :item-value="r => r"
  29. />
  30. <v-btn color="primary" class="mt-5 buttons" elevation="5" rounded @click="submit">执行比较</v-btn>
  31. </center>
  32. </m-card>
  33. </template>
  34. <script>
  35. // 对比
  36. import MCard from '@/components/MCard'
  37. import { coreGraph } from '@/api'
  38. import { organizationList } from '@/api/panoramic.js'
  39. export default {
  40. name: 'comparison-page',
  41. components: { MCard },
  42. props: {
  43. category: {
  44. type: String,
  45. default: '支行'
  46. },
  47. label: {
  48. type: String,
  49. default: '机构'
  50. },
  51. // 员工对比
  52. isEmp: {
  53. type: Boolean,
  54. default: false
  55. }
  56. },
  57. data () {
  58. return {
  59. candidate: {},
  60. comparison: {},
  61. items: []
  62. }
  63. },
  64. computed: {
  65. candidateItems () {
  66. return this.items.filter(e => e.value !== this.comparison.value)
  67. },
  68. comparisonItems () {
  69. return this.items.filter(e => e.value !== this.candidate.value)
  70. }
  71. },
  72. created () {
  73. this.isEmp ? this.initEmp() : this.init()
  74. },
  75. methods: {
  76. async init () {
  77. try {
  78. const { data } = await organizationList(
  79. {
  80. page: { current: 1, size: 999 },
  81. entity: { organizationCategory: this.category }
  82. }
  83. )
  84. this.items = data.records.map(e => {
  85. return { text: e.entity.organizationName, value: e.entity.organizationNo }
  86. })
  87. } catch (error) {
  88. this.$snackbar.error(error)
  89. }
  90. },
  91. async initEmp () {
  92. const query = {
  93. metaDataCombinationEngName: 'employee_list',
  94. history: 1,
  95. pageState: 0
  96. }
  97. try {
  98. const { data } = await coreGraph(query)
  99. this.items = data.map(item => {
  100. return { text: item.employee_name, value: item.personnel_code }
  101. })
  102. } catch (error) {
  103. this.$snackbar.error(error)
  104. }
  105. },
  106. submit () {
  107. if (!this.candidate.value || !this.comparison.value) {
  108. this.$snackbar.warning(`请选择对比的${this.label}`)
  109. return
  110. }
  111. this.$emit('vsClick', `${this.candidate.value},${this.comparison.value}`, `${this.candidate.text},${this.comparison.text}`)
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .select {
  118. width: 30%;
  119. }
  120. </style>