selectContact.vue 9.0 KB

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