index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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 ? (item.totalWeight/1000).toFixed(3) : 0 }}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 ? (item.maxWeight/1000).toFixed(3) : 0 }}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.form.remarks = ''
  148. _this.messagePop = true
  149. }else{
  150. _this.messagePop = false
  151. }
  152. })
  153. },
  154. // 取消清运
  155. cancelFun(){
  156. this.messagePop = false
  157. },
  158. // 确定清运
  159. submitFun(){
  160. const _this = this
  161. uni.showLoading({
  162. mask: true,
  163. title: '加载中'
  164. })
  165. let obj = {}
  166. obj.deviceNo = (this.networkData && this.networkData.deviceNo) ? this.networkData.deviceNo : ''
  167. obj.remarks = this.form.remarks
  168. cleanDevice(obj).then(res => {
  169. uni.hideLoading()
  170. if(res.status == 200){
  171. uni.showToast({ icon:'none', title: '清运成功,库存重量已重置为0' })
  172. _this.messagePop = false
  173. setTimeout(()=>{
  174. _this.refresh()
  175. },1000)
  176. }else{
  177. uni.showToast({ icon:'none', title: res.message })
  178. }
  179. })
  180. },
  181. // 增加清运网点
  182. openQuery(){
  183. uni.navigateTo({
  184. url: '/pages/cleared/chooseNetwork'
  185. })
  186. },
  187. // 获取查询参数 刷新列表
  188. refresh(){
  189. this.listdata = []
  190. this.total = 0
  191. this.searchHandle(1)
  192. },
  193. // 搜索查询
  194. searchHandle (pageNo) {
  195. uni.showLoading({
  196. mask: true,
  197. title: '加载中'
  198. })
  199. this.status = "loading"
  200. pageNo ? this.pageNo = pageNo : null
  201. getSelfCleanTaskList({
  202. pageNo: this.pageNo,
  203. pageSize: this.pageSize
  204. }).then(res => {
  205. uni.hideLoading()
  206. if (res.status == 200) {
  207. if(this.pageNo>1){
  208. this.listdata = this.listdata.concat(res.data.list || [])
  209. }else{
  210. this.listdata = res.data.list || []
  211. this.scrollTop = 0
  212. }
  213. this.total = res.data.count || 0
  214. this.noDataText = '暂无数据'
  215. } else {
  216. this.noDataText = res.message
  217. this.listdata = []
  218. this.total = 0
  219. }
  220. this.status = "loadmore"
  221. })
  222. },
  223. // 移除
  224. removeFun(row){
  225. const _this = this
  226. uni.showModal({
  227. title: '提示',
  228. content: '确认移除该网点的清运单?',
  229. success(res) {
  230. if (res.confirm) {
  231. uni.showLoading({
  232. mask: true,
  233. title: '加载中'
  234. })
  235. cleanStationRemove({ stationNo: row.stationNo }).then(ret => {
  236. uni.hideLoading()
  237. if(ret.status == 200){
  238. uni.showToast({ title: ret.message, icon: 'none' })
  239. _this.searchHandle(1)
  240. }
  241. })
  242. }
  243. }
  244. })
  245. },
  246. // 查看详情
  247. goPage(row){
  248. uni.navigateTo({
  249. url: '/pages/cleared/network?stationNo='+row.stationNo
  250. })
  251. },
  252. // scroll-view到底部加载更多
  253. onreachBottom() {
  254. if(this.listdata.length!=0 && this.listdata.length < this.total){
  255. this.pageNo++
  256. this.searchHandle()
  257. }else{
  258. uni.showToast({ title: '已经到底了', icon: 'none' })
  259. this.status = "nomore"
  260. }
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss">
  266. page{
  267. height: 100%;
  268. }
  269. .unclear-container {
  270. width: 100%;
  271. height: 100%;
  272. display: flex;
  273. flex-direction: column;
  274. padding-bottom: 204rpx;
  275. // 列表
  276. .scroll-con{
  277. flex: 1;
  278. overflow: auto;
  279. }
  280. // 列表样式
  281. .cell-item-con{
  282. .cell-item{
  283. margin: $uni-spacing-col-base $uni-spacing-row-base;
  284. background-color: #fff;
  285. border-radius: $uni-border-radius-base;
  286. color: $uni-text-color;
  287. font-size: $uni-font-size-base;
  288. box-shadow: 3rpx 3rpx 5rpx #eee;
  289. padding: 40rpx 20rpx;
  290. position: relative;
  291. .cell-item-c{
  292. display: flex;
  293. justify-content: space-around;
  294. align-items: center;
  295. .cell-item-info{
  296. flex-grow: 1;
  297. .cell-item-info-network{
  298. word-break: break-all;
  299. margin-bottom: 26rpx;
  300. display: inline-block;
  301. position: relative;
  302. }
  303. .cell-item-info-weight{
  304. font-size: 24rpx;
  305. display: flex;
  306. align-items: center;
  307. justify-content: space-between;
  308. .cell-item-weight-bar{
  309. position: relative;
  310. display: inline-block;
  311. padding-right: 50rpx;
  312. &:nth-child(2){
  313. padding-right: 76rpx;
  314. }
  315. }
  316. }
  317. }
  318. .arrow-right{
  319. flex-shrink: 0;
  320. margin-left: 80rpx;
  321. }
  322. }
  323. .handle-btn{
  324. position: absolute;
  325. right: $uni-spacing-row-sm;
  326. top: $uni-spacing-col-sm;
  327. }
  328. }
  329. }
  330. .footer-bar{
  331. width: 100%;
  332. height: 204rpx;
  333. padding: 0 10%;
  334. position: fixed;
  335. bottom: 0;
  336. left: 0;
  337. text-align: center;
  338. .footer-handle-btn{
  339. display: block;
  340. .btn-icon{
  341. margin-right: 10rpx;
  342. }
  343. }
  344. .scan-btn{
  345. margin-top: 24rpx;
  346. margin-bottom: 20rpx;
  347. }
  348. }
  349. // 弹框样式
  350. .custom-pop{
  351. .custom-con{
  352. text-align: center;
  353. background: url(/static/pop-bg.png) no-repeat;
  354. background-size: 100% 100%;
  355. font-size: 30rpx;
  356. color: #5a5a5a;
  357. line-height: 54rpx;
  358. .pop-title{
  359. padding: 20rpx 0;
  360. color: #fff;
  361. font-weight: bold;
  362. }
  363. .pop-con{
  364. padding: 80rpx 0 40rpx;
  365. .pop-item{
  366. padding: 0 20rpx;
  367. }
  368. .form-con{
  369. padding: 10rpx 30rpx;
  370. }
  371. }
  372. .btn-con{
  373. border-top: 1rpx solid rgba(213,213,213,0.8);
  374. .handle-pop-btn{
  375. padding: 20rpx 0;
  376. width: 50%;
  377. display: inline-block;
  378. }
  379. .cancel-btn{
  380. border-right: 1rpx solid rgba(213,213,213,0.8);
  381. }
  382. .submit-btn{
  383. color: #16d1bc;
  384. }
  385. }
  386. }
  387. }
  388. .nodata{
  389. padding-top: 400rpx;
  390. }
  391. }
  392. </style>