SelectDealer.vue 3.4 KB

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