feat: 同步规则优化

This commit is contained in:
GaoHao
2025-04-11 17:25:02 +08:00
parent 85eba13919
commit 688f30635b
8 changed files with 59 additions and 43 deletions

View File

@@ -20,7 +20,15 @@ const contentConfig: IContentConfig = {
return Api.edit(data); return Api.edit(data);
}, },
pk: "id", pk: "id",
toolbar: ["add"], toolbar: [
{
icon: "plus",
text: "新增",
type: "primary",
name: "add",
auth: "import",
},
],
defaultToolbar: ["refresh", "filter", "search"], defaultToolbar: ["refresh", "filter", "search"],
cols: [ cols: [
// { type: "selection", width: 50, align: "center" }, // { type: "selection", width: 50, align: "center" },
@@ -49,7 +57,7 @@ const contentConfig: IContentConfig = {
fixed: "right", fixed: "right",
width: 280, width: 280,
templet: "tool", templet: "tool",
operat: ["edit"], operat: [{ text: "编辑", icon: 'edit', name: "edit"}],
}, },
], ],
}; };

View File

@@ -89,13 +89,13 @@ const {
} = usePage(); } = usePage();
if (isSyncStatus()) { if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){ contentConfig.toolbar[0].hidden = true
contentConfig.toolbar?.splice(0, 1) contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true
} } else {
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("edit") != -1){ contentConfig.toolbar[0].hidden = false
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(0, 1) contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false
}
} }
// 新增 // 新增
async function handleAddClick() { async function handleAddClick() {
addModalRef.value?.setModalVisible(); addModalRef.value?.setModalVisible();

View File

@@ -28,7 +28,13 @@ const contentConfig: IContentConfig = {
indexActionData: {}, indexActionData: {},
pk: "id", pk: "id",
toolbar: [ toolbar: [
"add", {
icon: "plus",
text: "新增",
type: "primary",
name: "add",
auth: "import",
},
{ {
icon: "refresh", icon: "refresh",
text: "同步", text: "同步",

View File

@@ -125,20 +125,16 @@ if (conName) {
searchConfig.formItems[1].initialValue = conName; searchConfig.formItems[1].initialValue = conName;
} }
} }
console.log(isSyncStatus())
console.log(contentConfig)
if (isSyncStatus()) { if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){ contentConfig.toolbar[0].hidden = true
contentConfig.toolbar?.splice(0, 1) contentConfig.toolbar[1].hidden = false
}
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("delete") != -1){
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(2, 1)
}
} else { } else {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("sync") != -1){ contentConfig.toolbar[0].hidden = false
contentConfig.toolbar?.splice(1, 1) contentConfig.toolbar[1].hidden = true
}
} }
//统计数据 //统计数据
const gongjiData = reactive({ totalRow: 0 }); const gongjiData = reactive({ totalRow: 0 });
function getTongji(params: IObject | undefined) { function getTongji(params: IObject | undefined) {

View File

@@ -23,7 +23,15 @@ const contentConfig: IContentConfig = {
return Api.edit(data); return Api.edit(data);
}, },
pk: "id", pk: "id",
toolbar: ["add"], toolbar: [
{
icon: "plus",
text: "新增",
type: "primary",
name: "add",
auth: "import",
},
],
defaultToolbar: ["refresh", "filter", "search"], defaultToolbar: ["refresh", "filter", "search"],
cols: [ cols: [
// { type: "selection", width: 50, align: "center" }, // { type: "selection", width: 50, align: "center" },
@@ -71,7 +79,7 @@ const contentConfig: IContentConfig = {
fixed: "right", fixed: "right",
width: 280, width: 280,
templet: "tool", templet: "tool",
operat: ["edit", "delete"], operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}],
}, },
], ],
}; };

View File

@@ -87,14 +87,17 @@ const {
handleSearchClick, handleSearchClick,
handleFilterChange, handleFilterChange,
} = usePage(); } = usePage();
if (isSyncStatus()) { if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){ contentConfig.toolbar[0].hidden = true
contentConfig.toolbar?.splice(0, 1) contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true
} contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = true
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("edit") != -1){ } else {
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(0, 1) contentConfig.toolbar[0].hidden = false
} contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false
contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false
} }
// 新增 // 新增
async function handleAddClick() { async function handleAddClick() {
addModalRef.value?.setModalVisible(); addModalRef.value?.setModalVisible();

View File

@@ -200,21 +200,16 @@ let datas = reactive({
remark: "", remark: "",
images: [] images: []
}); });
console.log(isSyncStatus())
console.log(contentConfig.toolbar)
if (isSyncStatus()) { if (isSyncStatus()) {
if (JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1) { contentConfig.toolbar[0].hidden = true
// contentConfig.toolbar?.splice(0, 1) contentConfig.toolbar[1].hidden = false
} contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true
if (JSON.stringify(contentConfig.cols[contentConfig.cols.length - 1].operat)?.indexOf("delete") != -1) {
contentConfig.cols[contentConfig.cols.length - 1].operat?.splice(2, 1)
}
} else { } else {
if (JSON.stringify(contentConfig.toolbar)?.indexOf("sync") != -1) { contentConfig.toolbar[0].hidden = false
// contentConfig.toolbar?.splice(1, 1) contentConfig.toolbar[1].hidden = true
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false
} }
}
console.log(contentConfig.toolbar)
onMounted(() => { onMounted(() => {
console.log(route.query); console.log(route.query);

View File

@@ -120,7 +120,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
fixed: "right", fixed: "right",
width: 280, width: 280,
templet: "tool", templet: "tool",
operat: [{ text: "报损" }, "edit", "delete"], operat: [{ text: "报损", name: ''}, { text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}],
}, },
], ],
}; };