feat:智能柜商品分类

This commit is contained in:
dzc committed 2025-04-03 10:58:49 +08:00
1 parent ba54812e15
commit 24d03cf88e
3 files changed
+53 -14

No files matched your search

+24 -11
View File
@@ -1,16 +1,24 @@
<template>
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
<el-dialog :title="form.id ? '编辑' : '新增'" width="30%" v-model="visible" :close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
<el-row :gutter="24">
<el-col :span="12" class="mb20">
<el-col :span="24" class="mb20">
<el-form-item label="商户" prop="mchId">
<select-mch v-model="form.mchId" :apiParams="{ types: '2' }" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="分类名" prop="name">
<el-input v-model="form.name" placeholder="请输入分类名" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-col :span="24" class="mb20">
<el-form-item label="排序" prop="sort">
<el-input v-model="form.sort" placeholder="请输入排序" />
<template #label>
<span>排序:</span>
<tip content="越大越在前" />
</template>
<el-input-number :min="0" :step="1" v-model="form.sort" placeholder="" />
</el-form-item>
</el-col>
</el-row>
@@ -27,8 +35,7 @@
<script setup lang="ts" name="HardSpuCategoryDialog">
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/hard/hard-spu-category"
import { rule } from "/@/utils/validate"
import * as hardSpuCategory from "/@/api/hard/hard-spu-category"
const emit = defineEmits(["refresh"])
// 定义变量内容
@@ -40,12 +47,17 @@ const loading = ref(false)
// 提交表单数据
const form = reactive({
id: "",
mchId: "",
name: "",
sort: "",
sort: 0,
})
// 定义校验规则
const dataRules = ref({})
const dataRules = ref({
mchId: [{ required: true, message: "请选择商户", trigger: "change" }],
name: [{ required: true, message: "分类名不能为空", trigger: "blur" }],
sort: [{ required: true, message: "商户不能为空", trigger: "blur" }],
})
// 打开弹窗
const openDialog = (id: string) => {
@@ -71,7 +83,7 @@ const onSubmit = async () => {
try {
loading.value = true
form.id ? await putObj(form) : await addObj(form)
form.id ? await hardSpuCategory.putObj(form) : await hardSpuCategory.addObj(form)
useMessage().success(form.id ? "修改成功" : "添加成功")
visible.value = false
emit("refresh")
@@ -86,7 +98,8 @@ const onSubmit = async () => {
const gethardSpuCategoryData = (id: string) => {
// 获取数据
loading.value = true
getObj(id)
hardSpuCategory
.getObj(id)
.then((res: any) => {
Object.assign(form, res.data)
})
+21 -3
View File
@@ -1,6 +1,19 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form v-if="showSearch" ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 300px" label="分类" prop="name">
<el-input v-model="state.queryForm.name" placeholder="请输入分类" />
</el-form-item>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">
{{ $t("common.queryBtn") }}
</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'hard_hardSpuCategory_add'">
@@ -38,6 +51,11 @@
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="name" label="分类名" show-overflow-tooltip />
<el-table-column label="商户" show-overflow-tooltip>
<template #default="{ row }">
<span>{{ row.merchantName }} </span>
</template>
</el-table-column>
<el-table-column prop="sort" label="排序" show-overflow-tooltip />
<el-table-column label="操作" width="150">
<template #default="scope">
@@ -65,7 +83,7 @@
<script setup lang="ts" name="systemHardSpuCategory">
import { BasicTableProps, useTable } from "/@/hooks/table"
import { fetchList, delObjs } from "/@/api/hard/hard-spu-category"
import * as hardSpuCategory from "/@/api/hard/hard-spu-category"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
@@ -84,7 +102,7 @@ const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList,
pageList: hardSpuCategory.pageJoin,
})
// table hook
@@ -119,7 +137,7 @@ const handleDelete = async (ids: string[]) => {
}
try {
await delObjs(ids)
await hardSpuCategory.delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {