|
|
@ -14,6 +14,7 @@ export default { |
|
|
|
name: "AppList", |
|
|
|
components: { |
|
|
|
AppForm: defineAsyncComponent(() => import("../form/index.js")), |
|
|
|
AppFormInput: defineAsyncComponent(() => import("../../components/form/form-input.js")), |
|
|
|
SvgIcon: defineAsyncComponent(() => import("../../components/icon/index.js")), |
|
|
|
AppFormInput: defineAsyncComponent(() => import("../form/form-input.js")), |
|
|
|
VueOfficeExcel, |
|
|
@ -26,13 +27,18 @@ export default { |
|
|
|
inline |
|
|
|
mode="query" |
|
|
|
label-position="left" |
|
|
|
:schema="querySchema" |
|
|
|
:schema="config.query.schema" |
|
|
|
v-model="queryModel" |
|
|
|
@submit="load" |
|
|
|
:hideButton="true" |
|
|
|
:isQueryForm="true" |
|
|
|
v-if="querySchema" |
|
|
|
/> |
|
|
|
> |
|
|
|
<template v-for="item in filterList.filter(o=>o.readOnly)"> |
|
|
|
<el-form-item :label="config.edit.schema.properties[item.column].title"> |
|
|
|
<app-form-input v-model="item" :schema="config.edit.schema.properties[item.column]" prop="value" /> |
|
|
|
</el-form-item> |
|
|
|
</template> |
|
|
|
</app-form> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-row style="padding-bottom:20px;"> |
|
|
@ -231,23 +237,26 @@ export default { |
|
|
|
</el-form> |
|
|
|
</template> |
|
|
|
<template v-else-if="editFormMode==='import'"> |
|
|
|
<el-form :model="importModel" inline> |
|
|
|
<el-form-item :label="$t('部分成功')"> |
|
|
|
<el-switch v-model="importModel.partial" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('全部替换')"> |
|
|
|
<el-switch v-model="importModel.replace" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form :model="importModel" style="height:100%;"> |
|
|
|
<el-form-item :label="$t('导入模板')"> |
|
|
|
<el-link type="primary" @click="getImportTemplate">{{$t('下载')}}</el-link> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('文件')"> |
|
|
|
<el-form-item label="选择工厂" label-width="80px"> |
|
|
|
<el-select v-model="importModel.version"> |
|
|
|
<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-select v-model="importModel.factory"> |
|
|
|
<el-option v-for="item in versions" :value="item.value" :label="item.label" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="$t('文件')" label-width="80px"> |
|
|
|
<el-upload |
|
|
|
ref="uploadRef" |
|
|
|
class="upload" |
|
|
|
drag |
|
|
|
accept=".xlsx" |
|
|
|
:disabled="fileList.length===1" |
|
|
|
:limit="1" |
|
|
|
:auto-upload="false" |
|
|
|
:on-change="handleChange" |
|
|
|
> |
|
|
@ -257,37 +266,33 @@ export default { |
|
|
|
</el-form> |
|
|
|
</template> |
|
|
|
<template v-else-if="editFormMode==='filter'"> |
|
|
|
<el-form :model="queryList" inline class="filter"> |
|
|
|
<el-row v-for="(item,index) in queryList"> |
|
|
|
<el-form :model="filterList" inline class="filter"> |
|
|
|
<el-row v-for="(item,index) in filterList"> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-select v-model="item.property" :placeholder="$t('字段')"> |
|
|
|
<el-option v-for="(value, prop) in querySchema.properties" :value="prop" :label="value.title" /> |
|
|
|
<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('操作符')"> |
|
|
|
<el-option value="{0}=@0" :label="$t('等于')" /> |
|
|
|
<el-option value="{0}!=@0" :label="$t('不等于')" /> |
|
|
|
<el-option value="{0}>@0" :label="$t('大于')" /> |
|
|
|
<el-option value="{0}>=@0" :label="$t('大于等于')" /> |
|
|
|
<el-option value="{0}<@0" :label="$t('小于')" /> |
|
|
|
<el-option value="{0}<=@0" :label="$t('小于等于')" /> |
|
|
|
<el-option value="{0}.Contains(@0)" :label="$t('包含')" /> |
|
|
|
<el-option value="{0}.StartsWith(@0)" :label="$t('开始于')" /> |
|
|
|
<el-option value="{0}.StartsWith(@0)" :label="$t('结束于')" /> |
|
|
|
<template v-if="item.column"> |
|
|
|
<el-option |
|
|
|
v-for="item in getOperators(config.edit.schema.properties[item.column])" |
|
|
|
value="item.value" |
|
|
|
:label="item.label" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
</el-select> |
|
|
|
</el-col> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-input v-model="item.value" :placeholder="$t('值')" /> |
|
|
|
<el-col :span="6" v-if="item.column"> |
|
|
|
<app-form-input v-model="item" :schema="config.edit.schema.properties[item.column]" prop="value" /> |
|
|
|
</el-col> |
|
|
|
<!-- <el-col :span="4"> |
|
|
|
<el-select v-model="item.logic" :placeholder="$t('关系')"> |
|
|
|
<el-option value="and" :label="$t('且')" /> |
|
|
|
<el-option value="or" :label="$t('或')" /> |
|
|
|
</el-select> |
|
|
|
</el-col> --> |
|
|
|
<el-col :span="2"> |
|
|
|
<el-button circle @click="queryList.splice(index, 1)"> |
|
|
|
<el-button circle @click="filterList.splice(index, 1)" v-if="!item.readOnly"> |
|
|
|
<template #icon> |
|
|
|
<ep-close /> |
|
|
|
</template> |
|
|
@ -296,7 +301,7 @@ export default { |
|
|
|
</el-row> |
|
|
|
<el-row> |
|
|
|
<el-col> |
|
|
|
<el-button circle @click="pushQueryList"> |
|
|
|
<el-button circle @click="pushfilterList"> |
|
|
|
<template #icon> |
|
|
|
<ep-plus /> |
|
|
|
</template> |
|
|
@ -322,6 +327,22 @@ export default { |
|
|
|
.el-form.filter .el-col { |
|
|
|
padding: 5px; |
|
|
|
} |
|
|
|
dl.upload { |
|
|
|
min-height: 100%; |
|
|
|
} |
|
|
|
dl.upload dt { |
|
|
|
font-weight: bold; |
|
|
|
line-height: 3em; |
|
|
|
} |
|
|
|
dl.upload dd { |
|
|
|
line-height: 2em; |
|
|
|
} |
|
|
|
dl.upload .el-form-item { |
|
|
|
width: 300px; |
|
|
|
} |
|
|
|
div.upload { |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
</style>`, |
|
|
|
props: ["modelValue", "config", "querySchema", "controller", "query", "buttons"], |
|
|
|
emits: ["command"], |
|
|
@ -361,7 +382,7 @@ export default { |
|
|
|
const queryModel = ref({}); |
|
|
|
const sortColumns = ref(new Map()); |
|
|
|
const querySchema = ref(props.querySchema); |
|
|
|
const queryList = ref([]); |
|
|
|
const filterList = ref([]); |
|
|
|
const tableSchema = ref({}); |
|
|
|
const tableData = ref([]); |
|
|
|
const editFormRef = ref(null); |
|
|
@ -375,9 +396,13 @@ export default { |
|
|
|
includeDeleted: false, |
|
|
|
}); |
|
|
|
const importModel = reactive({ |
|
|
|
partial: true, |
|
|
|
replace: false, |
|
|
|
// partial: true,
|
|
|
|
// replace: false,
|
|
|
|
factory: "", |
|
|
|
version: "", |
|
|
|
}); |
|
|
|
const factories = ref([]); |
|
|
|
const versions = ref([]); |
|
|
|
const fileList = ref([]); |
|
|
|
const getSortModel = (model) => { |
|
|
|
model.orderBy |
|
|
@ -415,6 +440,9 @@ export default { |
|
|
|
await load(); |
|
|
|
}; |
|
|
|
const showColumn = (item, prop) => { |
|
|
|
if (item.showForList === true) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return ( |
|
|
|
item.type !== "object" && |
|
|
|
item.type !== "array" && |
|
|
@ -430,12 +458,11 @@ export default { |
|
|
|
const url = config.query.url; |
|
|
|
const method = config.query.method; |
|
|
|
//
|
|
|
|
queryModel.value = schemaToModel(config.query.schema); |
|
|
|
queryModel.value.maxResultCount = pageModel.pageSize; |
|
|
|
queryModel.value.skipCount = (pageModel.pageIndex - 1) * pageModel.pageSize; |
|
|
|
//
|
|
|
|
const postData = JSON.parse(JSON.stringify(queryModel.value)); |
|
|
|
postData.filters = queryList.value.filter((o) => o.property && o.value); |
|
|
|
postData.filters = filterList.value.filter((o) => o.property && o.value); |
|
|
|
if (postData.items) { |
|
|
|
delete postData["items"]; |
|
|
|
} |
|
|
@ -462,8 +489,7 @@ export default { |
|
|
|
const click = async (item, rows) => { |
|
|
|
editFormloading.value = true; |
|
|
|
editFormMode.value = item.path ?? item; |
|
|
|
context.emit("command", item, rows); |
|
|
|
if (item.path === "index") { |
|
|
|
if (item.path === "query") { |
|
|
|
//list
|
|
|
|
await load(); |
|
|
|
} else if (item.path === "details") { |
|
|
@ -485,13 +511,39 @@ export default { |
|
|
|
editFormTitle.value = `${t(item.path)}${config.edit.schema.title}`; |
|
|
|
dialogVisible.value = true; |
|
|
|
} else if (item.path === "delete") { |
|
|
|
if (!rows.length) { |
|
|
|
return; |
|
|
|
} |
|
|
|
//delete
|
|
|
|
const url = format(config.edit.deleteUrl, rows[0].id); |
|
|
|
if (item.meta.isTop) { |
|
|
|
// 批量删除
|
|
|
|
return; |
|
|
|
try { |
|
|
|
await ElMessageBox.confirm("删除", "提示", { |
|
|
|
type: "warning", |
|
|
|
message: format("确认删除选中的%s行数据吗?", rows.length), |
|
|
|
}); |
|
|
|
const response = await request( |
|
|
|
url, |
|
|
|
rows.map((o) => o.id), |
|
|
|
{ method: config.edit.deleteMethod } |
|
|
|
); |
|
|
|
if (!response.errors) { |
|
|
|
ElMessage({ |
|
|
|
type: "info", |
|
|
|
message: "操作完毕", |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
if (error === "cancel") { |
|
|
|
ElMessage({ |
|
|
|
type: "info", |
|
|
|
message: "删除取消", |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 单个删除
|
|
|
|
const url = format(config.edit.deleteUrl, rows[0].id); |
|
|
|
try { |
|
|
|
await ElMessageBox.confirm("删除", "提示", { |
|
|
|
type: "warning", |
|
|
@ -511,7 +563,6 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const url = `${baseUrl}/${item.path}`; |
|
|
|
// await post(
|
|
|
|
// url,
|
|
|
|
// rows.map((o) => o.id)
|
|
|
@ -523,13 +574,33 @@ export default { |
|
|
|
dialogVisible.value = true; |
|
|
|
} else if (item.path === "import") { |
|
|
|
//import
|
|
|
|
const url = `${baseUrl}/${item.path}`; |
|
|
|
editFormTitle.value = `${t(item.path)}${querySchema.value?.title}`; |
|
|
|
fileList.value = []; |
|
|
|
dialogVisible.value = true; |
|
|
|
try { |
|
|
|
editFormloading.value = true; |
|
|
|
editFormTitle.value = `${t(item.path)}${config.query.schema.title}`; |
|
|
|
fileList.value = []; |
|
|
|
dialogVisible.value = true; |
|
|
|
versions.value = ( |
|
|
|
await request("settleaccount/centralized-control/get-all", null, { method: "POST" }) |
|
|
|
).data.items.map((o) => ({ |
|
|
|
value: o.version, |
|
|
|
label: o.version, |
|
|
|
})); |
|
|
|
factories.value = ( |
|
|
|
await request("settleaccount/code-setting/get-all", null, { method: "POST" }) |
|
|
|
).data.items.map((o) => ({ |
|
|
|
value: o.project, |
|
|
|
label: o.project, |
|
|
|
})); |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
} finally { |
|
|
|
editFormloading.value = false; |
|
|
|
} |
|
|
|
} else if (item === "filter") { |
|
|
|
editFormTitle.value = t("自定义查询"); |
|
|
|
dialogVisible.value = true; |
|
|
|
} else { |
|
|
|
context.emit("command", item, rows, load); |
|
|
|
} |
|
|
|
editFormloading.value = false; |
|
|
|
}; |
|
|
@ -545,10 +616,10 @@ export default { |
|
|
|
url = format(url, editFormModel.value.id); |
|
|
|
} |
|
|
|
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod; |
|
|
|
const result = await request(url, editFormModel.value, { method }); |
|
|
|
if (result.errors) { |
|
|
|
model.errors = result.errors; //??
|
|
|
|
} else { |
|
|
|
const response = await request(url, editFormModel.value, { method }); |
|
|
|
if (!response.errors) { |
|
|
|
ElMessageBox.alert(`错误:${response.errors?.error?.message}`, `代码:${response.errors?.error?.code}`); |
|
|
|
//model.errors = response.errors; //??
|
|
|
|
await load(); |
|
|
|
editFormMode.value = null; |
|
|
|
dialogVisible.value = false; |
|
|
@ -564,7 +635,7 @@ export default { |
|
|
|
editFormMode.value = null; |
|
|
|
} else if (editFormMode.value === "export") { |
|
|
|
const postData = JSON.parse(JSON.stringify(queryModel.value)); |
|
|
|
postData.filters = queryList.value.filter((o) => o.property && o.value); |
|
|
|
postData.filters = filterList.value.filter((o) => o.property && o.value); |
|
|
|
delete postData.query["items"]; |
|
|
|
delete postData.query["id"]; |
|
|
|
const url = `${baseUrl}/${editFormMode.value}?${qs.stringify(exportModel)}`; |
|
|
@ -573,13 +644,14 @@ export default { |
|
|
|
dialogVisible.value = false; |
|
|
|
} else if (editFormMode.value === "import") { |
|
|
|
editFormloading.value = true; |
|
|
|
const url = `${baseUrl}/${editFormMode.value}`; |
|
|
|
const url = config.edit.importUrl; |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append("partial", importModel.partial); |
|
|
|
formData.append("replace", importModel.replace); |
|
|
|
formData.append("file", fileList.value[0]?.raw); |
|
|
|
console.log(uploadRef.value); |
|
|
|
const response = await post(url, formData); |
|
|
|
formData.append("version", importModel.version); |
|
|
|
formData.append("factory", importModel.factory); |
|
|
|
for (let i = 0; i < fileList.value.length; i++) { |
|
|
|
formData.append(`files`, fileList.value[i].raw); |
|
|
|
} |
|
|
|
await post(url, formData); |
|
|
|
editFormloading.value = false; |
|
|
|
dialogVisible.value = false; |
|
|
|
await load(); |
|
|
@ -610,14 +682,6 @@ export default { |
|
|
|
subDrawer.value = true; |
|
|
|
} |
|
|
|
}; |
|
|
|
const pushQueryList = () => { |
|
|
|
queryList.value.push({ |
|
|
|
property: "", |
|
|
|
operator: "{0}=@0", |
|
|
|
value: "", |
|
|
|
logic: "and", |
|
|
|
}); |
|
|
|
}; |
|
|
|
const download = (response) => { |
|
|
|
const downloadUrl = window.URL.createObjectURL(response.data); |
|
|
|
const filename = response.filename; |
|
|
@ -642,6 +706,24 @@ export default { |
|
|
|
} |
|
|
|
return false; |
|
|
|
}; |
|
|
|
const pushfilterList = () => { |
|
|
|
filterList.value.push({ |
|
|
|
logic: "", |
|
|
|
column: "", |
|
|
|
action: "", |
|
|
|
value: "", |
|
|
|
}); |
|
|
|
}; |
|
|
|
const getOperators = (schema) => { |
|
|
|
if (schema.type === "int") { |
|
|
|
} |
|
|
|
return [ |
|
|
|
{ |
|
|
|
value: 0, |
|
|
|
label: "等于", |
|
|
|
}, |
|
|
|
]; |
|
|
|
}; |
|
|
|
onMounted(async () => { |
|
|
|
if (route.meta.children?.length) { |
|
|
|
for (const item of route.meta.children) { |
|
|
@ -650,7 +732,10 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
pushQueryList(); |
|
|
|
//
|
|
|
|
queryModel.value = schemaToModel(config.query.schema); |
|
|
|
filterList.value = queryModel.value.filters; |
|
|
|
//pushfilterList();
|
|
|
|
// if (!querySchema.value) {
|
|
|
|
// const vm = (await get(indexUrl)).data;
|
|
|
|
// querySchema.value = vm.schema.properties.query;
|
|
|
@ -662,9 +747,6 @@ export default { |
|
|
|
// getSortModel(data.value);
|
|
|
|
// getColumns(vm.schema.properties.query);
|
|
|
|
// }
|
|
|
|
if (!config) { |
|
|
|
//
|
|
|
|
} |
|
|
|
getColumns(config.table.schema); |
|
|
|
if (props.query) { |
|
|
|
Object.assign(queryModel.value.query, props.query); |
|
|
@ -673,7 +755,9 @@ export default { |
|
|
|
// getColumns(vm.schema.properties.query);
|
|
|
|
await load(); |
|
|
|
}); |
|
|
|
context.expose({ load }); |
|
|
|
return { |
|
|
|
load, |
|
|
|
config, |
|
|
|
queryModel, |
|
|
|
pageModel, |
|
|
@ -689,7 +773,7 @@ export default { |
|
|
|
dialogVisible, |
|
|
|
selectedRows, |
|
|
|
querySchema, |
|
|
|
queryList, |
|
|
|
filterList, |
|
|
|
tableSchema, |
|
|
|
buttons, |
|
|
|
tableData, |
|
|
@ -713,10 +797,13 @@ export default { |
|
|
|
submit, |
|
|
|
showList, |
|
|
|
subListQuery, |
|
|
|
pushQueryList, |
|
|
|
fileList, |
|
|
|
handleChange, |
|
|
|
getButtonDisabled, |
|
|
|
factories, |
|
|
|
versions, |
|
|
|
pushfilterList, |
|
|
|
getOperators, |
|
|
|
}; |
|
|
|
}, |
|
|
|
}; |
|
|
|