| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <!--选择用户-->
- <Drawer title="选择用户" placement="right" :class="[position === 'top' ? 'top486' : 'delistingBottom']" @cancel="cancel">
- <a-spin :spinning="loading">
- <div class="listed">
- <a-form class="inlineForm dialogForm">
- <a-input-search placeholder="搜索用户名称" class="searchFriendInput noSuffixInput" enter-button
- v-model:value="searchValue" @change="searchUser">
- <template #prefix>
- <SearchOutlined />
- </template>
- </a-input-search>
- <div class="formBar ant-checkbox-group commonCheckboxGroup whitebgCheckbox">
- <!-- <a-checkbox-group class="commonCheckboxGroup"> -->
- <div class="ant-checkbox-wrapper" style="width: 100%">
- <a-checkbox-group v-model:value="selectedUser" style="width: 100%">
- <div class="item" v-for="(item, index) in userList" :key="index + '11'">
- <a-checkbox :value="item.userid">
- <span class="txt">{{ item.userid }} {{ item.username }}</span>
- </a-checkbox>
- </div>
- </a-checkbox-group>
- </div>
- <!-- </a-checkbox-group> -->
- </div>
- <a-row :gutter="24">
- <a-col :span="24" class="fixedBtns">
- <a-form-item class="btnCenter">
- <a-button class="listedBtn" @click="submit">确定</a-button>
- </a-form-item>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </a-spin>
- </Drawer>
- </template>
- <script lang="ts">
- import { defineComponent, PropType, ref, computed } from 'vue';
- import Drawer from '@/common/components/drawer/index.vue';
- import { SearchOutlined } from '@ant-design/icons-vue';
- import { QueryWrSearchUserRsp } from '@/services/go/wrtrade/interface';
- import { queryWrSearchUser } from '@/services/go/wrtrade';
- import { message } from 'ant-design-vue';
- import { timerInterceptor } from '@/@next/utils/timer'
- export default defineComponent({
- emits: ['update:visible', 'update:selectedValue'],
- components: {
- Drawer,
- SearchOutlined
- },
- props: {
- position: {
- type: String,
- default: 'top',
- },
- selectedValue: {
- type: Array as PropType<number[]>,
- default: [],
- },
- },
- setup(props, context) {
- const loading = ref<boolean>(false);
- const searchValue = ref<string>('');
- const userList = ref<QueryWrSearchUserRsp[]>([]);
- const selectedUser = computed({
- get: () => props.selectedValue,
- set: (val) => context.emit('update:selectedValue', val)
- })
- // 查询用户
- const searchUser = timerInterceptor.setDebounce(() => {
- userList.value = [];
- selectedUser.value = [];
- if (searchValue.value) {
- loading.value = true;
- queryWrSearchUser({ username: searchValue.value })
- .then((res) => {
- userList.value = res;
- })
- .catch((err: string) => message.error(err))
- .finally(() => {
- loading.value = false;
- })
- }
- }, 500)
- const submit = () => {
- if (selectedUser.value.length) {
- cancel();
- } else {
- message.warn('请选择用户');
- }
- }
- const cancel = () => {
- context.emit('update:visible', false);
- }
- return {
- loading,
- userList,
- selectedUser,
- cancel,
- submit,
- searchValue,
- searchUser,
- };
- },
- });
- </script>
- <style lang="less" scoped>
- .listed {
- flex: 1;
- padding: 18px 20px 0;
- .formBar {
- height: calc(100% - 120px);
- padding: 0 20px 0 13px;
- margin-top: 16px;
- background: @m-grey63;
- border: 1px solid @m-black45;
- .item {
- width: 100%;
- height: 50px;
- line-height: 50px;
- border-bottom: 1px solid @m-black45;
- font-size: 16px;
- color: @m-white6;
- }
- }
- }
- .listedBtn {
- width: 120px;
- height: 30px;
- line-height: 30px;
- background: linear-gradient(0deg, @m-blue2 0%, @m-blue0 100%);
- border-radius: 3px;
- color: @m-white0;
- font-size: 14px;
- text-align: center;
- border: 0;
- &:hover {
- background: linear-gradient(0deg, @m-blue0-hover 0%, @m-blue2-hover 100%);
- color: @m-white0-hover;
- }
- }
- .ant-checkbox-group.commonCheckboxGroup {
- .ant-checkbox-wrapper {
- span.txt {
- color: @m-white11;
- }
- }
- }
- </style>
|