chooseNetwork.vue 9.0 KB

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