selectContact.vue 9.1 KB

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