diff --git a/src/views/hard/hard-door-manager/form.vue b/src/views/hard/hard-door-manager/form.vue deleted file mode 100644 index 012a123..0000000 --- a/src/views/hard/hard-door-manager/form.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - diff --git a/src/views/hard/hard-door-manager/goods-putaway.vue b/src/views/hard/hard-door-manager/goods-putaway.vue index a54f43d..6035688 100644 --- a/src/views/hard/hard-door-manager/goods-putaway.vue +++ b/src/views/hard/hard-door-manager/goods-putaway.vue @@ -97,17 +97,11 @@ const emit = defineEmits(["refreshCabinet"]) const { yes_no_type, hard_ks_sku_type } = useDict("yes_no_type", "hard_ks_sku_type") const queryRef = ref() const visible = ref(false) - const state: BasicTableProps = reactive({ queryForm: {}, pageList: hardSpu.pageJoin, }) -const curCabinetItem = reactive<{ - hardId: string - cabinetItem: any - floorIndex: number | undefined - indexNo: number | undefined -}>({ hardId: "", cabinetItem: {}, floorIndex: undefined, indexNo: undefined }) +const curCabinetItemId = ref("") const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state) @@ -115,33 +109,21 @@ const resetQuery = () => { queryRef.value?.resetFields() getDataList() } -const resetCurCabinetItem = () => { - curCabinetItem.hardId = "" - curCabinetItem.cabinetItem = {} - curCabinetItem.floorIndex = undefined - curCabinetItem.indexNo = undefined -} -const openDialog = (hardId: string, cabinetItem: any, floorIndex: number, indexNo: number) => { - if (!hardId) return useMessage().error("设备id不存在") +const openDialog = (cabinetItemId: string) => { + if (!cabinetItemId) return useMessage().error("绑定id不存在") resetQuery() - resetCurCabinetItem() - - curCabinetItem.hardId = hardId - curCabinetItem.cabinetItem = cabinetItem - curCabinetItem.floorIndex = floorIndex - curCabinetItem.indexNo = indexNo - + curCabinetItemId.value = cabinetItemId visible.value = true } // 点击上架 const clickPutaway = async (row: any) => { - if (!row.id || !curCabinetItem.cabinetItem.id) return useMessage().error("设备id不存在") - const res = await hardSpu.putaway({ id: curCabinetItem.cabinetItem.id, hardSpuId: row.id }) + if (!row.id) return useMessage().error("商品id不存在") + const res = await hardSpu.putaway({ id: curCabinetItemId.value, hardSpuId: row.id }) if (res.code == 0) { useMessage().success("上架成功") - // emit("refreshCabinet", row, curPos) + emit("refreshCabinet") visible.value = false return } diff --git a/src/views/hard/hard-door-manager/index.vue b/src/views/hard/hard-door-manager/index.vue index 1b9940f..085aa9b 100644 --- a/src/views/hard/hard-door-manager/index.vue +++ b/src/views/hard/hard-door-manager/index.vue @@ -1,6 +1,6 @@ @@ -106,7 +128,7 @@ import { useMessage } from "/@/hooks/message" import { displayPrice } from "/@/utils/formatMoney" import * as hardDoorManager from "/@/api/hard/hard-door-manager" import { ElMessageBox } from "element-plus" -import { getByCabinetNo } from "/@/api/hard/hard-spu" +import { getByCabinetNo, unPutaway } from "/@/api/hard/hard-spu" const InfoSetting = defineAsyncComponent(() => import("./info-setting.vue")) const VolumeSetting = defineAsyncComponent(() => import("./volume-setting.vue")) @@ -121,6 +143,7 @@ const state = reactive({ hardId: "", deviceDetail: {}, cabinetData: [], + curActivedTabIndex: 0, }) onMounted(async () => { @@ -152,6 +175,16 @@ const getCabinet = async (cabinetIndex: number = 0) => { } } +// 修改基本信息 +const changeInfo = async () => { + if (infoSettingRef.value) { + infoSettingRef.value.openDialog(state.hardId) + } +} +const refreshInfo = () => { + doRefresh() +} + // 音量设置 const doVolumeSetting = async () => { if (volumeSettingRef.value) { @@ -165,44 +198,50 @@ const refreshVolume = (data: { hardId: string; mediaVolume: number; systemVolume // 点击柜门tab const tabClick = async (tab: any) => { - // curActive = tab.index + state.curActivedTabIndex = tab.index await getCabinet(tab.index) } +// 点击上架 +const clickPutaway = (cabinetItemId: any) => { + if (goodsPutawayRef.value) { + goodsPutawayRef.value.openDialog(cabinetItemId) + } +} +const refreshCabinet = async () => { + try { + loading.value = true + await getCabinet(state.curActivedTabIndex) + } finally { + loading.value = false + } +} + const doRefresh = async () => { try { loading.value = true await getDetail() - await getCabinet() + await getCabinet(state.curActivedTabIndex) } finally { loading.value = false } } -// ======================================================================================== -// 绑定信息 -const doBind = async () => { - if (infoSettingRef.value) { - infoSettingRef.value.openDialog(state.deviceDetail.hardId) - } -} -// 基本信息 -const refreshInfo = () => {} -// 点击上架 -const clickPutaway = (cabinetItem: any, floorIndex: number, indexNo: number) => { - if (goodsPutawayRef.value) { - goodsPutawayRef.value.openDialog(state.hardId, cabinetItem, floorIndex, indexNo) - } -} -const refreshCabinet = (row: any, curPos: { hardId: string; floorIndex: number; posIndex: number }) => { - state.doorGoods[curPos.floorIndex][curPos.posIndex] = row -} - -// 删除商品 -const deleteGoods = async (floorIndex: number, posIndex: number) => { - ElMessageBox.confirm("确定删除吗?", "删除", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }).then(async () => { - state.doorGoods[floorIndex][posIndex] = {} - }) +// 下架商品 +const deleteGoods = async (v: any) => { + if (!v.id) return useMessage().error("绑定id不存在") + if (!v.spuId) return useMessage().error("商品id不存在") + ElMessageBox.confirm("确定下架吗?", "商品下架", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }).then( + async () => { + loading.value = true + const res = await unPutaway({ id: v.id, hardSpuId: v.spuId }).finally(() => (loading.value = false)) + if (res.code == 0) { + useMessage().success("下架成功") + return getCabinet(state.curActivedTabIndex) + } + useMessage().error(res.msg || "下架失败") + }, + ) } diff --git a/src/views/hard/hard-door-manager/info-setting.vue b/src/views/hard/hard-door-manager/info-setting.vue index eca745f..c03088a 100644 --- a/src/views/hard/hard-door-manager/info-setting.vue +++ b/src/views/hard/hard-door-manager/info-setting.vue @@ -1,13 +1,13 @@