123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <view class="moreShelfPart flex flex_column">
- <view class="moreShelfPart-search">
- <u-search
- placeholder="请输入货架名称搜索"
- v-model="shelfName"
- :show-action="false"
- @input="$u.debounce(getShelfList, 800)"
- @custom="$u.debounce(getShelfList, 500)"
- @search="$u.debounce(getShelfList, 500)"
- @clear="clearSearch"
- :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
- </u-search>
- </view>
- <view class="moreShelfPart-body">
- <scroll-view
- class="nav-right"
- scroll-y
- @scrolltolower="onreachBottom">
- <u-checkbox-group wrap class="nav-right-item" @change="checkboxGroupChange">
- <u-checkbox
- v-model="item.checked"
- v-for="(item, index) in shelfList"
- :key="item.shelfSn"
- :name="item.shelfSn"
- >
- <text style="margin-right: 0.5rem;">{{item.shelfName}}</text>
- <text style="font-size: 0.6rem;background-color: #f8f8f8;">{{item.state=='WRITE_OFF'?'已注销':''}}</text>
- </u-checkbox>
- </u-checkbox-group>
- <view v-if="shelfList&&shelfList.length==0">
- <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
- </view>
- <view style="padding: 20upx;" v-else>
- <u-loadmore :status="status" />
- </view>
- </scroll-view>
- </view>
- <view class="batchPrint-manualPrint-footer">
- <view style="color: #999;">
- 已选 {{checkList.length}} 个货架
- </view>
- <view>
- <u-button class="handle-btn" :loading="loading" shape="circle" size="medium" hover-class="none" @click="resetForm">重置</u-button>
- <u-button class="handle-btn" :loading="loading" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="submit">确定</u-button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getShelfList } from '@/api/shelf'
- export default {
- props: {
- checkEdList: { // 默认查询条件
- type: Array,
- default: () => {
- return []
- }
- },
- },
- data() {
- return {
- shelfName: '',
- isGobleSearch: false,
- shelfList: [],
- pageNo:1,
- pageSize: 1000,
- total: 0, // 列表总数
- noDataText: '暂无货架',
- status: 'loading',
- tempData: null,
- allChecked: false,
- customBtnStyle: { // 自定义按钮样式
- borderColor: this.$config('primaryColor'),
- backgroundColor: this.$config('primaryColor'),
- color: '#fff'
- },
- checkList: [],
- loading: false
- }
- },
- mounted() {
- this.clearSearch()
- this.checkList = this.checkEdList
- },
- methods: {
- checkboxGroupChange(e) {
- console.log(e);
- this.getChecked()
- },
- clearSearch(){
- this.shelfName = ''
- this.pageNo = 1
- this.total = 0
- this.shelfList = []
- this.getShelfList()
- },
- resetForm(){
- this.checkList = []
- this.$emit("ok", [])
- },
- getChecked(){
- const ret = this.shelfList.filter(item => item.checked)
- const list = []
- ret.map(item => {
- list.push(item.shelfSn)
- })
- this.checkList = list
- return list
- },
- submit(){
- const ret = this.getChecked()
- let shelfName = ''
- if(ret.length == 1){
- shelfName = this.shelfList.find(item => item.shelfSn == ret[0]).shelfName
- }
- this.$emit("ok", ret, shelfName)
- },
- setChecked(){
- this.shelfList.map(item => {
- item.checked = this.checkEdList.find(k => k == item.shelfSn) ? true : false
- })
- },
- // 获取数字货架列表
- getShelfList(){
- const _this = this
- if(this.shelfName == ''){
- this.pageNo = 1
- this.total = 0
- }
- let params = {
- pageNo: this.pageNo,
- pageSize: this.pageSize,
- shelfName: this.shelfName,
- // stateSet: [ 'ENABLE', 'SUSPEND', 'DISABLED' ]
- }
- _this.status = 'loading'
- getShelfList(params).then(res => {
- uni.hideLoading()
- if(res.status == 200){
- let list = res.data.list
- if (list && list.length){
- // 分页 拼接数据
- if(_this.pageNo>1){
- _this.shelfList = _this.shelfList.concat(res.data.list || [])
- }else{
- _this.shelfList = res.data.list
- }
- _this.total = res.data.count
- console.log(res.data.count)
- if (_this.shelfList.length == res.data.count) {
- _this.status = 'nomore'
- } else {
- _this.status = 'loadmore'
- }
- } else {
- _this.shelfList = list || []
- _this.total = 0
- _this.status = 'nomore'
- _this.noDataText = '没有查询到相关货架'
- }
- _this.noDataText = '暂无货架'
- _this.setChecked()
- }else{
- _this.status = 'loadmore'
- _this.shelfList = []
- _this.total = 0
- _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
- }
- })
- },
- // 加载更多
- onreachBottom () {
- if(this.shelfList.length < this.total ){
- if(this.isGobleSearch&&this.shelfName==''){
- return
- }
- this.pageNo++
- this.getShelfList()
- }else{
- this.status = "nomore"
- }
- },
- }
- }
- </script>
- <style lang="less">
- .moreShelfPart{
- width: 100%;
- height: calc(100vh - 120rpx) ;
- .moreShelfPart-search{
- padding: 0 20rpx;
- background-color: #FFFFFF;
- }
- .moreShelfPart-body{
- flex-grow: 1;
- background-color: #fff;
- }
- .nav-right{
- padding: 0 20upx;
- height: calc(100vh - 250rpx);
- box-sizing: border-box;
-
- .nav-right-item{
- ::v-deep .u-checkbox{
- border-bottom: 1rpx solid #f8f8f8;
- padding: 20upx 10upx;
- }
- ::v-deep .u-checkbox__label{
- flex-grow: 1;
- margin-right: 0;
- }
- }
- }
- .batchPrint-manualPrint-footer{
- padding: 10upx;
- background-color: #fff;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-top: 1rpx solid #f8f8f8;
- > view{
- &:first-child{
- flex-grow: 1;
- width: 40%;
- font-size: 24rpx;
- }
- &:last-child{
- width: 60%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .handle-btn{
- width: 50%;
- margin-right: 15rpx;
- }
- }
- }
- }
- }
- </style>
|