feat: 添加10格柜配置并优化智能柜详情页

- 在cabinetImgMap中添加10格柜的图片和名称配置
- 新增获取商店详情的API接口
- 将运行模式相关逻辑从智能柜模块移至商店模块
- 智能柜详情页增加商店信息获取和展示
- 优化商品配置前的商店信息校验
This commit is contained in:
dzq 2025-06-13 11:51:56 +08:00
parent 3fa6aa7014
commit e9bde6e00c
6 changed files with 52 additions and 31 deletions

View File

@ -120,6 +120,13 @@ export const getSmartCabinetList = (params?: SmartCabinetQuery) => {
});
};
export const getSmartCabinetListQuery = (params?: SmartCabinetQuery) => {
return http.request<ResponseData<SmartCabinetDTO[]>>('get', '/cabinet/smartCabinet/list', {
params
});
};
export const addSmartCabinet = (data: AddSmartCabinetCommand) => {
return http.request<ResponseData<void>>('post', '/cabinet/smartCabinet', {
data
@ -149,25 +156,6 @@ export const getSmartCabinetDetailApi = (cabinetId: number) => {
};
/**
*
* @param mode
*/
export const getModeText = (mode?: number) => {
switch (mode) {
case 0:
return '支付模式';
case 1:
return '审批模式';
case 2:
return '借还模式';
case 3:
return '会员模式';
default:
return '未知模式';
}
};
/**
*
* @param balanceEnable

View File

@ -96,6 +96,11 @@ export const getShopList = (params?: ShopQuery) => {
});
};
/** 获取商店详情 */
export const getShopById = (id: number) => {
return http.request<ResponseData<ShopDTO>>('get', `/shop/shops/${id}`);
};
/** 新增商店 */
export const addShop = (data: AddShopCommand) => {
return http.request<ResponseData<void>>('post', '/shop/shops', {

View File

@ -35,4 +35,8 @@ export const CabinetImgMap = {
img: "cabinet_4.jpg",
name: "4格柜",
},
10: {
img: "cabinet_16.jpg",
name: "10格柜",
},
}

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getSmartCabinetDetailApi, type SmartCabinetDTO, getModeText, getBalanceEnableText } from "@/api/cabinet/smart-cabinet";
import { getSmartCabinetDetailApi, type SmartCabinetDTO, getBalanceEnableText } from "@/api/cabinet/smart-cabinet";
import { CabinetCellQuery, changeGoodsCellsStock, clearGoodsCells, getCabinetCellList, type CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { CabinetImgMap } from "@/utils/cabinetImgMap";
@ -22,6 +22,7 @@ import CellEditModal from "@/views/cabinet/cabinet-cell/cell-edit-modal.vue";
import { getGoodsInfo } from "@/api/shop/goods";
import EditCabinetDrawer from "./edit-cabinet-drawer.vue";
import { CabinetMainboardDTO, deleteMainboard, getMainboardList, updateMainboard } from "@/api/cabinet/mainboards";
import { getShopById, ShopDTO, getModeText } from "@/api/shop/shop";
defineOptions({
name: "SmartCabinetDetail"
@ -37,6 +38,19 @@ const cabinetInfo = ref<SmartCabinetDTO>({
lockControlNo: 0,
location: 0
});
const shopInfo = ref<ShopDTO>({
shopId: 0,
shopName: "",
corpid: '',
/** 封面图URL */
coverImg: '',
/** 归属类型0-借还柜 1-固资通) */
belongType:0,
/** 运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式) */
mode: -1,
/** 借呗支付1-正常使用 0-禁止使用) */
balanceEnable: 1,
});
const loading = ref(false);
const activeTab = ref('cells');
const mainboardList = ref<CabinetMainboardDTO[]>([]);
@ -70,8 +84,12 @@ function handleConfigure(row: CabinetCellDTO) {
currentCell.value = row;
configuredGoodsVisible.value = true;
} else {
currentCellId.value = row.cellId;
goodsConfigVisible.value = true;
if (shopInfo.value && shopInfo.value.shopId) {
currentCellId.value = row.cellId;
goodsConfigVisible.value = true;
} else {
ElMessage.error('请先配置机柜所属地址!');
}
}
}
@ -135,6 +153,11 @@ async function fetchCabinetDetail() {
loading.value = true;
const { data } = await getSmartCabinetDetailApi(cabinetId.value);
cabinetInfo.value = data;
//
if (cabinetInfo.value.shopId) {
const { data: shopData } = await getShopById(cabinetInfo.value.shopId);
shopInfo.value = shopData;
}
} finally {
loading.value = false;
}
@ -265,7 +288,7 @@ onMounted(() => {
<el-descriptions class="cabinet-details" :column="1" border>
<el-descriptions-item label="名称">{{ cabinetInfo.cabinetName }}</el-descriptions-item>
<el-descriptions-item label="模式">{{ getModeText(cabinetInfo.mode) }}</el-descriptions-item>
<el-descriptions-item label="模式">{{ getModeText(shopInfo.mode) }}</el-descriptions-item>
<el-descriptions-item label="格式">{{ CabinetImgMap[cabinetInfo.templateNo]?.name || '-'
}}</el-descriptions-item>
<el-descriptions-item label="已用">{{ cabinetInfo.usedCells || '0' }}</el-descriptions-item>
@ -291,7 +314,7 @@ onMounted(() => {
</div>
<el-descriptions :column="2" border>
<el-descriptions-item label="柜体名称">{{ cabinetInfo.cabinetName || '-' }}</el-descriptions-item>
<el-descriptions-item label="运行模式">{{ getModeText(cabinetInfo.mode) }}</el-descriptions-item>
<el-descriptions-item label="运行模式">{{ getModeText(shopInfo.mode) }}</el-descriptions-item>
<el-descriptions-item label="柜体格式">{{ CabinetImgMap[cabinetInfo.templateNo]?.name || '-'
}}</el-descriptions-item>
<el-descriptions-item label="柜体地址">{{ cabinetInfo.shopName || '-' }}
@ -302,11 +325,11 @@ onMounted(() => {
<el-button type="warning" link @click="gatewayConfigVisible = true">
配置
</el-button></el-descriptions-item>
<el-descriptions-item label="借呗支付">{{ getBalanceEnableText(cabinetInfo.balanceEnable)
<el-descriptions-item label="借呗支付">{{ getBalanceEnableText(shopInfo.balanceEnable)
}}</el-descriptions-item>
<el-descriptions-item label="商品模式">
<!-- <el-descriptions-item label="商品模式">
{{ cabinetInfo.belongType === 0 ? '借还模式' : '固资模式' }}
</el-descriptions-item>
</el-descriptions-item> -->
</el-descriptions>
</div>
@ -411,7 +434,7 @@ onMounted(() => {
@refresh="fetchCabinetDetail" />
</el-drawer>
<el-drawer v-model="goodsConfigVisible" title="配置商品" size="50%" direction="rtl">
<CabinetGoodsConfigModal v-model="goodsConfigVisible" :cell-id="currentCellId" :belong-type="cabinetInfo.belongType" @refresh="fetchCellList" />
<CabinetGoodsConfigModal v-model="goodsConfigVisible" :cell-id="currentCellId" :belong-type="shopInfo.belongType" @refresh="fetchCellList" />
</el-drawer>
<el-drawer v-model="configuredGoodsVisible" title="管理商品" size="30%" direction="rtl">
<ConfiguredGoodsModal v-model="configuredGoodsVisible" :cell-id="currentCell?.cellId"

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { getSmartCabinetList, type SmartCabinetDTO, getModeText } from "@/api/cabinet/smart-cabinet";
import { getSmartCabinetList, type SmartCabinetDTO } from "@/api/cabinet/smart-cabinet";
import { type PaginationProps } from "@pureadmin/table";
import { CommonUtils } from "@/utils/common";
import { useRouter } from "vue-router";
@ -13,6 +13,7 @@ import View from "@iconify-icons/ep/view";
import AddFill from "@iconify-icons/ri/add-circle-line";
import SmartCabinetCardFormModal from "./smart-cabinet-card-form-modal.vue";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { getModeText } from "@/api/shop/shop";
const { VITE_PUBLIC_IMG_PATH: IMG_PATH } = import.meta.env;
defineOptions({

View File

@ -25,7 +25,7 @@ import { updateSmartCabinet } from '@/api/cabinet/smart-cabinet';
const props = defineProps<{
modelValue: boolean;
cabinetId: number;
belongType?: number;
// belongType?: number;
}>();
const emit = defineEmits(['update:modelValue', 'refresh']);
@ -49,7 +49,7 @@ const loadShops = async () => {
const { data } = await getShopList({
pageSize: pagination.value.pageSize,
pageNum: pagination.value.currentPage,
belongType: props.belongType
// belongType: props.belongType
});
shopList.value = data.rows;
pagination.value.total = data.total;