selectProject.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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: 10,
  73. isEnd: false,
  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. onShow() {
  91. this.isEnd = false
  92. this.page = 1
  93. this.getList()
  94. },
  95. onLoad({
  96. isAll
  97. }) {
  98. this.isAll = isAll //1多选 2单选
  99. this.getList()
  100. },
  101. onShow() {},
  102. methods: {
  103. scrolltolower() {
  104. this.getList()
  105. },
  106. //列表数据
  107. getList() {
  108. if (this.isEnd) {
  109. return
  110. }
  111. uni.showLoading({
  112. title: '加载中'
  113. })
  114. let params = {
  115. pageNum: this.page,
  116. size: this.size,
  117. name: this.searchVal
  118. }
  119. projectsPageAPI(params).then(res => {
  120. if (this.page === 1) {
  121. this.listData = res.list
  122. } else {
  123. this.listData.push(...res.list)
  124. }
  125. this.page += 1
  126. this.isEnd = this.listData.length >= res.count
  127. }).then(() => {
  128. uni.hideLoading()
  129. })
  130. // this.isEnd = false
  131. // this._getClassifyList()
  132. },
  133. async _getClassifyList() {
  134. uni.showLoading({
  135. title: '数据加载中'
  136. })
  137. const params = {
  138. pageNum: 1,
  139. size: this.size,
  140. name: this.searchVal,
  141. }
  142. projectsPageAPI(params).then(res => {
  143. uni.hideLoading()
  144. if (this.page == 1) {
  145. this.listData = []
  146. }
  147. this.listData = this.listData.concat(res.list)
  148. this.isEnd = this.listData.length >= res.count
  149. })
  150. },
  151. confirm([id]) {
  152. this.categoryLevelId = id
  153. this.page = 1
  154. this.getList()
  155. },
  156. async getClassify() {
  157. listOrganizations(1).then(res => {
  158. this.classificationList = res
  159. this.page = 1
  160. this.getList()
  161. });
  162. },
  163. doSearch() {
  164. this.isEnd = false
  165. this.page = 1
  166. this.getList()
  167. },
  168. //勾选
  169. selectVal(e, val, index) {
  170. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  171. if (this.isAll != 1) {
  172. this.listData.forEach((item, i) => {
  173. if (item.id != val.id) {
  174. this.$set(this.listData[i], 'checked', false)
  175. }
  176. })
  177. } else {
  178. this.seletedAll = !this.listData.some(item => !item.checked)
  179. }
  180. },
  181. //全选按钮
  182. _seletedAll() {
  183. if (!this.seletedAll) {
  184. this.seletedAll = true
  185. this.listData.map(item => {
  186. this.$set(item, 'checked', true)
  187. })
  188. } else {
  189. this.seletedAll = false
  190. this.listData.map(item => {
  191. this.$set(item, 'checked', false)
  192. })
  193. }
  194. },
  195. //跳转回添加页面
  196. jumpAdd() {
  197. uni.$emit(
  198. 'setProject',
  199. this.listData.filter(item => item.checked)
  200. )
  201. uni.navigateBack()
  202. },
  203. //返回添加页
  204. backAdd() {
  205. uni.navigateBack()
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .mainBox {
  212. height: 100vh;
  213. display: flex;
  214. flex-direction: column;
  215. .wrapper {
  216. flex: 1;
  217. overflow: hidden;
  218. }
  219. .searchBox {
  220. padding: 10rpx 0;
  221. box-sizing: border-box;
  222. background-color: #dedede;
  223. height: 90rpx;
  224. width: 100%;
  225. line-height: 90rpx;
  226. display: flex;
  227. justify-content: space-around;
  228. align-items: center;
  229. input {
  230. height: 78rpx;
  231. width: 65%;
  232. background: #f9f9f9 !important;
  233. margin: 0 10rpx;
  234. padding: 0 10rpx;
  235. box-sizing: border-box;
  236. border-radius: 5rpx;
  237. }
  238. .searchBtn {
  239. height: 80rpx;
  240. background: #f9f9f9 !important;
  241. color: #676767;
  242. font-size: 28rpx;
  243. padding: 0 42rpx;
  244. box-sizing: border-box;
  245. outline: none;
  246. border: none;
  247. width: 260rpx;
  248. .icon-sousuo {
  249. font-size: 22px;
  250. }
  251. .text {
  252. font-size: 16px;
  253. margin-left: 10px;
  254. }
  255. }
  256. }
  257. .tab-title {
  258. position: fixed;
  259. top: 190rpx;
  260. z-index: 99;
  261. width: 100%;
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. height: $tab-height;
  266. line-height: $tab-height;
  267. background-color: #ffffff;
  268. border-bottom: 2rpx solid #f2f2f2;
  269. box-sizing: border-box;
  270. .tab-item {
  271. width: 25%;
  272. text-align: center;
  273. font-size: 32rpx;
  274. color: $uni-text-color-grey;
  275. }
  276. .tab-item.active {
  277. color: $j-primary-border-green;
  278. border-bottom: 1px solid $j-primary-border-green;
  279. font-weight: bold;
  280. }
  281. .tab-item.filter {
  282. flex: 1;
  283. padding: 0px 30rpx;
  284. .uni-icons {
  285. display: flex;
  286. padding-top: 5px;
  287. }
  288. }
  289. .screenIcon {
  290. display: flex;
  291. width: 80px;
  292. justify-content: center;
  293. .screenText {
  294. font-size: 32rpx;
  295. color: $uni-text-color-grey;
  296. }
  297. }
  298. }
  299. .listContent {
  300. height: 100% !important;
  301. .listBox {
  302. display: flex;
  303. // height: 180rpx;
  304. padding: 20rpx 0;
  305. border-bottom: 2rpx solid #e5e5e5;
  306. .listBox-sel {
  307. height: 90rpx;
  308. width: 80rpx;
  309. // line-height: 90rpx;
  310. text-align: center;
  311. checkbox {
  312. transform: scale(1.2);
  313. }
  314. }
  315. .listBox-con {
  316. width: 100%;
  317. // display: flex;
  318. // flex-wrap: wrap;
  319. // justify-content: space-between;
  320. align-items: center;
  321. padding: 0 18rpx 0 0;
  322. .listBox-top {
  323. width: 100%;
  324. display: flex;
  325. justify-content: space-between;
  326. padding-bottom: 10rpx;
  327. .listBox-name,
  328. .listBox-code {
  329. display: inline-block;
  330. font-size: $uni-font-size-sm;
  331. font-weight: bold;
  332. }
  333. }
  334. .listBox-bottom {
  335. width: 100%;
  336. display: flex;
  337. justify-content: space-between;
  338. font-size: $uni-font-size-sm;
  339. flex-wrap: wrap;
  340. >view {
  341. width: 50%;
  342. overflow: hidden;
  343. white-space: nowrap;
  344. text-overflow: ellipsis;
  345. }
  346. }
  347. }
  348. }
  349. .noDate {
  350. height: 100%;
  351. }
  352. }
  353. //底部按钮
  354. .footer {
  355. height: 90rpx;
  356. position: relative;
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. bottom: 0;
  361. width: 100%;
  362. height: 100rpx;
  363. border-top: 1rpx solid #eeecec;
  364. background-color: #ffffff;
  365. z-index: 999;
  366. .bottom {
  367. margin-left: 10rpx;
  368. }
  369. .u-reset-button {
  370. position: absolute;
  371. right: 10rpx;
  372. top: 20rpx;
  373. width: 150rpx;
  374. }
  375. }
  376. }
  377. </style>