SelectPartnersConcat.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-08-01 16:27:11
  6. * @Description: file content
  7. * @FilePath: \oms\components\SelectPartnersConcat.vue
  8. -->
  9. <template>
  10. <view>
  11. <u-popup :show="selectVisible" @close="close">
  12. <view class="select-header">
  13. <view class="tit">选择合作伙伴联系人</view>
  14. <view class="save-btn" @click="close()">保存</view>
  15. </view>
  16. <view class="search-container">
  17. <view class="search-input">
  18. <u-input
  19. clearable
  20. placeholderStyle="font-size:26rpx"
  21. :customStyle="{ height: '66rpx' }"
  22. v-model="queryForm.name"
  23. prefixIcon="search"
  24. prefixIconStyle="font-size: 22px;color: #909399"
  25. placeholder="请输入客户名称"
  26. shape="circle"
  27. @input="getUserList()"
  28. border="surround"></u-input>
  29. </view>
  30. </view>
  31. <u-empty mode="list" v-if="userList.length == 0"></u-empty>
  32. <view class="concat-list" v-else>
  33. <u-radio-group v-model="userValue" placement="column">
  34. <view class="radio-item" v-for="item in userList" :key="item.id">
  35. <u-radio :label="item.label" :name="item.id" @change="radioChange"></u-radio>
  36. </view>
  37. </u-radio-group>
  38. </view>
  39. </u-popup>
  40. </view>
  41. </template>
  42. <script>
  43. import partnerApi from '@/api/partner'
  44. import to from 'await-to-js'
  45. export default {
  46. name: 'OmsCustomerContact',
  47. props: {
  48. queryParams: {
  49. type: Object,
  50. default() {
  51. return {}
  52. },
  53. },
  54. },
  55. data() {
  56. return {
  57. selectVisible: false,
  58. userList: [],
  59. queryForm: {
  60. name: '',
  61. pageNum: 1,
  62. pageSize: 999,
  63. },
  64. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  65. userValue: null,
  66. selected: null,
  67. }
  68. },
  69. methods: {
  70. async getUserList() {
  71. let params = Object.assign(this.queryForm, this.queryParams)
  72. const [err, res] = await to(partnerApi.getCompanyConcatList(params))
  73. if (err) return
  74. if (res.code == 200) {
  75. if (res.data.list && res.data.list.length > 0) {
  76. this.userList = res.data.list.map((item) => ({
  77. id: item.id,
  78. label: item.name,
  79. name: item.name,
  80. }))
  81. } else {
  82. this.userList = []
  83. }
  84. }
  85. },
  86. open(userValue) {
  87. console.log(userValue)
  88. this.userValue = userValue || null
  89. this.selected = null
  90. this.selectVisible = true
  91. this.getUserList()
  92. },
  93. close() {
  94. this.selectVisible = false
  95. this.$emit('close', this.selected)
  96. },
  97. radioChange(n) {
  98. this.selected = this.userList.find((item) => item.id == n)
  99. },
  100. },
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .search-container {
  105. padding: 30rpx 30rpx 0 30rpx;
  106. display: flex;
  107. align-items: center;
  108. .search-input {
  109. flex: 1;
  110. }
  111. .search-btn {
  112. text-align: center;
  113. line-height: 60rpx;
  114. border-radius: 12rpx;
  115. width: 100rpx;
  116. height: 60rpx;
  117. font-size: 26rpx;
  118. margin: 0 0 0 12rpx;
  119. background: $u-primary;
  120. color: #ffffff;
  121. }
  122. }
  123. .concat-list {
  124. padding: 0 0 20rpx 0;
  125. width: 100%;
  126. height: 900rpx;
  127. overflow: auto;
  128. margin-top: 20rpx;
  129. .radio-item {
  130. padding: 20rpx 30rpx;
  131. border-bottom: 1px solid #ccc;
  132. }
  133. }
  134. </style>