SelectDealer.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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-loading-icon
  33. text="数据加载中"
  34. color="green"
  35. :vertical="true"
  36. v-if="loading"
  37. :customStyle="{ padding: '20px' }"></u-loading-icon>
  38. <u-empty mode="list" v-else-if="!loading && userList.length == 0"></u-empty>
  39. <view class="concat-list" v-else>
  40. <u-radio-group v-model="userValue" placement="column">
  41. <view class="radio-item" v-for="item in userList" :key="item.id">
  42. <u-radio :label="item.label" :name="item.id" @change="radioChange"></u-radio>
  43. </view>
  44. </u-radio-group>
  45. </view>
  46. </u-popup>
  47. </view>
  48. </template>
  49. <script>
  50. import distrApi from '@/api/base/distr'
  51. import to from 'await-to-js'
  52. export default {
  53. name: 'OmsCustomerContact',
  54. props: {
  55. distrId: {
  56. type: String | Array,
  57. default: () => null,
  58. },
  59. },
  60. data() {
  61. return {
  62. selectVisible: false,
  63. userList: [],
  64. queryForm: {
  65. distName: '',
  66. pageNum: 1,
  67. pageSize: 999,
  68. },
  69. loading: false,
  70. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  71. userValue: null,
  72. selected: null,
  73. }
  74. },
  75. computed: {
  76. distrLabel: function () {
  77. let str = ''
  78. if (this.distrId) {
  79. str = this.distrId == '30' ? '经销商' : '代理商'
  80. } else {
  81. str = '经销商/代理商'
  82. }
  83. return str
  84. },
  85. },
  86. methods: {
  87. async getList() {
  88. this.loading = true
  89. let params = this.queryForm
  90. if (this.distrId) {
  91. params.distType = parseInt(this.distrId) - 20 + ''
  92. }
  93. const [err, res] = await to(distrApi.getList(params))
  94. this.loading = false
  95. if (err) return
  96. if (res.code == 200) {
  97. if (res.data.list && res.data.list.length > 0) {
  98. this.userList = res.data.list.map((item) => ({
  99. id: item.id,
  100. label: `${item.distName}/${item.abbrName}/${item.provinceDesc}/${item.belongSale}/${item.distBoss}`,
  101. name: item.distName,
  102. }))
  103. } else {
  104. this.userList = []
  105. }
  106. }
  107. },
  108. open() {
  109. this.userList = []
  110. this.selected = null
  111. this.selectVisible = true
  112. this.getList()
  113. },
  114. close() {
  115. this.$emit('close', this.selected)
  116. this.selectVisible = false
  117. },
  118. radioChange(n) {
  119. this.selected = this.userList.find((item) => item.id == n)
  120. },
  121. },
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .tit {
  126. font-size: 26rpx;
  127. font-weight: bold;
  128. padding: 30rpx 0 0 30rpx;
  129. }
  130. .search-container {
  131. padding: 30rpx 30rpx 0 30rpx;
  132. display: flex;
  133. align-items: center;
  134. .search-input {
  135. flex: 1;
  136. }
  137. .search-btn {
  138. text-align: center;
  139. line-height: 60rpx;
  140. border-radius: 12rpx;
  141. width: 100rpx;
  142. height: 60rpx;
  143. font-size: 26rpx;
  144. margin: 0 0 0 12rpx;
  145. background: $u-primary;
  146. color: #ffffff;
  147. }
  148. }
  149. .concat-list {
  150. padding: 0 0 20rpx 0;
  151. width: 100%;
  152. height: 900rpx;
  153. overflow: auto;
  154. margin-top: 20rpx;
  155. .radio-item {
  156. padding: 20rpx 30rpx;
  157. border-bottom: 1px solid #ccc;
  158. }
  159. }
  160. </style>