Browse Source

update

master
wanggang 1 year ago
parent
commit
b4ae9c8745
  1. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js
  2. 110
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  3. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/role.js
  4. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/user.js
  5. 0
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/version.js
  6. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/input/fa-yun.js
  7. 44
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
  8. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js
  9. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js
  10. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/version.js

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js

@ -29,7 +29,6 @@ export default {
<el-tab-pane key="all" label="全部" :value="null" />
<el-tab-pane v-for="item in options" :key="item.key" :label="item.label" :name="item.value" />
</el-tabs>
<br />
</template>
<template v-else-if="getInput(schema)==='month'||getInput(schema)==='datetime'||getInput(schema)==='datetimerange'">
<el-date-picker v-model="model[prop]" :type="schema.input" :value-format="schema.format??'YYYY-MM-DD HH:mm:ss'" />

110
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -60,7 +60,7 @@ export default {
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')">
<template #default="scope"> {{ (pageModel.pageIndex - 1) * pageModel.pageSize + scope.$index + 1 }} </template>
</el-table-column>
@ -186,7 +186,7 @@ export default {
</span>
</template>
</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>
<el-row v-loading="editFormloading">
<el-col style="max-height:calc(100% - 180px );min-height:100%;">
@ -399,6 +399,39 @@ export default {
const defaultImportModel = schemaToModel(config.import.schema);
const importModel = ref(null);
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) => {
(model.sorting ?? "")
.split(",")
@ -469,11 +502,14 @@ export default {
tableLoading.value = false;
}
};
const onPageIndexChange = async () => await load();
const onPageSizeChange = async () => {
const reload = async () => {
pageModel.pageIndex = 1;
await load();
};
const onPageIndexChange = async () => await load();
const onPageSizeChange = async () => {
await reload();
};
const click = async (item, rows) => {
editFormloading.value = true;
editFormMode.value = item.path ?? item;
@ -504,11 +540,16 @@ export default {
type: "warning",
});
tableLoading.value = true;
const response = await request(
const result = await request(
url,
rows.map((o) => o.id),
{ method: config.edit.deleteMethod }
{ method: config.edit.deleteMethod },
true
);
if (!result.data?.code || result.data.code === 200) {
pageModel.pageIndex = 1;
await reload();
}
} catch (error) {
if (error === "cancel") {
ElMessage({
@ -525,7 +566,8 @@ export default {
await ElMessageBox.confirm(format("确认删除当前行数据吗?", rows[0]), "提示", {
type: "warning",
});
await request(url, null, { method: config.edit.deleteMethod });
await request(url, null, { method: config.edit.deleteMethod }, true);
await reload();
} catch (error) {
if (error === "cancel") {
ElMessage({
@ -541,10 +583,12 @@ export default {
const url = config.edit.exportUrl;
const method = config.edit.exportMethod;
const postData = buildQuery();
await onClick(async () => {
const response = await request(url, postData, { method });
if (!response.errors) {
window.open(getUrl(`settleaccount/getblobfile/download/${response.data}`));
}
}, "确认导出?");
} else if (item.meta.pattern === "file") {
window.open(getUrl(`settleaccount/getblobfile/download/${rows[0]["downFileName"]}`));
} else if ((item.meta.pattern = "row")) {
@ -585,21 +629,23 @@ export default {
try {
const valid = await editFormRef.value.validate();
if (valid) {
editFormloading.value = true;
await onClick(
async () => {
let url = (editFormMode.value === "create" ? config.edit.createUrl : config.edit.updateUrl) ?? config.query.url;
if (editFormMode.value === "update") {
url = format(url, editFormModel.value.id);
}
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod;
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; //??
} else {
await load();
editFormMode.value = null;
const result = await request(url, editFormModel.value, { method }, true);
if (!result.errors) {
dialogVisible.value = false;
editFormMode.value = null;
await reload();
}
},
null,
true
);
}
} catch (error) {
console.log(error);
@ -783,37 +829,6 @@ export default {
}
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) {
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;
}
};
onMounted(async () => {
if (route.meta.children?.length) {
for (const item of route.meta.children) {
@ -836,7 +851,8 @@ export default {
return {
listScrollbarRef,
load,
action,
reload,
onClick,
config,
queryModel,
buildQuery,

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/role.js

@ -1,6 +1,7 @@
const schema = {
title: "角色",
type: "object",
disableSelection: true,
properties: {
name: {
title: "角色名",

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/user.js

@ -1,6 +1,7 @@
const schema = {
title: "用户",
type: "object",
disableSelection: true,
properties: {
userName: {
title: "用户名",
@ -59,10 +60,7 @@ const schema = {
title: "邮箱",
type: "string",
showForList: true,
rules: [
{ required: true },
{ pattern: "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z]{2,4})+$", message: "%s必须是正确的格式" },
],
rules: [{ required: true }, { pattern: "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z]{2,4})+$", message: "%s必须是正确的格式" }],
},
roleNames: {
title: "角色",

0
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/centralized-control.js → code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/version.js

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/input/fa-yun.js

@ -313,10 +313,10 @@ export default function (businessType) {
let schema = null;
let service = null;
const syncService = "hand-se-sync/sync";
if (businessType === "JisBBAC") {
if (businessType === "JisBBAC" || businessType === "MaiDanJianBBAC") {
schema = schema1;
service = "bbac_se_detail_service";
} else if (businessType === "JisHBPO") {
} else if (businessType === "JisHBPO" || businessType === "MaiDanJianHBPO") {
schema = schema1;
service = "hbpo_se_detail_service";
} else {

44
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js

@ -9,23 +9,23 @@ import { ElMessage, ElMessageBox } from "element-plus";
// baseURL: "/api",
// };
const addToken = async (options) => {
async function addToken(options) {
if (await isLogin()) {
const appStore = useAppStore();
options.headers ??= {};
options.headers.Authorization = `Bearer ${appStore.token}`;
}
};
}
const getUrl = (url) => {
function getUrl(url) {
if (url.startsWith("http")) {
return url;
}
let result = settings.baseURL;
return (result += `/${url}`);
};
}
const getResult = async (response) => {
async function getResult(response) {
const messages = new Map([
[200, "操作成功"],
[201, "已创建"],
@ -59,9 +59,9 @@ const getResult = async (response) => {
ElMessageBox.alert(`${result.errors?.error?.message ?? messages.get(response.status) ?? result.status}`, `${result.errors?.error?.code ?? "错误"}`);
}
return result;
};
}
async function request(url, data, options, withoutToken = false) {
async function request(url, data, options, notify = false) {
url = getUrl(url);
let defaultOptions = {
method: "POST",
@ -87,18 +87,28 @@ async function request(url, data, options, withoutToken = false) {
defaultOptions.body = JSON.stringify(data);
}
}
if (!withoutToken) {
await addToken(defaultOptions);
}
const response = await fetch(url, defaultOptions);
// if (!result.data?.code || result.data.code === 200) {
// ElMessage({
// type: "success",
// message: "操作成功",
// });
// }
return getResult(response);
const result = await getResult(response);
if (!result.errors && notify && (!result.data?.code || result.data.code === 200)) {
ElMessage({
type: "success",
message: "操作成功",
});
}
if (result.data?.code && result.data.code !== 200) {
result.errors = result.data.message;
}
return result;
}
async function get(url, data, notify = false) {
return await request(url, data, { method: "GET" }, notify);
}
async function post(url, data, notify = false) {
return await request(url, data, { method: "POST" }, notify);
}
export default request;
export { getUrl };
export { getUrl, get, post };

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js

@ -23,7 +23,7 @@ export default [
children: [createButton("query", "title=查询&isTop=true"), createButton("export", "title=导出&isTop=true&pattern=paged")],
},
{
...createPage("centralized-control", "title=期间设置"),
...createPage("version", "title=期间设置"),
children: [
createButton("query", "title=查询&isTop=true"),
createButton("create", "title=新建&isTop=true"),

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js

@ -13,11 +13,7 @@ export default {
const onCommand = async (item, rows) => {
if (item.path === "reset-password") {
const url = `base/user/${rows[0].id}/${item.path}`;
await appListRef.value.action(
async () => await request(url, null, { method: item.meta.method }),
`是否重置用户${rows[0].userName}密码?`,
`${rows[0].userName}密码已经重置为123456`
);
await appListRef.value.onClick(async () => await request(url, null, { method: item.meta.method }, true), `是否重置用户${rows[0].userName}密码?`, false);
}
};
return { appListRef, config, onCommand };

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/centralized-control.js → code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/version.js

@ -2,9 +2,8 @@ import html from "html";
import { ref } from "vue";
import request from "../../request/index.js";
import AppList from "../../components/list/index.js";
import useConfig from "../../models/base-data/centralized-control.js";
import useConfig from "../../models/base-data/version.js";
import { ElMessage, ElMessageBox } from "element-plus";
import { format } from "../../utils/index.js";
export default {
components: { AppList },
Loading…
Cancel
Save