|
@ -1,10 +1,9 @@ |
|
|
import html, { getProp } from "html"; |
|
|
import html, { getProp } from "html"; |
|
|
import request, { get, getUrl, post } from "../../request/index.js"; |
|
|
import request, { getUrl } from "../../request/index.js"; |
|
|
import { defineAsyncComponent, ref, reactive, onMounted, watch } from "vue"; |
|
|
import { defineAsyncComponent, ref, reactive, onMounted, watch, nextTick } from "vue"; |
|
|
import { useRoute, useRouter } from "vue-router"; |
|
|
import { useRoute, useRouter } from "vue-router"; |
|
|
import { useI18n } from "vue-i18n"; |
|
|
import { useI18n } from "vue-i18n"; |
|
|
import { listToTree, schemaToModel, importFunction, format } from "../../utils/index.js"; |
|
|
import { listToTree, schemaToModel, importFunction, format } from "../../utils/index.js"; |
|
|
import qs from "../../lib/qs/shim.js"; |
|
|
|
|
|
import { camelCase, capitalize } from "lodash"; |
|
|
import { camelCase, capitalize } from "lodash"; |
|
|
import { ElMessage, ElMessageBox } from "element-plus"; |
|
|
import { ElMessage, ElMessageBox } from "element-plus"; |
|
|
|
|
|
|
|
@ -17,8 +16,10 @@ export default { |
|
|
AppFormInput: defineAsyncComponent(() => import("../form/form-input.js")), |
|
|
AppFormInput: defineAsyncComponent(() => import("../form/form-input.js")), |
|
|
}, |
|
|
}, |
|
|
template: html` |
|
|
template: html` |
|
|
<div v-loading="tableLoading"> |
|
|
<div class="c-list" v-loading="tableLoading" style="height:100%;"> |
|
|
<el-row> |
|
|
<div style="height:calc(100% - 52px);"> |
|
|
|
|
|
<el-scrollbar ref="listScrollbarRef" :always="true" style="height:100%;"> |
|
|
|
|
|
<el-row style="padding-bottom:20px;"> |
|
|
<el-col> |
|
|
<el-col> |
|
|
<app-form inline mode="query" label-position="left" :schema="config.query.schema" v-model="queryModel" @submit="load" :hideButton="true" :isQueryForm="true"> |
|
|
<app-form inline mode="query" label-position="left" :schema="config.query.schema" v-model="queryModel" @submit="load" :hideButton="true" :isQueryForm="true"> |
|
|
<template v-for="item in filterList.filter(o=>!o.hidden&&o.readOnly)"> |
|
|
<template v-for="item in filterList.filter(o=>!o.hidden&&o.readOnly)"> |
|
@ -27,10 +28,6 @@ export default { |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</template> |
|
|
</template> |
|
|
</app-form> |
|
|
</app-form> |
|
|
</el-col> |
|
|
|
|
|
</el-row> |
|
|
|
|
|
<el-row style="padding-bottom:20px;"> |
|
|
|
|
|
<el-col> |
|
|
|
|
|
<template v-for="item in buttons"> |
|
|
<template v-for="item in buttons"> |
|
|
<el-button |
|
|
<el-button |
|
|
:class="item.meta.htmlClass??'el-button--primary'" |
|
|
:class="item.meta.htmlClass??'el-button--primary'" |
|
@ -49,9 +46,6 @@ export default { |
|
|
<slot name="tableButtons" :rows="selectedRows"></slot> |
|
|
<slot name="tableButtons" :rows="selectedRows"></slot> |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
<el-row> |
|
|
|
|
|
<el-col> |
|
|
|
|
|
<el-scrollbar> |
|
|
|
|
|
<el-table |
|
|
<el-table |
|
|
:key="tableKey" |
|
|
:key="tableKey" |
|
|
ref="tableRef" |
|
|
ref="tableRef" |
|
@ -64,8 +58,9 @@ export default { |
|
|
table-layout="auto" |
|
|
table-layout="auto" |
|
|
border |
|
|
border |
|
|
fit |
|
|
fit |
|
|
|
|
|
style="width:calc(100% - 26px);" |
|
|
> |
|
|
> |
|
|
<el-table-column fixed="left" type="selection" :selectable="config.table.selectable" /> |
|
|
<el-table-column v-if="!config.table.schema.disableSelection" fixed="left" type="selection" :selectable="config.table.selectable" /> |
|
|
<el-table-column type="index" :label="$t('rowIndex')"> |
|
|
<el-table-column type="index" :label="$t('rowIndex')"> |
|
|
<template #default="scope"> {{ (pageModel.pageIndex - 1) * pageModel.pageSize + scope.$index + 1 }} </template> |
|
|
<template #default="scope"> {{ (pageModel.pageIndex - 1) * pageModel.pageSize + scope.$index + 1 }} </template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
@ -140,30 +135,27 @@ export default { |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
|
</el-table> |
|
|
</el-table> |
|
|
</el-scrollbar> |
|
|
</el-scrollbar> |
|
|
</el-col> |
|
|
</div> |
|
|
</el-row> |
|
|
<div style="height:52px;padding-top:20px;"> |
|
|
<el-row> |
|
|
<el-scrollbar> |
|
|
<el-col> |
|
|
|
|
|
<el-pagination |
|
|
<el-pagination |
|
|
v-model:currentPage="pageModel.pageIndex" |
|
|
v-model:currentPage="pageModel.pageIndex" |
|
|
v-model:page-size="pageModel.pageSize" |
|
|
v-model:page-size="pageModel.pageSize" |
|
|
:total="pageModel.total" |
|
|
:total="pageModel.total" |
|
|
:page-sizes="pageModel.sizeList" |
|
|
:page-sizes="pageModel.sizeList" |
|
|
class="justify-end" |
|
|
|
|
|
:background="true" |
|
|
:background="true" |
|
|
layout="total, sizes, prev, pager, next, jumper" |
|
|
layout="total, sizes, prev, pager, next, jumper" |
|
|
@size-change="onPageSizeChange" |
|
|
@size-change="onPageSizeChange" |
|
|
@current-change="onPageIndexChange" |
|
|
@current-change="onPageIndexChange" |
|
|
style="margin-top:20px" |
|
|
|
|
|
/> |
|
|
/> |
|
|
</el-col> |
|
|
</el-scrollbar> |
|
|
</el-row> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<el-drawer v-model="filterDrawer" :close-on-click-modal="false" destroy-on-close @close="tableRef.doLayout()"> |
|
|
<el-drawer v-model="filterDrawer" :close-on-click-modal="false" destroy-on-close @close="tableRef.doLayout()"> |
|
|
<template #header> <span class="el-dialog__title"> {{$t('filter')}} </span> </template> |
|
|
<template #header> <span class="el-dialog__title"> {{$t('filter')}} </span> </template> |
|
|
<el-scrollbar> |
|
|
<el-scrollbar> |
|
|
<el-row> |
|
|
<el-row> |
|
|
<el-col style="max-height:calc(100vh - 180px);"> |
|
|
<el-col style="max-height:calc(100% - 180px);"> |
|
|
<el-form inline> |
|
|
<el-form inline> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-button type="primary" @click="columns.forEach(o=>o.checked=true)"> {{$t('selectAll')}} </el-button> |
|
|
<el-button type="primary" @click="columns.forEach(o=>o.checked=true)"> {{$t('selectAll')}} </el-button> |
|
@ -194,10 +186,10 @@ export default { |
|
|
</span> |
|
|
</span> |
|
|
</template> |
|
|
</template> |
|
|
</el-drawer> |
|
|
</el-drawer> |
|
|
<el-dialog v-model="dialogVisible" align-center destroy-on-close :close-on-click-modal="false" style="width:auto;min-width:500px;max-width:1000px;"> |
|
|
<el-dialog v-model="dialogVisible" align-center destroy-on-close :close-on-click-modal="false" style="width:auto;width:700px;"> |
|
|
<template #header> <span class="el-dialog__title"> {{editFormTitle}} </span> </template> |
|
|
<template #header> <span class="el-dialog__title"> {{editFormTitle}} </span> </template> |
|
|
<el-row v-loading="editFormloading"> |
|
|
<el-row v-loading="editFormloading"> |
|
|
<el-col style="max-height:calc(100vh - 180px );min-height:100%;"> |
|
|
<el-col style="max-height:calc(100% - 180px );min-height:100%;"> |
|
|
<el-scrollbar> |
|
|
<el-scrollbar> |
|
|
<template v-if="editFormMode==='create'||editFormMode==='update'||editFormMode==='details'"> |
|
|
<template v-if="editFormMode==='create'||editFormMode==='update'||editFormMode==='details'"> |
|
|
<app-form |
|
|
<app-form |
|
@ -326,6 +318,7 @@ export default { |
|
|
props: ["modelValue", "config", "querySchema", "query", "buttons"], |
|
|
props: ["modelValue", "config", "querySchema", "query", "buttons"], |
|
|
emits: ["command"], |
|
|
emits: ["command"], |
|
|
setup(props, context) { |
|
|
setup(props, context) { |
|
|
|
|
|
const listScrollbarRef = ref(null); |
|
|
/*变量定义*/ |
|
|
/*变量定义*/ |
|
|
// 配置
|
|
|
// 配置
|
|
|
const config = reactive(props.config); |
|
|
const config = reactive(props.config); |
|
@ -406,6 +399,39 @@ export default { |
|
|
const defaultImportModel = schemaToModel(config.import.schema); |
|
|
const defaultImportModel = schemaToModel(config.import.schema); |
|
|
const importModel = ref(null); |
|
|
const importModel = ref(null); |
|
|
const versions = ref([]); |
|
|
const versions = ref([]); |
|
|
|
|
|
const onClick = async (method, confirMmessage = "确认操作吗?", reload = true) => { |
|
|
|
|
|
try { |
|
|
|
|
|
if (confirMmessage) { |
|
|
|
|
|
await ElMessageBox.confirm(confirMmessage, "提示", { |
|
|
|
|
|
type: "warning", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
tableLoading.value = true; |
|
|
|
|
|
let result = null; |
|
|
|
|
|
if (method.constructor.name == "AsyncFunction") { |
|
|
|
|
|
result = await method(); |
|
|
|
|
|
} else { |
|
|
|
|
|
result = method(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!result.errors) { |
|
|
|
|
|
if (!result.data?.code || result.data.code === 200) { |
|
|
|
|
|
if (reload) { |
|
|
|
|
|
pageModel.pageIndex = 1; |
|
|
|
|
|
await load(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if (error === "cancel") { |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
type: "info", |
|
|
|
|
|
message: "操作取消", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} finally { |
|
|
|
|
|
tableLoading.value = false; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
const getSortModel = (model) => { |
|
|
const getSortModel = (model) => { |
|
|
(model.sorting ?? "") |
|
|
(model.sorting ?? "") |
|
|
.split(",") |
|
|
.split(",") |
|
@ -466,30 +492,30 @@ export default { |
|
|
pageModel.total = listData.totalCount; |
|
|
pageModel.total = listData.totalCount; |
|
|
//data.value = listData;
|
|
|
//data.value = listData;
|
|
|
tableKey.value = !tableKey.value; |
|
|
tableKey.value = !tableKey.value; |
|
|
|
|
|
nextTick(() => { |
|
|
|
|
|
tableRef.value.doLayout(); |
|
|
|
|
|
nextTick(() => listScrollbarRef.value.update()); |
|
|
|
|
|
}); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(error); |
|
|
console.log(error); |
|
|
} finally { |
|
|
} finally { |
|
|
tableLoading.value = false; |
|
|
tableLoading.value = false; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
const onPageIndexChange = async () => await load(); |
|
|
const reload = async () => { |
|
|
const onPageSizeChange = async () => { |
|
|
|
|
|
pageModel.pageIndex = 1; |
|
|
pageModel.pageIndex = 1; |
|
|
await load(); |
|
|
await load(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
const onPageIndexChange = async () => await load(); |
|
|
|
|
|
const onPageSizeChange = async () => { |
|
|
|
|
|
await reload(); |
|
|
|
|
|
}; |
|
|
const click = async (item, rows) => { |
|
|
const click = async (item, rows) => { |
|
|
editFormloading.value = true; |
|
|
editFormloading.value = true; |
|
|
editFormMode.value = item.path ?? item; |
|
|
editFormMode.value = item.path ?? item; |
|
|
if (item.path === "query") { |
|
|
if (item.path === "query") { |
|
|
//list
|
|
|
//list
|
|
|
await load(); |
|
|
await load(); |
|
|
} else if (item.path === "details") { |
|
|
|
|
|
//details
|
|
|
|
|
|
const url = `${baseUrl}/${item.path}?${qs.stringify({ id: rows[0].id })}`; |
|
|
|
|
|
editFormSchema.value = (await get(url)).data; |
|
|
|
|
|
editFormModel.value = (await post(url)).data; |
|
|
|
|
|
editFormTitle.value = `${config.edit.schema.title}${t("details")}`; |
|
|
|
|
|
dialogVisible.value = true; |
|
|
|
|
|
} else if (item.path === "create" || item.path === "update") { |
|
|
} else if (item.path === "create" || item.path === "update") { |
|
|
//create
|
|
|
//create
|
|
|
if (item.path === "create") { |
|
|
if (item.path === "create") { |
|
@ -514,22 +540,21 @@ export default { |
|
|
type: "warning", |
|
|
type: "warning", |
|
|
}); |
|
|
}); |
|
|
tableLoading.value = true; |
|
|
tableLoading.value = true; |
|
|
const response = await request( |
|
|
const result = await request( |
|
|
url, |
|
|
url, |
|
|
rows.map((o) => o.id), |
|
|
rows.map((o) => o.id), |
|
|
{ method: config.edit.deleteMethod } |
|
|
{ method: config.edit.deleteMethod }, |
|
|
|
|
|
true |
|
|
); |
|
|
); |
|
|
if (!response.errors) { |
|
|
if (!result.data?.code || result.data.code === 200) { |
|
|
ElMessage({ |
|
|
pageModel.pageIndex = 1; |
|
|
type: "info", |
|
|
await reload(); |
|
|
message: "操作完毕", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
if (error === "cancel") { |
|
|
if (error === "cancel") { |
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
type: "info", |
|
|
type: "info", |
|
|
message: "删除取消", |
|
|
message: "操作取消", |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} finally { |
|
|
} finally { |
|
@ -541,16 +566,13 @@ export default { |
|
|
await ElMessageBox.confirm(format("确认删除当前行数据吗?", rows[0]), "提示", { |
|
|
await ElMessageBox.confirm(format("确认删除当前行数据吗?", rows[0]), "提示", { |
|
|
type: "warning", |
|
|
type: "warning", |
|
|
}); |
|
|
}); |
|
|
await request(url, null, { method: config.edit.deleteMethod }); |
|
|
await request(url, null, { method: config.edit.deleteMethod }, true); |
|
|
ElMessage({ |
|
|
await reload(); |
|
|
type: "info", |
|
|
|
|
|
message: "操作完毕", |
|
|
|
|
|
}); |
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
if (error === "cancel") { |
|
|
if (error === "cancel") { |
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
type: "info", |
|
|
type: "info", |
|
|
message: "删除取消", |
|
|
message: "操作取消", |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -561,10 +583,12 @@ export default { |
|
|
const url = config.edit.exportUrl; |
|
|
const url = config.edit.exportUrl; |
|
|
const method = config.edit.exportMethod; |
|
|
const method = config.edit.exportMethod; |
|
|
const postData = buildQuery(); |
|
|
const postData = buildQuery(); |
|
|
|
|
|
await onClick(async () => { |
|
|
const response = await request(url, postData, { method }); |
|
|
const response = await request(url, postData, { method }); |
|
|
if (!response.errors) { |
|
|
if (!response.errors) { |
|
|
window.open(getUrl(`settleaccount/getblobfile/download/${response.data}`)); |
|
|
window.open(getUrl(`settleaccount/getblobfile/download/${response.data}`)); |
|
|
} |
|
|
} |
|
|
|
|
|
}, "确认导出?"); |
|
|
} else if (item.meta.pattern === "file") { |
|
|
} else if (item.meta.pattern === "file") { |
|
|
window.open(getUrl(`settleaccount/getblobfile/download/${rows[0]["downFileName"]}`)); |
|
|
window.open(getUrl(`settleaccount/getblobfile/download/${rows[0]["downFileName"]}`)); |
|
|
} else if ((item.meta.pattern = "row")) { |
|
|
} else if ((item.meta.pattern = "row")) { |
|
@ -605,21 +629,23 @@ export default { |
|
|
try { |
|
|
try { |
|
|
const valid = await editFormRef.value.validate(); |
|
|
const valid = await editFormRef.value.validate(); |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
editFormloading.value = true; |
|
|
await onClick( |
|
|
|
|
|
async () => { |
|
|
let url = (editFormMode.value === "create" ? config.edit.createUrl : config.edit.updateUrl) ?? config.query.url; |
|
|
let url = (editFormMode.value === "create" ? config.edit.createUrl : config.edit.updateUrl) ?? config.query.url; |
|
|
if (editFormMode.value === "update") { |
|
|
if (editFormMode.value === "update") { |
|
|
url = format(url, editFormModel.value.id); |
|
|
url = format(url, editFormModel.value.id); |
|
|
} |
|
|
} |
|
|
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod; |
|
|
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod; |
|
|
const response = await request(url, editFormModel.value, { method }); |
|
|
const result = await request(url, editFormModel.value, { method }, true); |
|
|
if (response.errors) { |
|
|
if (!result.errors) { |
|
|
ElMessageBox.alert(`错误:${response.errors?.error?.message}`, `代码:${response.errors?.error?.code}`); |
|
|
|
|
|
//model.errors = response.errors; //??
|
|
|
|
|
|
} else { |
|
|
|
|
|
await load(); |
|
|
|
|
|
editFormMode.value = null; |
|
|
|
|
|
dialogVisible.value = false; |
|
|
dialogVisible.value = false; |
|
|
|
|
|
editFormMode.value = null; |
|
|
|
|
|
await reload(); |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
null, |
|
|
|
|
|
true |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(error); |
|
|
console.log(error); |
|
@ -699,11 +725,6 @@ export default { |
|
|
link.click(); |
|
|
link.click(); |
|
|
window.URL.revokeObjectURL(downloadUrl); |
|
|
window.URL.revokeObjectURL(downloadUrl); |
|
|
}; |
|
|
}; |
|
|
const getImportTemplate = async () => { |
|
|
|
|
|
const url = `${baseUrl}/${editFormMode.value}`; |
|
|
|
|
|
const response = await get(url); |
|
|
|
|
|
download(url, response.filename); |
|
|
|
|
|
}; |
|
|
|
|
|
const getButtonDisabled = async (src, row) => { |
|
|
const getButtonDisabled = async (src, row) => { |
|
|
if (src) { |
|
|
if (src) { |
|
|
const method = await importFunction(src); |
|
|
const method = await importFunction(src); |
|
@ -719,10 +740,6 @@ export default { |
|
|
value: null, |
|
|
value: null, |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
const logic = [ |
|
|
|
|
|
{ value: "and", label: "且" }, |
|
|
|
|
|
{ value: "or", label: "或" }, |
|
|
|
|
|
]; |
|
|
|
|
|
const operators = [ |
|
|
const operators = [ |
|
|
{ |
|
|
{ |
|
|
value: "equal", |
|
|
value: "equal", |
|
@ -812,39 +829,6 @@ export default { |
|
|
} |
|
|
} |
|
|
return postData; |
|
|
return postData; |
|
|
} |
|
|
} |
|
|
const action = async (method, confirMmessage = "确认操作吗?", successMessage = "操作成功", reload = true) => { |
|
|
|
|
|
try { |
|
|
|
|
|
await ElMessageBox.confirm(confirMmessage, "提示", { |
|
|
|
|
|
type: "warning", |
|
|
|
|
|
}); |
|
|
|
|
|
tableLoading.value = true; |
|
|
|
|
|
let result = null; |
|
|
|
|
|
if (method.constructor.name == "AsyncFunction") { |
|
|
|
|
|
result = await method(); |
|
|
|
|
|
} else { |
|
|
|
|
|
result = method(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!result.errors) { |
|
|
|
|
|
await ElMessage({ |
|
|
|
|
|
type: "info", |
|
|
|
|
|
message: successMessage, |
|
|
|
|
|
}); |
|
|
|
|
|
if (reload) { |
|
|
|
|
|
pageModel.pageIndex = 1; |
|
|
|
|
|
await load(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if (error === "cancel") { |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
type: "info", |
|
|
|
|
|
message: "操作取消", |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} finally { |
|
|
|
|
|
tableLoading.value = false; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
onMounted(async () => { |
|
|
onMounted(async () => { |
|
|
if (route.meta.children?.length) { |
|
|
if (route.meta.children?.length) { |
|
|
for (const item of route.meta.children) { |
|
|
for (const item of route.meta.children) { |
|
@ -865,8 +849,10 @@ export default { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
return { |
|
|
return { |
|
|
|
|
|
listScrollbarRef, |
|
|
load, |
|
|
load, |
|
|
action, |
|
|
reload, |
|
|
|
|
|
onClick, |
|
|
config, |
|
|
config, |
|
|
queryModel, |
|
|
queryModel, |
|
|
buildQuery, |
|
|
buildQuery, |
|
@ -890,7 +876,6 @@ export default { |
|
|
getClass, |
|
|
getClass, |
|
|
sortChange, |
|
|
sortChange, |
|
|
getProp, |
|
|
getProp, |
|
|
getImportTemplate, |
|
|
|
|
|
importFormRef, |
|
|
importFormRef, |
|
|
editFormRef, |
|
|
editFormRef, |
|
|
editFormloading, |
|
|
editFormloading, |
|
|