chooseNetwork.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="choose-network-container">
  3. <!-- 筛选弹框 -->
  4. <search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
  5. <view class="choose-network-header">
  6. <view class="checked-all">
  7. <u-checkbox
  8. v-if="listdata.length>0"
  9. class="checked-all-c"
  10. active-color="#01c9b2"
  11. @change="checkedAll"
  12. v-model="isCheckedAll"
  13. label-size="26"
  14. name="checkedAll"
  15. >全选</u-checkbox>
  16. </view>
  17. <view class="choose-checked" @tap="openScreen=true">
  18. 已选:<text>{{checkedList.length}}</text>
  19. <image class="filter-icon" src="@/static/filter.png"></image>
  20. </view>
  21. </view>
  22. <scroll-view class="scroll-con" scroll-y :scroll-top="scrollTop" @scrolltolower="onreachBottom">
  23. <!-- 列表数据 -->
  24. <u-checkbox-group class="cell-item-con">
  25. <view class="cell-item" v-for="(item, index) in listdata" :key="index">
  26. <u-checkbox
  27. class="cell-item-checkbox"
  28. @change="checkboxChange($event, index)"
  29. active-color="#01c9b2"
  30. v-model="item.checked"
  31. :name="item.id">
  32. </u-checkbox>
  33. <view class="cell-item-c" @tap="goPage(item)">
  34. <view class="cell-item-info">
  35. <view class="cell-item-info-network">
  36. {{item.stationName}}
  37. <u-badge type="success" bgColor="#c90101" :count="item.unCleanNum" :offset="[-10,-32]" size="mini"></u-badge>
  38. </view>
  39. <view class="cell-item-info-weight">
  40. <view class="cell-item-weight-bar">
  41. {{item.totalWeight}}kg
  42. <u-badge class="badge" type="primary" bgColor="#01c9b2" count="总" :offset="[0,0]"></u-badge>
  43. </view>
  44. <view class="cell-item-weight-bar">
  45. {{item.maxWeight}}kg
  46. <u-badge class="badge" type="warning" bgColor="#05695d" count="最大" :offset="[0,0]"></u-badge>
  47. </view>
  48. </view>
  49. </view>
  50. <u-icon name="arrow-right" class="arrow-right" :size="28" color="#999"></u-icon>
  51. </view>
  52. </view>
  53. </u-checkbox-group>
  54. <u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
  55. <view class="loadmore">
  56. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  57. </view>
  58. </scroll-view>
  59. <view class="footer-bar">
  60. <u-button class="footer-handle-btn handle-btn" hover-class="none" :custom-style="btnStyle" shape="circle" @click="handleAdd" size="medium" type="primary">
  61. <text>加入待清运清单</text>
  62. </u-button>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import searchModal from '@/pages/cleared/searchModal.vue'
  68. import { waitToCleanList } from '@/api/cleared.js'
  69. export default{
  70. components: { searchModal },
  71. data(){
  72. return{
  73. listdata: [{id:1},{id:2}],
  74. pageNo: 1, // 当前页码
  75. pageSize: 10, // 每页条数
  76. total: 0, // 数据总条数
  77. noDataText: '暂无数据', // 列表请求状态提示语
  78. status: 'loadmore', // 加载中状态
  79. scrollTop: 0, // 滚动条位置
  80. isCheckedAll: false, // 全选状态
  81. checkedNum: 0, // 已选个数
  82. checkedList: [], // 已选清运网点
  83. openScreen: false, // 是否打开筛选
  84. searchForm: {
  85. // 查询条件
  86. stationName: '', // 网点名称
  87. orderType: 'max', // 排序方式
  88. },
  89. btnStyle: { // 自定义按钮样式
  90. borderColor: '#07c160',
  91. backgroundColor: '#07c160',
  92. width: '100%'
  93. },
  94. }
  95. },
  96. onShow() {
  97. this.openScreen = false // 关闭筛选框
  98. this.refresh(this.searchForm)
  99. },
  100. methods: {
  101. // 加入清运单
  102. handleAdd(){
  103. },
  104. // 选中某个复选框时,由checkbox时触发
  105. checkboxChange(e,ind) {
  106. this.listdata[ind].checked = e.value
  107. let len = 0
  108. this.checkedList = []
  109. this.listdata.map(item => {
  110. if(item.checked){
  111. len++
  112. this.checkedList.push(item.id)
  113. }
  114. })
  115. this.checkedNum = len
  116. },
  117. // 全选
  118. checkedAll(e) {
  119. this.isCheckedAll = e
  120. let len = 0
  121. this.checkedList = []
  122. this.listdata.map(val => {
  123. val.checked = e.value ? true : false
  124. if(val.checked){
  125. len++
  126. this.checkedList.push(val.id)
  127. }
  128. })
  129. this.checkedNum = len
  130. },
  131. // 获取查询参数 刷新列表
  132. refresh(params){
  133. this.searchForm = params
  134. this.listdata = []
  135. this.total = 0
  136. this.searchHandle(1)
  137. },
  138. // 搜索查询
  139. searchHandle (pageNo) {
  140. this.status = "loading"
  141. pageNo ? this.pageNo = pageNo : null,
  142. waitToCleanList({
  143. pageNo: this.pageNo,
  144. pageSize: this.pageSize,
  145. stationName: this.searchForm.stationName,
  146. orderType: this.searchForm.orderType
  147. }).then(res => {
  148. if (res.status == 200) {
  149. res.data.list.map(item => {
  150. item.checked = false
  151. })
  152. if(this.pageNo>1){
  153. this.listdata = this.listdata.concat(res.data.list || [])
  154. }else{
  155. this.listdata = res.data.list || []
  156. this.scrollTop = 0
  157. }
  158. this.total = res.data.count || 0
  159. this.noDataText = '暂无数据'
  160. } else {
  161. this.noDataText = res.message
  162. this.listdata = []
  163. this.total = 0
  164. }
  165. this.status = "loadmore"
  166. })
  167. },
  168. // 查看详情
  169. goPage(row){
  170. uni.navigateTo({
  171. url: '/pages/cleared/network?stationNo=' + item.stationNo
  172. })
  173. },
  174. // scroll-view到底部加载更多
  175. onreachBottom() {
  176. if(this.listdata.length < this.total){
  177. this.pageNo += 1
  178. this.searchHandle()
  179. }else{
  180. uni.showToast({ title: '已经到底了', icon: 'none' })
  181. this.status = "nomore"
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss">
  188. page{
  189. height: 100%;
  190. }
  191. .choose-network-container {
  192. width: 100%;
  193. height: 100%;
  194. display: flex;
  195. flex-direction: column;
  196. padding-top: 80rpx;
  197. padding-bottom: 102rpx;
  198. position: relative;
  199. // 顶部固定
  200. .choose-network-header{
  201. position: fixed;
  202. top: 0;
  203. left: 0;
  204. width: 100%;
  205. display: flex;
  206. justify-content: space-between;
  207. align-items: center;
  208. padding: 0 $uni-spacing-row-base;
  209. box-sizing: border-box;
  210. background-color: #fff;
  211. line-height: 80rpx;
  212. font-size: 26rpx;
  213. .checked-all{
  214. .checked-all-c{
  215. font-size: 26rpx;
  216. }
  217. }
  218. .choose-checked{
  219. text{
  220. color: red;
  221. }
  222. .filter-icon{
  223. width: 36rpx;
  224. height: 36rpx;
  225. padding-left: 30rpx;
  226. vertical-align: text-top;
  227. }
  228. }
  229. }
  230. // 列表
  231. .scroll-con{
  232. flex: 1;
  233. overflow: auto;
  234. }
  235. // 列表样式
  236. .cell-item-con{
  237. .cell-item{
  238. margin: $uni-spacing-col-base $uni-spacing-row-base;
  239. background-color: #fff;
  240. border-radius: $uni-border-radius-base;
  241. color: $uni-text-color;
  242. font-size: $uni-font-size-base;
  243. box-shadow: 3rpx 3rpx 5rpx #eee;
  244. display: flex;
  245. align-items: center;
  246. padding: 30rpx 20rpx;
  247. // 多选框
  248. .cell-item-checkbox{
  249. flex-shrink: 0;
  250. }
  251. .cell-item-c{
  252. flex-grow: 1;
  253. display: flex;
  254. justify-content: space-around;
  255. align-items: center;
  256. .cell-item-info{
  257. flex-grow: 1;
  258. .cell-item-info-network{
  259. word-break: break-all;
  260. margin-bottom: 26rpx;
  261. display: inline-block;
  262. position: relative;
  263. }
  264. .cell-item-info-weight{
  265. font-size: 24rpx;
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. .cell-item-weight-bar{
  270. position: relative;
  271. display: inline-block;
  272. padding-right: 50rpx;
  273. &:nth-child(2){
  274. padding-right: 76rpx;
  275. }
  276. }
  277. }
  278. }
  279. .arrow-right{
  280. flex-shrink: 0;
  281. margin-left: 64rpx;
  282. }
  283. }
  284. }
  285. }
  286. .footer-bar{
  287. width: 100%;
  288. height: 102rpx;
  289. padding: 0 10%;
  290. position: fixed;
  291. bottom: 0;
  292. left: 0;
  293. text-align: center;
  294. .footer-handle-btn{
  295. display: block;
  296. .btn-icon{
  297. margin-right: 10rpx;
  298. }
  299. }
  300. .handle-btn{
  301. margin-top: 18rpx;
  302. margin-bottom: 20rpx;
  303. }
  304. }
  305. }
  306. </style>