SelectUser.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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="concatVisible" @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. concatVisible: 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 && res.data.list.length > 0)
  72. this.userList = res.data.list.map((item) => ({ id: item.id, label: item.nickName }))
  73. },
  74. open() {
  75. this.concatVisible = true
  76. this.getUserList()
  77. },
  78. close() {
  79. this.concatVisible = false
  80. this.$emit('close', this.selected)
  81. },
  82. radioChange(n) {
  83. this.selected = this.userList.find((item) => item.id == n)
  84. },
  85. },
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .tit {
  90. font-size: 26rpx;
  91. font-weight: bold;
  92. padding: 30rpx 0 0 30rpx;
  93. }
  94. .search-container {
  95. padding: 30rpx 30rpx 0 30rpx;
  96. display: flex;
  97. align-items: center;
  98. .search-input {
  99. flex: 1;
  100. }
  101. .search-btn {
  102. text-align: center;
  103. line-height: 60rpx;
  104. border-radius: 12rpx;
  105. width: 100rpx;
  106. height: 60rpx;
  107. font-size: 26rpx;
  108. margin: 0 0 0 12rpx;
  109. background: $u-primary;
  110. color: #ffffff;
  111. }
  112. }
  113. .concat-list {
  114. padding: 0 0 20rpx 0;
  115. width: 100%;
  116. height: 900rpx;
  117. overflow: auto;
  118. margin-top: 20rpx;
  119. .radio-item {
  120. padding: 20rpx 30rpx;
  121. border-bottom: 1px solid #ccc;
  122. }
  123. }
  124. </style>