123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <view>
- <view class="tab">
- <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
- <view class="length">{{ dataCount }}件商品</view>
- </view>
- <view class="goodsManageList">
- <view class="item" v-for="(item, index) in list" :key="index">
- <view class="top">
- <view class="title omit">{{ item.goodsName }}</view>
- <view class="state" v-if="item.goodsStatus == 1">
- <text class="icon" style="color: #13ce66"></text>
- <text>在售</text>
- </view>
- <view class="state" v-else>
- <text class="icon" style="color: #f44336"></text>
- <text>下架</text>
- </view>
- <view class="clear"></view>
- </view>
- <view class="con">
- <view class="flex fs">
- <view class="f">
- <view class="tag">类型</view>
- <view class="v omit">{{ item.goodsType }}</view>
- </view>
- <view class="f">
- <view class="tag">单位</view>
- <view class="v omit">{{ item.goodsUnits || '吨' }}</view>
- </view>
- <view class="f">
- <view class="tag">价格</view>
- <view class="v omit">¥{{ item.price }}</view>
- </view>
- <view class="f">
- <view class="tag">库存</view>
- <view class="v omit">{{ item.stock }}</view>
- </view>
- </view>
- <view class="tradeAreaName">{{ item.tradeAreaName }}</view>
- <view class="date">发布于:{{ item.createTime }}</view>
- </view>
- <view class="op">
- <view class="flex">
- <view class="f rline" style="color: #0081ff" @click.stop="edit(item.id)">
- <text class="icon"></text>
- <text>编辑</text>
- </view>
- <view class="f" style="color: #f44336" @click.stop="del(item.id)">
- <text class="icon"></text>
- <text>删除</text>
- </view>
- </view>
- </view>
- <view class="clear"></view>
- </view>
- <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
- <u-empty v-if="!loadMore && list.length == 0"></u-empty>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- tab: [
- { name: '全部', goodsStatus: '' },
- { name: '在售', goodsStatus: 1 },
- { name: '下架', goodsStatus: 0 }
- ],
- param: { pageNo: 1, pageSize: 10, isOrders: 0 },
- list: [],
- loadMore: true,
- dataCount: 0
- };
- },
- onLoad() {
- this.getData();
- uni.$on('goodsHandle', res => {
- this.refresh();
- });
- },
- methods: {
- getData() {
- this.http.request({
- url: '/level-one-server/app/TbGoodsTransit/getTransitList',
- loading: 'false',
- data: this.param,
- success: res => {
- this.dataCount = res.data.dataCount;
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- }
- });
- },
- //点击tab切换
- click(e) {
- this.param.goodsStatus = e.goodsStatus;
- this.refresh();
- },
- del(id) {
- uni.showModal({
- title: '提示',
- content: '确定删除?',
- success: res => {
- if (res.confirm) {
- this.http.request({
- url: '/level-one-server/app/TbGoodsTransit/deleteById?id=' + id,
- success: res => {
- uni.showToast({ title: '删除成功' });
- this.refresh();
- }
- });
- }
- }
- });
- },
- edit(id) {
- uni.navigateTo({ url: '/pages/market/one/merchant/goods/add?id=' + id });
- },
- //刷新数据
- refresh() {
- this.loadMore = true;
- this.param.pageNo = 1;
- this.list = [];
- this.getData();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.refresh();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- //上拉加载
- onReachBottom() {
- if (this.loadMore) {
- this.param.pageNo++;
- this.getData();
- }
- },
- onNavigationBarButtonTap() {
- uni.navigateTo({ url: '/pages/market/one/merchant/goods/add' });
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: $pg;
- }
- </style>
|