SelectDealer.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-05-22 11:14:36
  6. * @Description: file content
  7. * @FilePath: \oms\components\SelectDealer.vue
  8. -->
  9. <template>
  10. <view>
  11. <u-popup :show="selectVisible" @close="close">
  12. <view class="select-header">
  13. <view class="tit">选择{{ distrLabel }}</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">{{ distrLabel }}/助记名/所在省份/归属销售/负责人</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. props: {
  49. distrId: {
  50. type: String | Array,
  51. default: () => null,
  52. },
  53. },
  54. data() {
  55. return {
  56. selectVisible: false,
  57. userList: [],
  58. queryForm: {
  59. distName: '',
  60. pageNum: 1,
  61. pageSize: 999,
  62. },
  63. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  64. userValue: null,
  65. selected: null,
  66. }
  67. },
  68. computed: {
  69. distrLabel: function () {
  70. let str = ''
  71. if (this.distrId) {
  72. str = this.distrId == '30' ? '经销商' : '代理商'
  73. } else {
  74. str = '经销商/代理商'
  75. }
  76. return str
  77. },
  78. },
  79. methods: {
  80. async getList() {
  81. let params = this.queryForm
  82. if (this.distrId) {
  83. params.distType = parseInt(this.distrId) - 20 + ''
  84. }
  85. const [err, res] = await to(distrApi.getList(params))
  86. if (err) return
  87. if (res.code == 200) {
  88. if (res.data.list && res.data.list.length > 0) {
  89. this.userList = res.data.list.map((item) => ({
  90. id: item.id,
  91. label: `${item.distName}/${item.abbrName}/${item.provinceDesc}/${item.belongSale}/${item.distBoss}`,
  92. name: item.distName,
  93. }))
  94. } else {
  95. this.userList = []
  96. }
  97. }
  98. },
  99. open() {
  100. this.selectVisible = true
  101. this.getList()
  102. },
  103. close() {
  104. this.selectVisible = false
  105. this.$emit('close', this.selected)
  106. },
  107. radioChange(n) {
  108. this.selected = this.userList.find((item) => item.id == n)
  109. },
  110. },
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .tit {
  115. font-size: 26rpx;
  116. font-weight: bold;
  117. padding: 30rpx 0 0 30rpx;
  118. }
  119. .search-container {
  120. padding: 30rpx 30rpx 0 30rpx;
  121. display: flex;
  122. align-items: center;
  123. .search-input {
  124. flex: 1;
  125. }
  126. .search-btn {
  127. text-align: center;
  128. line-height: 60rpx;
  129. border-radius: 12rpx;
  130. width: 100rpx;
  131. height: 60rpx;
  132. font-size: 26rpx;
  133. margin: 0 0 0 12rpx;
  134. background: $u-primary;
  135. color: #ffffff;
  136. }
  137. }
  138. .concat-list {
  139. padding: 0 0 20rpx 0;
  140. width: 100%;
  141. height: 900rpx;
  142. overflow: auto;
  143. margin-top: 20rpx;
  144. .radio-item {
  145. padding: 20rpx 30rpx;
  146. border-bottom: 1px solid #ccc;
  147. }
  148. }
  149. </style>