CustomerContact.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-02-15 10:34:49
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-15 14:10:58
  6. * @Description: file content
  7. * @FilePath: \oms\components\selectUser.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.keyWords"
  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="getUserList()">搜索</view>
  27. </view>
  28. <u-empty mode="list" v-if="userList.length == 0"></u-empty>
  29. <view class="concat-list" v-else>
  30. <u-radio-group v-model="userValue" placement="column">
  31. <view class="radio-item" v-for="item in userList" :key="item.id">
  32. <u-radio :label="item.label" :name="item.id" @change="radioChange"></u-radio>
  33. </view>
  34. </u-radio-group>
  35. </view>
  36. </u-popup>
  37. </view>
  38. </template>
  39. <script>
  40. import userApi from '@/api/system/user'
  41. import to from 'await-to-js'
  42. export default {
  43. name: 'OmsCustomerContact',
  44. data() {
  45. return {
  46. selectVisible: false,
  47. userList: [],
  48. queryForm: {
  49. custId: 0,
  50. keyword: '',
  51. pageNum: 1,
  52. pageSize: 10,
  53. type: '全部客户',
  54. },
  55. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  56. userValue: null,
  57. selected: null,
  58. }
  59. },
  60. methods: {
  61. async getUserList() {
  62. let params = this.queryForm
  63. const [err, res] = await to(userApi.getContact(params))
  64. if (err) return
  65. if (res.code == 200) {
  66. if (res.data.list.length > 0) {
  67. this.userList = res.data.list.map((item) => ({ ...item, label: item.cuctName }))
  68. } else {
  69. this.userList = []
  70. }
  71. }
  72. },
  73. open(id) {
  74. console.log(id)
  75. this.queryForm.custId = id
  76. this.selectVisible = true
  77. this.getUserList()
  78. },
  79. close() {
  80. this.selectVisible = false
  81. this.$emit('close', this.selected)
  82. },
  83. radioChange(n) {
  84. this.selected = this.userList.find((item) => item.id == n)
  85. },
  86. },
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .tit {
  91. font-size: 26rpx;
  92. font-weight: bold;
  93. padding: 30rpx 0 0 30rpx;
  94. }
  95. .search-container {
  96. padding: 30rpx 30rpx 0 30rpx;
  97. display: flex;
  98. align-items: center;
  99. .search-input {
  100. flex: 1;
  101. }
  102. .search-btn {
  103. text-align: center;
  104. line-height: 60rpx;
  105. border-radius: 12rpx;
  106. width: 100rpx;
  107. height: 60rpx;
  108. font-size: 26rpx;
  109. margin: 0 0 0 12rpx;
  110. background: $u-primary;
  111. color: #ffffff;
  112. }
  113. }
  114. .concat-list {
  115. padding: 0 0 20rpx 0;
  116. width: 100%;
  117. height: 900rpx;
  118. overflow: auto;
  119. margin-top: 30rpx;
  120. .radio-item {
  121. padding: 20rpx 30rpx;
  122. border-bottom: 1px solid #ccc;
  123. }
  124. }
  125. </style>