selectContact.vue 11 KB

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