From 86746d655afdac62d9fabbc0ead5d36e3a3a99ad Mon Sep 17 00:00:00 2001
From: wanggang <76527413@qq.com>
Date: Sat, 15 Jul 2023 13:06:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E5=A4=9A=E5=88=97=E6=8E=92?=
=?UTF-8?q?=E5=BA=8F=EF=BC=9B=E5=89=8D=E7=AB=AF=E5=AF=BC=E5=87=BA=E5=AE=8C?=
=?UTF-8?q?=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../vanilla/components/form/form-input.js | 2 +
code/WebApp/vanilla/components/list/index.js | 175 ++++++++++++------
.../vanilla/models/centralized-control.js | 7 +-
code/WebApp/vanilla/models/code-setting.js | 24 ++-
code/WebApp/vanilla/request/index.js | 4 +-
code/WebApp/vanilla/router/routes.js | 19 ++
.../SettleAccountEfCoreRepository.cs | 56 +++---
7 files changed, 186 insertions(+), 101 deletions(-)
diff --git a/code/WebApp/vanilla/components/form/form-input.js b/code/WebApp/vanilla/components/form/form-input.js
index f4b0e543..24a7112c 100644
--- a/code/WebApp/vanilla/components/form/form-input.js
+++ b/code/WebApp/vanilla/components/form/form-input.js
@@ -56,6 +56,7 @@ export default {
{{item.meta.title}}
-
+
{{$t('筛选')}}
@@ -246,7 +246,7 @@ export default {
-
+
@@ -269,30 +269,30 @@ export default {
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
@@ -405,7 +405,7 @@ export default {
const versions = ref([]);
const fileList = ref([]);
const getSortModel = (model) => {
- model.orderBy
+ (model.sorting ?? "")
.split(",")
.map((o) => o.trim())
.filter((o) => o)
@@ -418,7 +418,7 @@ export default {
const getColumns = (schema) => {
Object.keys(schema.properties).forEach((propertyName) => {
const property = schema.properties[propertyName];
- if (property.type !== "object" && property.type !== "array" && !property.hidden && property.showForList) {
+ if (property.showForList || (property.type !== "object" && property.type !== "array" && !property.hidden)) {
columns.value.push({ name: propertyName, title: property.title, checked: true });
}
});
@@ -434,41 +434,21 @@ export default {
} else {
sortColumns.value.set(prop, order);
}
- queryModel.value.orderBy = Array.from(sortColumns.value)
+ queryModel.value.sorting = Array.from(sortColumns.value)
.map((o) => capitalize(o[0]) + (o[1] === "ascending" ? "" : ` DESC`))
.join(",");
await load();
};
const showColumn = (item, prop) => {
- if (item.showForList === true) {
- return true;
- }
- return (
- item.type !== "object" &&
- item.type !== "array" &&
- !item.hidden &&
- columns.value.findIndex((o) => o.name === prop && o.checked) >= 0
- );
+ return columns.value.some((o) => o.name === prop && o.checked);
};
-
const handleSelectionChange = (rows) => (selectedRows.value = rows);
const load = async () => {
tableLoading.value = true;
try {
const url = config.query.url;
const method = config.query.method;
- //
- queryModel.value.maxResultCount = pageModel.pageSize;
- queryModel.value.skipCount = (pageModel.pageIndex - 1) * pageModel.pageSize;
- //
- const postData = JSON.parse(JSON.stringify(queryModel.value));
- postData.filters = filterList.value.filter((o) => o.property && o.value);
- if (postData.items) {
- delete postData["items"];
- }
- if (postData.query?.id) {
- delete postData.query["id"];
- }
+ const postData = buildQuery();
const listData = (await request(url, postData, { method })).data;
const items = listData.items;
if (tableSchema.value.isTree) {
@@ -570,8 +550,18 @@ export default {
await load();
} else if (item.path === "export") {
//export
- editFormTitle.value = `${t(item.path)}${querySchema.value?.title}`;
- dialogVisible.value = true;
+ if ((item.pattern = "paged")) {
+ const url = config.edit.exportUrl;
+ const method = config.edit.exportMethod;
+ const postData = buildQuery();
+ const response = await request(url, postData, { method });
+ if (!response.errors) {
+ window.open(getUrl(`settleaccount/getblobfile/download/${response.data}`));
+ }
+ } else {
+ editFormTitle.value = `${t(item.path)}${querySchema.value?.title}`;
+ dialogVisible.value = true;
+ }
} else if (item.path === "import") {
//import
try {
@@ -682,9 +672,8 @@ export default {
subDrawer.value = true;
}
};
- const download = (response) => {
- const downloadUrl = window.URL.createObjectURL(response.data);
- const filename = response.filename;
+ const download = (url, filename) => {
+ const downloadUrl = window.URL.createObjectURL(url);
let link = document.createElement("a");
link.href = downloadUrl;
link.download = filename;
@@ -694,7 +683,7 @@ export default {
const getImportTemplate = async () => {
const url = `${baseUrl}/${editFormMode.value}`;
const response = await get(url);
- download(response);
+ download(url, response.filename);
};
const handleChange = (uploadFile, uploadFiles) => {
fileList.value = uploadFiles;
@@ -708,22 +697,85 @@ export default {
};
const pushfilterList = () => {
filterList.value.push({
- logic: "",
+ logic: "and",
column: "",
- action: "",
- value: "",
+ action: "equal",
+ value: null,
});
};
+ const logic = [
+ { value: "and", label: "且" },
+ { value: "or", label: "或" },
+ ];
+ const operators = [
+ {
+ value: "equal",
+ label: "等于",
+ },
+ {
+ value: "notEqual",
+ label: "不等于",
+ },
+ {
+ value: "biggerThan",
+ label: "大于",
+ },
+ {
+ value: "smallThan",
+ label: "小于",
+ },
+ {
+ value: "biggerThanOrEqual",
+ label: "大于等于",
+ },
+ {
+ value: "smallThanOrEqual",
+ label: "小于等于",
+ },
+ {
+ value: "like",
+ label: "类似于",
+ },
+ {
+ value: "notLike",
+ label: "不类似于",
+ },
+ {
+ value: "in",
+ label: "包含于",
+ },
+ {
+ value: "notIn",
+ label: "不包含于",
+ },
+ ];
const getOperators = (schema) => {
- if (schema.type === "int") {
+ const values = ["equal", "notEqual"];
+ if (schema.type === "string") {
+ values.push("like", "notLike");
+ if (schema.input && ["year", "month", "date", "datetime"].includes(schema.input)) {
+ values.push("biggerThan", "smallThan", "biggerThanOrEqual", "smallThanOrEqual");
+ }
+ } else if (schema.type === "boolean") {
+ } else {
+ values.push("biggerThan", "smallThan", "biggerThanOrEqual", "smallThanOrEqual");
}
- return [
- {
- value: 0,
- label: "等于",
- },
- ];
+ return operators.filter((o) => values.includes(o.value));
};
+ function buildQuery() {
+ queryModel.value.maxResultCount = pageModel.pageSize;
+ queryModel.value.skipCount = (pageModel.pageIndex - 1) * pageModel.pageSize;
+ //
+ const postData = JSON.parse(JSON.stringify(queryModel.value));
+ postData.filters = filterList.value.filter((o) => o.column && o.action && (o.value || o.value === false));
+ if (postData.items) {
+ delete postData["items"];
+ }
+ if (postData.query?.id) {
+ delete postData.query["id"];
+ }
+ return postData;
+ }
onMounted(async () => {
if (route.meta.children?.length) {
for (const item of route.meta.children) {
@@ -734,7 +786,8 @@ export default {
}
//
queryModel.value = schemaToModel(config.query.schema);
- filterList.value = queryModel.value.filters;
+ getSortModel(queryModel.value);
+ filterList.value = queryModel.value?.filters ?? [];
//pushfilterList();
// if (!querySchema.value) {
// const vm = (await get(indexUrl)).data;
diff --git a/code/WebApp/vanilla/models/centralized-control.js b/code/WebApp/vanilla/models/centralized-control.js
index b32e730f..5e6a6dd2 100644
--- a/code/WebApp/vanilla/models/centralized-control.js
+++ b/code/WebApp/vanilla/models/centralized-control.js
@@ -70,6 +70,7 @@ export default function () {
query: {
url: queryUrl,
method: queryMethod,
+ hasFilter: true,
schema: {
title: "通用代码",
type: "object",
@@ -96,10 +97,10 @@ export default function () {
},
default: [
{
- logic: 0,
+ logic: "and",
column: "year",
- action: 6,
- value: "",
+ action: "like",
+ value: null,
readOnly: true,
},
],
diff --git a/code/WebApp/vanilla/models/code-setting.js b/code/WebApp/vanilla/models/code-setting.js
index aabb1858..a6375733 100644
--- a/code/WebApp/vanilla/models/code-setting.js
+++ b/code/WebApp/vanilla/models/code-setting.js
@@ -46,34 +46,29 @@ const createUrl = `${baseUrl}/create`;
const updateUrl = `${baseUrl}/update/%s`;
const deleteUrl = `${baseUrl}/delete-list`;
const importUrl = `${baseUrl}/code-setting-upload-excel-import`;
+const exportUrl = `${baseUrl}/export`;
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST";
const updateMethod = "POST";
const deleteMethod = "POST";
const importMethod = "POST";
+const exportMethod = "POST";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
+ hasFilter: true,
schema: {
title: "通用代码",
type: "object",
properties: {
- project: {
- type: "string",
- },
- value: {
- type: "string",
- },
- description: {
- type: "string",
- },
filters: {
title: "项目",
type: "array",
+ hidden: true,
items: {
type: "object",
properties: {
@@ -91,6 +86,15 @@ export default function () {
},
},
},
+ default: [
+ {
+ logic: "and",
+ column: "project",
+ action: "like",
+ value: null,
+ readOnly: true,
+ },
+ ],
},
skipCount: {
hidden: true,
@@ -115,11 +119,13 @@ export default function () {
updateUrl,
deleteUrl,
importUrl,
+ exportUrl,
detailsMethod,
createMethod,
updateMethod,
deleteMethod,
importMethod,
+ exportMethod,
schema: schema,
},
};
diff --git a/code/WebApp/vanilla/request/index.js b/code/WebApp/vanilla/request/index.js
index efd5bcf8..a3e4efa6 100644
--- a/code/WebApp/vanilla/request/index.js
+++ b/code/WebApp/vanilla/request/index.js
@@ -52,6 +52,8 @@ const getResult = async (response) => {
const contentType = response.headers.get("Content-Type");
if (contentType.indexOf("application/json") > -1) {
result.data = await response.json();
+ } else if (contentType.indexOf("text/plain") > -1) {
+ result.data = await response.text();
} else if (contentType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
result.data = await response.blob();
result.filename = getFileName(response.headers.get("Content-Disposition"));
@@ -145,4 +147,4 @@ async function request(url, data, options, withoutToken = false) {
}
export default request;
-export { get, post };
+export { get, post, getUrl };
diff --git a/code/WebApp/vanilla/router/routes.js b/code/WebApp/vanilla/router/routes.js
index 319f4187..6a2777dc 100644
--- a/code/WebApp/vanilla/router/routes.js
+++ b/code/WebApp/vanilla/router/routes.js
@@ -180,6 +180,15 @@ export default [
title: "通用代码",
icon: "file",
children: [
+ {
+ path: "query",
+ meta: {
+ type: "button",
+ title: "查询",
+ icon: "file",
+ isTop: true,
+ },
+ },
{
path: "create",
meta: {
@@ -207,6 +216,16 @@ export default [
isTop: true,
},
},
+ {
+ path: "export",
+ meta: {
+ type: "button",
+ title: "导出",
+ icon: "file",
+ isTop: true,
+ pattern: "paged",
+ },
+ },
],
},
},
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountEfCoreRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountEfCoreRepository.cs
index 6a3edbcf..4256a044 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountEfCoreRepository.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountEfCoreRepository.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
@@ -92,45 +93,46 @@ namespace Win.Sfs.SettleAccount.Repository
protected static IQueryable GetSortingQueryable(IQueryable entities, string sorting)
{
- if (string.IsNullOrEmpty(sorting))
- {
- entities = entities.OrderByDescending("Id");
- }
- else
- {
+ return string.IsNullOrEmpty(sorting)?entities:DynamicQueryableExtensions.OrderBy(entities, sorting);
+ //if (string.IsNullOrEmpty(sorting))
+ //{
+ // entities = entities.OrderByDescending("Id");
+ //}
+ //else
+ //{
- var sortParams = sorting?.Split(' ');
- var sortName = sortParams[0];
+ // var sortParams = sorting?.Split(' ');
+ // var sortName = sortParams[0];
- Type t = typeof(TEntity);
- var _first=t.GetProperties().Where(p => p.Name.ToUpper() == sortName.ToUpper()).FirstOrDefault();
- if (_first != null)
- {
- sortName = _first.Name;
- }
+ // Type t = typeof(TEntity);
+ // var _first=t.GetProperties().Where(p => p.Name.ToUpper() == sortName.ToUpper()).FirstOrDefault();
+ // if (_first != null)
+ // {
+ // sortName = _first.Name;
+ // }
- bool isDesc;
- if (sortParams.Length > 1)
- {
- var sortDirection = sortParams[1];
- isDesc = sortDirection.ToUpper().Contains("DESC")?true:false;
- }
- else
- {
- isDesc = true;
- }
+ // bool isDesc;
+ // if (sortParams.Length > 1)
+ // {
+ // var sortDirection = sortParams[1];
+ // isDesc = sortDirection.ToUpper().Contains("DESC")?true:false;
+ // }
+ // else
+ // {
+ // isDesc = true;
+ // }
- entities = isDesc ? entities.OrderByDescending(sortName) : entities.OrderBy(sortName);
- }
+ // entities = isDesc ? entities.OrderByDescending(sortName) : entities.OrderBy(sortName);
+ //}
- return entities;
+ //return entities;
}