selectProject.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="backAdd">
  4. </uni-nav-bar>
  5. <view class="searchBox">
  6. <input v-model="searchVal" placeholder="请输入名称" class="searchInput" />
  7. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
  8. <view class="iconfont icon-sousuo"></view>
  9. <view class="text">搜索</view>
  10. </u-button>
  11. </view>
  12. <view class="wrapper">
  13. <u-list @scrolltolower="scrolltolower" class="listContent">
  14. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  15. <label>
  16. <view class="listBox">
  17. <view class="listBox-sel">
  18. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  19. :checked="item.checked" />
  20. </view>
  21. <view class="listBox-con">
  22. <view class="listBox-top">
  23. <view class="listBox-name">
  24. {{ item.name }}
  25. </view>
  26. <view class="listBox-code">
  27. {{ item.code }}
  28. </view>
  29. </view>
  30. <view class="listBox-bottom">
  31. <view>负责部门:{{ item.responsibleDeptName }}</view>
  32. <view>项目经理:{{ item.responsibleUserName }}</view>
  33. <view>项目团队:{{ item.teamName }}</view>
  34. <view>项目周期:{{ item.cycle }}</view>
  35. <view>项目预算:{{ item.budget }}</view>
  36. <view>计划开始日期:{{ item.planStartDate }}</view>
  37. <view>计划完成日期:{{ item.planEndDate }}</view>
  38. </view>
  39. </view>
  40. </view>
  41. </label>
  42. </checkbox-group>
  43. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  44. </u-list>
  45. </view>
  46. <view class="footer">
  47. <view class="bottom" v-if="this.isAll==1">
  48. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  49. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  50. </checkbox>
  51. </view>
  52. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  53. <view class="selBtn">选择( {{ checkListLen }} )</view>
  54. </u-button>
  55. </view>
  56. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
  57. :localdata="classificationList" valueKey="id" textKey="name" />
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. projectsPageAPI,
  63. } from '@/api/saleManage/saleorder'
  64. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  65. export default {
  66. components: {
  67. baTreePicker
  68. },
  69. data() {
  70. return {
  71. page: 1,
  72. size: 20,
  73. isEnd: true,
  74. searchVal: '',
  75. pickTabIndex: 1,
  76. popupShow: false, //右侧搜索窗
  77. typeIndex: 1,
  78. listData: [], //列表数据
  79. classificationList: [], //分类数据
  80. seletedAll: false, //全选状态,
  81. isAll: ''
  82. }
  83. },
  84. //选择的列表长度
  85. computed: {
  86. checkListLen() {
  87. return this.listData.filter(el => el.checked).length
  88. },
  89. },
  90. onLoad({
  91. isAll
  92. }) {
  93. this.isAll = isAll //1多选 2单选
  94. this.getList()
  95. },
  96. onShow() {},
  97. methods: {
  98. scrolltolower() {
  99. if (this.isEnd) {
  100. return
  101. }
  102. // 显示加载图标
  103. uni.showLoading({
  104. title: '数据加载中'
  105. })
  106. //获取更多数据
  107. this.page++
  108. this.getList()
  109. },
  110. //列表数据
  111. async getList() {
  112. this.isEnd = false
  113. this._getClassifyList()
  114. },
  115. async _getClassifyList() {
  116. uni.showLoading({
  117. title: '数据加载中'
  118. })
  119. const params = {
  120. pageNum: 1,
  121. size: this.page,
  122. name: this.searchVal,
  123. }
  124. projectsPageAPI(params).then(res => {
  125. uni.hideLoading()
  126. if (this.page == 1) {
  127. this.listData = []
  128. }
  129. this.listData = this.listData.concat(res.list)
  130. this.isEnd = this.listData.length >= res.count
  131. })
  132. },
  133. confirm([id]) {
  134. this.categoryLevelId = id
  135. this.page = 1
  136. this.getList()
  137. },
  138. async getClassify() {
  139. listOrganizations(1).then(res => {
  140. this.classificationList = res
  141. this.page = 1
  142. this.getList()
  143. });
  144. },
  145. doSearch() {
  146. this.page = 1
  147. this.getList()
  148. },
  149. //勾选
  150. selectVal(e, val, index) {
  151. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  152. if (this.isAll != 1) {
  153. this.listData.forEach((item, i) => {
  154. if (item.id != val.id) {
  155. this.$set(this.listData[i], 'checked', false)
  156. }
  157. })
  158. } else {
  159. this.seletedAll = !this.listData.some(item => !item.checked)
  160. }
  161. },
  162. //全选按钮
  163. _seletedAll() {
  164. if (!this.seletedAll) {
  165. this.seletedAll = true
  166. this.listData.map(item => {
  167. this.$set(item, 'checked', true)
  168. })
  169. } else {
  170. this.seletedAll = false
  171. this.listData.map(item => {
  172. this.$set(item, 'checked', false)
  173. })
  174. }
  175. },
  176. //跳转回添加页面
  177. jumpAdd() {
  178. uni.$emit(
  179. 'setProject',
  180. this.listData.filter(item => item.checked)
  181. )
  182. uni.navigateBack()
  183. },
  184. //返回添加页
  185. backAdd() {
  186. uni.navigateBack()
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .mainBox {
  193. height: 100vh;
  194. display: flex;
  195. flex-direction: column;
  196. .wrapper {
  197. flex: 1;
  198. overflow: hidden;
  199. }
  200. .searchBox {
  201. padding: 10rpx 0;
  202. box-sizing: border-box;
  203. background-color: #dedede;
  204. height: 90rpx;
  205. width: 100%;
  206. line-height: 90rpx;
  207. display: flex;
  208. justify-content: space-around;
  209. align-items: center;
  210. input {
  211. height: 78rpx;
  212. width: 65%;
  213. background: #f9f9f9 !important;
  214. margin: 0 10rpx;
  215. padding: 0 10rpx;
  216. box-sizing: border-box;
  217. border-radius: 5rpx;
  218. }
  219. .searchBtn {
  220. height: 80rpx;
  221. background: #f9f9f9 !important;
  222. color: #676767;
  223. font-size: 28rpx;
  224. padding: 0 42rpx;
  225. box-sizing: border-box;
  226. outline: none;
  227. border: none;
  228. width: 260rpx;
  229. .icon-sousuo {
  230. font-size: 22px;
  231. }
  232. .text {
  233. font-size: 16px;
  234. margin-left: 10px;
  235. }
  236. }
  237. }
  238. .tab-title {
  239. position: fixed;
  240. top: 190rpx;
  241. z-index: 99;
  242. width: 100%;
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. height: $tab-height;
  247. line-height: $tab-height;
  248. background-color: #ffffff;
  249. border-bottom: 2rpx solid #f2f2f2;
  250. box-sizing: border-box;
  251. .tab-item {
  252. width: 25%;
  253. text-align: center;
  254. font-size: 32rpx;
  255. color: $uni-text-color-grey;
  256. }
  257. .tab-item.active {
  258. color: $j-primary-border-green;
  259. border-bottom: 1px solid $j-primary-border-green;
  260. font-weight: bold;
  261. }
  262. .tab-item.filter {
  263. flex: 1;
  264. padding: 0px 30rpx;
  265. .uni-icons {
  266. display: flex;
  267. padding-top: 5px;
  268. }
  269. }
  270. .screenIcon {
  271. display: flex;
  272. width: 80px;
  273. justify-content: center;
  274. .screenText {
  275. font-size: 32rpx;
  276. color: $uni-text-color-grey;
  277. }
  278. }
  279. }
  280. .listContent {
  281. height: 100% !important;
  282. .listBox {
  283. display: flex;
  284. // height: 180rpx;
  285. padding: 20rpx 0;
  286. border-bottom: 2rpx solid #e5e5e5;
  287. .listBox-sel {
  288. height: 90rpx;
  289. width: 80rpx;
  290. // line-height: 90rpx;
  291. text-align: center;
  292. checkbox {
  293. transform: scale(1.2);
  294. }
  295. }
  296. .listBox-con {
  297. width: 100%;
  298. // display: flex;
  299. // flex-wrap: wrap;
  300. // justify-content: space-between;
  301. align-items: center;
  302. padding: 0 18rpx 0 0;
  303. .listBox-top {
  304. width: 100%;
  305. display: flex;
  306. justify-content: space-between;
  307. padding-bottom: 10rpx;
  308. .listBox-name,
  309. .listBox-code {
  310. display: inline-block;
  311. font-size: $uni-font-size-sm;
  312. font-weight: bold;
  313. }
  314. }
  315. .listBox-bottom {
  316. width: 100%;
  317. display: flex;
  318. justify-content: space-between;
  319. font-size: $uni-font-size-sm;
  320. flex-wrap: wrap;
  321. >view {
  322. width: 50%;
  323. overflow: hidden;
  324. white-space: nowrap;
  325. text-overflow: ellipsis;
  326. }
  327. }
  328. }
  329. }
  330. .noDate {
  331. height: 100%;
  332. }
  333. }
  334. //底部按钮
  335. .footer {
  336. height: 90rpx;
  337. position: relative;
  338. display: flex;
  339. justify-content: space-between;
  340. align-items: center;
  341. bottom: 0;
  342. width: 100%;
  343. height: 100rpx;
  344. border-top: 1rpx solid #eeecec;
  345. background-color: #ffffff;
  346. z-index: 999;
  347. .bottom {
  348. margin-left: 10rpx;
  349. }
  350. .u-reset-button {
  351. position: absolute;
  352. right: 10rpx;
  353. top: 20rpx;
  354. width: 150rpx;
  355. }
  356. }
  357. }
  358. </style>