index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!-- 屏蔽企业 -->
  2. <template>
  3. <view style="height: 100%; overflow: auto;">
  4. <!-- 搜索条 -->
  5. <view class="white-bgc stick ss-p-t-10">
  6. <view style="position: relative;">
  7. <uni-search-bar
  8. v-model="name"
  9. placeholder="请输入公司关键字"
  10. cancelButton="none"
  11. :focus="false"
  12. bgColor="#fff"
  13. @confirm="getEntList($event.value)"
  14. @clear="query.content = ''"
  15. >
  16. </uni-search-bar>
  17. <button class="search-btn" @click.stop="getEntList" :loading="loading">搜索</button>
  18. </view>
  19. </view>
  20. <!-- 已屏蔽的企业 -->
  21. <view class="tags">
  22. <view style="color: #777; width: 100%; margin-bottom: 15px;">已屏蔽的企业:</view>
  23. <view
  24. v-for="k in dataList" :key="k.id"
  25. class="tag"
  26. style="color: #00B760; background-color: #e2f0ef;;"
  27. @tap="handleDel(k)"
  28. >
  29. {{ k.name }}
  30. <uni-icons type="clear" size="16" color="#00B760"></uni-icons>
  31. </view>
  32. </view>
  33. <uni-popup ref="popup" type="bottom" background-color="#fff">
  34. <view style="padding: 30rpx;">
  35. <view class="entListBox">
  36. <view style="color: #777; margin: 20rpx 0 30rpx 40rpx; ">请选择要屏蔽的企业</view>
  37. <view v-if="!entList?.length" style="color: #777; text-align: center; margin-top: 20vh;">未查询到相关内容 . . .</view>
  38. <uni-card v-else v-for="item in entList" :key="item.key" @click="joinBlock(item)" :is-shadow="true" :border='false' shadow="0px 0px 3px 1px rgba(0,0,0,0.1)">
  39. <view>{{ item.value }}</view>
  40. </uni-card>
  41. </view>
  42. </view>
  43. </uni-popup>
  44. <!-- 确认框 -->
  45. <uni-popup ref="confirm" type="dialog">
  46. <uni-popup-dialog
  47. type="warn"
  48. cancelText="取消"
  49. confirmText="确认"
  50. title="系统提示"
  51. :content="dialogContent"
  52. @confirm="handleConfirm"
  53. @close="handleClose"
  54. ></uni-popup-dialog>
  55. </uni-popup>
  56. </view>
  57. </template>
  58. <script setup>
  59. import { ref } from 'vue'
  60. import {
  61. getBlockEnterpriseList,
  62. handleBlockEnterprise,
  63. handleUnBlockEnterprise,
  64. } from '@/api/vip'
  65. import { enterpriseSearchByName } from '@/api/resume.js'
  66. const dataList = ref([])
  67. const getData = async () => {
  68. try {
  69. const res = await getBlockEnterpriseList()
  70. dataList.value = res?.data?.list || []
  71. } catch (error) {
  72. uni.showToast({
  73. title: '查询数据失败,请重试',
  74. icon: 'none'
  75. })
  76. }
  77. }
  78. getData()
  79. let confirm = ref()
  80. const handleConfirm = async () => {
  81. if (isDel) {
  82. await handleUnBlockEnterprise(enterpriseId)
  83. uni.showToast({ title: '取消屏蔽成功!', icon: 'none' })
  84. } else {
  85. await handleBlockEnterprise({ enterpriseId })
  86. uni.showToast({ title: '屏蔽企业成功!', icon: 'none' })
  87. }
  88. getData()
  89. }
  90. const handleClose = () => {
  91. confirm.value.close()
  92. dialogContent = ''
  93. enterpriseId = ''
  94. }
  95. let enterpriseId = ''
  96. let dialogContent = ''
  97. let isDel = false
  98. // 屏蔽
  99. const joinBlock = (item) => {
  100. isDel = false
  101. enterpriseId = item.key
  102. dialogContent = `是否屏蔽【${item.value}】?`
  103. confirm.value.open()
  104. }
  105. // 取消屏蔽
  106. const handleDel = (item) => {
  107. isDel = true
  108. enterpriseId = item.id
  109. dialogContent = `是否取消屏蔽【${item.name}】?`
  110. confirm.value.open()
  111. }
  112. // 搜索企业
  113. const popup = ref()
  114. const loading = ref(false)
  115. const name = ref('')
  116. const entList = ref([])
  117. // 获取企业列表
  118. const getEntList = async () => {
  119. if (!name.value || name.value === '公司' || name.value === '有限公司') {
  120. uni.showToast({ title: '请输入公司名称关键字查询', icon: 'none' })
  121. return
  122. }
  123. if (name.value.length < 2) {
  124. uni.showToast({ title: '输入内容过少,请输入更多关键字查询', icon: 'none' })
  125. return
  126. }
  127. try {
  128. loading.value = true
  129. const res = await enterpriseSearchByName({ name: name.value })
  130. entList.value = res?.data || []
  131. popup.value.open()
  132. loading.value = false
  133. } catch (error) {
  134. uni.showToast({
  135. title: '搜索失败',
  136. icon: 'none'
  137. })
  138. loading.value = false
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .stick {
  144. z-index: 1;
  145. position: sticky;
  146. top: 0;
  147. }
  148. .search-btn {
  149. position: absolute;
  150. right: 11px;
  151. top: 10px;
  152. width: 110px;
  153. height: 40px;
  154. font-size: 16px;
  155. background-color: #00B760;
  156. color: #fff;
  157. border-radius: 0 5px 5px 0;
  158. z-index: 9;
  159. }
  160. :deep(.uni-searchbar__box) {
  161. width: calc(100% - 105px);
  162. height: 40px !important;
  163. border: 1px solid #00B760;
  164. padding-right: 20px;
  165. flex: none;
  166. }
  167. .tags {
  168. display: flex;
  169. flex-wrap: wrap;
  170. justify-content: center;
  171. padding: 30rpx;
  172. .tag {
  173. margin: 0 15rpx 12rpx 0;
  174. border: 2rpx 15rpx #00B760;
  175. color: #00B760;
  176. white-space: nowrap;
  177. padding: 4rpx 10rpx;
  178. border-radius: 10rpx;
  179. font-size: 24rpx;
  180. }
  181. }
  182. .entListBox {
  183. height: 70vh;
  184. overflow: auto;
  185. }
  186. </style>