SelectPartners.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-23 10:57:44
  6. * @Description: file content
  7. * @FilePath: \oms\components\SelectCustomer.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.custName"
  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. pageNum: 1,
  61. pageSize: 999,
  62. },
  63. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  64. userValue: null,
  65. selected: null,
  66. }
  67. },
  68. methods: {
  69. async getUserList() {
  70. let params = Object.assign(this.queryForm, this.queryParams)
  71. const [err, res] = await to(partnerApi.getCompanyList(params))
  72. if (err) return
  73. if (res.code == 200) {
  74. if (res.data.list && res.data.list.length > 0) {
  75. this.userList = res.data.list.map((item) => ({
  76. id: item.id,
  77. label: item.partnerName,
  78. name: item.partnerName,
  79. }))
  80. } else {
  81. this.userList = []
  82. }
  83. }
  84. },
  85. open() {
  86. this.selectVisible = true
  87. this.getUserList()
  88. },
  89. close() {
  90. this.selectVisible = false
  91. this.$emit('close', this.selected)
  92. },
  93. radioChange(n) {
  94. this.selected = this.userList.find((item) => item.id == n)
  95. },
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .search-container {
  101. padding: 30rpx 30rpx 0 30rpx;
  102. display: flex;
  103. align-items: center;
  104. .search-input {
  105. flex: 1;
  106. }
  107. .search-btn {
  108. text-align: center;
  109. line-height: 60rpx;
  110. border-radius: 12rpx;
  111. width: 100rpx;
  112. height: 60rpx;
  113. font-size: 26rpx;
  114. margin: 0 0 0 12rpx;
  115. background: $u-primary;
  116. color: #ffffff;
  117. }
  118. }
  119. .concat-list {
  120. padding: 0 0 20rpx 0;
  121. width: 100%;
  122. height: 900rpx;
  123. overflow: auto;
  124. margin-top: 20rpx;
  125. .radio-item {
  126. padding: 20rpx 30rpx;
  127. border-bottom: 1px solid #ccc;
  128. }
  129. }
  130. </style>