ProjectContact.vue 3.3 KB

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