This commit is contained in:
parent
8ecfe79909
commit
c4079cd7a1
|
@ -1,43 +1,45 @@
|
|||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup ref="popupRef" :title="popupTitle" :async="true" width="550px" @confirm="handleSubmit" @close="handleClose">
|
||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||
<el-form-item label="所属ID" prop="pid">
|
||||
<!-- <el-input v-model="formData.pid" clearable placeholder="请输入所属ID" /> -->
|
||||
<el-cascader v-model="formData.pid" :props="props" :show-all-levels="false" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
<el-input v-model="formData.name" clearable placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注信息" prop="data">
|
||||
<el-input v-model="formData.data" clearable placeholder="请输入备注信息" />
|
||||
</el-form-item>
|
||||
<el-form-item label="图片" prop="pic">
|
||||
<material-picker v-model="formData.pic" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="formData.sort" clearable placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
<div class="edit-popup">
|
||||
<popup ref="popupRef" :title="popupTitle" :async="true" width="550px" @confirm="handleSubmit"
|
||||
@close="handleClose">
|
||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||
<el-form-item label="所属ID" prop="pid">
|
||||
<!-- <el-input v-model="formData.pid" clearable placeholder="请输入所属ID" /> -->
|
||||
<el-cascader v-model="formData.pid" :props="props" :show-all-levels="false" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
<el-input v-model="formData.name" clearable placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注信息" prop="data">
|
||||
<el-input v-model="formData.data" clearable placeholder="请输入备注信息" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="图片" prop="pic">
|
||||
<material-picker v-model="formData.pic" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="formData.sort" clearable placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="storeCategoryEdit">
|
||||
import type { FormInstance } from "element-plus";
|
||||
import Popup from "@/components/popup/index.vue";
|
||||
import {
|
||||
apiStoreCategoryAdd,
|
||||
apiStoreCategoryEdit,
|
||||
apiStoreCategoryDetail, apiStoreCategoryLists,
|
||||
apiStoreCategoryAdd,
|
||||
apiStoreCategoryEdit,
|
||||
apiStoreCategoryDetail, apiStoreCategoryLists,
|
||||
} from "@/api/store_category";
|
||||
import { timeFormat } from "@/utils/util";
|
||||
import type { PropType } from "vue";
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({}),
|
||||
},
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(["success", "close"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
|
@ -46,104 +48,104 @@ const mode = ref("add");
|
|||
|
||||
|
||||
const props = {
|
||||
value: "id",
|
||||
label: "name",
|
||||
checkStrictly: true,
|
||||
emitPath: false,
|
||||
lazy: true,
|
||||
lazyLoad(node, resolve) {
|
||||
let pid = node.value || 0;
|
||||
apiStoreCategoryLists({
|
||||
pid: pid,
|
||||
page_size: 10000,
|
||||
}).then((res) => {
|
||||
resolve(
|
||||
res.lists.map((item: any) => {
|
||||
item.leaf = item.pid > 0;
|
||||
return item;
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
value: "id",
|
||||
label: "name",
|
||||
checkStrictly: true,
|
||||
emitPath: false,
|
||||
lazy: true,
|
||||
lazyLoad(node, resolve) {
|
||||
let pid = node.value || 0;
|
||||
apiStoreCategoryLists({
|
||||
pid: pid,
|
||||
page_size: 10000,
|
||||
}).then((res) => {
|
||||
resolve(
|
||||
res.lists.map((item: any) => {
|
||||
item.leaf = item.pid > 0;
|
||||
return item;
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// 弹窗标题
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == "edit" ? "编辑商品分类表" : "新增商品分类表";
|
||||
return mode.value == "edit" ? "编辑商品分类表" : "新增商品分类表";
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
pid: 0,
|
||||
name: "",
|
||||
data: "",
|
||||
pic: "",
|
||||
sort: "",
|
||||
id: "",
|
||||
pid: 0,
|
||||
name: "",
|
||||
data: "",
|
||||
pic: "",
|
||||
sort: "",
|
||||
});
|
||||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
// pid: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: "请输入所属ID",
|
||||
// trigger: ["blur"],
|
||||
// },
|
||||
// ],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入分类名称",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
// pid: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: "请输入所属ID",
|
||||
// trigger: ["blur"],
|
||||
// },
|
||||
// ],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入分类名称",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await apiStoreCategoryDetail({
|
||||
id: row.id,
|
||||
});
|
||||
setFormData(data);
|
||||
const data = await apiStoreCategoryDetail({
|
||||
id: row.id,
|
||||
});
|
||||
setFormData(data);
|
||||
};
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
let data = { ...formData };
|
||||
await formRef.value?.validate();
|
||||
let data = { ...formData };
|
||||
|
||||
mode.value == "edit"
|
||||
? await apiStoreCategoryEdit(data)
|
||||
: await apiStoreCategoryAdd(data);
|
||||
popupRef.value?.close();
|
||||
emit("success");
|
||||
mode.value == "edit"
|
||||
? await apiStoreCategoryEdit(data)
|
||||
: await apiStoreCategoryAdd(data);
|
||||
popupRef.value?.close();
|
||||
emit("success");
|
||||
};
|
||||
|
||||
//打开弹窗
|
||||
const open = (type = "add") => {
|
||||
mode.value = type;
|
||||
popupRef.value?.open();
|
||||
mode.value = type;
|
||||
popupRef.value?.open();
|
||||
};
|
||||
|
||||
// 关闭回调
|
||||
const handleClose = () => {
|
||||
emit("close");
|
||||
emit("close");
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail,
|
||||
open,
|
||||
setFormData,
|
||||
getDetail,
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,75 +1,77 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form class="mb-[-16px] disabledEdit" :model="queryParams" inline>
|
||||
<!-- <el-form-item label="所属ID" prop="pid">
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form class="mb-[-16px] disabledEdit" :model="queryParams" inline>
|
||||
<!-- <el-form-item label="所属ID" prop="pid">
|
||||
<el-input class="w-[280px]" v-model="queryParams.pid" clearable placeholder="请输入所属ID" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
<el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注信息" prop="data">
|
||||
<el-input class="w-[280px]" v-model="queryParams.data" clearable placeholder="请输入备注信息" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input class="w-[280px]" v-model="queryParams.sort" clearable placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store.storecategory/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button v-perms="['store.storecategory/delete']" :disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)">
|
||||
删除
|
||||
</el-button>
|
||||
<div class="mt-4" style="cursor: pointer">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange" @cell-click="cellClick">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" width="120" />
|
||||
<el-table-column label="所属ID" prop="pid" show-overflow-tooltip />
|
||||
<el-table-column label="分类名称" prop="name" show-overflow-tooltip />
|
||||
<el-table-column label="备注信息" prop="data" show-overflow-tooltip />
|
||||
<el-table-column label="图片" prop="pic">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width: 50px; height: 50px" :src="row.pic" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序" prop="sort" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['store.storecategory/edit']" type="primary" link @click.stop="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-perms="['store.storecategory/delete']" type="danger" link @click.stop="handleDelete(row.id)">
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
<el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注信息" prop="data">
|
||||
<el-input class="w-[280px]" v-model="queryParams.data" clearable placeholder="请输入备注信息" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input class="w-[280px]" v-model="queryParams.sort" clearable placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store.storecategory/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button v-perms="['store.storecategory/delete']" :disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<!-- <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> -->
|
||||
</div>
|
||||
</el-button>
|
||||
<div class="mt-4" style="cursor: pointer">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange" @cell-click="cellClick">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" width="120" />
|
||||
<el-table-column label="所属ID" prop="pid" show-overflow-tooltip />
|
||||
<el-table-column label="分类名称" prop="name" show-overflow-tooltip />
|
||||
<el-table-column label="备注信息" prop="data" show-overflow-tooltip />
|
||||
<el-table-column label="图片" prop="pic">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width: 50px; height: 50px" :src="row.pic" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序" prop="sort" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['store.storecategory/edit']" type="primary" link
|
||||
@click.stop="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-perms="['store.storecategory/delete']" type="danger" link
|
||||
@click.stop="handleDelete(row.id)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<!-- <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="storeCategoryLists">
|
||||
import { usePaging } from "@/hooks/usePaging";
|
||||
import { useDictData } from "@/hooks/useDictOptions";
|
||||
import {
|
||||
apiStoreCategoryLists,
|
||||
apiStoreCategoryDelete,
|
||||
apiStoreCategoryLists,
|
||||
apiStoreCategoryDelete,
|
||||
} from "@/api/store_category";
|
||||
import { timeFormat } from "@/utils/util";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
@ -85,11 +87,11 @@ const router = useRouter();
|
|||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
pid: route.query?.pid || 0,
|
||||
name: "",
|
||||
data: "",
|
||||
pic: "",
|
||||
sort: "",
|
||||
pid: route.query?.pid || 0,
|
||||
name: "",
|
||||
data: "",
|
||||
pic: "",
|
||||
sort: "",
|
||||
});
|
||||
|
||||
// 选中数据
|
||||
|
@ -97,7 +99,7 @@ const selectData = ref<any[]>([]);
|
|||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ id }) => id);
|
||||
selectData.value = val.map(({ id }) => id);
|
||||
};
|
||||
|
||||
// 获取字典数据
|
||||
|
@ -105,43 +107,43 @@ const { dictData } = useDictData("");
|
|||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiStoreCategoryLists,
|
||||
params: queryParams,
|
||||
fetchFun: apiStoreCategoryLists,
|
||||
params: queryParams,
|
||||
});
|
||||
|
||||
// 添加
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true;
|
||||
await nextTick();
|
||||
editRef.value?.open("add");
|
||||
showEdit.value = true;
|
||||
await nextTick();
|
||||
editRef.value?.open("add");
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true;
|
||||
await nextTick();
|
||||
editRef.value?.open("edit");
|
||||
editRef.value?.setFormData(data);
|
||||
showEdit.value = true;
|
||||
await nextTick();
|
||||
editRef.value?.open("edit");
|
||||
editRef.value?.setFormData(data);
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (id: number | any[]) => {
|
||||
await feedback.confirm("确定要删除?");
|
||||
await apiStoreCategoryDelete({ id });
|
||||
getLists();
|
||||
await feedback.confirm("确定要删除?");
|
||||
await apiStoreCategoryDelete({ id });
|
||||
getLists();
|
||||
};
|
||||
|
||||
getLists();
|
||||
|
||||
// 跳转子级分类
|
||||
const cellClick = (row: any, column: any) => {
|
||||
if (column.no == 7) return console.log("无效点击");
|
||||
if (column.no == 7) return console.log("无效点击");
|
||||
|
||||
router.push({
|
||||
path: "/store/store_category",
|
||||
query: {
|
||||
pid: row.id,
|
||||
},
|
||||
});
|
||||
router.push({
|
||||
path: "/store/store_category",
|
||||
query: {
|
||||
pid: row.id,
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
title="详情"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:cancelButtonText="false"
|
||||
:confirmButtonText="false"
|
||||
>
|
||||
<popup ref="popupRef" title="详情" :async="true" width="550px" :cancelButtonText="false"
|
||||
:confirmButtonText="false">
|
||||
<el-form ref="formRef" :model="formData" label-width="90px">
|
||||
<el-form-item label="商品名称" prop="store_name">
|
||||
<el-input v-model="formData.store_name" clearable placeholder="请输入商品名称" :readonly="true"/>
|
||||
<el-input v-model="formData.store_name" clearable placeholder="请输入商品名称" :readonly="true" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
|
@ -52,8 +46,8 @@ const setFormData = async (data: Record<any, any>) => {
|
|||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
|
|
|
@ -1,114 +1,62 @@
|
|||
<template>
|
||||
<el-card>
|
||||
<div class="mb-4 text-lg font-bold">
|
||||
{{ mode == "add" ? "添加商品" : "编辑商品" }}
|
||||
</div>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="90px"
|
||||
:rules="formRules"
|
||||
>
|
||||
<el-form-item label="商品图片" prop="image">
|
||||
<material-picker v-model="formData.image" :limit="1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称" prop="store_name">
|
||||
<el-input
|
||||
v-model="formData.store_name"
|
||||
clearable
|
||||
placeholder="请输入商品名称"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品条码" prop="bar_code">
|
||||
<el-input
|
||||
v-model="formData.bar_code"
|
||||
clearable
|
||||
placeholder="请输入商品条码"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="cate_id">
|
||||
<el-input
|
||||
v-model="formData.cate_id"
|
||||
clearable
|
||||
placeholder="请输入商品分类"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品价格" prop="price">
|
||||
<el-input
|
||||
v-model="formData.price"
|
||||
clearable
|
||||
placeholder="请输入商品价格"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品单位" prop="unit">
|
||||
<el-input
|
||||
v-model="formData.unit"
|
||||
clearable
|
||||
placeholder="请输入商品单位"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock">
|
||||
<el-input
|
||||
v-model="formData.stock"
|
||||
clearable
|
||||
placeholder="请输入库存"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="成本价" prop="cost">
|
||||
<el-input
|
||||
v-model="formData.cost"
|
||||
clearable
|
||||
placeholder="请输入成本价"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="采购价" prop="purchase">
|
||||
<el-input
|
||||
v-model="formData.purchase"
|
||||
clearable
|
||||
placeholder="请输入采购价"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="上浮比例" prop="rose">
|
||||
<el-input
|
||||
v-model="formData.rose"
|
||||
clearable
|
||||
placeholder="请输入上浮比例"
|
||||
:readonly="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="">
|
||||
<el-button @click="handleSubmit" type="primary" class="w-40"
|
||||
>提交</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div class="mb-4 text-lg font-bold">
|
||||
{{ mode == "add" ? "添加商品" : "编辑商品" }}
|
||||
</div>
|
||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||
<el-form-item label="商品图片" prop="image">
|
||||
<material-picker v-model="formData.image" :limit="1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称" prop="store_name">
|
||||
<el-input v-model="formData.store_name" clearable placeholder="请输入商品名称" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品条码" prop="bar_code">
|
||||
<el-input v-model="formData.bar_code" clearable placeholder="请输入商品条码" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="cate_id">
|
||||
<el-input v-model="formData.cate_id" clearable placeholder="请输入商品分类" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品价格" prop="price">
|
||||
<el-input v-model="formData.price" clearable placeholder="请输入商品价格" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品单位" prop="unit">
|
||||
<el-input v-model="formData.unit" clearable placeholder="请输入商品单位" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock">
|
||||
<el-input v-model="formData.stock" clearable placeholder="请输入库存" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="成本价" prop="cost">
|
||||
<el-input v-model="formData.cost" clearable placeholder="请输入成本价" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="采购价" prop="purchase">
|
||||
<el-input v-model="formData.purchase" clearable placeholder="请输入采购价" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上浮比例" prop="rose">
|
||||
<el-input v-model="formData.rose" clearable placeholder="请输入上浮比例" :readonly="false" />
|
||||
</el-form-item>
|
||||
<el-form-item label="">
|
||||
<el-button @click="handleSubmit" type="primary" class="w-40">提交</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="storeProductEdit">
|
||||
import type { FormInstance } from "element-plus";
|
||||
import useMultipleTabs from "@/hooks/useMultipleTabs";
|
||||
import {
|
||||
apiStoreProductAdd,
|
||||
apiStoreProductEdit,
|
||||
apiStoreProductDetail,
|
||||
apiStoreProductAdd,
|
||||
apiStoreProductEdit,
|
||||
apiStoreProductDetail,
|
||||
} from "@/api/store_product";
|
||||
import { timeFormat } from "@/utils/util";
|
||||
import type { PropType } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({}),
|
||||
},
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(["success", "close"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
|
@ -117,118 +65,118 @@ const mode = ref("add");
|
|||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
image: "",
|
||||
store_name: "",
|
||||
bar_code: "",
|
||||
cate_id: "",
|
||||
price: "",
|
||||
unit: "",
|
||||
stock: "",
|
||||
cost: "",
|
||||
purchase: "",
|
||||
rose: "0",
|
||||
image: "",
|
||||
store_name: "",
|
||||
bar_code: "",
|
||||
cate_id: "",
|
||||
price: "",
|
||||
unit: "",
|
||||
stock: "",
|
||||
cost: "",
|
||||
purchase: "",
|
||||
rose: "0",
|
||||
});
|
||||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
store_name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品名称",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
bar_code: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品条码",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
cate_id: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品分类",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
price: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品价格",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
unit: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品单位",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
stock: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入库存",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
cost: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入成本价",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
purchase: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入采购价",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
image: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品图片",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
store_name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品名称",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
bar_code: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品条码",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
cate_id: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品分类",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
price: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品价格",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
unit: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品单位",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
stock: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入库存",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
cost: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入成本价",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
purchase: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入采购价",
|
||||
trigger: ["blur"],
|
||||
},
|
||||
],
|
||||
image: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入商品图片",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await apiStoreProductDetail({
|
||||
id: row.id,
|
||||
});
|
||||
setFormData(data);
|
||||
const data = await apiStoreProductDetail({
|
||||
id: row.id,
|
||||
});
|
||||
setFormData(data);
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
removeTab();
|
||||
router.push({
|
||||
path: "/store/store_product",
|
||||
});
|
||||
await formRef.value?.validate();
|
||||
const data = { ...formData };
|
||||
mode.value == "edit"
|
||||
? await apiStoreProductEdit(data)
|
||||
: await apiStoreProductAdd(data);
|
||||
removeTab();
|
||||
router.push({
|
||||
path: "/store/store_product",
|
||||
});
|
||||
await formRef.value?.validate();
|
||||
const data = { ...formData };
|
||||
mode.value == "edit"
|
||||
? await apiStoreProductEdit(data)
|
||||
: await apiStoreProductAdd(data);
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
setFormData,
|
||||
getDetail,
|
||||
setFormData,
|
||||
getDetail,
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,144 +1,86 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form class="mb-[-16px]" :model="queryParams" inline>
|
||||
<el-form-item label="商品名称" prop="store_name">
|
||||
<el-input
|
||||
class="w-[280px]"
|
||||
v-model="queryParams.store_name"
|
||||
clearable
|
||||
placeholder="请输入商品名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button
|
||||
v-perms="['store_product.store_product/add']"
|
||||
type="primary"
|
||||
icon="Plus"
|
||||
>
|
||||
<router-link
|
||||
:to="{
|
||||
path: 'store_product_edit',
|
||||
query: { id: 0, mode: 'add' },
|
||||
}"
|
||||
>
|
||||
新增
|
||||
</router-link>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['store_product.store_product/delete']"
|
||||
:disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="商品ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="商品图片" prop="image">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width: 50px; height: 50px" :src="row.image" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="商品名称"
|
||||
prop="store_name"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="分类id"
|
||||
prop="cate_id"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="商品价格"
|
||||
prop="price"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="单位名"
|
||||
prop="unit_name"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="销量" prop="sales" show-overflow-tooltip />
|
||||
<el-table-column label="库存" prop="stock" show-overflow-tooltip />
|
||||
<el-table-column label="状态" prop="is_show" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.is_show ? "上架" : "未上架" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="是否新品"
|
||||
prop="is_new"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="添加时间"
|
||||
prop="add_time"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="是否包邮"
|
||||
prop="is_postage"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="是否删除"
|
||||
prop="is_del"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="成本价" prop="cost" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['store_product.store_product/edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['store_product.store_product/edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDetail(row)"
|
||||
>
|
||||
详情
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['store_product.store_product/delete']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form class="mb-[-16px]" :model="queryParams" inline>
|
||||
<el-form-item label="商品名称" prop="store_name">
|
||||
<el-input class="w-[280px]" v-model="queryParams.store_name" clearable placeholder="请输入商品名称" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['store_product.store_product/add']" type="primary" icon="Plus">
|
||||
<router-link :to="{
|
||||
path: 'store_product_edit',
|
||||
query: { id: 0, mode: 'add' },
|
||||
}">
|
||||
新增
|
||||
</router-link>
|
||||
</el-button>
|
||||
<el-button v-perms="['store_product.store_product/delete']" :disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<Details ref="detailsRef"></Details>
|
||||
</div>
|
||||
</el-button>
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="商品ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="商品图片" prop="image">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width: 50px; height: 50px" :src="row.image" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品名称" prop="store_name" show-overflow-tooltip />
|
||||
<el-table-column label="分类id" prop="cate_id" show-overflow-tooltip />
|
||||
<el-table-column label="商品价格" prop="price" show-overflow-tooltip />
|
||||
<el-table-column label="单位名" prop="unit_name" show-overflow-tooltip />
|
||||
<el-table-column label="销量" prop="sales" show-overflow-tooltip />
|
||||
<el-table-column label="库存" prop="stock" show-overflow-tooltip />
|
||||
<el-table-column label="状态" prop="is_show" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.is_show ? "上架" : "未上架" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否新品" prop="is_new" show-overflow-tooltip />
|
||||
<el-table-column label="添加时间" prop="add_time" show-overflow-tooltip />
|
||||
<el-table-column label="是否包邮" prop="is_postage" show-overflow-tooltip />
|
||||
<el-table-column label="是否删除" prop="is_del" show-overflow-tooltip />
|
||||
<el-table-column label="成本价" prop="cost" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['store_product.store_product/edit']" type="primary" link
|
||||
@click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-perms="['store_product.store_product/edit']" type="primary" link
|
||||
@click="handleDetail(row)">
|
||||
详情
|
||||
</el-button>
|
||||
<el-button v-perms="['store_product.store_product/delete']" type="danger" link
|
||||
@click="handleDelete(row.id)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<Details ref="detailsRef"></Details>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="storeProductLists">
|
||||
import { usePaging } from "@/hooks/usePaging";
|
||||
import { useDictData } from "@/hooks/useDictOptions";
|
||||
import {
|
||||
apiStoreProductLists,
|
||||
apiStoreProductDelete,
|
||||
apiStoreProductLists,
|
||||
apiStoreProductDelete,
|
||||
} from "@/api/store_product";
|
||||
import { timeFormat } from "@/utils/util";
|
||||
import feedback from "@/utils/feedback";
|
||||
|
@ -148,8 +90,8 @@ const detailsRef = ref(null);
|
|||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
store_name: "",
|
||||
cate_id: "",
|
||||
store_name: "",
|
||||
cate_id: "",
|
||||
});
|
||||
|
||||
// 选中数据
|
||||
|
@ -157,7 +99,7 @@ const selectData = ref<any[]>([]);
|
|||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ id }) => id);
|
||||
selectData.value = val.map(({ id }) => id);
|
||||
};
|
||||
|
||||
// 获取字典数据
|
||||
|
@ -165,31 +107,31 @@ const { dictData } = useDictData("");
|
|||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiStoreProductLists,
|
||||
params: queryParams,
|
||||
fetchFun: apiStoreProductLists,
|
||||
params: queryParams,
|
||||
});
|
||||
|
||||
// 添加
|
||||
const handleAdd = async () => {
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 详情
|
||||
const handleDetail = async (data: any) => {
|
||||
detailsRef.value?.open();
|
||||
detailsRef.value?.setFormData();
|
||||
detailsRef.value?.open();
|
||||
detailsRef.value?.setFormData();
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = async (data: any) => {
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (id: number | any[]) => {
|
||||
await feedback.confirm("确定要删除?");
|
||||
await apiStoreProductDelete({ id });
|
||||
getLists();
|
||||
await feedback.confirm("确定要删除?");
|
||||
await apiStoreProductDelete({ id });
|
||||
getLists();
|
||||
};
|
||||
|
||||
getLists();
|
||||
|
|
Loading…
Reference in New Issue