chooseNetwork.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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" v-if="listdata.length!=0">
  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. import { cleanStationAdd } from '@/api/unclear.js'
  70. export default{
  71. components: { searchModal },
  72. data(){
  73. return{
  74. listdata: [],
  75. pageNo: 1, // 当前页码
  76. pageSize: 40, // 每页条数
  77. total: 0, // 数据总条数
  78. noDataText: '暂无数据', // 列表请求状态提示语
  79. status: 'loadmore', // 加载中状态
  80. scrollTop: 0, // 滚动条位置
  81. isCheckedAll: false, // 全选状态
  82. checkedNum: 0, // 已选个数
  83. checkedList: [], // 已选清运网点
  84. openScreen: false, // 是否打开筛选
  85. searchForm: {
  86. // 查询条件
  87. stationName: '', // 网点名称
  88. orderType: 'max', // 排序方式
  89. },
  90. btnStyle: { // 自定义按钮样式
  91. borderColor: '#07c160',
  92. backgroundColor: '#07c160',
  93. width: '100%'
  94. },
  95. }
  96. },
  97. onShow() {
  98. this.openScreen = false // 关闭筛选框
  99. this.refresh(this.searchForm)
  100. },
  101. methods: {
  102. // 加入清运单
  103. handleAdd(){
  104. if(this.checkedList.length > 0){
  105. uni.showLoading({
  106. mask: true,
  107. title: '加载中'
  108. })
  109. cleanStationAdd({ stationNoList: this.checkedList }).then(res => {
  110. uni.hideLoading()
  111. if(res.status == 200){
  112. uni.showToast({ icon:'none', title: res.message })
  113. setTimeout(()=>{
  114. uni.navigateBack()
  115. }, 1000)
  116. }else{
  117. uni.showToast({ icon:'none', title: res.message })
  118. }
  119. })
  120. }else{
  121. uni.showToast({ icon:'none', title: '暂无需加入待清运清单的网点' })
  122. }
  123. },
  124. // 选中某个复选框时,由checkbox时触发
  125. checkboxChange(e,ind) {
  126. this.listdata[ind].checked = e.value
  127. let len = 0
  128. this.checkedList = []
  129. this.listdata.map(item => {
  130. if(item.checked){
  131. len++
  132. this.checkedList.push(item.stationNo)
  133. }
  134. })
  135. this.checkedNum = len
  136. },
  137. // 全选
  138. checkedAll(e) {
  139. this.isCheckedAll = e
  140. let len = 0
  141. this.checkedList = []
  142. this.listdata.map(val => {
  143. val.checked = e.value ? true : false
  144. if(val.checked){
  145. len++
  146. this.checkedList.push(val.stationNo)
  147. }
  148. })
  149. this.checkedNum = len
  150. },
  151. // 获取查询参数 刷新列表
  152. refresh(params){
  153. this.searchForm = params
  154. this.listdata = []
  155. this.total = 0
  156. this.isCheckedAll = false
  157. this.checkedList = []
  158. this.searchHandle(1)
  159. },
  160. // 搜索查询
  161. searchHandle (pageNo) {
  162. this.status = "loading"
  163. pageNo ? this.pageNo = pageNo : null,
  164. waitToCleanList({
  165. pageNo: this.pageNo,
  166. pageSize: this.pageSize,
  167. stationName: this.searchForm.stationName,
  168. orderType: this.searchForm.orderType
  169. }).then(res => {
  170. if (res.status == 200) {
  171. res.data.list.map(item => {
  172. item.checked = false
  173. })
  174. if(this.pageNo>1){
  175. this.listdata = this.listdata.concat(res.data.list || [])
  176. }else{
  177. this.listdata = res.data.list || []
  178. this.scrollTop = 0
  179. }
  180. this.total = res.data.count || 0
  181. this.noDataText = '暂无数据'
  182. } else {
  183. this.noDataText = res.message
  184. this.listdata = []
  185. this.total = 0
  186. }
  187. this.status = "loadmore"
  188. })
  189. },
  190. // 查看详情
  191. goPage(record){
  192. uni.navigateTo({
  193. url: '/pages/cleared/network?stationNo=' + record.stationNo
  194. })
  195. },
  196. // scroll-view到底部加载更多
  197. onreachBottom() {
  198. if(this.listdata.length!=0 && this.listdata.length < this.total){
  199. this.pageNo += 1
  200. this.searchHandle()
  201. }else{
  202. uni.showToast({ title: '已经到底了', icon: 'none' })
  203. this.status = "nomore"
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. page{
  211. height: 100%;
  212. }
  213. .choose-network-container {
  214. width: 100%;
  215. height: 100%;
  216. display: flex;
  217. flex-direction: column;
  218. padding-top: 80rpx;
  219. padding-bottom: 102rpx;
  220. position: relative;
  221. // 顶部固定
  222. .choose-network-header{
  223. position: fixed;
  224. top: 0;
  225. left: 0;
  226. width: 100%;
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding: 0 $uni-spacing-row-base;
  231. box-sizing: border-box;
  232. background-color: #fff;
  233. line-height: 80rpx;
  234. font-size: 26rpx;
  235. .checked-all{
  236. .checked-all-c{
  237. font-size: 26rpx;
  238. }
  239. }
  240. .choose-checked{
  241. text{
  242. color: red;
  243. }
  244. .filter-icon{
  245. width: 36rpx;
  246. height: 36rpx;
  247. padding-left: 30rpx;
  248. vertical-align: text-top;
  249. }
  250. }
  251. }
  252. // 列表
  253. .scroll-con{
  254. flex: 1;
  255. overflow: auto;
  256. }
  257. // 列表样式
  258. .cell-item-con{
  259. .cell-item{
  260. margin: $uni-spacing-col-base $uni-spacing-row-base;
  261. background-color: #fff;
  262. border-radius: $uni-border-radius-base;
  263. color: $uni-text-color;
  264. font-size: $uni-font-size-base;
  265. box-shadow: 3rpx 3rpx 5rpx #eee;
  266. display: flex;
  267. align-items: center;
  268. padding: 30rpx 20rpx;
  269. // 多选框
  270. .cell-item-checkbox{
  271. flex-shrink: 0;
  272. }
  273. .cell-item-c{
  274. flex-grow: 1;
  275. display: flex;
  276. justify-content: space-around;
  277. align-items: center;
  278. .cell-item-info{
  279. flex-grow: 1;
  280. .cell-item-info-network{
  281. word-break: break-all;
  282. margin-bottom: 26rpx;
  283. display: inline-block;
  284. position: relative;
  285. }
  286. .cell-item-info-weight{
  287. font-size: 24rpx;
  288. display: flex;
  289. align-items: center;
  290. justify-content: space-between;
  291. .cell-item-weight-bar{
  292. position: relative;
  293. display: inline-block;
  294. padding-right: 50rpx;
  295. &:nth-child(2){
  296. padding-right: 76rpx;
  297. }
  298. }
  299. }
  300. }
  301. .arrow-right{
  302. flex-shrink: 0;
  303. margin-left: 64rpx;
  304. }
  305. }
  306. }
  307. }
  308. .footer-bar{
  309. width: 100%;
  310. height: 102rpx;
  311. padding: 0 10%;
  312. position: fixed;
  313. bottom: 0;
  314. left: 0;
  315. text-align: center;
  316. .footer-handle-btn{
  317. display: block;
  318. .btn-icon{
  319. margin-right: 10rpx;
  320. }
  321. }
  322. .handle-btn{
  323. margin-top: 18rpx;
  324. margin-bottom: 20rpx;
  325. }
  326. }
  327. .nodata{
  328. padding-top: 400rpx;
  329. }
  330. }
  331. </style>