SelectDealer.vue 3.5 KB

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