SelectPartners.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.selected = null
  87. this.selectVisible = true
  88. this.getUserList()
  89. },
  90. close() {
  91. this.selectVisible = false
  92. this.$emit('close', this.selected)
  93. },
  94. radioChange(n) {
  95. this.selected = this.userList.find((item) => item.id == n)
  96. },
  97. },
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .search-container {
  102. padding: 30rpx 30rpx 0 30rpx;
  103. display: flex;
  104. align-items: center;
  105. .search-input {
  106. flex: 1;
  107. }
  108. .search-btn {
  109. text-align: center;
  110. line-height: 60rpx;
  111. border-radius: 12rpx;
  112. width: 100rpx;
  113. height: 60rpx;
  114. font-size: 26rpx;
  115. margin: 0 0 0 12rpx;
  116. background: $u-primary;
  117. color: #ffffff;
  118. }
  119. }
  120. .concat-list {
  121. padding: 0 0 20rpx 0;
  122. width: 100%;
  123. height: 900rpx;
  124. overflow: auto;
  125. margin-top: 20rpx;
  126. .radio-item {
  127. padding: 20rpx 30rpx;
  128. border-bottom: 1px solid #ccc;
  129. }
  130. }
  131. </style>