DistrContact.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-05-22 17:32:58
  6. * @Description: file content
  7. * @FilePath: \oms\components\DistrContact.vue
  8. -->
  9. <template>
  10. <view>
  11. <u-popup :show="selectVisible" @close="close">
  12. <view class="select-header">
  13. <view class="tit">选择{{ distrType == '50' ? '经销商' : '代理商' }}联系人</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="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.name" :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 distrApi from '@/api/base/distr'
  44. import to from 'await-to-js'
  45. export default {
  46. name: 'OmsCustomerContact',
  47. props: {
  48. distrType: {
  49. type: String | Number,
  50. required: true,
  51. },
  52. },
  53. data() {
  54. return {
  55. selectVisible: false,
  56. userList: [],
  57. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  58. userValue: null,
  59. selected: null,
  60. distId: 0,
  61. name: '',
  62. }
  63. },
  64. methods: {
  65. async getUserList() {
  66. const params = {
  67. distId: this.distId,
  68. name: this.name,
  69. }
  70. const [err, res] = await to(distrApi.getContactList(params))
  71. if (err) return
  72. if (res.code == 200) {
  73. this.userList = res.data.list
  74. }
  75. },
  76. open(id) {
  77. this.distId = id
  78. this.selectVisible = true
  79. this.getUserList()
  80. },
  81. close() {
  82. this.selectVisible = false
  83. this.$emit('close', this.selected)
  84. },
  85. radioChange(n) {
  86. this.selected = this.userList.find((item) => item.id == n)
  87. },
  88. },
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .search-container {
  93. padding: 30rpx 30rpx 0 30rpx;
  94. display: flex;
  95. align-items: center;
  96. .search-input {
  97. flex: 1;
  98. }
  99. .search-btn {
  100. text-align: center;
  101. line-height: 60rpx;
  102. border-radius: 12rpx;
  103. width: 100rpx;
  104. height: 60rpx;
  105. font-size: 26rpx;
  106. margin: 0 0 0 12rpx;
  107. background: $u-primary;
  108. color: #ffffff;
  109. }
  110. }
  111. .concat-list {
  112. padding: 0 0 20rpx 0;
  113. width: 100%;
  114. height: 900rpx;
  115. overflow: auto;
  116. margin-top: 30rpx;
  117. .radio-item {
  118. padding: 20rpx 30rpx;
  119. border-bottom: 1px solid #ccc;
  120. }
  121. }
  122. </style>