searchCompanys.vue 3.6 KB

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