feat: 通知中心

This commit is contained in:
wwz
2025-04-10 14:29:10 +08:00
parent c5f75a20af
commit 5b30b23ad3
11 changed files with 90 additions and 48 deletions

View File

@@ -34,7 +34,7 @@ const Api = {
}, },
edit(data: any) { edit(data: any) {
return request<any>({ return request<any>({
url: `${baseURL}/read`, url: `${baseURL}/syncNotice/read`,
method: "put", method: "put",
data, data,
}); });
@@ -42,7 +42,7 @@ const Api = {
delete(id: string | number) { delete(id: string | number) {
return request<any>({ return request<any>({
url: `${baseURL}/syncNotice/` + id, url: `${baseURL}/syncNotice?id=` + id,
method: "delete", method: "delete",
}); });
}, },

View File

@@ -25,6 +25,7 @@ const contentConfig: IContentConfig = {
// modifyAction: function (data) { // modifyAction: function (data) {
// // return Api.edit(data); // // return Api.edit(data);
// }, // },
indexActionData: {},
pk: "id", pk: "id",
toolbar: [ toolbar: [
"add", "add",

View File

@@ -1,5 +1,5 @@
import type { ISearchConfig } from "@/components/CURD/types"; import type { ISearchConfig } from "@/components/CURD/types";
import consGroupApi from '@/api/product/cons-group' import consGroupApi from "@/api/product/cons-group";
import { statusOptions, payTypeOptions } from "./config"; import { statusOptions, payTypeOptions } from "./config";
const searchConfig: ISearchConfig = { const searchConfig: ISearchConfig = {
pageName: "sys:user", pageName: "sys:user",
@@ -20,14 +20,14 @@ const searchConfig: ISearchConfig = {
initialValue: "", initialValue: "",
initFn(formItem) { initFn(formItem) {
console.log(formItem); console.log(formItem);
consGroupApi.getAllList({}).then(res => { consGroupApi.getAllList({}).then((res) => {
formItem.options = res.map((item: { name: any; id: any; }) => { formItem.options = res.map((item: { name: any; id: any }) => {
return { return {
label: item?.name, label: item?.name,
value: item?.id value: item?.id,
} };
}) });
}) });
}, },
}, },
@@ -42,6 +42,7 @@ const searchConfig: ISearchConfig = {
width: "200px", width: "200px",
}, },
}, },
initialValue: "",
}, },
{ {
type: "date-picker", type: "date-picker",

View File

@@ -136,6 +136,16 @@ function toGoods(id: number | string) {
router.push({ path: "/product/index", query: { id: id } }); router.push({ path: "/product/index", query: { id: id } });
} }
// 默认初始数据
const route = useRoute();
const { conName } = route.query;
if (conName) {
contentConfig.indexActionData = { conName };
if (conName) {
searchConfig.formItems[1].initialValue = conName;
}
}
//统计数据 //统计数据
const gongjiData = reactive({ totalRow: 0 }); const gongjiData = reactive({ totalRow: 0 });
function getTongji(params: IObject | undefined) { function getTongji(params: IObject | undefined) {

View File

@@ -54,15 +54,10 @@ const contentConfig: IContentConfig = {
align: "center", align: "center",
prop: "unitName", prop: "unitName",
}, },
{
label: "所属商品",
align: "center",
prop: "unitName",
},
{ {
label: "供应商", label: "供应商",
align: "center", align: "center",
prop: "unitName", prop: "vendorName",
}, },
{ {
label: "变动原因", label: "变动原因",

View File

@@ -19,7 +19,6 @@ const modalConfig: IModalConfig = {
console.log("提交之前处理", data); console.log("提交之前处理", data);
}, },
formItems: [ formItems: [
{ {
label: "名称", label: "名称",
prop: "name", prop: "name",
@@ -41,7 +40,7 @@ const modalConfig: IModalConfig = {
prop: "telephone", prop: "telephone",
rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }], rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }],
attrs: { attrs: {
placeholder: "请输入联系人名字", placeholder: "请输入联系人电话",
}, },
}, },
{ {
@@ -69,7 +68,6 @@ const modalConfig: IModalConfig = {
placeholder: "请输入排序", placeholder: "请输入排序",
}, },
}, },
], ],
}; };

View File

@@ -57,13 +57,13 @@ const contentConfig: IContentConfig = {
align: "center", align: "center",
prop: "createTime", prop: "createTime",
}, },
{ // {
label: "状态", // label: "状态",
align: "center", // align: "center",
prop: "status", // prop: "status",
templet: 'custom', // templet: 'custom',
slotName: 'switch' // slotName: 'switch'
}, // },
{ {
label: "操作", label: "操作",
@@ -71,7 +71,7 @@ const contentConfig: IContentConfig = {
fixed: "right", fixed: "right",
width: 280, width: 280,
templet: "tool", templet: "tool",
operat: ["edit", 'delete'], operat: ["edit", "delete"],
}, },
], ],
}; };

View File

@@ -19,7 +19,6 @@ const modalConfig: IModalConfig = {
console.log("提交之前处理", data); console.log("提交之前处理", data);
}, },
formItems: [ formItems: [
{ {
label: "名称", label: "名称",
prop: "name", prop: "name",
@@ -41,7 +40,7 @@ const modalConfig: IModalConfig = {
prop: "telephone", prop: "telephone",
rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }], rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }],
attrs: { attrs: {
placeholder: "请输入联系人名字", placeholder: "请输入联系人电话",
}, },
}, },
{ {
@@ -69,7 +68,6 @@ const modalConfig: IModalConfig = {
placeholder: "请输入排序", placeholder: "请输入排序",
}, },
}, },
], ],
}; };

View File

@@ -47,9 +47,7 @@ const contentConfig: IContentConfig = {
{ {
label: "通知类型", label: "通知类型",
align: "center", align: "center",
prop: "type", prop: "title",
slotName: "type",
templet: "custom",
}, },
{ {
label: "是否已读", label: "是否已读",
@@ -63,7 +61,7 @@ const contentConfig: IContentConfig = {
align: "center", align: "center",
prop: "content", prop: "content",
slotName: "content", slotName: "content",
templet: "list", templet: "custom",
}, },
{ {
label: "创建时间", label: "创建时间",

View File

@@ -16,12 +16,16 @@ const searchConfig: ISearchConfig = {
}, },
options: [ options: [
{ {
label: "商品", label: "数据同步",
value: "0", value: "数据同步",
}, },
{ {
label: "耗材", label: "数据变动",
value: "1", value: "数据变动",
},
{
label: "库存预警",
value: "库存预警",
}, },
], ],
}, },

View File

@@ -7,8 +7,24 @@
<page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick" <page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick"
@edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick" @edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick"
@toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange"> @toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange">
<template #type="scope"> <!-- <template #type="scope">
{{ scope.row.type == 1 ? "耗材变动" : "商品变动 " }} <span v-if="scope.row.type == 0">商品新增</span>
<span v-if="scope.row.type == 1">商品编辑</span>
<span v-if="scope.row.type == 2">耗材新增</span>
<span v-if="scope.row.type == 3">耗材编辑</span>
</template> -->
<template #content="scope">
<span>{{ scope.row.title }}</span>
<!-- <span v-if="scope.row.type == 1">商品编辑</span>
<span v-if="scope.row.type == 2">耗材新增</span>
<span v-if="scope.row.type == 3">耗材编辑</span> -->
<div v-for="(item, index) in matchedProducts(scope.row.content)" :key="index">
<span v-for="i in item.map" :key="i.id" style="color: #6161f7" @click="handleContentClick(scope, i)">
{{ i.name }},
</span>
</div>
请及时确认
</template> </template>
<template #isRead="scope"> <template #isRead="scope">
<el-tag :type="scope.row.isRead == 1 ? 'success' : 'info'"> <el-tag :type="scope.row.isRead == 1 ? 'success' : 'info'">
@@ -22,9 +38,11 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
"> ">
<el-button link type="primary" @click="refAddHaocaiTakinShow(scope.row, '')"> <div>
设为已读 <el-button link type="primary" @click="refAddHaocaiTakinShow(scope.row, '')">
</el-button> 设为已读
</el-button>
</div>
<el-button link type="primary" @click="refAddHaocaiTakinShow(scope.row, 'delete')"> <el-button link type="primary" @click="refAddHaocaiTakinShow(scope.row, 'delete')">
删除 删除
</el-button> </el-button>
@@ -49,6 +67,8 @@ import contentConfig from "./config/content";
import editModalConfig from "./config/edit"; import editModalConfig from "./config/edit";
import searchConfig from "./config/search"; import searchConfig from "./config/search";
import Api from "@/api/notifications"; import Api from "@/api/notifications";
import router from "@/router";
import { log } from "console";
const { const {
searchRef, searchRef,
@@ -75,30 +95,47 @@ async function handleEditClick(row: IObject) {
editModalRef.value?.handleDisabled(false); editModalRef.value?.handleDisabled(false);
editModalRef.value?.setModalVisible(); editModalRef.value?.setModalVisible();
// 根据id获取数据进行填充 // 根据id获取数据进行填充
console.log(row);
editModalRef.value?.setFormData({ ...row }); editModalRef.value?.setFormData({ ...row });
} }
1;
// 其他工具栏 // 其他工具栏
function handleToolbarClick(name: string) { function handleToolbarClick(name: string) {
console.log(name);
if (name === "custom1") { if (name === "custom1") {
ElMessage.success("点击了自定义1按钮"); ElMessage.success("点击了自定义1按钮");
} }
} }
const matchedProducts = (data: string) => {
return JSON.parse(data);
};
//删除 //删除
function refAddHaocaiTakinShow(item: any, type: string) { async function refAddHaocaiTakinShow(item: any, type: string) {
console.log(item);
if (type === "delete") { if (type === "delete") {
Api.delete(item.id); Api.delete(item.id);
} else { } else {
Api.edit(item.id); Api.edit({
noticeIdList: [item.id],
});
} }
contentRef.value?.fetchPageData();
} }
// 其他操作列 // 其他操作列
async function handleOperatClick(data: IOperatData) { async function handleOperatClick(data: IOperatData) {
console.log(data); console.log(data);
} }
// Handle content click
function handleContentClick(scope: any, item: any) {
if (scope.type == "1" || scope.type == "0") {
router.push({
path: "/product/addgoods",
query: { goods_id: item.id },
});
} else {
router.push({
path: "/inventory/consumables",
query: { conName: item.name },
});
}
}
</script> </script>