SelectDealer.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. onHide() {
  87. this.userList = []
  88. },
  89. methods: {
  90. async getList() {
  91. this.loading = true
  92. let params = this.queryForm
  93. if (this.distrId) {
  94. params.distType = parseInt(this.distrId) - 20 + ''
  95. }
  96. const [err, res] = await to(distrApi.getList(params))
  97. this.loading = false
  98. if (err) return
  99. if (res.code == 200) {
  100. if (res.data.list && res.data.list.length > 0) {
  101. this.userList = res.data.list.map((item) => ({
  102. id: item.id,
  103. label: `${item.distName}/${item.abbrName}/${item.provinceDesc}/${item.belongSale}/${item.distBoss}`,
  104. name: item.distName,
  105. }))
  106. } else {
  107. this.userList = []
  108. }
  109. }
  110. },
  111. open() {
  112. this.selectVisible = true
  113. this.getList()
  114. },
  115. close() {
  116. this.selectVisible = false
  117. this.$emit('close', this.selected)
  118. },
  119. radioChange(n) {
  120. this.selected = this.userList.find((item) => item.id == n)
  121. },
  122. },
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .tit {
  127. font-size: 26rpx;
  128. font-weight: bold;
  129. padding: 30rpx 0 0 30rpx;
  130. }
  131. .search-container {
  132. padding: 30rpx 30rpx 0 30rpx;
  133. display: flex;
  134. align-items: center;
  135. .search-input {
  136. flex: 1;
  137. }
  138. .search-btn {
  139. text-align: center;
  140. line-height: 60rpx;
  141. border-radius: 12rpx;
  142. width: 100rpx;
  143. height: 60rpx;
  144. font-size: 26rpx;
  145. margin: 0 0 0 12rpx;
  146. background: $u-primary;
  147. color: #ffffff;
  148. }
  149. }
  150. .concat-list {
  151. padding: 0 0 20rpx 0;
  152. width: 100%;
  153. height: 900rpx;
  154. overflow: auto;
  155. margin-top: 20rpx;
  156. .radio-item {
  157. padding: 20rpx 30rpx;
  158. border-bottom: 1px solid #ccc;
  159. }
  160. }
  161. </style>