周宾
14 小时以前 2f93b5a6157c3752230485e5aa56f79fdabd5fb4
天津双奇点-开发仓储物流板块
已添加6个文件
已修改3个文件
918 ■■■■■ 文件已修改
src/api/inventoryManagement/issueManagement.js 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/inventoryManagement/receiptManagement.js 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/config.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages.json 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inventoryManagement/issueManagement/edit.vue 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inventoryManagement/issueManagement/index.vue 221 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inventoryManagement/receiptManagement/edit.vue 209 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inventoryManagement/receiptManagement/index.vue 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/inventoryManagement/issueManagement.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
// å·¡æ£€ä¸Šä¼ 
import request from '@/utils/request'
// é‡‡è´­å‡ºåº“列表
export function listPage(query) {
    return request({
        url: '/stockin/listPage',
        method: 'get',
        params: query
    })
}
//自定义出库列表
export function listPageByCustom(query) {
    return request({
        url: '/stockin/listPageByCustom',
        method: 'get',
        params: query
    })
}
//领用
export function stockout(query) {
  return request({
    url: '/stockmanagement/stockout',
    method: 'post',
    data: query
  })
}
src/api/inventoryManagement/receiptManagement.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
// å·¡æ£€ä¸Šä¼ 
import request from '@/utils/request'
// é‡‡è´­å…¥åº“列表
export function listPage(query) {
    return request({
        url: '/stockin/listPage',
        method: 'get',
        params: query
    })
}
//自定义入库列表
export function listPageByCustom(query) {
    return request({
        url: '/stockin/listPageByCustom',
        method: 'get',
        params: query
    })
}
//新增自定义入库
// èŽ·å–ç”¨æˆ·ä¿¡æ¯
export function addCustom(query) {
  return request({
    url: '/stockin/addCustom',
    method: 'post',
    data: query
  })
}
src/config.js
@@ -2,7 +2,8 @@
const config = {
  //  baseUrl: 'https://vue.ruoyi.vip/prod-api',
  // baseUrl: 'http://localhost/prod-api',
  baseUrl: 'http://114.132.189.42:9066', // å®å¤æ¶¦æ³°
    baseUrl: 'http://192.168.1.211:8888', // å¤©æ´¥åŒå¥‡ç‚¹
  // baseUrl: 'http://114.132.189.42:9066', // å®å¤æ¶¦æ³°
  // baseUrl: 'http://114.132.189.42:9068', // æ–°ç–†æµ·å·å¼€å¿ƒ
  // baseUrl: 'http://192.168.1.147:9036',
   //cloud后台网关地址
src/pages.json
@@ -610,6 +610,43 @@
          "path": "code/index"
        }
      ]
    },
        {
            "root": "pages/inventoryManagement",
            "pages": [
                {
                    "path": "receiptManagement/index",
                    "style": {
                        "navigationBarTitleText": "入库管理",
            "navigationStyle": "custom",
            "enablePullDownRefresh": true,
            "backgroundColor": "#f8f8f8"
                    }
                },
        {
                    "path": "receiptManagement/edit",
                    "style": {
                        "navigationBarTitleText": "自定义入库",
            "navigationStyle": "custom"
                    }
                },
        {
                    "path": "issueManagement/index",
                    "style": {
                        "navigationBarTitleText": "出库管理",
            "navigationStyle": "custom",
            "enablePullDownRefresh": true,
            "backgroundColor": "#f8f8f8"
                    }
                },
        {
                    "path": "issueManagement/edit",
                    "style": {
                        "navigationBarTitleText": "自定义出库",
            "navigationStyle": "custom"
                    }
                }
            ]
    }
  ],
  "tabBar": {
src/pages/index.vue
@@ -31,7 +31,35 @@
        <!--                </view>-->
        <!--            </view>-->
        <!--        </view>-->
        <!-- ä»“储物流模块 -->
        <view class="common-module marketing-module">
            <view class="module-header">
                <view class="module-title-container">
                    <text class="module-title">仓储物流</text>
                </view>
            </view>
            <view class="module-content">
                <up-grid
                    :border="false"
                    col="4"
                >
                    <up-grid-item
                        v-for="(item, index) in warehousingLogisticsItems"
                        :key="index"
                        @click="handleCommonItemClick(item)"
                    >
                        <view class="icon-container" :style="{ background: item.bgColor }">
                            <up-icon
                                :name="item.icon"
                                :size="58"
                                color="#ffffff"
                            ></up-icon>
                        </view>
                        <text class="item-label">{{item.label}}</text>
                    </up-grid-item>
                </up-grid>
            </view>
        </view>
        <!-- è¥é”€ç®¡ç†æ¨¡å— -->
        <view class="common-module marketing-module">
            <view class="module-header">
@@ -213,6 +241,26 @@
        currentStatus.value = statusList[statusIndex]
    }, 3000)
}
//仓储物流功能数据
const warehousingLogisticsItems = reactive([
    {
        icon: '/static/images/icon/xiaoshoutaizhang@2x.png',
        label: '入库管理',
    },
    {
        icon: '/static/images/icon/kaipiaodengji@2x.png',
        label: '出库管理',
    },
    {
        icon: '/static/images/icon/kaipiaotaizhang@2x.png',
        label: '出库台账',
    },
    {
        icon: '/static/images/icon/huikuandengji@2x.png',
        label: '库存管理',
    }
]);
// è¥é”€ç®¡ç†åŠŸèƒ½æ•°æ®
const marketingItems = reactive([
@@ -490,6 +538,16 @@
                url: '/pages/equipmentManagement/verification/index'
            });
            break;
        case '入库管理':
            uni.navigateTo({
                url: '/pages/inventoryManagement/receiptManagement/index'
            });
            break
        case '出库管理':
            uni.navigateTo({
                url: '/pages/inventoryManagement/issueManagement/index'
            });
            break
        default:
            uni.showToast({
                title: `点击了${item.label}`,
src/pages/inventoryManagement/issueManagement/edit.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,114 @@
<template>
    <PageHeader :title="pageTitle" @back="goBack" />
    <view class="account-detail">
        <view class="box">
            <view class="form-box">
                <uni-forms :key="index" label-position="top" label-width="400rpx">
                    <uni-forms-item label="名称" required>
                        <uni-easyinput v-model="productCategory" placeholder="" disabled />
                    </uni-forms-item>
                    <uni-forms-item label="出库数量/ä»¶" required>
                        <uni-number-box v-model="goods.quantity" :min="0"></uni-number-box>
                    </uni-forms-item>
                    <uni-forms-item label="出库日期" required>
                        <uni-datetime-picker type="date" :clear-icon="false" v-model="goods.time" />
                    </uni-forms-item>
                    <uni-forms-item label="出库人" required>
                        <picker :range="userList" @change="swichUser" range-key="nickName">
                            <text>{{ userName||'请选择' }}</text>
                        </picker>
                    </uni-forms-item>
                </uni-forms>
            </view>
            <view style="display: flex;justify-content: flex-end;">
                <button class="mini-btn" type="primary" size="mini"
                    style="margin-left: 0;margin-right: 0;margin-right: 20rpx;" @click="submitForm">确定</button>
                <button class="mini-btn" size="mini" style="margin-left: 0;margin-right: 0;" @click="goBack">取消</button>
            </view>
        </view>
    </view>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { stockout } from '@/api/inventoryManagement/issueManagement.js'
const productCategory = ref('')
import { userListNoPageByTenantId } from "@/api/system/user"
const pageTitle = ref('领用产品')
const userList = ref([])
const userName = ref('')
const goods = ref({
    id: 0,
    quantity: 0,
    salesLedgerProductId: 0,
    time: "",
    type: 3,
    userId: undefined
})
const props = defineProps(['goods'])
const goBack = () => {
    uni.navigateBack()
}
const submitForm = async () => {
    let res = await stockout(goods.value)
    if (res.code !== 200) {
        uni.showToast({
            title: res.msg,
            icon: 'none'
        })
        return
    }
    uni.showToast({
        title: '成功领用',
        icon: 'none'
    })
    goBack()
}
const initContacts = () => {
  userListNoPageByTenantId().then((res) => {
    console.log('userListNoPageByTenantId',res.data)
    userList.value = res.data
  })
}
const swichUser = (e) => {
    goods.value.userId = userList.value[e.detail.value].userId
    userName.value = userList.value[e.detail.value].nickName
}
onMounted(() => {
    let _goods = JSON.parse(props.goods)
    goods.value.id = _goods.id
    productCategory.value = _goods.productCategory
    initContacts()
})
</script>
<style lang="scss" scoped>
.box {
    background-color: #fff;
    box-sizing: border-box;
    padding: 20rpx;
    min-height: 80rpx;
    padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
}
.form-box {
    box-sizing: border-box;
    margin-bottom: 20rpx;
    padding: 20rpx;
    background-color: #f5f5f5;
    border-radius: 20rpx;
}
.add-img {
    .img {
        background-color: #efefef;
        border-radius: 10rpx;
        width: 200rpx;
        height: 200rpx;
    }
}
</style>
src/pages/inventoryManagement/issueManagement/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,221 @@
<template>
    <view>
        <PageHeader title="出库管理" @back="goBack" />
        <view class="tabs">
            <uni-segmented-control :current="tabCurrent" :values="tabItems" @clickItem="switchTab" />
        </view>
        <view v-if="contentList?.length !== 0" class="content">
            <view v-if="tabCurrent === 0">
                <block v-for="item in contentList" :key="item.id">
                    <view class="item-box item-box0"></view>
                </block>
                <uni-load-more :status="loadMoreStatus"></uni-load-more>
            </view>
            <view v-if="tabCurrent === 1">
                <block v-for="item in contentList" :key="item.id">
                    <view class="item-box item-box1">
                        <view class="item">
                            <view class="label">产品图片</view>
                            <view class="value">
                                <image class="img" :src="baseUrl + item.url" mode="aspectFill‌" lazy-load></image>
                            </view>
                        </view>
                        <view class="item">
                            <view class="label">入库时间</view>
                            <view class="value">{{ item.inboundDate }}</view>
                        </view>
                        <view class="item">
                            <view class="label">产品名称</view>
                            <view class="value">{{ item.productCategory }}</view>
                        </view>
                        <view class="item">
                            <view class="label">产品高度</view>
                            <view class="value">{{ item.specificationModel }}{{ item.unit }}</view>
                        </view>
                        <view class="item">
                            <view class="label">入库数量/ä»¶</view>
                            <view class="value">{{ item.inboundNum }}</view>
                        </view>
                        <view class="item">
                            <view class="label">库存数量/ä»¶</view>
                            <view class="value">{{ item.inboundNum0 }}</view>
                        </view>
                        <view class="item">
                            <view class="label">每件数量/支</view>
                            <view class="value">{{ item.boxNum }}</view>
                        </view>
                        <view class="item">
                            <view class="label">单价(元)/支</view>
                            <view class="value">{{ item.taxInclusiveUnitPrice }}</view>
                        </view>
                        <view class="item">
                            <view class="label">纸箱规格</view>
                            <view class="value">{{ item.cartonSpecifications }}cm</view>
                        </view>
                        <view class="item">
                            <view class="label">入库人</view>
                            <view class="value">{{ item.createBy }}</view>
                        </view>
                        <view class="item" style="justify-content: flex-end;">
                            <button class="mini-btn" type="primary" size="mini" style="margin-left: 0;margin-right: 0;"
                                @click="openForm(item, 'edit')">领用</button>
                        </view>
                    </view>
                </block>
                <uni-load-more :status="loadMoreStatus"></uni-load-more>
            </view>
        </view>
        <view v-if="contentList?.length === 0" class="no-data">
            <text>暂无数据</text>
        </view>
    </view>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
import { listPage, listPageByCustom } from '@/api/inventoryManagement/issueManagement.js'
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
import config from '@/config'
const baseUrl = config.baseUrl
// tab相关
const tabItems = reactive(['采购出库', '成品出库'])
const tabCurrent = ref(0)
const switchTab = (e) => {
    if (tabCurrent.value !== e.currentIndex) {
        tabCurrent.value = e.currentIndex
    }
    reloadPage()
}
// è¿”回上一页
const goBack = () => {
    uni.navigateBack()
}
// æ‰“开编辑/新增
const openForm = (goods, type) => {
    uni.navigateTo({
        url: '/pages/inventoryManagement/issueManagement/edit?goods=' + JSON.stringify(goods)
    })
}
// åˆ†é¡µç›¸å…³
const pageParams = reactive({
    size: 10,
    current: 1
})
const totalSize = ref(0)
const noMore = computed(() => {
    return contentList.value.length >= totalSize.value
})
const loading = ref(false)
const contentList = ref([])
const loadMoreStatus = computed(() => {
    if (loading.value) {
        return 'loading'
    }
    if (noMore.value) {
        return 'noMore'
    }
    return 'more'
})
const loadPage = () => {
    if (noMore.value || loading.value) {
        return
    }
    pageParams.current += 1
    getList()
}
const reloadPage = () => {
    pageParams.current = 1
    contentList.value = []
    getList()
}
const getList = async () => {
    let getListApi = null
    if (tabCurrent.value == 1) {
        getListApi = listPageByCustom
    } else if (tabCurrent.value == 0) {
        getListApi = listPage
    }
    loading.value = true
    let resp = await getListApi(pageParams)
    loading.value = false
    if (resp.code != 200 || !resp.data) {
        contentList.value = []
        totalSize.value = 0
        return
    }
    contentList.value = [...contentList.value, ...resp.data.records]
    console.log(resp.data.records)
    totalSize.value = resp.data.total
}
onReachBottom(() => {
    loadPage()
})
onPullDownRefresh(() => {
    reloadPage()
    uni.stopPullDownRefresh()
})
onShow(() => {
    reloadPage()
})
</script>
<style lang='scss' scoped>
.tabs {
    box-sizing: border-box;
    padding: 20rpx 40rpx;
}
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}
.item-box {
    box-sizing: border-box;
    margin: 20rpx;
    padding: 20rpx;
    border-radius: 10rpx;
    background-color: #f5f5f5;
}
.item {
    display: flex;
    justify-content: space-between;
    margin: 10rpx 0;
    .label {}
    .value {
        .img {
            width: 200rpx;
            height: 200rpx;
            background-color: #999;
            border-radius: 10rpx;
        }
    }
}
// æµ®åŠ¨æŒ‰é’®æ ·å¼
.fab-button {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom));
    right: 30px;
    width: 56px;
    height: 56px;
    background: #2979ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(41, 121, 255, 0.3);
    z-index: 1000;
}
</style>
src/pages/inventoryManagement/receiptManagement/edit.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,209 @@
<template>
    <PageHeader :title="pageTitle" @back="goBack" />
    <view class="account-detail">
        <view class="box">
            <view v-if="type == 'add'">
                <button class="mini-btn" type="primary" size="mini" style="margin-left: 0;margin-right: 0;"
                    @click="addItem">新增</button>
            </view>
            <view v-for="(item, index) in goodsList" class="form-box">
                <uni-forms :key="index" label-position="top" label-width="400rpx">
                    <uni-forms-item label="产品图片" required>
                        <view class="add-img">
                            <image v-if="item.url" class="img" :src="baseUrl + item.url" mode="aspectFill" />
                            <uni-icons v-else type="camera-filled" size="56" style="color: #8a8a8a"
                                @click="addImg(index)"></uni-icons>
                        </view>
                    </uni-forms-item>
                    <uni-forms-item label="名称" required>
                        <uni-easyinput v-model="item.productCategory" placeholder="请输入名称" />
                    </uni-forms-item>
                    <uni-forms-item label="高度" required>
                        <uni-easyinput v-model="item.specificationModel" type="number" placeholder="请输入高度" />
                    </uni-forms-item>
                    <uni-forms-item label="高度单位" required>
                        <uni-easyinput v-model="item.unit" placeholder="请输入高度单位" />
                    </uni-forms-item>
                    <uni-forms-item label="纸箱规格" required>
                        <uni-easyinput v-model="item.cartonSpecifications" placeholder="请输入纸箱规格" />
                    </uni-forms-item>
                    <uni-forms-item label="入库数量/ä»¶" required>
                        <uni-number-box v-model="item.inboundNum" :min="0"></uni-number-box>
                    </uni-forms-item>
                    <uni-forms-item label="每件数量/支" required>
                        <uni-number-box v-model="item.boxNum" :min="0"></uni-number-box>
                    </uni-forms-item>
                    <uni-forms-item label="单价(元)/支" required>
                        <uni-number-box v-model="item.taxInclusiveUnitPrice" :min="0" :step="0.01"></uni-number-box>
                    </uni-forms-item>
                    <uni-forms-item label="入库日期" required>
                        <uni-datetime-picker type="date" :clear-icon="false" v-model="item.inboundDate" />
                    </uni-forms-item>
                </uni-forms>
            </view>
            <view style="display: flex;justify-content: flex-end;">
                <button class="mini-btn" type="primary" size="mini"
                    style="margin-left: 0;margin-right: 0;margin-right: 20rpx;" @click="submitForm">确定</button>
                <button class="mini-btn" size="mini" style="margin-left: 0;margin-right: 0;" @click="goBack">取消</button>
            </view>
        </view>
    </view>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { getToken } from "@/utils/auth";
import { addCustom } from '@/api/inventoryManagement/receiptManagement.js'
import config from '@/config'
const baseUrl = config.baseUrl
const pageTitle = ref('新增自定义入库')
const goodsList = ref([])
const type = ref('add')
const props = defineProps(['goods'])
const defaultGoods = {
    boxNum: 0,
    cartonSpecifications: "",
    id: null,
    inboundDate: "",
    inboundNum: 0,
    itemType: "",
    productCategory: "",
    specificationModel: "",
    supplierName: "",
    taxExclusiveTotalPrice: 0,
    taxInclusiveTotalPrice: 0,
    taxInclusiveUnitPrice: 0,
    taxRate: 0,
    unit: "",
    url: "",
}
const goBack = () => {
    uni.navigateBack()
}
const submitForm = async() => {
    let res = await addCustom(goodsList.value)
    if(res.code !== 200){
        uni.showToast({
            title: res.msg,
            icon: 'none'
        })
        return
    }
    uni.showToast({
        title: '新增成功',
        icon: 'none'
    })
    goBack()
}
const addImg = (index) => {
    uni.chooseMedia({
        count: 1,
        mediaType: ['image'],
        sourceType: ['album', 'camera'],
        sizeType: ['original', 'compressed'],
        success: (res) => {
            let imgList = []
            let isHeGe = true
            if (res.tempFiles && res.tempFiles.length) {
                res.tempFiles.forEach(item => {
                    imgList.push(item.tempFilePath)
                    if (item.size > 10000000) {
                        isHeGe = false
                    }
                })
            }
            if (!isHeGe) {
                uni.showToast({
                    title: "图片不能大于10M",
                    icon: "none"
                })
                return
            }
            UploadImage(imgList[0], index)
        },
        fail: (e) => {
            console.log('chooseMedia:fail', e)
            if (e.errMsg == 'chooseMedia:fail cancel') {
                return
            }
            uni.showToast({
                title: "上传失败",
                icon: 'none',
                duration: 1500
            })
        }
    })
}
const UploadImage = (url, index) => {
    uni.uploadFile({
        url: baseUrl + '/file/upload', // æ›¿æ¢ä¸ºå®žé™…的上传接口
        filePath: url,
        name: 'file',
        header: { Authorization: 'Bearer ' + getToken() },
        success: (res) => {
            const data = JSON.parse(res.data)
            if (data.code === 200) {
                goodsList.value[index].url = data.data.tempPath
                uni.showToast({
                    title: '上传成功',
                    icon: 'none',
                    duration: 1500
                })
            } else {
                console.log('上传失败', res)
                uni.showToast({
                    title: '上传失败',
                    icon: 'none'
                })
            }
        },
        fail: (e) => {
            console.log('uploadFile:fail', e)
            uni.showToast({
                title: '上传失败',
                icon: 'none'
            })
        }
    })
}
onMounted(() => {
    let _goods = JSON.parse(props.goods)
    if (_goods.id) {
        pageTitle.value = '编辑自定义入库'
        type.value = 'edit'
    }
    goodsList.value.push({...defaultGoods,..._goods})
})
const addItem = () => {
    goodsList.value.push({...defaultGoods})
}
</script>
<style lang="scss" scoped>
.box {
    background-color: #fff;
    box-sizing: border-box;
    padding: 20rpx;
    min-height: 80rpx;
    padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
}
.form-box {
    box-sizing: border-box;
    margin-bottom: 20rpx;
    padding: 20rpx;
    background-color: #f5f5f5;
    border-radius: 20rpx;
}
.add-img {
    .img {
        background-color: #efefef;
        border-radius: 10rpx;
        width: 200rpx;
        height: 200rpx;
    }
}
</style>
src/pages/inventoryManagement/receiptManagement/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,218 @@
<template>
    <view>
        <PageHeader title="入库管理" @back="goBack" />
        <view class="tabs">
            <uni-segmented-control :current="tabCurrent" :values="tabItems" @clickItem="switchTab" />
        </view>
        <!-- <button class="mini-btn" type="primary" size="mini" style="margin-left: 0;margin-right: 0;" @click="openForm({},'add')">新增入库</button> -->
        <view v-if="contentList?.length !== 0" class="content">
            <view v-if="tabCurrent === 0">
                <block v-for="item in contentList" :key="item.id">
                    <view class="item-box item-box0"></view>
                </block>
                <uni-load-more :status="loadMoreStatus"></uni-load-more>
            </view>
            <view v-if="tabCurrent === 1">
                <block v-for="item in contentList" :key="item.id">
                    <view class="item-box item-box1">
                        <view class="item">
                            <view class="label">产品图片</view>
                            <view class="value">
                                <image class="img" :src="baseUrl + item.url" mode="aspectFill‌" lazy-load></image>
                            </view>
                        </view>
                        <view class="item">
                            <view class="label">入库时间</view>
                            <view class="value">{{ item.inboundDate }}</view>
                        </view>
                        <view class="item">
                            <view class="label">产品名称</view>
                            <view class="value">{{ item.productCategory }}</view>
                        </view>
                        <view class="item">
                            <view class="label">产品高度</view>
                            <view class="value">{{ item.specificationModel }}{{ item.unit }}</view>
                        </view>
                        <view class="item">
                            <view class="label">入库数量/ä»¶</view>
                            <view class="value">{{ item.inboundNum }}</view>
                        </view>
                        <view class="item">
                            <view class="label">每件数量/支</view>
                            <view class="value">{{ item.boxNum }}</view>
                        </view>
                        <view class="item">
                            <view class="label">单价(元)/支</view>
                            <view class="value">{{ item.taxInclusiveUnitPrice }}</view>
                        </view>
                        <view class="item">
                            <view class="label">纸箱规格</view>
                            <view class="value">{{ item.cartonSpecifications }}cm</view>
                        </view>
                        <view class="item">
                            <view class="label">入库人</view>
                            <view class="value">{{ item.createBy }}</view>
                        </view>
                        <view class="item" style="justify-content: flex-end;">
                            <button class="mini-btn" type="primary" size="mini" style="margin-left: 0;margin-right: 0;" @click="openForm(item,'edit')">编辑</button>
                        </view>
                    </view>
                </block>
                <uni-load-more :status="loadMoreStatus"></uni-load-more>
            </view>
        </view>
        <view class="fab-button" @click="openForm({},'add')">
            <up-icon name="plus" size="24" color="#ffffff"></up-icon>
        </view>
        <view v-if="contentList?.length === 0" class="no-data">
            <text>暂无数据</text>
        </view>
    </view>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
import { listPage, listPageByCustom } from '@/api/inventoryManagement/receiptManagement.js'
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
import config from '@/config'
const baseUrl = config.baseUrl
// tab相关
const tabItems = reactive(['采购入库', '成品入库'])
const tabCurrent = ref(0)
const switchTab = (e) => {
    if (tabCurrent.value !== e.currentIndex) {
        tabCurrent.value = e.currentIndex
    }
    reloadPage()
}
// è¿”回上一页
const goBack = () => {
    uni.navigateBack()
}
// æ‰“开编辑/新增
const openForm = (goods,type) => {
    uni.navigateTo({
        url: '/pages/inventoryManagement/receiptManagement/edit?goods=' + JSON.stringify(goods)
    })
}
// åˆ†é¡µç›¸å…³
const pageParams = reactive({
    size: 10,
    current: 1
})
const totalSize = ref(0)
const noMore = computed(() => {
    return contentList.value.length >= totalSize.value
})
const loading = ref(false)
const contentList = ref([])
const loadMoreStatus = computed(() => {
    if (loading.value) {
        return 'loading'
    }
    if (noMore.value) {
        return 'noMore'
    }
    return 'more'
})
const loadPage = () => {
    if (noMore.value || loading.value) {
        return
    }
    pageParams.current += 1
    getList()
}
const reloadPage = () => {
    pageParams.current = 1
    contentList.value = []
    getList()
}
const getList = async () => {
    let getListApi = null
    if (tabCurrent.value == 1) {
        getListApi = listPageByCustom
    } else if (tabCurrent.value == 0) {
        getListApi = listPage
    }
    loading.value = true
    let resp = await getListApi(pageParams)
    loading.value = false
    if (resp.code != 200 || !resp.data) {
        contentList.value = []
        totalSize.value = 0
        return
    }
    contentList.value = [...contentList.value, ...resp.data.records]
    console.log(resp.data.records)
    totalSize.value = resp.data.total
}
onReachBottom(() => {
    loadPage()
})
onPullDownRefresh(() => {
    reloadPage()
    uni.stopPullDownRefresh()
})
onShow(() => {
    reloadPage()
})
</script>
<style lang='scss' scoped>
.tabs {
    box-sizing: border-box;
    padding: 20rpx 40rpx;
}
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}
.item-box{
    box-sizing: border-box;
    margin: 20rpx;
    padding: 20rpx;
    border-radius: 10rpx;
    background-color: #f5f5f5;
}
.item {
    display: flex;
    justify-content: space-between;
    margin: 10rpx 0;
    .label {}
    .value {
        .img {
            width: 200rpx;
            height: 200rpx;
            background-color: #999;
            border-radius: 10rpx;
        }
    }
}
// æµ®åŠ¨æŒ‰é’®æ ·å¼
.fab-button {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom));
    right: 30px;
    width: 56px;
    height: 56px;
    background: #2979ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(41, 121, 255, 0.3);
    z-index: 1000;
}
</style>