This commit is contained in:
weiwei committed 2025-04-18 14:18:55 +08:00
commit b5a622d43e
2 files changed
+205 -66

No files matched your search

+84 -32
View File
@@ -11,26 +11,38 @@
:auto-scroll-to-top-when-reload="false"
>
<template #top>
<view class="h-30rpx" />
<tm-tabs
item-width="50%"
gap="0"
line-full
line-height="4rpx"
round="10"
active-title-color=""
:list="['门1', '门2']"
@change="doorTabsChange"
/>
<view class="h-10rpx" />
<view class="bg-white rounded-20rpx my-20rpx font-bold">
<z-tabs
:list="
state.detail.cabinetList?.length &&
state.detail.cabinetList.map((item:any, index:number) => {
return {
name: state.detail.deviceCode + '-' + item.cabinetNo,
value: index,
}
})
"
bar-width="150"
:active-style="{
fontSize: '30rpx',
}"
:inactive-style="{
fontSize: '30rpx',
}"
@change="doorTabsChange"
/>
</view>
</template>
<view class="w-full w-full">
<view v-for="(item, index) in new Array(6).fill(new Array(10)).map((item) => item.fill({}))" :key="index">
<tm-text class="text-center mt-4">第 {{ index + 1 }} 层</tm-text>
<view class="flex flex-wrap">
<view v-for="(v, i) in item" :key="i" class="w-1/4 h-200 p-1">
<view class="card w-full h-full p-2 flex items-center justify-center active:bg-#e8e8e8!" @click="doPutaway">
<view v-for="(item, index) in state.cabinetList" :key="index">
<tm-text class="text-center">第 {{ index + 1 }} 层</tm-text>
<view class="flex flex-wrap mb-4">
<view v-for="(v, i) in item[index + 1]" :key="i" class="w-1/5 h-150 p-1">
<view v-if="v.spuId && v.spuDetail" class="card w-full h-full flex items-center justify-center">
<image class="w-full h-full" :src="v.spuDetail.pic" />
</view>
<view v-else class="card w-full h-full p-2 flex items-center justify-center active:bg-#e8e8e8!" @click="doPutaway">
<image class="w-half h-half" src="@/static/page/加号.svg" />
</view>
</view>
@@ -91,30 +103,70 @@
</template>
<script setup lang="ts">
import { reactive, ref } from "vue"
import { computed, reactive } from "vue"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
import { doorApi } from "@/sheep/api"
import { onLoad, onShow } from "@dcloudio/uni-app"
const state = reactive<any>({
hardDoorId: "",
detail: {},
curDoorTabIndex: 0,
cabinetList: [],
curGoodsTabIndex: 0,
showDrawer: false,
checkboxValue: [],
})
const curCabinetNo = computed(() => {
if (state.detail.cabinetList) return state.detail.cabinetList[state.curDoorTabIndex].cabinetNo
})
const listview = ref<any>([
{ text: "科技创新引领制造业高质量发展", id: 1 },
{ text: "明确提出“建立保持制造业合理比重投入机制”。", id: 2 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 3 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 4 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 5 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 6 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 7 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 8 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 9 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 10 },
])
onLoad((option: any) => {
if (!option.hardDoorId) return
state.hardDoorId = option.hardDoorId
})
const doorTabsChange = (index: number) => {
state.curDoorTabIndex = index
onShow(async () => {
if (!state.hardDoorId) return
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await doorApi.hardDoorDetail({ hardDoorId: state.hardDoorId })
if (res.code == 0) {
state.detail = res.data
} else {
uni.showToast({ title: res.msg, icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
// 获取货柜补货商品列表
await getCabinetList()
})
// 获取货柜商品列表
const getCabinetList = async () => {
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await doorApi.cabinetList({ hardId: state.hardDoorId, cabinetNo: curCabinetNo.value })
if (res.code == 0) {
state.cabinetList = res.data
} else {
uni.showToast({ title: res.msg, icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
}
const doorTabsChange = async (e: number) => {
state.curDoorTabIndex = e
await getCabinetList()
}
const goodsTabsChange = (index: number) => {
+121 -34
View File
@@ -13,10 +13,15 @@
<template #top>
<view class="bg-white rounded-20rpx my-20rpx font-bold">
<z-tabs
:list="[
{ name: '门1', value: 1 },
{ name: '门2', value: 2 },
]"
:list="
state.detail.cabinetList?.length &&
state.detail.cabinetList.map((item:any, index:number) => {
return {
name: state.detail.deviceCode + '-' + item.cabinetNo,
value: index,
}
})
"
bar-width="150"
:active-style="{
fontSize: '30rpx',
@@ -29,18 +34,26 @@
</view>
</template>
<tm-sheet v-for="(item, index) in listview" :key="index" :margin="[0, 20]">
<view class="flex">
<image class="w-120rpx h-120rpx" />
<tm-sheet v-for="(item, index) in state.cabinetPutawayList" :key="index" :margin="[0, 0, 0, 20]" :padding="15">
<view class="flex items-center">
<image class="w-180rpx h-180rpx" :src="item.spuDetail?.pic" />
<view class="ml-2 flex-1 flex-col">
<tm-text font-size="32">更改圆角</tm-text>
<view class="flex justify-between my-1">
<tm-text font-size="26">规格:</tm-text>
<tm-text font-size="26">规格:</tm-text>
<tm-text font-size="30">{{ item.spuDetail?.name }}</tm-text>
<view class="flex justify-between mt-1">
<tm-text font-size="26">种类:{{ item.spuDetail?.categoryName }}</tm-text>
<tm-text font-size="26">售卖数量:{{ item.spuDetail?.salesCount }}</tm-text>
<tm-text font-size="26">层数:{{ item.hardDoorNumber }}</tm-text>
</view>
<view class="flex justify-end items-center">
<tm-text font-size="30">库存:</tm-text>
<tm-stepper width="200" v-model="item.stock" />
<view class="flex justify-between">
<tm-text font-size="26">库存:{{ item.spuDetail?.repertoryCount || 0 }}</tm-text>
</view>
<view class="flex justify-between items-center">
<tm-text font-size="30" color="red">¥{{ displayPrice(item.spuDetail?.price) }}</tm-text>
<view class="flex items-center">
<tm-text font-size="28">补货数:</tm-text>
<tm-stepper width="200" v-model="item.plusCount" :max="99" splitBtn fontSize="30" />
</view>
</view>
</view>
</view>
@@ -49,39 +62,113 @@
<template #main-bottom>
<view class="m-30rpx flex justify-between">
<tm-button block @click="openDoor" :disabled="!state.isUseDoor">一键补满</tm-button>
<tm-button block @click="openDoor" :disabled="false">开门补货</tm-button>
&nbsp;&nbsp;
<tm-button block @click="openDoor" :disabled="!state.isUseDoor">开 门</tm-button>
&nbsp;&nbsp;
<tm-button block @click="save" :disabled="!state.isUseDoor">保 存</tm-button>
<tm-button block @click="replenishmentComplete" :disabled="!state['flowId' + curCabinetNo.value]">补货完成</tm-button>
</view>
</template>
</crud-layout>
</template>
<script setup lang="ts">
import { reactive, ref } from "vue"
import { computed, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
import { doorApi } from "@/sheep/api"
import { displayPrice } from "@/sheep/utils/formatMoney"
const listview = ref<any>([
{ text: "科技创新引领制造业高质量发展", id: 1 },
{ text: "明确提出“建立保持制造业合理比重投入机制”。", id: 2 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 3 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 4 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 5 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 6 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 7 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 8 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 9 },
{ text: "改造提升传统产业,培育壮大新兴产业,布局建设未来产业,完善现代化产业体系", id: 10 },
])
const state = reactive({
const state = reactive<any>({
hardDoorId: "",
detail: {},
curDoorTabIndex: 0,
cabinetPutawayList: [],
})
const curCabinetNo = computed(() => {
if (state.detail.cabinetList) return state.detail.cabinetList[state.curDoorTabIndex].cabinetNo
})
const putawayList = computed(() => state.cabinetPutawayList.map((item: any) => ({ hardSpuId: item.spuId, plusCount: item.plusCount || 0 })))
onLoad((option: any) => {
if (!option.hardDoorId) return
state.hardDoorId = option.hardDoorId
})
onShow(async () => {
if (!state.hardDoorId) return
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await doorApi.hardDoorDetail({ hardDoorId: state.hardDoorId })
if (res.code == 0) {
state.detail = res.data
} else {
uni.showToast({ title: res.msg, icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
// 获取货柜补货商品列表
await getCabinetPutawayList()
})
// 获取货柜补货商品列表
const getCabinetPutawayList = async () => {
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await doorApi.cabinetPutawayList({ hardDoorId: state.detail.id, cabinetNo: curCabinetNo.value })
if (res.code == 0) {
state.cabinetPutawayList = res.data
} else {
uni.showToast({ title: res.msg, icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
}
// 柜门tab切换
const doorTabsChange = (e: number) => {
const doorTabsChange = async (e: number) => {
state.curDoorTabIndex = e
await getCabinetPutawayList()
}
// 开门补货
const openDoor = async () => {
try {
uni.showLoading({ title: "正在开门", mask: true })
const res = await doorApi.openRepertory({ hardDoorId: state.detail.id, cabinetNo: curCabinetNo.value })
if (res.code == 0) {
state["flowId" + curCabinetNo.value] = res.data
uni.showToast({ title: "开门成功", icon: "none" })
} else {
uni.showToast({ title: res.msg || "开门失败", icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
}
// 补货完成
const replenishmentComplete = async () => {
if (!state["flowId" + curCabinetNo.value]) return uni.showToast({ title: "请先开门", icon: "none" })
try {
uni.showLoading({ title: "正在保存", mask: true })
const res = await doorApi.repertoryDone({ flowId: state["flowId" + curCabinetNo.value], list: putawayList.value })
if (res.code == 0) {
uni.showToast({ title: "保存成功", icon: "none" })
} else {
uni.showToast({ title: res.msg || "保存失败", icon: "none" })
}
} catch (error: any) {
uni.showToast({ title: error.msg, icon: "none" })
} finally {
uni.hideLoading()
}
}
</script>