SelectUser.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. props: {
  45. queryParams: {
  46. type: Object,
  47. default() {
  48. return {}
  49. },
  50. },
  51. },
  52. data() {
  53. return {
  54. selectVisible: false,
  55. userList: [],
  56. queryForm: {
  57. keyWords: '',
  58. pageNum: 1,
  59. pageSize: 999,
  60. },
  61. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  62. userValue: null,
  63. selected: null,
  64. }
  65. },
  66. methods: {
  67. async getUserList() {
  68. let params = Object.assign(this.queryForm, this.queryParams)
  69. const [err, res] = await to(userApi.getList(params))
  70. if (err) return
  71. if (res.code == 200) {
  72. if (res.data.list) {
  73. this.userList = res.data.list.map((item) => ({ id: item.id, label: item.nickName }))
  74. } else {
  75. this.userList = []
  76. }
  77. }
  78. },
  79. open() {
  80. this.selectVisible = true
  81. this.getUserList()
  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>