123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- <template>
- <!-- 我的钢瓶 -->
- <view>
- <view class="head_sticky">
- <view class="head_mine_title">我的钢瓶</view>
- <view style="width: 100%;">
- <u-tabs :current="tabNumber" :list="bottleList" lineWidth="40" :scrollable="false"
- @click="bottleClick"></u-tabs>
- </view>
- </view>
- <view style="width: 100%;border-bottom: 1rpx solid #e4e7ed;">
- <u-tabs :list="list4" :current="belowStandard" lineWidth="20" :scrollable="false" lineHeight="7"
- :lineColor="`url(${lineBg}) 100% 100%`" @click="standardClick"
- itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" v-if="current == 3">
- </u-tabs>
- </view>
- <!-- 在这里放置可滚动的内容 -->
- <view v-if="list.length > 0">
- <u-swipe-action>
- <u-swipe-action-item :name="index" :options="options" v-for="(item,index) in list" :key="index"
- @click="event=>slideDelete(event,item)" :ref="'swipeAction' + index">
- <view class="card_dinay">
- <view style="display: flex;align-items: center;">
- <view class="item_current">{{index + 1}}</view>
- <view class="item_title1">{{item.inner_code}}</view>
- </view>
- <view class="iconfont icon-yehuaqiping icon_cylinder" :style="{color:getColor()}"></view>
- </view>
- </u-swipe-action-item>
- </u-swipe-action>
- <view style="width: 100%;height: 150rpx;"></view>
- </view>
- <view class="empty_information" v-else>
- <u-empty mode="list" text="暂无钢瓶"></u-empty>
- </view>
- <view class="card_button_bottom">
- <view class="bottom_btn_flex">
- <u-button class="but_allot" type="primary" text="添加" @click="addCylinder"></u-button>
- </view>
- <view style="flex: 1;" v-if="disqualification">
- <view class="bottom_btn_flex" v-if="allotFlag">
- <u-button class="but_allot" type="primary" text="调拨" @click="transferCylinders"></u-button>
- </view>
- <view class="bottom_btn_flex" v-else>
- <u-button class="but_allot" type="success" text="充装" @click="transferCylinders"></u-button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- tabNumber: {
- type: Number,
- default: 0
- },
- },
- data() {
- return {
- lineBg: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAOCAYAAABdC15GAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFxSURBVHgBzZNRTsJAEIb/WTW+lpiY+FZPIDew3ABP4GJ8hxsI9zBpOYHeQDwBPQI+mRiRvpLojtPdYhCorQqF/6GdbGd2vvwzBXZcNAt4oj1ANeUoAT5iqkUjbEFLHNmhD1YPEvpZ3ghkGlVDCkc94/BmHMq998I5ONiY1ZBfpKAyuOtgAc5yOEDmYEWNh32BHF91sGHZHmwW4azciN9aQwnz3SJEgOmte+R2tdLprTYoa50mvuomlLpD4Y3oQZnov6D2RzCqI93bWOHaEmAGqQUyRBlZR1WfarcD/EJ2z8DtzDGvsMCwpm8XOCfDUsVOCYhiqRxI/CTQo4UOvjzO7Pow18vfywneuUHHUUxLn55lLw5JFpZ8bEUcY8oXdOLWiHLTxvoGpLqoUmy6dBT15o/ox3znpoycAmxUsiJTbs1cmxeVKp+0zmFIS7bGWiVghC7Vwse8jFKAX9eljh4ggKLLv7uaQvG9/F59Oo2SouxPu7OTCxN/s8wAAAAASUVORK5CYII=',
- list: [],
- bottleList: [{
- name: '重瓶区',
- }, {
- name: '空瓶区',
- }, {
- name: '不合格瓶区'
- }],
- current: 1,
- Pagination: {
- PageIndex: 1,
- PageSize: 20,
- Total: 0,
- },
- loadingMore: true,
- allotFlag: true,
- disqualification: true,
- options: [{
- text: '删除',
- style: {
- backgroundColor: '#f56c6c'
- }
- }],
- list4: [{
- name: '超期',
- }, {
- name: '报废'
- }],
- belowStandard: 0,
- }
- },
- mounted() {
- var userInfo = this.$cache.getCache('userInfo')
- if (userInfo.provUser && this.tabNumber == 1) {
- if (userInfo.provUser.userType == 5) {
- this.current = 2
- this.allotFlag = false
- }
- } else {
- this.allotFlag = true
- this.disqualification = true
- }
- this.getList()
- },
- methods: {
- // 刷新列表
- refreshList() {
- this.list = []
- this.Pagination.PageIndex = 1
- this.getList()
- },
- // 删除钢瓶
- slideDelete(event, value) {
- if (this.current == 2) {
- let arr = []
- if (event.index == 0) {
- // 超期
- arr.push(value.inner_code)
- this.editSteelCylinder('extended', arr, event.name)
- } else if (event.index == 1) {
- // 报废
- arr.push(value.inner_code)
- this.editSteelCylinder('scrap', arr, event.name)
- } else if (event.index == 2) {
- this.delSteelCylinder(value.id, event.name)
- }
- } else if (this.current == 1) {
- this.delSteelCylinder(value.id, event.name)
- } else if (this.current == 3) {
- this.delSteelCylinder(value.id, event.name)
- }
- },
- // 修改钢瓶状态
- editSteelCylinder(type, list, index) {
- this.$api.put('/api/gas-cylinder-status', {
- status: type,
- innerCodeList: list,
- }).then(res => {
- if (res.code == 200) {
- this.list.splice(index, 1);
- uni.$u.toast(res.msg)
- let idx = 'swipeAction' + index
- this.$refs[idx][0].closeHandler()
- } else {
- uni.$u.toast(res.data.msg)
- }
- })
- },
- // 删除钢瓶
- delSteelCylinder(id, index) {
- this.$api.delete('/api/gas-cylinder-status', {
- id: id,
- }).then(res => {
- if (res.code == 200) {
- this.list.splice(index, 1);
- uni.$u.toast(res.msg)
- let idx = 'swipeAction' + index
- this.$refs[idx][0].closeHandler()
- } else {
- uni.$u.toast(res.data.msg)
- }
- })
- },
- // 触底事件
- bottomingEvent() {
- if (!this.loadingMore) {
- this.getList()
- }
- },
- bottleClick(value) {
- var userInfo = this.$cache.getCache('userInfo')
- if (userInfo.provUser && value.index == 1) {
- if (userInfo.provUser.userType == 5) {
- this.allotFlag = false
- }
- } else {
- this.allotFlag = true
- this.disqualification = true
- }
- if (userInfo.provUser && value.index == 2) {
- if (userInfo.provUser.userType == 5) {
- this.disqualification = false
- }
- } else {
- this.disqualification = true
- }
- if (value.index == 1) {
- let arr = {
- text: '超期',
- style: {
- backgroundColor: '#ff9900'
- }
- }
- let arr1 = {
- text: '报废',
- style: {
- backgroundColor: '#fab6b6'
- }
- }
- this.options.unshift(arr1)
- this.options.unshift(arr)
- } else {
- if (this.options[0].text == '超期') {
- this.options.splice(0, 1)
- }
- if (this.options[0].text == '报废') {
- this.options.splice(0, 1)
- }
- }
- this.current = value.index + 1
- this.Pagination.PageIndex = 1
- this.list = []
- this.getList()
- },
- // 超期/报废
- standardClick(event) {
- this.belowStandard = event.index
- this.Pagination.PageIndex = 1
- this.list = []
- this.getList()
- },
- // 获取列表
- getList() {
- uni.showLoading({
- mask: true,
- });
- this.loadingMore = true;
- let state = ''
- if (this.current == 3) {
- if (this.belowStandard == 0) {
- state = 'extended'
- } else {
- state = 'scrap'
- }
- } else {
- state = this.current
- }
- this.$api.get('/api/gas-cylinder-status', {
- page: this.Pagination.PageIndex,
- pageSize: this.Pagination.PageSize,
- status: state,
- }).then(res => {
- if (res.code == 200) {
- const data = res.data.list
- if (this.loadingMore == true && data) {
- this.list = this.list.concat(data);
- }
- this.list.forEach(item => {
- item.show = false
- })
- if (data.length < this.Pagination.PageSize) {
- this.loadingMore = true
- } else {
- this.loadingMore = false
- this.Pagination.PageIndex++
- }
- }
- uni.hideLoading();
- }).catch(() => {
- uni.hideLoading();
- })
- },
- getColor() {
- if (this.current == 1) {
- return '#19be6b'
- } else if (this.current == 2) {
- return '#ff9900'
- } else if (this.current == 3) {
- return '#fa3534'
- }
- },
- // 添加钢瓶
- addCylinder() {
- let statuNum = ''
- let hintTitle = ''
- if (this.current == 3) {
- if (this.belowStandard == 0) {
- statuNum = 'extended'
- hintTitle = '添加超期瓶'
- } else if (this.belowStandard == 1) {
- statuNum = 'scrap'
- hintTitle = '添加报废瓶'
- }
- } else {
- if (this.current == 1) {
- hintTitle = '添加重瓶'
- } else if (this.current == 2) {
- hintTitle = '添加空瓶'
- }
- statuNum = this.current
- }
- uni.navigateTo({
- url: '/pages/information/cylinder?status=' + statuNum + '&title=' + hintTitle
- });
- },
- // 调拨钢瓶
- transferCylinders() {
- let statuNum = ''
- statuNum = this.current
- if (this.current == 3) {
- if (this.belowStandard == 0) {
- statuNum = 'extended'
- } else if (this.belowStandard == 1) {
- statuNum = 'scrap'
- }
- } else {
- statuNum = this.current
- }
- uni.navigateTo({
- url: '/pages/information/transfer?status=' + statuNum + '&allotFlag=' + this.allotFlag
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .head_mine_title {
- display: flex;
- align-items: center;
- justify-content: center;
- padding-top: 20rpx;
- font-size: 36rpx;
- font-weight: 600;
- }
- .head_sticky {
- position: -webkit-sticky;
- position: sticky;
- top: 0;
- /* 设置吸顶的位置 */
- background: #fff;
- z-index: 1000;
- padding-top: var(--status-bar-height);
- }
- .card_dinay {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: calc(100% - 40rpx);
- border-bottom: 1rpx solid #e4e7ed;
- padding: 30rpx 20rpx;
- }
- .item_current {
- margin-left: 10px;
- min-width: 40rpx;
- color: #82848a;
- }
- .item_title1 {
- margin-left: 5rpx;
- }
- .icon_cylinder {
- font-size: 50rpx;
- }
- .card_button_bottom {
- position: fixed;
- bottom: 20rpx;
- left: 0;
- right: 0;
- background-color: #fff;
- height: 120rpx;
- margin-bottom: 80rpx;
- padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
- padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
- display: flex;
- align-items: flex-start;
- z-index: 2025;
- }
- .bottom_btn_flex {
- margin-top: 20rpx;
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 2026;
- }
- .but_allot {
- width: 90%;
- z-index: 2027;
- }
- .empty_information {
- margin-top: 30%;
- }
- </style>
|