| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <template>
- <view class="container">
- <label class="sel_event" @click="sel_show ()">
- <view class="sel_point">
- <view class="sel_field">
- {{sel_item}}
- </view>
- <view class="triangle" :style="tri_style">
- </view>
- </view>
- </label>
- <u-select v-model="show" value-name="id" label-name="name" mode="single-column" :list="list" @confirm="confirm">
- </u-select>
- <view class="content">
- <view class="table_hed">
- <view class="table_cell_h">
- <span>编号</span>
- <span>名称</span>
- <span class="introduce">介绍</span>
- <span>库存</span>
- </view>
- </view>
- <scroll-view :scroll-top="scrollTop" @scrolltolower="lower()" scroll-y="true" class="scroll-Y"
- v-if="numList != null">
- <view class="table_cell" v-for="(item,i) in numList" :key="item.id">
- <span>{{item.id}}</span>
- <span>{{item.name}}</span>
- <span class="introduce u-line-1">{{item.description}}</span>
- <span>{{item.count}}</span>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- import {
- num,
- numType
- } from '@/api/index.js'
- export default {
- data() {
- return {
- sel_item: '', //选择框值
- show: false, //选择框弹出
- tri_style: '', //三角样式
- //物品类别列表
- list: [{
- value: '1',
- label: '电子产品'
- },
- {
- value: '2',
- label: '抗疫物资'
- },
- ],
- numList: [], //库存物品列表
- scrollnum: 2, //页码(懒加载)
- }
- },
- onLoad() {
- this.getNumType()
- },
- watch: {
- sel_item(newOption, oldOption) {
- this.getNum(newOption);
- },
- show(newOption, oldOption) {
- if (!newOption) {
- this.tri_style =
- 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color:transparent;';
- }
- }
- },
-
- methods: {
- sel_show() {
- this.show = !this.show;
- this.tri_style =
- 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;';
- },
- lower() {
- this.getNum(this.sel_item, this.scrollnum, 10);
- this.scrollnum += 1;
- },
- //获取库存类别
- async getNumType() {
- let {
- data
- } = await numType()
- this.list.length = 0
- data.list.forEach(ite => {
- this.list.push(ite)
- })
- this.$nextTick(function() {
- this.sel_item = this.list[0].name;
- })
- },
- async getNum(type, page, size) {
- page || (page = 1)
- size || (size = 10)
- let {
- data
- } = await num({
- type,
- page,
- size
- })
- data.list.forEach(ite => {
- this.numList.push(ite)
- })
- },
- // 回调参数为包含多个元素的数组,每个元素分别反应每一列的选择情况
- confirm(e) {
- this.$nextTick(function() {
- this.sel_item = e[0].label;
- })
-
- }
- }
- }
- </script>
- <style lang="scss">
- .container {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100%;
- height: 100%;
- background-color: #FFFFFF;
- }
- .sel_point {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- width: 690rpx;
- height: 30rpx;
- margin: 29rpx 0 38rpx 0;
- text-align: left;
- }
- .sel_field {
- margin-right: 30rpx;
- font-size: 28rpx;
- font-family: Microsoft YaHei-3970(82674968);
- font-weight: 400;
- color: #333333;
- text-indent: 10rpx;
- }
- .triangle {
- margin-top: 10rpx;
- display: inline-block;
- /* Base Style */
- border: solid 10rpx transparent;
- border-top-color: #808080;
- }
- .content {
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: center;
- width: 690rpx;
- height: 100%;
- background: #FFFFFF;
- box-shadow: 0px 0px 24px 0px rgba(6, 0, 1, 0.1);
- border-radius: 10px 10px 0px 0px;
- overflow: hidden;
- .table_hed {
- width: 690rpx;
- height: 70rpx;
- background: #EBF8FF;
- }
- .table_cell,
- .table_cell_h {
- display: flex;
- justify-content: space-around;
- align-items: center;
- width: 630rpx;
- height: 70rpx;
- margin: 0 auto;
- border-bottom: solid 1rpx #E6E6E6;
- span {
- width: 140rpx;
- font-size: 28rpx;
- font-family: Microsoft YaHei-3970(82674968);
- font-weight: 400;
- color: #333333;
- text-align: center;
- }
- .introduce {
- max-width: 308rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- }
- .table_cell_h {
- border-bottom: none;
- }
- .scroll-Y {
- width: 690rpx;
- height: calc( 100vh - 180rpx );
- }
- }
- </style>
|