index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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="tabNumber" :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="options" v-for="(item,index) in list" :key="index"
  21. @click="event=>slideDelete(event,item)" :ref="'swipeAction' + index">
  22. <view class="card_dinay">
  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. options: [{
  80. text: '删除',
  81. style: {
  82. backgroundColor: '#f56c6c'
  83. }
  84. }],
  85. list4: [{
  86. name: '超期',
  87. }, {
  88. name: '报废'
  89. }],
  90. belowStandard: 0,
  91. }
  92. },
  93. mounted() {
  94. var userInfo = this.$cache.getCache('userInfo')
  95. if (userInfo.provUser && this.tabNumber == 1) {
  96. if (userInfo.provUser.userType == 5) {
  97. this.current = 2
  98. this.allotFlag = false
  99. }
  100. } else {
  101. this.allotFlag = true
  102. this.disqualification = true
  103. }
  104. this.getList()
  105. },
  106. methods: {
  107. // 刷新列表
  108. refreshList() {
  109. this.list = []
  110. this.Pagination.PageIndex = 1
  111. this.getList()
  112. },
  113. // 删除钢瓶
  114. slideDelete(event, value) {
  115. if (this.current == 2) {
  116. let arr = []
  117. if (event.index == 0) {
  118. // 超期
  119. arr.push(value.inner_code)
  120. this.editSteelCylinder('extended', arr, event.name)
  121. } else if (event.index == 1) {
  122. // 报废
  123. arr.push(value.inner_code)
  124. this.editSteelCylinder('scrap', arr, event.name)
  125. } else if (event.index == 2) {
  126. this.delSteelCylinder(value.id, event.name)
  127. }
  128. } else if (this.current == 1) {
  129. this.delSteelCylinder(value.id, event.name)
  130. } else if (this.current == 3) {
  131. this.delSteelCylinder(value.id, event.name)
  132. }
  133. },
  134. // 修改钢瓶状态
  135. editSteelCylinder(type, list, index) {
  136. this.$api.put('/api/gas-cylinder-status', {
  137. status: type,
  138. innerCodeList: list,
  139. }).then(res => {
  140. if (res.code == 200) {
  141. this.list.splice(index, 1);
  142. uni.$u.toast(res.msg)
  143. let idx = 'swipeAction' + index
  144. this.$refs[idx][0].closeHandler()
  145. } else {
  146. uni.$u.toast(res.data.msg)
  147. }
  148. })
  149. },
  150. // 删除钢瓶
  151. delSteelCylinder(id, index) {
  152. this.$api.delete('/api/gas-cylinder-status', {
  153. id: id,
  154. }).then(res => {
  155. if (res.code == 200) {
  156. this.list.splice(index, 1);
  157. uni.$u.toast(res.msg)
  158. let idx = 'swipeAction' + index
  159. this.$refs[idx][0].closeHandler()
  160. } else {
  161. uni.$u.toast(res.data.msg)
  162. }
  163. })
  164. },
  165. // 触底事件
  166. bottomingEvent() {
  167. if (!this.loadingMore) {
  168. this.getList()
  169. }
  170. },
  171. bottleClick(value) {
  172. var userInfo = this.$cache.getCache('userInfo')
  173. if (userInfo.provUser && value.index == 1) {
  174. if (userInfo.provUser.userType == 5) {
  175. this.allotFlag = false
  176. }
  177. } else {
  178. this.allotFlag = true
  179. this.disqualification = true
  180. }
  181. if (userInfo.provUser && value.index == 2) {
  182. if (userInfo.provUser.userType == 5) {
  183. this.disqualification = false
  184. }
  185. } else {
  186. this.disqualification = true
  187. }
  188. if (value.index == 1) {
  189. let arr = {
  190. text: '超期',
  191. style: {
  192. backgroundColor: '#ff9900'
  193. }
  194. }
  195. let arr1 = {
  196. text: '报废',
  197. style: {
  198. backgroundColor: '#fab6b6'
  199. }
  200. }
  201. this.options.unshift(arr1)
  202. this.options.unshift(arr)
  203. } else {
  204. if (this.options[0].text == '超期') {
  205. this.options.splice(0, 1)
  206. }
  207. if (this.options[0].text == '报废') {
  208. this.options.splice(0, 1)
  209. }
  210. }
  211. this.current = value.index + 1
  212. this.Pagination.PageIndex = 1
  213. this.list = []
  214. this.getList()
  215. },
  216. // 超期/报废
  217. standardClick(event) {
  218. this.belowStandard = event.index
  219. this.Pagination.PageIndex = 1
  220. this.list = []
  221. this.getList()
  222. },
  223. // 获取列表
  224. getList() {
  225. uni.showLoading({
  226. mask: true,
  227. });
  228. this.loadingMore = true;
  229. let state = ''
  230. if (this.current == 3) {
  231. if (this.belowStandard == 0) {
  232. state = 'extended'
  233. } else {
  234. state = 'scrap'
  235. }
  236. } else {
  237. state = this.current
  238. }
  239. this.$api.get('/api/gas-cylinder-status', {
  240. page: this.Pagination.PageIndex,
  241. pageSize: this.Pagination.PageSize,
  242. status: state,
  243. }).then(res => {
  244. if (res.code == 200) {
  245. const data = res.data.list
  246. if (this.loadingMore == true && data) {
  247. this.list = this.list.concat(data);
  248. }
  249. this.list.forEach(item => {
  250. item.show = false
  251. })
  252. if (data.length < this.Pagination.PageSize) {
  253. this.loadingMore = true
  254. } else {
  255. this.loadingMore = false
  256. this.Pagination.PageIndex++
  257. }
  258. }
  259. uni.hideLoading();
  260. }).catch(() => {
  261. uni.hideLoading();
  262. })
  263. },
  264. getColor() {
  265. if (this.current == 1) {
  266. return '#19be6b'
  267. } else if (this.current == 2) {
  268. return '#ff9900'
  269. } else if (this.current == 3) {
  270. return '#fa3534'
  271. }
  272. },
  273. // 添加钢瓶
  274. addCylinder() {
  275. let statuNum = ''
  276. let hintTitle = ''
  277. if (this.current == 3) {
  278. if (this.belowStandard == 0) {
  279. statuNum = 'extended'
  280. hintTitle = '添加超期瓶'
  281. } else if (this.belowStandard == 1) {
  282. statuNum = 'scrap'
  283. hintTitle = '添加报废瓶'
  284. }
  285. } else {
  286. if (this.current == 1) {
  287. hintTitle = '添加重瓶'
  288. } else if (this.current == 2) {
  289. hintTitle = '添加空瓶'
  290. }
  291. statuNum = this.current
  292. }
  293. uni.navigateTo({
  294. url: '/pages/information/cylinder?status=' + statuNum + '&title=' + hintTitle
  295. });
  296. },
  297. // 调拨钢瓶
  298. transferCylinders() {
  299. let statuNum = ''
  300. statuNum = this.current
  301. if (this.current == 3) {
  302. if (this.belowStandard == 0) {
  303. statuNum = 'extended'
  304. } else if (this.belowStandard == 1) {
  305. statuNum = 'scrap'
  306. }
  307. } else {
  308. statuNum = this.current
  309. }
  310. uni.navigateTo({
  311. url: '/pages/information/transfer?status=' + statuNum + '&allotFlag=' + this.allotFlag
  312. });
  313. }
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .head_mine_title {
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. padding-top: 20rpx;
  323. font-size: 36rpx;
  324. font-weight: 600;
  325. }
  326. .head_sticky {
  327. position: -webkit-sticky;
  328. position: sticky;
  329. top: 0;
  330. /* 设置吸顶的位置 */
  331. background: #fff;
  332. z-index: 1000;
  333. padding-top: var(--status-bar-height);
  334. }
  335. .card_dinay {
  336. display: flex;
  337. align-items: center;
  338. justify-content: space-between;
  339. width: calc(100% - 40rpx);
  340. border-bottom: 1rpx solid #e4e7ed;
  341. padding: 30rpx 20rpx;
  342. }
  343. .item_current {
  344. margin-left: 10px;
  345. min-width: 40rpx;
  346. color: #82848a;
  347. }
  348. .item_title1 {
  349. margin-left: 5rpx;
  350. }
  351. .icon_cylinder {
  352. font-size: 50rpx;
  353. }
  354. .card_button_bottom {
  355. position: fixed;
  356. bottom: 20rpx;
  357. left: 0;
  358. right: 0;
  359. background-color: #fff;
  360. height: 120rpx;
  361. margin-bottom: 80rpx;
  362. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  363. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  364. display: flex;
  365. align-items: flex-start;
  366. z-index: 2025;
  367. }
  368. .bottom_btn_flex {
  369. margin-top: 20rpx;
  370. flex: 1;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. z-index: 2026;
  375. }
  376. .but_allot {
  377. width: 90%;
  378. z-index: 2027;
  379. }
  380. .empty_information {
  381. margin-top: 30%;
  382. }
  383. </style>