selectContract.vue 8.8 KB

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