feat(柜体和店铺管理): 添加删除柜体和店铺功能
- 在智能柜体详情页添加删除柜体功能,包含确认对话框和权限控制 - 在店铺表单弹窗中添加删除店铺功能,包含确认对话框和条件判断 - 两个功能均调用对应API并处理成功/失败状态
This commit is contained in:
parent
f7677f136a
commit
d89a2a25e2
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, onMounted, computed } from "vue";
|
import { ref, watch, onMounted, computed } from "vue";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { paymentMethodOptions, modeToPaymentMethodMap } from "@/utils/maps/payment";
|
import { paymentMethodOptions, modeToPaymentMethodMap } from "@/utils/maps/payment";
|
||||||
import { addShop, updateShop, ShopDTO, UpdateShopCommand, AddShopCommand } from "@/api/shop/shop";
|
import { addShop, updateShop, deleteShop, ShopDTO, UpdateShopCommand, AddShopCommand } from "@/api/shop/shop";
|
||||||
import { useWxStore } from "@/store/modules/wx";
|
import { useWxStore } from "@/store/modules/wx";
|
||||||
import Upload from "@iconify-icons/ep/upload";
|
import Upload from "@iconify-icons/ep/upload";
|
||||||
import { useSysConfigStoreHook } from "@/store/modules/sysConfig";
|
import { useSysConfigStoreHook } from "@/store/modules/sysConfig";
|
||||||
|
|
@ -27,6 +27,7 @@ const wxStore = useWxStore();
|
||||||
const sysConfigStore = useSysConfigStoreHook();
|
const sysConfigStore = useSysConfigStoreHook();
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
|
const deleteDialogVisible = ref(false);
|
||||||
const formData = ref<UpdateShopCommand>({
|
const formData = ref<UpdateShopCommand>({
|
||||||
corpid: wxStore.corpid,
|
corpid: wxStore.corpid,
|
||||||
shopId: 0,
|
shopId: 0,
|
||||||
|
|
@ -134,6 +135,27 @@ const copyLink = () => {
|
||||||
const success = copyTextToClipboard(url);
|
const success = copyTextToClipboard(url);
|
||||||
success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制');
|
success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
deleteDialogVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmDelete = async () => {
|
||||||
|
try {
|
||||||
|
await deleteShop(formData.value.shopId.toString());
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
deleteDialogVisible.value = false;
|
||||||
|
emit("update:visible", false);
|
||||||
|
emit("refresh");
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
ElMessage.error("删除失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelDelete = () => {
|
||||||
|
deleteDialogVisible.value = false;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -209,9 +231,31 @@ const copyLink = () => {
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="handleClose" style="margin-right: 5px;">取消</el-button>
|
<el-button @click="handleClose" style="margin-right: 5px;">取消</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="formData.shopId && (props.row.cabinetCount || 0) === 0"
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete"
|
||||||
|
style="margin-right: 5px;">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
|
<!-- 删除确认对话框 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="deleteDialogVisible"
|
||||||
|
title="确认删除"
|
||||||
|
width="400px"
|
||||||
|
:close-on-click-modal="false">
|
||||||
|
<span>确定要删除地址 "{{ formData.shopName }}" 吗?此操作不可恢复。</span>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="cancelDelete">取消</el-button>
|
||||||
|
<el-button type="danger" @click="confirmDelete">确定删除</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
@ -243,4 +287,10 @@ const copyLink = () => {
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed } from "vue";
|
import { ref, onMounted, computed } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { getSmartCabinetDetailApi, type SmartCabinetDTO, getBalanceEnableText } from "@/api/cabinet/smart-cabinet";
|
import { getSmartCabinetDetailApi, type SmartCabinetDTO, getBalanceEnableText, deleteSmartCabinet } from "@/api/cabinet/smart-cabinet";
|
||||||
import { CabinetCellQuery, changeGoodsCellsStock, clearGoodsCells, getCabinetCellList, type CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
|
import { CabinetCellQuery, changeGoodsCellsStock, clearGoodsCells, getCabinetCellList, type CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import { CabinetImgMap } from "@/utils/cabinetImgMap";
|
import { CabinetImgMap } from "@/utils/cabinetImgMap";
|
||||||
|
|
@ -279,6 +279,22 @@ async function handleDeleteMainboard(row: CabinetMainboardDTO) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleDeleteCabinet() {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确认要删除柜体「${cabinetInfo.value.cabinetName}」吗?此操作将不可恢复。`,
|
||||||
|
'删除柜体',
|
||||||
|
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
||||||
|
);
|
||||||
|
await deleteSmartCabinet(cabinetId.value.toString());
|
||||||
|
ElMessage.success('柜体删除成功');
|
||||||
|
// 返回列表页面
|
||||||
|
router.push('/cabinet/smart-cabinet');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('操作取消或失败', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleAb98ViewDetail = (ab98UserId: number, name: string) => {
|
const handleAb98ViewDetail = (ab98UserId: number, name: string) => {
|
||||||
// 保存信息到标签页
|
// 保存信息到标签页
|
||||||
|
|
@ -341,6 +357,10 @@ onMounted(() => {
|
||||||
|
|
||||||
<div class="info-details" v-if="activeTab === 'basic'">
|
<div class="info-details" v-if="activeTab === 'basic'">
|
||||||
<div style="display: flex; justify-content: flex-end; margin-bottom: 16px;">
|
<div style="display: flex; justify-content: flex-end; margin-bottom: 16px;">
|
||||||
|
<el-button v-if="hasPermission('shop:cabinet:write')" type="danger" link :icon="useRenderIcon(Delete)"
|
||||||
|
@click="handleDeleteCabinet" style="margin-right: 16px;">
|
||||||
|
删除柜体
|
||||||
|
</el-button>
|
||||||
<el-button v-if="hasPermission('shop:cabinet:write')" type="primary" link :icon="useRenderIcon(EditPen)"
|
<el-button v-if="hasPermission('shop:cabinet:write')" type="primary" link :icon="useRenderIcon(EditPen)"
|
||||||
@click="editCabinetDrawerVisible = true">
|
@click="editCabinetDrawerVisible = true">
|
||||||
编辑柜体
|
编辑柜体
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue