|
|
@ -1,5 +1,5 @@ |
|
|
|
import html, { getProp } from "html"; |
|
|
|
import request, { get, post } from "../../request/index.js"; |
|
|
|
import request, { get, getUrl, post } from "../../request/index.js"; |
|
|
|
import { defineAsyncComponent, ref, reactive, onMounted } from "vue"; |
|
|
|
import { useRoute, useRouter } from "vue-router"; |
|
|
|
import { useI18n } from "vue-i18n"; |
|
|
@ -54,7 +54,7 @@ export default { |
|
|
|
<span>{{item.meta.title}}</span> |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
<el-button @click="click('filter',selectedRows)"> |
|
|
|
<el-button @click="click('filter',selectedRows)" v-if="config.query.hasFilter"> |
|
|
|
<el-icon><ep-filter /></el-icon> |
|
|
|
<span>{{$t('筛选')}}</span> |
|
|
|
</el-button> |
|
|
@ -246,7 +246,7 @@ export default { |
|
|
|
<el-option v-for="item in versions" :value="item.value" :label="item.label" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="选择版本" label-width="80px"> |
|
|
|
<el-form-item label="选择期间" label-width="80px"> |
|
|
|
<el-select v-model="importModel.factory"> |
|
|
|
<el-option v-for="item in versions" :value="item.value" :label="item.label" /> |
|
|
|
</el-select> |
|
|
@ -269,30 +269,30 @@ export default { |
|
|
|
<el-form :model="filterList" inline class="filter"> |
|
|
|
<el-row v-for="(item,index) in filterList"> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-select v-model="item.column" :placeholder="$t('字段')"> |
|
|
|
<el-option |
|
|
|
v-for="(value, prop) in config.edit.schema.properties" |
|
|
|
:value="prop" |
|
|
|
:label="value.title" |
|
|
|
/> |
|
|
|
</el-select> |
|
|
|
</el-col> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-select v-model="item.operator" :placeholder="$t('操作符')"> |
|
|
|
<template v-if="item.column"> |
|
|
|
<el-select clearable :disabled="item.readOnly" v-model="item.column" :placeholder="$t('字段')"> |
|
|
|
<template v-for="(value, prop) in config.edit.schema.properties"> |
|
|
|
<el-option |
|
|
|
v-for="item in getOperators(config.edit.schema.properties[item.column])" |
|
|
|
value="item.value" |
|
|
|
:label="item.label" |
|
|
|
v-if="value.type!=='object'&&value.type!=='array'&&value.input!=='textarea'" |
|
|
|
:value="prop" |
|
|
|
:label="value.title" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
</el-select> |
|
|
|
</el-col> |
|
|
|
<el-col :span="6" v-if="item.column"> |
|
|
|
<el-select clearable :disabled="item.readOnly" v-model="item.action" :placeholder="$t('操作符')"> |
|
|
|
<el-option |
|
|
|
v-for="item in getOperators(config.edit.schema.properties[item.column])" |
|
|
|
:value="item.value" |
|
|
|
:label="item.label" |
|
|
|
/> |
|
|
|
</el-select> |
|
|
|
</el-col> |
|
|
|
<el-col :span="8" v-if="item.column"> |
|
|
|
<app-form-input v-model="item" :schema="config.edit.schema.properties[item.column]" prop="value" /> |
|
|
|
</el-col> |
|
|
|
<el-col :span="2"> |
|
|
|
<el-button circle @click="filterList.splice(index, 1)" v-if="!item.readOnly"> |
|
|
|
<el-col :span="2" v-if="!item.readOnly&&item.action"> |
|
|
|
<el-button circle @click="filterList.splice(index, 1)"> |
|
|
|
<template #icon> |
|
|
|
<ep-close /> |
|
|
|
</template> |
|
|
@ -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;
|
|
|
|