{{$t('application')}}
@@ -12,6 +13,7 @@ export default {
const appStore = useAppStore();
return {
appStore,
+ reload,
};
},
};
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/locale/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/locale/index.js
index e0dfab9e..3fd338b3 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/locale/index.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/locale/index.js
@@ -1,13 +1,7 @@
import { createI18n } from "vue-i18n";
-import { useAppStore } from "../store/index.js";
+import { getLocalizationAsync } from "../api/site.js";
-function useLocale() {
- const appStore = useAppStore();
- const i18n = createI18n({
- legacy: false,
- ...appStore.localization,
- });
- return i18n;
-}
+const localization = await getLocalizationAsync();
+const i18n = createI18n(localization);
-export default useLocale;
+export default i18n;
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/main.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/main.js
index 427a13b5..21c1e343 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/main.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/main.js
@@ -5,12 +5,12 @@ import router from "./router/index.js";
import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import App from "/app.js";
-import useLocale from "./locale/index.js";
+import i18n from "./locale/index.js";
const app = createApp(App);
app.use(store);
+app.use(i18n);
await useAppStore().init();
-app.use(useLocale());
app.use(router);
app.use(ElementPlus);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/account.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/account.js
new file mode 100644
index 00000000..068d69f4
--- /dev/null
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/account.js
@@ -0,0 +1,38 @@
+export default function () {
+ return {
+ title: "登录",
+ type: "object",
+ properties: {
+ currentPassword: {
+ title: "当前密码",
+ type: "string",
+ input: "password",
+ rules: [
+ {
+ required: true,
+ },
+ ],
+ },
+ newPassword: {
+ title: "新密码",
+ type: "string",
+ input: "password",
+ rules: [
+ {
+ required: true,
+ },
+ ],
+ },
+ newPassword2: {
+ title: "确认新密码",
+ type: "string",
+ input: "password",
+ rules: [
+ {
+ required: true,
+ },
+ ],
+ },
+ },
+ };
+}
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js
index 7dd7cf09..b87dba47 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js
@@ -6,23 +6,36 @@ const schema = {
type: "object",
properties: {
version,
- state: state3,
billNum: {
title: "发票号",
type: "string",
- link: true,
+ },
+ invGroupNum: {
+ title: "发票分组号",
+ type: "string",
+ },
+ groupNum: {
+ title: "结算分组号",
+ type: "string",
},
settleBillNum: {
title: "关联结算单号",
type: "string",
},
- invGroupNum: {
- title: "发票分组号",
+ lu: {
+ title: "厂内零件号",
+ type: "string",
+ },
+ pn: {
+ title: "生产码",
+ type: "string",
+ },
+ relu: {
+ title: "替换零件号",
type: "string",
- link: true,
},
- site: {
- title: "地点",
+ extend4: {
+ title: "客户零件号",
type: "string",
},
},
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
index c25a89f2..73a6bbe5 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
@@ -4,10 +4,7 @@ import { useAppStore } from "../store/index.js";
import { getFileName } from "../utils/index.js";
import settings from "../config/settings.js";
import { ElMessage, ElMessageBox } from "element-plus";
-
-// const requestSettings = {
-// baseURL: "/api",
-// };
+import i18n from "../locale/index.js";
async function addToken(options) {
if (await isLogin()) {
@@ -57,7 +54,9 @@ async function getResult(response) {
result.errors = error;
console.log(error);
}
- ElMessageBox.alert(`${result.errors?.error?.message ?? messages.get(response.status) ?? result.status}`, `${result.errors?.error?.code ?? "错误"}`);
+
+ const message = i18n.global.t(result.errors?.error?.code ?? "错误");
+ ElMessageBox({ title: "提示", message, type: "warning" });
}
return result;
}
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js
index 01f071f4..f5a55afa 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js
@@ -19,6 +19,14 @@ const routes = [
isHidden: true,
},
},
+ {
+ path: "/account",
+ component: () => import("../views/account.js"),
+ meta: {
+ title: "用户中心",
+ isHidden: true,
+ },
+ },
{
path: "/403",
component: () => import("../views/403.js"),
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css
index 9f4fb1bc..608dde91 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/styles/site.css
@@ -144,7 +144,8 @@ a.logo {
display: none;
}
.el-aside *,
-.el-header {
+.el-header,
+.el-header .el-dropdown-link {
background-color: #141414;
color: #e5eaf3;
}
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js
index 292cf583..0fcf790e 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js
@@ -137,16 +137,9 @@ async function importFunction(input) {
return result;
}
+function reload() {
+ location.href = `${location.protocol}//${location.host}${location.pathname}`;
+}
+
export default html;
-export {
- delay,
- persentFormat,
- bytesFormat,
- format,
- schemaToModel,
- listToTree,
- treeToList,
- getProp,
- getFileName,
- importFunction,
-};
+export { delay, persentFormat, bytesFormat, format, schemaToModel, listToTree, treeToList, getProp, getFileName, importFunction, reload };
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/validation.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/validation.js
index 03e32c3a..4c8aa116 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/validation.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/validation.js
@@ -118,9 +118,7 @@ const getRules = (parentSchema, property, data) => {
if (!property.rules) {
return null;
}
- const rules = [...(Array.isArray(property.rules) ? property.rules : [property.rules])].map((o) =>
- JSON.parse(JSON.stringify(o))
- );
+ const rules = [...(Array.isArray(property.rules) ? property.rules : [property.rules])].map((o) => Object.assign({}, o));
Object.values(rules).forEach((rule) => {
rule.data = data;
rule.schema = parentSchema;
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/account.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/account.js
new file mode 100644
index 00000000..1555470a
--- /dev/null
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/account.js
@@ -0,0 +1,64 @@
+import html, { schemaToModel } from "html";
+import { reactive } from "vue";
+import AppForm from "../components/form/index.js";
+import { getUser, setAccessToken } from "../api/user.js";
+import router, { refreshRouter } from "../router/index.js";
+import request from "../request/index.js";
+import LayoutLogo from "../layouts/logo.js";
+import LayoutLocale from "../layouts/locale.js";
+import LayoutFooter from "../layouts/footer.js";
+import { useAppStore } from "../store/index.js";
+import useConfig from "../models/account.js";
+import { ElMessage } from "element-plus";
+
+export default {
+ components: { AppForm, LayoutLogo, LayoutLocale, LayoutFooter },
+ template: html`
+
+
+
+ `,
+ setup() {
+ const schema = useConfig();
+ const model = reactive(schemaToModel(schema));
+ schema.properties.newPassword2.rules.push({
+ validator: (rule, value, callback) => {
+ if (value !== model.newPassword) {
+ callback(new Error("确认新密码和新密码必须一致"));
+ } else {
+ callback();
+ }
+ },
+ });
+ const submit = async (callback, loading) => {
+ try {
+ const appStore = useAppStore();
+ const url = `base/user/${appStore.user.id}/change-password`;
+ const result = await request(url, model, { method: "POST" });
+ if (!result.errors) {
+ ElMessage.success("密码修改成功");
+ }
+ } catch (error) {
+ console.log(error);
+ } finally {
+ loading.value = false;
+ }
+ };
+ return {
+ schema,
+ model,
+ submit,
+ };
+ },
+};
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/login.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/login.js
index d50f05d1..8e4862df 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/login.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/login.js
@@ -9,6 +9,8 @@ import LayoutLocale from "../layouts/locale.js";
import LayoutFooter from "../layouts/footer.js";
import { useAppStore } from "../store/index.js";
import useLoginModel from "../models/login.js";
+import { ElMessage } from "element-plus";
+import { useI18n } from "vue-i18n";
export default {
components: { AppForm, LayoutLogo, LayoutLocale, LayoutFooter },
@@ -31,20 +33,25 @@ export default {
setup() {
const schema = reactive(useLoginModel());
const model = reactive(schemaToModel(schema));
+ const { t } = useI18n();
const submit = async (callback, loading) => {
try {
const url = "base/token";
const appStore = useAppStore();
const result = await request(url, model, { method: "POST" });
if (!result.errors) {
- appStore.token = result.data.accessToken;
- if (appStore.token) {
- setAccessToken(appStore.token);
- //setRefreshToken(result.data.refresh_token);
- appStore.user = await getUser();
- await refreshRouter();
- const redirect = router.currentRoute.value.query?.redirect ?? "/";
- router.push(redirect);
+ if (result.data?.accessToken) {
+ appStore.token = result.data.accessToken;
+ if (appStore.token) {
+ setAccessToken(appStore.token);
+ //setRefreshToken(result.data.refresh_token);
+ appStore.user = await getUser();
+ await refreshRouter();
+ const redirect = router.currentRoute.value.query?.redirect ?? "/";
+ router.push(redirect);
+ }
+ } else {
+ ElMessage.error(t(result.data.errorDescription));
}
}
callback(result.errors);