selectContact.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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()" text="选择分类"></u-button>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="searchBox">
  10. <input v-model="searchVal" placeholder="请输入名称" class="searchInput" />
  11. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
  12. <view class="iconfont icon-sousuo"></view>
  13. <view class="text">搜索</view>
  14. </u-button>
  15. </view>
  16. <view class="wrapper">
  17. <u-list @scrolltolower="scrolltolower" class="listContent">
  18. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  19. <label>
  20. <view class="listBox">
  21. <view class="listBox-sel">
  22. <checkbox :value="item.code" color="#fff" :disabled="item.disabled" :checked="item.checked" />
  23. </view>
  24. <view class="listBox-con">
  25. <view class="listBox-top">
  26. <view class="listBox-name">
  27. {{ item.name }}
  28. </view>
  29. </view>
  30. <view class="listBox-bottom">
  31. <!-- <view v-for="(itm, index) in tableHeader" :key="index">{{ itm.label }}:{{ item[itm.prop] }}</view> -->
  32. <view>客户代号:{{ item.serialNo||'' }}</view>
  33. <view>详细地址:{{(item.addressName||'')+item.address||''}}</view>
  34. <view>是否指派:{{(item.assignStatus=== 1 ? '是' : '否')||''}}</view>
  35. <view>销售员:{{item.salesmanName||''}}</view>
  36. <view>创建人:{{item.createUsername||''}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </label>
  41. </checkbox-group>
  42. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  43. </u-list>
  44. </view>
  45. <view class="footer">
  46. <view class="bottom" v-if="this.isAll==1">
  47. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  48. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选</checkbox>
  49. </view>
  50. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  51. <view class="selBtn">选择( {{ checkListLen }} )</view>
  52. </u-button>
  53. </view>
  54. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类" :localdata="classificationList" valueKey="id" textKey="name" />
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. contactPage,
  60. } from '@/api/saleManage/contact/index.js'
  61. import {
  62. getTreeByPid
  63. } from "@/api/classifyManage/index.js"
  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({ isAll }) {
  91. this.isAll = isAll //1多选 2单选
  92. this.getClassify()
  93. },
  94. onShow() {
  95. },
  96. methods: {
  97. scrolltolower() {
  98. if (this.isEnd) {
  99. return
  100. }
  101. // 显示加载图标
  102. uni.showLoading({
  103. title: '数据加载中'
  104. })
  105. //获取更多数据
  106. this.page++
  107. this.getList()
  108. },
  109. //列表数据
  110. async getList() {
  111. this.isEnd = false
  112. this._getClassifyList()
  113. },
  114. async _getClassifyList() {
  115. uni.showLoading({
  116. title: '数据加载中'
  117. })
  118. const params = {
  119. pageNum: this.page,
  120. size: this.size,
  121. name: this.searchVal,
  122. categoryId: this.categoryLevelId
  123. }
  124. contactPage(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. getTreeByPid(17).then(res => {
  140. this.classificationList = res.data
  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.checkListLen = 0;
  172. this.listData.map(item => {
  173. this.$set(item, 'checked', false)
  174. })
  175. }
  176. },
  177. //跳转回添加页面
  178. jumpAdd() {
  179. uni.$emit(
  180. 'setSelectList',
  181. this.listData.filter(item => item.checked)
  182. )
  183. console.log(
  184. this.listData.filter(item => item.checked),
  185. '222'
  186. )
  187. uni.navigateBack()
  188. },
  189. //返回添加页
  190. backAdd() {
  191. uni.navigateBack()
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .mainBox {
  198. height: 100vh;
  199. display: flex;
  200. flex-direction: column;
  201. .wrapper {
  202. flex: 1;
  203. overflow: hidden;
  204. }
  205. .searchBox {
  206. padding: 10rpx 0;
  207. box-sizing: border-box;
  208. background-color: #dedede;
  209. height: 90rpx;
  210. width: 100%;
  211. line-height: 90rpx;
  212. display: flex;
  213. justify-content: space-around;
  214. align-items: center;
  215. input {
  216. height: 78rpx;
  217. width: 65%;
  218. background: #f9f9f9 !important;
  219. margin: 0 10rpx;
  220. padding: 0 10rpx;
  221. box-sizing: border-box;
  222. border-radius: 5rpx;
  223. }
  224. .searchBtn {
  225. height: 80rpx;
  226. background: #f9f9f9 !important;
  227. color: #676767;
  228. font-size: 28rpx;
  229. padding: 0 42rpx;
  230. box-sizing: border-box;
  231. outline: none;
  232. border: none;
  233. width: 260rpx;
  234. .icon-sousuo {
  235. font-size: 22px;
  236. }
  237. .text {
  238. font-size: 16px;
  239. margin-left: 10px;
  240. }
  241. }
  242. }
  243. .tab-title {
  244. position: fixed;
  245. top: 190rpx;
  246. z-index: 99;
  247. width: 100%;
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. height: $tab-height;
  252. line-height: $tab-height;
  253. background-color: #ffffff;
  254. border-bottom: 2rpx solid #f2f2f2;
  255. box-sizing: border-box;
  256. .tab-item {
  257. width: 25%;
  258. text-align: center;
  259. font-size: 32rpx;
  260. color: $uni-text-color-grey;
  261. }
  262. .tab-item.active {
  263. color: $j-primary-border-green;
  264. border-bottom: 1px solid $j-primary-border-green;
  265. font-weight: bold;
  266. }
  267. .tab-item.filter {
  268. flex: 1;
  269. padding: 0px 30rpx;
  270. .uni-icons {
  271. display: flex;
  272. padding-top: 5px;
  273. }
  274. }
  275. .screenIcon {
  276. display: flex;
  277. width: 80px;
  278. justify-content: center;
  279. .screenText {
  280. font-size: 32rpx;
  281. color: $uni-text-color-grey;
  282. }
  283. }
  284. }
  285. .listContent {
  286. height: 100% !important;
  287. .listBox {
  288. display: flex;
  289. // height: 180rpx;
  290. padding: 20rpx 0;
  291. border-bottom: 2rpx solid #e5e5e5;
  292. .listBox-sel {
  293. height: 90rpx;
  294. width: 80rpx;
  295. // line-height: 90rpx;
  296. text-align: center;
  297. checkbox {
  298. transform: scale(1.2);
  299. }
  300. }
  301. .listBox-con {
  302. width: 100%;
  303. // display: flex;
  304. // flex-wrap: wrap;
  305. // justify-content: space-between;
  306. align-items: center;
  307. padding: 0 18rpx 0 0;
  308. .listBox-top {
  309. width: 100%;
  310. display: flex;
  311. justify-content: space-between;
  312. padding-bottom: 10rpx;
  313. .listBox-name,
  314. .listBox-code {
  315. display: inline-block;
  316. font-size: $uni-font-size-sm;
  317. font-weight: bold;
  318. }
  319. }
  320. .listBox-bottom {
  321. width: 100%;
  322. display: flex;
  323. justify-content: space-between;
  324. font-size: $uni-font-size-sm;
  325. flex-wrap: wrap;
  326. > view {
  327. width: 50%;
  328. overflow: hidden;
  329. white-space: nowrap;
  330. text-overflow: ellipsis;
  331. }
  332. }
  333. }
  334. }
  335. .noDate {
  336. height: 100%;
  337. }
  338. }
  339. //底部按钮
  340. .footer {
  341. height: 90rpx;
  342. position: relative;
  343. display: flex;
  344. justify-content: space-between;
  345. align-items: center;
  346. bottom: 0;
  347. width: 100%;
  348. height: 100rpx;
  349. border-top: 1rpx solid #eeecec;
  350. background-color: #ffffff;
  351. z-index: 999;
  352. .bottom {
  353. margin-left: 10rpx;
  354. }
  355. .u-reset-button {
  356. position: absolute;
  357. right: 10rpx;
  358. top: 20rpx;
  359. width: 150rpx;
  360. }
  361. }
  362. }
  363. </style>