chooseNetwork.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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/1000).toFixed(2) }}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/1000).toFixed(2) }}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. uni.showLoading({
  163. mask: true,
  164. title: '加载中'
  165. })
  166. this.status = "loading"
  167. pageNo ? this.pageNo = pageNo : null,
  168. waitToCleanList({
  169. pageNo: this.pageNo,
  170. pageSize: this.pageSize,
  171. stationName: this.searchForm.stationName,
  172. orderType: this.searchForm.orderType
  173. }).then(res => {
  174. uni.hideLoading()
  175. if (res.status == 200) {
  176. res.data.list.map(item => {
  177. item.checked = false
  178. })
  179. if(this.pageNo>1){
  180. this.listdata = this.listdata.concat(res.data.list || [])
  181. }else{
  182. this.listdata = res.data.list || []
  183. this.scrollTop = 0
  184. }
  185. this.total = res.data.count || 0
  186. this.noDataText = '暂无数据'
  187. } else {
  188. this.noDataText = res.message
  189. this.listdata = []
  190. this.total = 0
  191. }
  192. this.status = "loadmore"
  193. })
  194. },
  195. // 查看详情
  196. goPage(record){
  197. uni.navigateTo({
  198. url: '/pages/cleared/network?stationNo=' + record.stationNo
  199. })
  200. },
  201. // scroll-view到底部加载更多
  202. onreachBottom() {
  203. if(this.listdata.length!=0 && this.listdata.length < this.total){
  204. this.pageNo += 1
  205. this.searchHandle()
  206. }else{
  207. uni.showToast({ title: '已经到底了', icon: 'none' })
  208. this.status = "nomore"
  209. }
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. page{
  216. height: 100%;
  217. }
  218. .choose-network-container {
  219. width: 100%;
  220. height: 100%;
  221. display: flex;
  222. flex-direction: column;
  223. padding-top: 80rpx;
  224. padding-bottom: 102rpx;
  225. position: relative;
  226. // 顶部固定
  227. .choose-network-header{
  228. position: fixed;
  229. top: 0;
  230. left: 0;
  231. width: 100%;
  232. display: flex;
  233. justify-content: space-between;
  234. align-items: center;
  235. padding: 0 $uni-spacing-row-base;
  236. box-sizing: border-box;
  237. background-color: #fff;
  238. line-height: 80rpx;
  239. font-size: 26rpx;
  240. .checked-all{
  241. .checked-all-c{
  242. font-size: 26rpx;
  243. }
  244. }
  245. .choose-checked{
  246. text{
  247. color: red;
  248. }
  249. .filter-icon{
  250. width: 36rpx;
  251. height: 36rpx;
  252. padding-left: 30rpx;
  253. vertical-align: text-top;
  254. }
  255. }
  256. }
  257. // 列表
  258. .scroll-con{
  259. flex: 1;
  260. overflow: auto;
  261. }
  262. // 列表样式
  263. .cell-item-con{
  264. .cell-item{
  265. margin: $uni-spacing-col-base $uni-spacing-row-base;
  266. background-color: #fff;
  267. border-radius: $uni-border-radius-base;
  268. color: $uni-text-color;
  269. font-size: $uni-font-size-base;
  270. box-shadow: 3rpx 3rpx 5rpx #eee;
  271. display: flex;
  272. align-items: center;
  273. padding: 40rpx 20rpx;
  274. // 多选框
  275. .cell-item-checkbox{
  276. flex-shrink: 0;
  277. }
  278. .cell-item-c{
  279. flex-grow: 1;
  280. display: flex;
  281. justify-content: space-around;
  282. align-items: center;
  283. .cell-item-info{
  284. flex-grow: 1;
  285. .cell-item-info-network{
  286. word-break: break-all;
  287. margin-bottom: 26rpx;
  288. display: inline-block;
  289. position: relative;
  290. }
  291. .cell-item-info-weight{
  292. font-size: 24rpx;
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. .cell-item-weight-bar{
  297. position: relative;
  298. display: inline-block;
  299. padding-right: 50rpx;
  300. &:nth-child(2){
  301. padding-right: 76rpx;
  302. }
  303. }
  304. }
  305. }
  306. .arrow-right{
  307. flex-shrink: 0;
  308. margin-left: 64rpx;
  309. }
  310. }
  311. }
  312. }
  313. .footer-bar{
  314. width: 100%;
  315. height: 102rpx;
  316. padding: 0 10%;
  317. position: fixed;
  318. bottom: 0;
  319. left: 0;
  320. text-align: center;
  321. .footer-handle-btn{
  322. display: block;
  323. .btn-icon{
  324. margin-right: 10rpx;
  325. }
  326. }
  327. .handle-btn{
  328. margin-top: 18rpx;
  329. margin-bottom: 20rpx;
  330. }
  331. }
  332. .nodata{
  333. padding-top: 400rpx;
  334. }
  335. }
  336. </style>