index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <!--选择用户-->
  3. <Drawer title="选择用户" placement="right" :class="[position === 'top' ? 'top486' : 'delistingBottom']" @cancel="cancel">
  4. <a-spin :spinning="loading">
  5. <div class="listed">
  6. <a-form class="inlineForm dialogForm">
  7. <a-input-search placeholder="搜索用户名称" class="searchFriendInput noSuffixInput" enter-button
  8. v-model:value="searchValue" @change="searchUser">
  9. <template #prefix>
  10. <SearchOutlined />
  11. </template>
  12. </a-input-search>
  13. <div class="formBar ant-checkbox-group commonCheckboxGroup whitebgCheckbox">
  14. <!-- <a-checkbox-group class="commonCheckboxGroup"> -->
  15. <div class="ant-checkbox-wrapper" style="width: 100%">
  16. <a-checkbox-group v-model:value="selectedUser" style="width: 100%">
  17. <div class="item" v-for="(item, index) in userList" :key="index + '11'">
  18. <a-checkbox :value="item.userid">
  19. <span class="txt">{{ item.userid }} {{ item.username }}</span>
  20. </a-checkbox>
  21. </div>
  22. </a-checkbox-group>
  23. </div>
  24. <!-- </a-checkbox-group> -->
  25. </div>
  26. <a-row :gutter="24">
  27. <a-col :span="24" class="fixedBtns">
  28. <a-form-item class="btnCenter">
  29. <a-button class="listedBtn" @click="submit">确定</a-button>
  30. </a-form-item>
  31. </a-col>
  32. </a-row>
  33. </a-form>
  34. </div>
  35. </a-spin>
  36. </Drawer>
  37. </template>
  38. <script lang="ts">
  39. import { defineComponent, PropType, ref, computed } from 'vue';
  40. import Drawer from '@/common/components/drawer/index.vue';
  41. import { SearchOutlined } from '@ant-design/icons-vue';
  42. import { QueryWrSearchUserRsp } from '@/services/go/wrtrade/interface';
  43. import { queryWrSearchUser } from '@/services/go/wrtrade';
  44. import { message } from 'ant-design-vue';
  45. import { timerInterceptor } from '@/@next/utils/timer'
  46. export default defineComponent({
  47. emits: ['update:visible', 'update:selectedValue'],
  48. components: {
  49. Drawer,
  50. SearchOutlined
  51. },
  52. props: {
  53. position: {
  54. type: String,
  55. default: 'top',
  56. },
  57. selectedValue: {
  58. type: Array as PropType<number[]>,
  59. default: [],
  60. },
  61. },
  62. setup(props, context) {
  63. const loading = ref<boolean>(false);
  64. const searchValue = ref<string>('');
  65. const userList = ref<QueryWrSearchUserRsp[]>([]);
  66. const selectedUser = computed({
  67. get: () => props.selectedValue,
  68. set: (val) => context.emit('update:selectedValue', val)
  69. })
  70. // 查询用户
  71. const searchUser = timerInterceptor.setDebounce(() => {
  72. userList.value = [];
  73. selectedUser.value = [];
  74. if (searchValue.value) {
  75. loading.value = true;
  76. queryWrSearchUser({ username: searchValue.value })
  77. .then((res) => {
  78. userList.value = res;
  79. })
  80. .catch((err: string) => message.error(err))
  81. .finally(() => {
  82. loading.value = false;
  83. })
  84. }
  85. }, 500)
  86. const submit = () => {
  87. if (selectedUser.value.length) {
  88. cancel();
  89. } else {
  90. message.warn('请选择用户');
  91. }
  92. }
  93. const cancel = () => {
  94. context.emit('update:visible', false);
  95. }
  96. return {
  97. loading,
  98. userList,
  99. selectedUser,
  100. cancel,
  101. submit,
  102. searchValue,
  103. searchUser,
  104. };
  105. },
  106. });
  107. </script>
  108. <style lang="less" scoped>
  109. .listed {
  110. flex: 1;
  111. padding: 18px 20px 0;
  112. .formBar {
  113. height: calc(100% - 120px);
  114. padding: 0 20px 0 13px;
  115. margin-top: 16px;
  116. background: @m-grey63;
  117. border: 1px solid @m-black45;
  118. .item {
  119. width: 100%;
  120. height: 50px;
  121. line-height: 50px;
  122. border-bottom: 1px solid @m-black45;
  123. font-size: 16px;
  124. color: @m-white6;
  125. }
  126. }
  127. }
  128. .listedBtn {
  129. width: 120px;
  130. height: 30px;
  131. line-height: 30px;
  132. background: linear-gradient(0deg, @m-blue2 0%, @m-blue0 100%);
  133. border-radius: 3px;
  134. color: @m-white0;
  135. font-size: 14px;
  136. text-align: center;
  137. border: 0;
  138. &:hover {
  139. background: linear-gradient(0deg, @m-blue0-hover 0%, @m-blue2-hover 100%);
  140. color: @m-white0-hover;
  141. }
  142. }
  143. .ant-checkbox-group.commonCheckboxGroup {
  144. .ant-checkbox-wrapper {
  145. span.txt {
  146. color: @m-white11;
  147. }
  148. }
  149. }
  150. </style>