index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. // {
  124. // charSet: "ISO8859-1"
  125. // errMsg: "scanCode:ok"
  126. // rawData: "aHR0cDovL3d3dy5zeHp4eWoubmV0L3dlYi9zdGF0aWMvcXJjb2RlL2Rvd25sb2FkLWFwcC5odG1sP2lkPTFiODM3M2JhLWNmMDAtNDU2NS04Y2ZkLTVmOGZlNTYwYmNmMiZ0eXBlPWR1c3RiaW4="
  127. // result: "http://www.sxzxyj.net/web/static/qrcode/download-app.html?id=1b8373ba-cf00-4565-8cfd-5f8fe560bcf2&type=dustbin"
  128. // scanType: "QR_CODE"
  129. // }
  130. if(e.scanType == 'QR_CODE'){
  131. // 将箱体二维码数据e.result携带参数转换为json
  132. _this.boxData = parseQueryString(e.result)
  133. _this.getNetworkInfo()
  134. }
  135. },
  136. fail(err) {
  137. console.log(err)
  138. }
  139. })
  140. },
  141. // 扫码获取网点信息
  142. getNetworkInfo(){
  143. const _this = this
  144. getDeviceMsg(_this.boxData).then(res => {
  145. if(res.status == 200){
  146. _this.networkData = res.data
  147. _this.messagePop = true
  148. }else{
  149. _this.messagePop = false
  150. }
  151. })
  152. },
  153. // 取消清运
  154. cancelFun(){
  155. this.messagePop = false
  156. },
  157. // 确定清运
  158. submitFun(){
  159. uni.showLoading({
  160. mask: true,
  161. title: '加载中'
  162. })
  163. cleanDevice({ remarks: this.form.remarks }).then(res => {
  164. uni.hideLoading()
  165. if(res.status == 200){
  166. this.refresh()
  167. this.messagePop = false
  168. uni.showToast({ icon:'none', title: res.message })
  169. }else{
  170. uni.showToast({ icon:'none', title: res.message })
  171. }
  172. })
  173. },
  174. // 增加清运网点
  175. openQuery(){
  176. uni.navigateTo({
  177. url: '/pages/cleared/chooseNetwork'
  178. })
  179. },
  180. // 获取查询参数 刷新列表
  181. refresh(){
  182. this.listdata = []
  183. this.total = 0
  184. this.searchHandle(1)
  185. },
  186. // 搜索查询
  187. searchHandle (pageNo) {
  188. this.status = "loading"
  189. pageNo ? this.pageNo = pageNo : null
  190. getSelfCleanTaskList({
  191. pageNo: this.pageNo,
  192. pageSize: this.pageSize
  193. }).then(res => {
  194. if (res.status == 200) {
  195. if(this.pageNo>1){
  196. this.listdata = this.listdata.concat(res.data.list || [])
  197. }else{
  198. this.listdata = res.data.list || []
  199. this.scrollTop = 0
  200. }
  201. this.total = res.data.count || 0
  202. this.noDataText = '暂无数据'
  203. } else {
  204. this.noDataText = res.message
  205. this.listdata = []
  206. this.total = 0
  207. }
  208. this.status = "loadmore"
  209. })
  210. },
  211. // 移除
  212. removeFun(row){
  213. const _this = this
  214. uni.showModal({
  215. title: '提示',
  216. content: '确认移除该网点的清运单?',
  217. success(res) {
  218. if (res.confirm) {
  219. cleanStationRemove({ stationNo: row.stationNo }).then(ret => {
  220. if(ret.status == 200){
  221. uni.showToast({ title: ret.message, icon: 'none' })
  222. _this.searchHandle(1)
  223. }
  224. })
  225. }
  226. }
  227. })
  228. },
  229. // 查看详情
  230. goPage(row){
  231. uni.navigateTo({
  232. url: '/pages/cleared/network?stationNo='+row.stationNo
  233. })
  234. },
  235. // scroll-view到底部加载更多
  236. onreachBottom() {
  237. if(this.listdata.length!=0 && this.listdata.length < this.total){
  238. this.pageNo++
  239. this.searchHandle()
  240. }else{
  241. uni.showToast({ title: '已经到底了', icon: 'none' })
  242. this.status = "nomore"
  243. }
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss">
  249. page{
  250. height: 100%;
  251. }
  252. .unclear-container {
  253. width: 100%;
  254. height: 100%;
  255. display: flex;
  256. flex-direction: column;
  257. padding-bottom: 204rpx;
  258. // 列表
  259. .scroll-con{
  260. flex: 1;
  261. overflow: auto;
  262. }
  263. // 列表样式
  264. .cell-item-con{
  265. .cell-item{
  266. margin: $uni-spacing-col-base $uni-spacing-row-base;
  267. background-color: #fff;
  268. border-radius: $uni-border-radius-base;
  269. color: $uni-text-color;
  270. font-size: $uni-font-size-base;
  271. box-shadow: 3rpx 3rpx 5rpx #eee;
  272. padding: 40rpx 20rpx;
  273. position: relative;
  274. .cell-item-c{
  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. .handle-btn{
  307. position: absolute;
  308. right: $uni-spacing-row-sm;
  309. top: $uni-spacing-col-sm;
  310. }
  311. }
  312. }
  313. .footer-bar{
  314. width: 100%;
  315. height: 204rpx;
  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. .scan-btn{
  328. margin-top: 24rpx;
  329. margin-bottom: 20rpx;
  330. }
  331. }
  332. // 弹框样式
  333. .custom-pop{
  334. .custom-con{
  335. text-align: center;
  336. background: url(/static/pop-bg.png) no-repeat;
  337. background-size: 100% 100%;
  338. font-size: 30rpx;
  339. color: #5a5a5a;
  340. line-height: 54rpx;
  341. .pop-title{
  342. padding: 20rpx 0;
  343. color: #fff;
  344. font-weight: bold;
  345. }
  346. .pop-con{
  347. padding: 80rpx 0 40rpx;
  348. .pop-item{
  349. padding: 0 20rpx;
  350. }
  351. .form-con{
  352. padding: 10rpx 30rpx;
  353. }
  354. }
  355. .btn-con{
  356. border-top: 1rpx solid rgba(213,213,213,0.8);
  357. .handle-pop-btn{
  358. padding: 20rpx 0;
  359. width: 50%;
  360. display: inline-block;
  361. }
  362. .cancel-btn{
  363. border-right: 1rpx solid rgba(213,213,213,0.8);
  364. }
  365. .submit-btn{
  366. color: #16d1bc;
  367. }
  368. }
  369. }
  370. }
  371. .nodata{
  372. padding-top: 400rpx;
  373. }
  374. }
  375. </style>