SelectProject.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <u-popup :show="selectProjectShow" mode="bottom" :round="10" @close="selectProjectShow=false">
  3. <view class="popbox project-popup">
  4. <view class="popbox-head">
  5. <view class="title">选择项目</view>
  6. <view class="close-btn" @click="selectProjectShow=false">
  7. <u-icon name="close" color="#ccc" size="18"></u-icon>
  8. </view>
  9. </view>
  10. <view class="search-box">
  11. <u-search placeholder="搜索项目" v-model="searchKeyword" :showAction="true" actionText="搜索"
  12. @search="searchProject" height="36" bgColor="#F5F5F5"></u-search>
  13. </view>
  14. <view class="popbox-body">
  15. <scroll-view scroll-y="true" class="project-scroll-view">
  16. <view class="tagbox-list">
  17. <view class="empty-tip" v-if="filteredProjectList.length<=0">
  18. 暂无项目
  19. </view>
  20. <view class="tag-item" v-for="(item,index) in filteredProjectList" :key='item.dictValue'>
  21. <u-tag :text="item.dictLabel"
  22. :plain="(tempProjectItem && tempProjectItem.dictValue) != item.dictValue"
  23. :type="(tempProjectItem && tempProjectItem.dictValue) == item.dictValue ? 'primary' : 'info'"
  24. @click="handleProjectSelect(item)"></u-tag>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. <view class="popbox-footer">
  30. <u-button type="primary" text="确定" shape="circle" @click="confirmProject"></u-button>
  31. </view>
  32. </view>
  33. </u-popup>
  34. </template>
  35. <script>
  36. import {
  37. beMember
  38. } from '@/pages_im/api/im.js'
  39. import {
  40. getDictProject,
  41. } from "@/pages_manage/api/courseManage.js"
  42. export default {
  43. name: "SelectProject",
  44. props: {
  45. selectProjectShow: {
  46. type: Boolean,
  47. default: false
  48. },
  49. application: Object,
  50. },
  51. data() {
  52. return {
  53. projectList: [],
  54. tempProjectItem: null,
  55. searchKeyword: '',
  56. };
  57. },
  58. computed: {
  59. filteredProjectList() {
  60. if (!this.searchKeyword) {
  61. return this.projectList;
  62. }
  63. return this.projectList.filter(item =>
  64. item.dictLabel.toLowerCase().includes(this.searchKeyword.toLowerCase())
  65. );
  66. },
  67. },
  68. created() {
  69. this.getDictProjectFun()
  70. },
  71. methods: {
  72. handleProjectSelect(item) {
  73. this.tempProjectItem = item;
  74. },
  75. async getDictProjectFun() {
  76. const res = await getDictProject()
  77. if (res.code == 200) {
  78. this.projectList = res.data
  79. }
  80. },
  81. async confirmProject() {
  82. let companyUserInfo = uni.getStorageSync('companyUserInfo')
  83. companyUserInfo = companyUserInfo && JSON.parse(companyUserInfo)
  84. let userId = this.application.fromUserID
  85. if (this.application.fromUserID.indexOf('U') !== -1) {
  86. userId = this.application.fromUserID.slice(1)
  87. }
  88. let params = {
  89. userId,
  90. companyUserId: companyUserInfo.userId,
  91. companyId: companyUserInfo.companyId,
  92. projectId: this.tempProjectItem.dictValue
  93. }
  94. const res = await beMember(params)
  95. if (res.code == 200) {
  96. this.$emit('agreeFun')
  97. } else {
  98. uni.showToast({
  99. icon: 'icon',
  100. title: res.msg
  101. })
  102. }
  103. },
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .project-popup {
  109. width: 100%;
  110. background-color: #fff;
  111. border-radius: 20rpx 20rpx 0 0;
  112. display: flex;
  113. flex-direction: column;
  114. .popbox-head {
  115. display: flex;
  116. justify-content: center;
  117. align-items: center;
  118. padding: 30rpx;
  119. font-size: 32rpx;
  120. font-weight: bold;
  121. position: relative;
  122. border-bottom: none;
  123. .title {
  124. flex: 1;
  125. text-align: center;
  126. }
  127. .close-btn {
  128. position: absolute;
  129. right: 30rpx;
  130. top: 50%;
  131. transform: translateY(-50%);
  132. padding: 10rpx;
  133. }
  134. }
  135. .search-box {
  136. padding: 0 30rpx 20rpx;
  137. }
  138. .popbox-body {
  139. flex: 1;
  140. overflow: hidden;
  141. padding: 0;
  142. }
  143. .project-scroll-view {
  144. height: 50vh;
  145. padding: 0 30rpx;
  146. box-sizing: border-box;
  147. }
  148. .tagbox-list {
  149. display: flex;
  150. flex-wrap: wrap;
  151. padding-bottom: 20rpx;
  152. }
  153. .tag-item {
  154. margin-right: 20rpx;
  155. margin-bottom: 20rpx;
  156. }
  157. .empty-tip {
  158. width: 100%;
  159. text-align: center;
  160. color: #999;
  161. padding: 50rpx 0;
  162. font-size: 28rpx;
  163. }
  164. .popbox-footer {
  165. padding: 20rpx 30rpx 40rpx;
  166. border-top: 1px solid #f5f5f5;
  167. }
  168. }
  169. .popbox {
  170. background-color: #fff;
  171. border-radius: 12px;
  172. font-family: PingFang SC, PingFang SC;
  173. font-weight: 400;
  174. font-size: 14px;
  175. color: #333;
  176. &-head {
  177. padding: 15px;
  178. font-weight: bold;
  179. font-size: 15px;
  180. text-align: center;
  181. position: relative;
  182. }
  183. .close-circle {
  184. position: absolute;
  185. right: 10px;
  186. top: 50%;
  187. transform: translateY(-50%);
  188. }
  189. &-body {
  190. padding: 10px 10px;
  191. }
  192. .radiobox {
  193. &-item {
  194. padding: 10px 0;
  195. border-bottom: 1px solid #f5f5f5;
  196. &:last-child {
  197. border-bottom: none;
  198. }
  199. }
  200. }
  201. &-footer {
  202. padding: 15px 0;
  203. }
  204. &-footer-btn {
  205. flex: 1;
  206. height: 44px;
  207. line-height: 44px;
  208. margin: 0 10px;
  209. border-radius: 50px;
  210. border: none;
  211. font-family: PingFang SC, PingFang SC;
  212. font-weight: 400;
  213. font-size: 14px;
  214. color: #333;
  215. &::after {
  216. border: none;
  217. }
  218. }
  219. .con-btn {
  220. background-color: #1677ff;
  221. color: #fff;
  222. }
  223. .choosetitle {
  224. font-family: PingFang SC, PingFang SC;
  225. font-weight: 400;
  226. font-size: 15px;
  227. color: #333;
  228. }
  229. .invitetip {
  230. margin-top: 10px;
  231. background-color: #ebf5fb;
  232. color: #1677ff;
  233. padding: 5px 10px;
  234. border-radius: 5px;
  235. }
  236. .sharePop-item {
  237. padding: 0 10px;
  238. box-sizing: border-box;
  239. font-family: PingFang SC, PingFang SC;
  240. font-weight: 400;
  241. font-size: 14px;
  242. display: inline-flex !important;
  243. image {
  244. height: 48px;
  245. width: 48px;
  246. margin-bottom: 10px;
  247. }
  248. }
  249. }
  250. </style>