index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <!--选择朋友-->
  3. <Drawer
  4. :title="'选择朋友'"
  5. :placement="'right'"
  6. :visible="visible"
  7. @cancel="cancel"
  8. :class="[position === 'top' ? 'top486' : 'delistingBottom']"
  9. >
  10. <a-spin :spinning="loading">
  11. <div class="listed">
  12. <a-form class="inlineForm dialogForm">
  13. <a-input-search
  14. placeholder="搜索朋友编码或名称"
  15. class="searchFriendInput noSuffixInput"
  16. enter-button
  17. v-model:value="searchValue"
  18. >
  19. <template #prefix>
  20. <SearchOutlined />
  21. </template>
  22. </a-input-search>
  23. <div class="formBar ant-checkbox-group commonCheckboxGroup whitebgCheckbox">
  24. <!-- <a-checkbox-group class="commonCheckboxGroup"> -->
  25. <div class="ant-checkbox-wrapper" style="width: 100%">
  26. <div
  27. class="item"
  28. v-for="(item, index) in getViewFriends()"
  29. :key="index + '11'"
  30. >
  31. <a-checkbox v-model:checked="item.checked">
  32. <span class="txt">{{ item.frienduserid }} {{ item.friendname }}</span>
  33. </a-checkbox>
  34. </div>
  35. </div>
  36. <!-- </a-checkbox-group> -->
  37. </div>
  38. <a-row :gutter="24">
  39. <a-col :span="24" class="fixedBtns">
  40. <a-form-item class="btnCenter">
  41. <a-button class="listedBtn" @click="submit">确定</a-button>
  42. </a-form-item>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. </a-spin>
  48. </Drawer>
  49. </template>
  50. <script lang="ts">
  51. import { defineComponent, PropType, ref } from 'vue';
  52. import { Des } from '@/common/components/commonDes';
  53. import { _closeModal } from '@/common/setup/modal/modal';
  54. import Drawer from '@/common/components/drawer/index.vue';
  55. import { PlusOutlined, MinusOutlined, SearchOutlined } from '@ant-design/icons-vue';
  56. import { QueryWrFriendApplyRsp } from '@/services/go/wrtrade/interface';
  57. import { TempWrOrderQuoteDetail } from '@/views/market/market-spot/components/post_buying/interface';
  58. import { queryQueryWrFriend } from '@/services/go/wrtrade';
  59. import { message } from 'ant-design-vue';
  60. interface FriendList extends QueryWrFriendApplyRsp {
  61. checked: boolean;
  62. }
  63. export default defineComponent({
  64. emits: ['cancel', 'update'],
  65. name: 'warehouse_receipt_trade_blocs_delisting',
  66. components: { Des, Drawer, PlusOutlined, MinusOutlined, SearchOutlined },
  67. props: {
  68. position: {
  69. type: String,
  70. default: 'top',
  71. },
  72. friends: {
  73. type: Array as PropType<number[]>,
  74. default: [],
  75. },
  76. },
  77. setup(props, context) {
  78. const { visible, cancel } = _closeModal(context);
  79. const loading = ref<boolean>(false);
  80. const searchValue = ref<string>('');
  81. const myFriends = ref<FriendList[]>([]);
  82. // 查询好友列表
  83. function queryMyFriend(value?: string) {
  84. loading.value = true;
  85. queryQueryWrFriend(value)
  86. .then((res) => {
  87. if (res) {
  88. myFriends.value = [];
  89. res.forEach((el) => {
  90. const checked = props.friends.includes(el.frienduserid) ? true : false;
  91. myFriends.value.push({ ...el, checked });
  92. });
  93. }
  94. })
  95. .catch((err: string) => message.error(err))
  96. .finally(() => {
  97. loading.value = false;
  98. });
  99. }
  100. queryMyFriend();
  101. function getViewFriends() {
  102. if (searchValue.value) {
  103. return myFriends.value.filter((el) => String(el.frienduserid).includes(searchValue.value));
  104. } else {
  105. return myFriends.value;
  106. }
  107. }
  108. function submit() {
  109. const result: number[] = [];
  110. myFriends.value.forEach((el) => {
  111. if (el.checked) {
  112. result.push(el.frienduserid);
  113. }
  114. });
  115. if (result.length) {
  116. context.emit('update', result);
  117. } else {
  118. message.warn('请选择朋友');
  119. }
  120. }
  121. return {
  122. loading,
  123. myFriends,
  124. cancel,
  125. visible,
  126. submit,
  127. searchValue,
  128. getViewFriends,
  129. };
  130. },
  131. });
  132. </script>
  133. <style lang="less" scoped>
  134. .listed {
  135. padding: 18px 20px 0;
  136. .formBar {
  137. height: calc(100% - 120px);
  138. padding: 0 20px 0 13px;
  139. margin-top: 16px;
  140. background: @m-grey63;
  141. border: 1px solid @m-black45;
  142. .item {
  143. width: 100%;
  144. height: 50px;
  145. line-height: 50px;
  146. border-bottom: 1px solid @m-black45;
  147. font-size: 16px;
  148. color: @m-white6;
  149. }
  150. }
  151. }
  152. .ant-checkbox-group.commonCheckboxGroup {
  153. .ant-checkbox-wrapper {
  154. span.txt {
  155. color: @m-white11;
  156. }
  157. }
  158. }
  159. </style>