MinterFilter.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <el-select
  3. v-model="minterId"
  4. filterable
  5. remote
  6. reserve-keyword
  7. placeholder="请输入艺术家"
  8. :remote-method="searchMinter"
  9. :loading="searchingMinter"
  10. @change="changeSelect"
  11. :disabled="disabled"
  12. class="filter-item"
  13. clearable
  14. >
  15. <el-option v-for="item in minters" :key="item.id" :label="item.nickname" :value="item.id" class="minter-item">
  16. <el-image :src="item.avatar" fit="cover" class="avatar"></el-image>
  17. <div class="content">
  18. <div class="name">{{ item.nickname }}</div>
  19. <div class="id">#{{ item.id }}</div>
  20. </div>
  21. </el-option>
  22. </el-select>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. value: {},
  28. disabled: {
  29. default() {
  30. return false;
  31. }
  32. },
  33. projectId: {}
  34. },
  35. data() {
  36. return {
  37. minters: [],
  38. minterId: null,
  39. searchingMinter: false,
  40. selected: null,
  41. id: 0
  42. };
  43. },
  44. created() {
  45. this.id = this.projectId;
  46. this.getData();
  47. },
  48. methods: {
  49. searchMinter(query) {
  50. this.searchingMinter = true;
  51. this.$http
  52. .post(
  53. '/user/all',
  54. {
  55. search: query,
  56. size: 30,
  57. query: { hasRole: 'ROLE_MINTER', minterProjectId: this.id }
  58. },
  59. { body: 'json' }
  60. )
  61. .then(res => {
  62. this.minters = res.content;
  63. this.searchingMinter = false;
  64. });
  65. },
  66. changeSelect(val) {
  67. this.$emit('input', val);
  68. },
  69. getData() {
  70. this.$http
  71. .post(
  72. '/user/all',
  73. { size: 30, query: { hasRole: 'ROLE_MINTER', minterProjectId: this.id } },
  74. { body: 'json' }
  75. )
  76. .then(res => {
  77. this.minters = res.content;
  78. });
  79. }
  80. },
  81. watch: {
  82. value(val) {
  83. if (this.minterId !== val) {
  84. this.minterId = val;
  85. }
  86. },
  87. projectId(val) {
  88. if (this.id !== val) {
  89. this.id = val;
  90. this.getData();
  91. }
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="less" scoped>
  97. .minter-item {
  98. .flex();
  99. height: 44px;
  100. .avatar {
  101. width: 32px;
  102. height: 32px;
  103. border-radius: 50%;
  104. }
  105. .content {
  106. margin-left: 10px;
  107. line-height: 1;
  108. .flex-col();
  109. justify-content: center;
  110. .name {
  111. font-size: 14px;
  112. color: @text2;
  113. }
  114. .id {
  115. font-size: 12px;
  116. color: @text3;
  117. margin-top: 5px;
  118. }
  119. }
  120. }
  121. </style>