index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <!-- 我的钢瓶 -->
  3. <view>
  4. <view class="head_sticky">
  5. <view class="head_mine_title">我的钢瓶</view>
  6. <view style="width: 100%;">
  7. <u-tabs :current="cylinderNumber" :list="bottleList" lineWidth="40" :scrollable="false"
  8. @click="bottleClick"></u-tabs>
  9. </view>
  10. </view>
  11. <view style="width: 100%;border-bottom: 1rpx solid #e4e7ed;">
  12. <u-tabs :list="list4" :current="belowStandard" lineWidth="20" :scrollable="false" lineHeight="7"
  13. :lineColor="`url(${lineBg}) 100% 100%`" @click="standardClick"
  14. itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" v-if="current == 3">
  15. </u-tabs>
  16. </view>
  17. <!-- 在这里放置可滚动的内容 -->
  18. <view v-if="list.length > 0">
  19. <u-swipe-action>
  20. <u-swipe-action-item :name="index" :options="optionsList" v-for="(item,index) in list" :key="index"
  21. @click="event=>slideDelete(event,item)" :ref="'swipeAction' + index">
  22. <view class="card_dinay" @click="goCylinder(item)">
  23. <view style="display: flex;align-items: center;">
  24. <view class="item_current">{{index + 1}}</view>
  25. <view class="item_title1">{{item.inner_code}}</view>
  26. </view>
  27. <view class="iconfont icon-yehuaqiping icon_cylinder" :style="{color:getColor()}"></view>
  28. </view>
  29. </u-swipe-action-item>
  30. </u-swipe-action>
  31. <view style="width: 100%;height: 150rpx;"></view>
  32. </view>
  33. <view class="empty_information" v-else>
  34. <u-empty mode="list" text="暂无钢瓶"></u-empty>
  35. </view>
  36. <view class="card_button_bottom">
  37. <view class="bottom_btn_flex">
  38. <u-button class="but_allot" type="primary" text="添加" @click="addCylinder"></u-button>
  39. </view>
  40. <view style="flex: 1;" v-if="disqualification">
  41. <view class="bottom_btn_flex" v-if="allotFlag">
  42. <u-button class="but_allot" type="primary" text="调拨" @click="transferCylinders"></u-button>
  43. </view>
  44. <view class="bottom_btn_flex" v-else>
  45. <u-button class="but_allot" type="success" text="充装" @click="transferCylinders"></u-button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. props: {
  54. tabNumber: {
  55. type: Number,
  56. default: 0
  57. },
  58. },
  59. data() {
  60. return {
  61. lineBg: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAOCAYAAABdC15GAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFxSURBVHgBzZNRTsJAEIb/WTW+lpiY+FZPIDew3ABP4GJ8hxsI9zBpOYHeQDwBPQI+mRiRvpLojtPdYhCorQqF/6GdbGd2vvwzBXZcNAt4oj1ANeUoAT5iqkUjbEFLHNmhD1YPEvpZ3ghkGlVDCkc94/BmHMq998I5ONiY1ZBfpKAyuOtgAc5yOEDmYEWNh32BHF91sGHZHmwW4azciN9aQwnz3SJEgOmte+R2tdLprTYoa50mvuomlLpD4Y3oQZnov6D2RzCqI93bWOHaEmAGqQUyRBlZR1WfarcD/EJ2z8DtzDGvsMCwpm8XOCfDUsVOCYhiqRxI/CTQo4UOvjzO7Pow18vfywneuUHHUUxLn55lLw5JFpZ8bEUcY8oXdOLWiHLTxvoGpLqoUmy6dBT15o/ox3znpoycAmxUsiJTbs1cmxeVKp+0zmFIS7bGWiVghC7Vwse8jFKAX9eljh4ggKLLv7uaQvG9/F59Oo2SouxPu7OTCxN/s8wAAAAASUVORK5CYII=',
  62. list: [],
  63. bottleList: [{
  64. name: '重瓶区',
  65. }, {
  66. name: '空瓶区',
  67. }, {
  68. name: '不合格瓶区'
  69. }],
  70. current: 1,
  71. Pagination: {
  72. PageIndex: 1,
  73. PageSize: 20,
  74. Total: 0,
  75. },
  76. loadingMore: true,
  77. allotFlag: true,
  78. disqualification: true,
  79. optionsList: [],
  80. options: [{
  81. text: '删除',
  82. style: {
  83. backgroundColor: '#f56c6c'
  84. }
  85. }],
  86. list4: [{
  87. name: '超期',
  88. }, {
  89. name: '报废'
  90. }],
  91. belowStandard: 0,
  92. cylinderNumber: 0,
  93. }
  94. },
  95. watch: {
  96. tabNumber: {
  97. handler: function(newUser, oldUser) {
  98. if (newUser) {
  99. this.cylinderNumber = newUser
  100. }
  101. },
  102. immediate: true,
  103. deep: true
  104. }
  105. },
  106. mounted() {
  107. var userInfo = this.$cache.getCache('userInfo')
  108. this.optionsList = this.options
  109. this.getList()
  110. },
  111. methods: {
  112. // 刷新列表
  113. refreshList() {
  114. this.list = []
  115. this.Pagination.PageIndex = 1
  116. this.getList()
  117. },
  118. // 删除钢瓶
  119. slideDelete(event, value) {
  120. console.log(event,value,24)
  121. if (this.current == 1) {
  122. this.delSteelCylinder(value.id, event.name)
  123. } else if (this.current == 2) {
  124. let arr = []
  125. if (event.index == 0) {
  126. // 超期
  127. arr.push(value.inner_code)
  128. this.editSteelCylinder('extended', arr, event.name)
  129. } else if (event.index == 1) {
  130. // 报废
  131. arr.push(value.inner_code)
  132. this.editSteelCylinder('scrap', arr, event.name)
  133. } else if (event.index == 2) {
  134. this.delSteelCylinder(value.id, event.name)
  135. }
  136. } else if (this.current == 3) {
  137. if (this.belowStandard == 0) {
  138. let arr = []
  139. if (event.index == 0) {
  140. arr.push(value.inner_code)
  141. this.editSteelCylinder('2', arr, event.name)
  142. } else {
  143. this.delSteelCylinder(value.id, event.name)
  144. }
  145. } else if (this.belowStandard == 1) {
  146. this.delSteelCylinder(value.id, event.name)
  147. }
  148. }
  149. },
  150. // 修改钢瓶状态
  151. editSteelCylinder(type, list, index) {
  152. this.$api.put('/api/gas-cylinder-status', {
  153. status: type,
  154. innerCodeList: list,
  155. }).then(res => {
  156. if (res.code == 200) {
  157. this.list.splice(index, 1);
  158. uni.$u.toast(res.msg)
  159. let idx = 'swipeAction' + index
  160. this.$refs[idx][0].closeHandler()
  161. } else {
  162. uni.$u.toast(res.data.msg)
  163. }
  164. })
  165. },
  166. // 删除钢瓶
  167. delSteelCylinder(id, index) {
  168. this.$api.delete('/api/gas-cylinder-status', {
  169. id: id,
  170. }).then(res => {
  171. if (res.code == 200) {
  172. this.list.splice(index, 1);
  173. uni.$u.toast(res.msg)
  174. let idx = 'swipeAction' + index
  175. this.$refs[idx][0].closeHandler()
  176. } else {
  177. uni.$u.toast(res.data.msg)
  178. }
  179. })
  180. },
  181. // 触底事件
  182. bottomingEvent() {
  183. if (!this.loadingMore) {
  184. this.getList()
  185. }
  186. },
  187. bottleClick(value) {
  188. this.cylinderNumber = value.index
  189. var userInfo = this.$cache.getCache('userInfo')
  190. if (userInfo.provUser && value.index == 1) {
  191. if (userInfo.provUser.userType == 5) {
  192. this.allotFlag = false
  193. }
  194. } else {
  195. this.allotFlag = true
  196. this.disqualification = true
  197. }
  198. if (userInfo.provUser && value.index == 2) {
  199. if (userInfo.provUser.userType == 5) {
  200. this.disqualification = true
  201. this.allotFlag = true
  202. }
  203. } else {
  204. this.disqualification = true
  205. }
  206. if (value.index == 1) {
  207. let arr = [{
  208. text: '超期',
  209. style: {
  210. backgroundColor: '#ff9900'
  211. }
  212. }, {
  213. text: '报废',
  214. style: {
  215. backgroundColor: '#fab6b6'
  216. }
  217. }, {
  218. text: '删除',
  219. style: {
  220. backgroundColor: '#f56c6c'
  221. }
  222. }]
  223. this.optionsList = arr
  224. } else if (value.index == 2) {
  225. if (this.belowStandard == 0) {
  226. let arr1 = [{
  227. text: '空瓶',
  228. style: {
  229. backgroundColor: '#ff9900'
  230. }
  231. }, {
  232. text: '删除',
  233. style: {
  234. backgroundColor: '#f56c6c'
  235. }
  236. }]
  237. this.optionsList = arr1
  238. } else {
  239. this.optionsList = this.options
  240. }
  241. } else {
  242. this.optionsList = this.options
  243. }
  244. this.current = value.index + 1
  245. this.Pagination.PageIndex = 1
  246. this.list = []
  247. this.getList()
  248. },
  249. // 超期/报废
  250. standardClick(event) {
  251. this.belowStandard = event.index
  252. if (event.index == 0) {
  253. let arr1 = [{
  254. text: '空瓶',
  255. style: {
  256. backgroundColor: '#ff9900'
  257. }
  258. }, {
  259. text: '删除',
  260. style: {
  261. backgroundColor: '#f56c6c'
  262. }
  263. }]
  264. this.optionsList = arr1
  265. } else {
  266. this.optionsList = this.options
  267. }
  268. this.Pagination.PageIndex = 1
  269. this.list = []
  270. this.getList()
  271. },
  272. // 获取列表
  273. getList() {
  274. uni.showLoading({
  275. mask: true,
  276. });
  277. this.loadingMore = true;
  278. let state = ''
  279. if (this.current == 3) {
  280. if (this.belowStandard == 0) {
  281. state = 'extended'
  282. } else {
  283. state = 'scrap'
  284. }
  285. } else {
  286. state = this.current
  287. }
  288. this.$api.get('/api/gas-cylinder-status', {
  289. page: this.Pagination.PageIndex,
  290. pageSize: this.Pagination.PageSize,
  291. status: state,
  292. }).then(res => {
  293. if (res.code == 200) {
  294. const data = res.data.list
  295. if (this.loadingMore == true && data) {
  296. this.list = this.list.concat(data);
  297. }
  298. this.list.forEach(item => {
  299. item.show = false
  300. })
  301. if (data.length < this.Pagination.PageSize) {
  302. this.loadingMore = true
  303. } else {
  304. this.loadingMore = false
  305. this.Pagination.PageIndex++
  306. }
  307. }
  308. uni.hideLoading();
  309. }).catch(() => {
  310. uni.hideLoading();
  311. })
  312. },
  313. getColor() {
  314. if (this.current == 1) {
  315. return '#19be6b'
  316. } else if (this.current == 2) {
  317. return '#ff9900'
  318. } else if (this.current == 3) {
  319. return '#fa3534'
  320. }
  321. },
  322. // 添加钢瓶
  323. addCylinder() {
  324. let statuNum = ''
  325. let hintTitle = ''
  326. if (this.current == 3) {
  327. if (this.belowStandard == 0) {
  328. statuNum = 'extended'
  329. hintTitle = '添加超期瓶'
  330. } else if (this.belowStandard == 1) {
  331. statuNum = 'scrap'
  332. hintTitle = '添加报废瓶'
  333. }
  334. } else {
  335. if (this.current == 1) {
  336. hintTitle = '添加重瓶'
  337. } else if (this.current == 2) {
  338. hintTitle = '添加空瓶'
  339. }
  340. statuNum = this.current
  341. }
  342. uni.navigateTo({
  343. url: '/pages/information/cylinder?status=' + statuNum + '&title=' + hintTitle
  344. });
  345. },
  346. // 钢瓶详情
  347. goCylinder(event){
  348. uni.navigateTo({
  349. url: '/pages/information/cylinderDetails?inner_code=' + event.inner_code
  350. });
  351. },
  352. // 调拨钢瓶
  353. transferCylinders() {
  354. let statuNum = ''
  355. statuNum = this.current
  356. if (this.current == 3) {
  357. if (this.belowStandard == 0) {
  358. statuNum = 'extended'
  359. } else if (this.belowStandard == 1) {
  360. statuNum = 'scrap'
  361. }
  362. } else {
  363. statuNum = this.current
  364. }
  365. uni.navigateTo({
  366. url: '/pages/information/transfer?status=' + statuNum + '&allotFlag=' + this.allotFlag
  367. });
  368. }
  369. }
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .head_mine_title {
  374. display: flex;
  375. align-items: center;
  376. justify-content: center;
  377. padding-top: 20rpx;
  378. font-size: 36rpx;
  379. font-weight: 600;
  380. }
  381. .head_sticky {
  382. position: -webkit-sticky;
  383. position: sticky;
  384. top: 0;
  385. /* 设置吸顶的位置 */
  386. background: #fff;
  387. z-index: 1000;
  388. padding-top: var(--status-bar-height);
  389. }
  390. .card_dinay {
  391. display: flex;
  392. align-items: center;
  393. justify-content: space-between;
  394. width: calc(100% - 40rpx);
  395. border-bottom: 1rpx solid #e4e7ed;
  396. padding: 30rpx 20rpx;
  397. }
  398. .item_current {
  399. margin-left: 10px;
  400. min-width: 40rpx;
  401. color: #82848a;
  402. }
  403. .item_title1 {
  404. margin-left: 5rpx;
  405. }
  406. .icon_cylinder {
  407. font-size: 50rpx;
  408. }
  409. .card_button_bottom {
  410. position: fixed;
  411. bottom: 20rpx;
  412. left: 0;
  413. right: 0;
  414. background-color: #fff;
  415. height: 120rpx;
  416. margin-bottom: 80rpx;
  417. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  418. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  419. display: flex;
  420. align-items: flex-start;
  421. z-index: 2025;
  422. }
  423. .bottom_btn_flex {
  424. margin-top: 20rpx;
  425. flex: 1;
  426. display: flex;
  427. align-items: center;
  428. justify-content: center;
  429. z-index: 2026;
  430. }
  431. .but_allot {
  432. width: 90%;
  433. z-index: 2027;
  434. }
  435. .empty_information {
  436. margin-top: 30%;
  437. }
  438. </style>