searchCompanys.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="page-container">
  3. <nav-bar title="选择公司"></nav-bar>
  4. <view class="search-bar flex align-center justify-between">
  5. <view class="search-input flex align-center">
  6. <image src="@/static/images/svg/search.svg" class="search-icon"></image>
  7. <input v-model="searchValue" type="text" placeholder="输入的是一个公司的名称,全模糊搜索" class="input" />
  8. </view>
  9. <view class="search-btn" @click="getData">搜索</view>
  10. </view>
  11. <view class="content">
  12. <scroll-view :scroll-y="true" class="scroll-view">
  13. <view class="scroll-wrapper">
  14. <u-radio-group v-model="companyId" @change="handleChangeSelect">
  15. <view v-for="company in companys" :key="company.companyId" style="width: 100%">
  16. <u-radio shape="circle" :name="company.companyId">{{ company.companyAllName }}</u-radio>
  17. </view>
  18. </u-radio-group>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. <view class="button-section">
  23. <view class="submit-btn" @click="handleSave">确定</view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import navBar from '@/components/nav-bar/index.vue'
  29. export default {
  30. components: {
  31. navBar
  32. },
  33. data() {
  34. return {
  35. searchValue: '',
  36. companyId: '',
  37. companyName: '',
  38. companys: [],
  39. searching: false,
  40. };
  41. },
  42. methods: {
  43. getData() {
  44. if (!this.searchValue) {
  45. return this.$queue.showToast('请输入公司名称')
  46. }
  47. if (this.searching) return
  48. this.searching = true
  49. uni.showLoading({
  50. title: '搜索中'
  51. })
  52. this.$Request
  53. .getT('/app/company/getVerifiedCompany', {
  54. page: 1,
  55. limit: 20,
  56. companyAllName: this.searchValue
  57. })
  58. .then(res => {
  59. if (res.code === 0) {
  60. this.companyId = ''
  61. this.companyName = ''
  62. if (res.data && res.data?.records?.length) {
  63. this.companys = res.data.records
  64. } else {
  65. this.$queue.showToast('没有搜索到对应公司')
  66. }
  67. }
  68. })
  69. .finally(() => {
  70. this.searching = false
  71. uni.hideLoading()
  72. })
  73. },
  74. handleChangeSelect(e) {
  75. this.companys.forEach(c => {
  76. if (c.companyId == e) {
  77. this.companyName = c.companyAllName
  78. }
  79. })
  80. },
  81. // 提交数据
  82. handleSave() {
  83. if (!this.companyId) {
  84. return this.$queue.showToast('请选择公司')
  85. }
  86. uni.$emit('selectCompany', {
  87. companyId: this.companyId,
  88. companyName: this.companyName
  89. })
  90. uni.navigateBack()
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. @import '@/common.scss';
  97. .page-container {
  98. display: flex;
  99. flex-direction: column;
  100. height: 100vh;
  101. font-family: DM Sans;
  102. .content {
  103. flex: 1;
  104. padding: 0 40rpx;
  105. overflow: auto;
  106. }
  107. .search-bar {
  108. margin: 32rpx 40rpx 40rpx;
  109. .search-input {
  110. flex: 1;
  111. box-sizing: border-box;
  112. border: 1px solid rgba(227, 231, 236, 1);
  113. border-radius: 48rpx;
  114. background: rgba(241, 241, 241, 1);
  115. padding: 8rpx 32rpx;
  116. .search-icon {
  117. display: block;
  118. width: 36rpx;
  119. height: 36rpx;
  120. margin-right: 16rpx;
  121. }
  122. .input {
  123. width: 500rpx;
  124. font-size: 20rpx;
  125. font-weight: 500;
  126. color: rgba(51, 51, 51, 1);
  127. }
  128. }
  129. .search-btn {
  130. width: 60rpx;
  131. font-size: 20rpx;
  132. font-weight: 500;
  133. line-height: 48rpx;
  134. color: rgba(1, 107, 246, 1);
  135. padding-left: 16rpx;
  136. }
  137. }
  138. .scroll-view {
  139. .scroll-wrapper {
  140. padding-bottom: 100rpx;
  141. }
  142. }
  143. }
  144. </style>