index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="unclear-container">
  3. <uni-navbar pageName="待清运" :isBack="false" :isMap="true"></uni-navbar>
  4. <scroll-view class="scroll-con" scroll-y :scroll-top="scrollTop" @scrolltolower="onreachBottom">
  5. <!-- 列表数据 -->
  6. <view class="cell-item-con">
  7. <view class="cell-item" v-for="(item, index) in listdata" :key="index">
  8. <view class="cell-item-c" @tap="goPage(item)">
  9. <view class="cell-item-info">
  10. <view class="cell-item-info-network">
  11. {{item.stationName}}
  12. <u-badge type="success" bgColor="#c90101" :count="item.unCleanNum" :offset="[-10,-32]" size="mini"></u-badge>
  13. </view>
  14. <view class="cell-item-info-weight">
  15. <view class="cell-item-weight-bar">
  16. {{item.totalWeight}}kg
  17. <u-badge class="badge" type="primary" bgColor="#01c9b2" count="总" :offset="[0,0]"></u-badge>
  18. </view>
  19. <view class="cell-item-weight-bar">
  20. {{item.maxWeight}}kg
  21. <u-badge class="badge" type="warning" bgColor="#05695d" count="最大" :offset="[0,0]"></u-badge>
  22. </view>
  23. </view>
  24. </view>
  25. <u-icon name="arrow-right" class="arrow-right" :size="28" color="#999"></u-icon>
  26. </view>
  27. <u-button size="mini" class="handle-btn" hover-class="none" :custom-style="customBtnStyle" @click="removeFun(item)">移除</u-button>
  28. </view>
  29. </view>
  30. <u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
  31. <view class="loadmore" v-if="listdata.length!=0">
  32. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  33. </view>
  34. </scroll-view>
  35. <view class="footer-bar">
  36. <u-button class="footer-handle-btn scan-btn" hover-class="none" :custom-style="scanBtnStyle" shape="circle" @click="clearingOutlets" size="medium" type="primary">
  37. <u-icon name="scan" class="btn-icon" :size="28" color="#fff"></u-icon>
  38. <text>扫码清运</text>
  39. </u-button>
  40. <u-button class="footer-handle-btn" hover-class="none" :custom-style="btnStyle" shape="circle" @click="openQuery" size="medium">
  41. <u-icon name="plus" class="btn-icon" :size="28" color="#606266"></u-icon>
  42. <text>增加清运网点</text>
  43. </u-button>
  44. </view>
  45. <!-- 确认清运 -->
  46. <u-popup v-model="messagePop" mode="center" class="custom-pop" length="80%" border-radius="14" :mask-close-able="false">
  47. <view class="custom-con">
  48. <view class="pop-title">提示</view>
  49. <view class="pop-con">
  50. <view class="pop-item">确认清运以下网点-设备内的可回收物?</view>
  51. <view class="pop-item">{{networkData.stationName || ''}}</view>
  52. <view class="pop-item">{{networkData.srcDeviceCode || ''}}</view>
  53. <view class="form-con">
  54. <u-form :model="form" ref="uForm">
  55. <u-form-item label="备注" :border-bottom="false">
  56. <u-input v-model="form.remarks" type="textarea" border />
  57. </u-form-item>
  58. </u-form>
  59. </view>
  60. </view>
  61. <view class="btn-con">
  62. <view class="handle-pop-btn cancel-btn" @click="cancelFun">取消</view>
  63. <view class="handle-pop-btn submit-btn" @click="submitFun">确定</view>
  64. </view>
  65. </view>
  66. </u-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import { getSelfCleanTaskList, cleanDevice, cleanStationRemove, getDeviceMsg } from '@/api/unclear.js'
  71. import { parseQueryString } from '@/libs/tools.js'
  72. export default {
  73. data() {
  74. return {
  75. listdata: [],
  76. pageNo: 1, // 当前页码
  77. pageSize: 10, // 每页条数
  78. total: 0, // 数据总条数
  79. noDataText: '暂无数据', // 列表请求状态提示语
  80. status: 'loadmore', // 加载中状态
  81. customBtnStyle: { // 自定义按钮样式
  82. borderColor: '#01c9b2',
  83. backgroundColor: '#01c9b2',
  84. color: '#fff'
  85. },
  86. scrollTop: 0, // 滚动条位置
  87. scanBtnStyle: { // 自定义按钮样式
  88. borderColor: '#07c160',
  89. backgroundColor: '#07c160',
  90. width: '100%'
  91. },
  92. btnStyle: { // 自定义按钮样式
  93. width: '100%'
  94. },
  95. form: {
  96. remarks: '' // 备注
  97. },
  98. boxData: null, // 箱体二维码数据
  99. messagePop: false, // 确认清运
  100. networkData: null // 网点详情
  101. }
  102. },
  103. onShow() {
  104. this.pageNo = 1
  105. this.refresh()
  106. },
  107. methods:{
  108. // 是否可清运
  109. clearingOutlets(){
  110. if(this.listdata.length==0){
  111. uni.showToast({ title: '请先选择待清运网点,再进行扫码清运', icon: 'none' })
  112. }else{
  113. this.openScan()
  114. }
  115. },
  116. // 扫码清运
  117. openScan(){
  118. const _this = this
  119. uni.scanCode({
  120. success(e) {
  121. console.log(e)
  122. // 普通二维码,用户扫箱体的二维码
  123. if(e.scanType == 'QR_CODE'){
  124. // 将箱体二维码数据转换为json
  125. _this.boxData = parseQueryString(e.result)
  126. _this.getNetworkInfo()
  127. }
  128. },
  129. fail(err) {
  130. console.log(err)
  131. }
  132. })
  133. },
  134. // 扫码获取网点信息
  135. getNetworkInfo(){
  136. const _this = this
  137. getDeviceMsg(_this.boxData).then(res => {
  138. if(res.status == 200){
  139. _this.networkData = res.data
  140. _this.messagePop = true
  141. }else{
  142. _this.messagePop = false
  143. }
  144. })
  145. },
  146. // 取消清运
  147. cancelFun(){
  148. this.messagePop = false
  149. },
  150. // 确定清运
  151. submitFun(){
  152. uni.showLoading({
  153. mask: true,
  154. title: '加载中'
  155. })
  156. cleanDevice({ remarks: this.form.remarks }).then(res => {
  157. uni.hideLoading()
  158. if(res.status == 200){
  159. this.refresh()
  160. this.messagePop = false
  161. uni.showToast({ icon:'none', title: res.message })
  162. }else{
  163. uni.showToast({ icon:'none', title: res.message })
  164. }
  165. })
  166. },
  167. // 增加清运网点
  168. openQuery(){
  169. uni.navigateTo({
  170. url: '/pages/cleared/chooseNetwork'
  171. })
  172. },
  173. // 获取查询参数 刷新列表
  174. refresh(){
  175. this.listdata = []
  176. this.total = 0
  177. this.searchHandle(1)
  178. },
  179. // 搜索查询
  180. searchHandle (pageNo) {
  181. this.status = "loading"
  182. pageNo ? this.pageNo = pageNo : null
  183. getSelfCleanTaskList({
  184. pageNo: this.pageNo,
  185. pageSize: this.pageSize
  186. }).then(res => {
  187. if (res.status == 200) {
  188. if(this.pageNo>1){
  189. this.listdata = this.listdata.concat(res.data.list || [])
  190. }else{
  191. this.listdata = res.data.list || []
  192. this.scrollTop = 0
  193. }
  194. this.total = res.data.count || 0
  195. this.noDataText = '暂无数据'
  196. } else {
  197. this.noDataText = res.message
  198. this.listdata = []
  199. this.total = 0
  200. }
  201. this.status = "loadmore"
  202. })
  203. },
  204. // 移除
  205. removeFun(row){
  206. const _this = this
  207. uni.showModal({
  208. title: '提示',
  209. content: '确认移除该网点的清运单?',
  210. success(res) {
  211. if (res.confirm) {
  212. cleanStationRemove({ stationNo: row.stationNo }).then(ret => {
  213. if(ret.status == 200){
  214. uni.showToast({ title: ret.message, icon: 'none' })
  215. _this.searchHandle(1)
  216. }
  217. })
  218. }
  219. }
  220. })
  221. },
  222. // 查看详情
  223. goPage(row){
  224. uni.navigateTo({
  225. url: '/pages/cleared/network?stationNo='+row.stationNo
  226. })
  227. },
  228. // scroll-view到底部加载更多
  229. onreachBottom() {
  230. if(this.listdata.length!=0 && this.listdata.length < this.total){
  231. this.pageNo++
  232. this.searchHandle()
  233. }else{
  234. uni.showToast({ title: '已经到底了', icon: 'none' })
  235. this.status = "nomore"
  236. }
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss">
  242. page{
  243. height: 100%;
  244. }
  245. .unclear-container {
  246. width: 100%;
  247. height: 100%;
  248. display: flex;
  249. flex-direction: column;
  250. padding-bottom: 204rpx;
  251. // 列表
  252. .scroll-con{
  253. flex: 1;
  254. overflow: auto;
  255. }
  256. // 列表样式
  257. .cell-item-con{
  258. .cell-item{
  259. margin: $uni-spacing-col-base $uni-spacing-row-base;
  260. background-color: #fff;
  261. border-radius: $uni-border-radius-base;
  262. color: $uni-text-color;
  263. font-size: $uni-font-size-base;
  264. box-shadow: 3rpx 3rpx 5rpx #eee;
  265. padding: 30rpx 20rpx;
  266. position: relative;
  267. .cell-item-c{
  268. display: flex;
  269. justify-content: space-around;
  270. align-items: center;
  271. .cell-item-info{
  272. flex-grow: 1;
  273. .cell-item-info-network{
  274. word-break: break-all;
  275. margin-bottom: 26rpx;
  276. display: inline-block;
  277. position: relative;
  278. }
  279. .cell-item-info-weight{
  280. font-size: 24rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. .cell-item-weight-bar{
  285. position: relative;
  286. display: inline-block;
  287. padding-right: 50rpx;
  288. &:nth-child(2){
  289. padding-right: 76rpx;
  290. }
  291. }
  292. }
  293. }
  294. .arrow-right{
  295. flex-shrink: 0;
  296. margin-left: 64rpx;
  297. }
  298. }
  299. .handle-btn{
  300. position: absolute;
  301. right: $uni-spacing-row-sm;
  302. top: $uni-spacing-col-sm;
  303. }
  304. }
  305. }
  306. .footer-bar{
  307. width: 100%;
  308. height: 204rpx;
  309. padding: 0 10%;
  310. position: fixed;
  311. bottom: 0;
  312. left: 0;
  313. text-align: center;
  314. .footer-handle-btn{
  315. display: block;
  316. .btn-icon{
  317. margin-right: 10rpx;
  318. }
  319. }
  320. .scan-btn{
  321. margin-top: 24rpx;
  322. margin-bottom: 20rpx;
  323. }
  324. }
  325. // 弹框样式
  326. .custom-pop{
  327. .custom-con{
  328. text-align: center;
  329. background: url(/static/pop-bg.png) no-repeat;
  330. background-size: 100% 100%;
  331. font-size: 30rpx;
  332. color: #5a5a5a;
  333. line-height: 54rpx;
  334. .pop-title{
  335. padding: 20rpx 0;
  336. color: #fff;
  337. font-weight: bold;
  338. }
  339. .pop-con{
  340. padding: 80rpx 0 40rpx;
  341. .pop-item{
  342. padding: 0 20rpx;
  343. }
  344. .form-con{
  345. padding: 10rpx 30rpx;
  346. }
  347. }
  348. .btn-con{
  349. border-top: 1rpx solid rgba(213,213,213,0.8);
  350. .handle-pop-btn{
  351. padding: 20rpx 0;
  352. width: 50%;
  353. display: inline-block;
  354. }
  355. .cancel-btn{
  356. border-right: 1rpx solid rgba(213,213,213,0.8);
  357. }
  358. .submit-btn{
  359. color: #16d1bc;
  360. }
  361. }
  362. }
  363. }
  364. .nodata{
  365. padding-top: 400rpx;
  366. }
  367. }
  368. </style>