Selaa lähdekoodia

国际化版本修改

sunyadv 5 vuotta sitten
vanhempi
commit
9d2a7e7f7a
3 muutettua tiedostoa jossa 117 lisäystä ja 85 poistoa
  1. 16 0
      ys_int/src/i18n/lang/en.js
  2. 16 0
      ys_int/src/i18n/lang/zh.js
  3. 85 85
      ys_int/src/views/Home.vue

+ 16 - 0
ys_int/src/i18n/lang/en.js

@@ -6,12 +6,21 @@ const lang = {
         password: "Password",
         login: "Login",
         prompt: "Prompt",
+
+        name: "Name",
+        mobile: "Mobile",
+        company: "Company",
     },
     msg: {
         changeLanguage: "Whether to change the language?",
         signOut: "Whether to log out?",
         loginAcc: "Please input Accounts",
         loginPass: "Please input Password",
+
+        inputNewPwd: "Please enter a new password",
+        inputName: "Please input Name",
+        inputMobile: "Please input Mobile",
+        inputCompany: "Please input Company",
     },
     home: {
         approval: "Approval",
@@ -26,6 +35,9 @@ const lang = {
         all: "View All",
 
         pwd: "Change Password",
+
+        newPwd: "New Password",
+
         msg: "Modify Information",
         exit: "Sign Out",
     },
@@ -48,6 +60,10 @@ const lang = {
         producer: "Producer Manage",
         device: "YM Mold Manage",
     },
+    prompt: {
+        success: "Success",
+        success1: "Success,please login again",
+    },
     sys: {
 
     },

+ 16 - 0
ys_int/src/i18n/lang/zh.js

@@ -6,12 +6,21 @@ const lang = {
         password: "密码",
         login: "登录",
         prompt: "提示",
+
+        name: "姓名",
+        mobile: "手机号",
+        company: "所属公司",
     },
     msg: {
         changeLanguage: "是否切换语言?",
         signOut: "是否退出登录?",
         loginAcc: "请输入账号",
         loginPass: "请输入密码",
+
+        inputNewPwd: "请输入新密码",
+        inputName: "请输入姓名",
+        inputMobile: "请输入手机号",
+        inputCompany: "请输入所属公司",
     },
     home: {
         approval: "审批",
@@ -26,7 +35,10 @@ const lang = {
         all: "查看全部",
 
         pwd: "修改密码",
+        newPwd: "新密码",
+
         msg: "修改信息",
+
         exit: "退出登录",
     },
     navigation: {
@@ -48,6 +60,10 @@ const lang = {
         producer: "生产方管理",
         device: "云模盒管理",
     },
+    prompt: {
+        success: "修改成功",
+        success1: "修改成功,请重新登录",
+    },
     sys: {
 
     },

+ 85 - 85
ys_int/src/views/Home.vue

@@ -150,38 +150,38 @@
                 </div>
 
                 <!--修改密码-->
-                <el-dialog title="修改密码" v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
-                    <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
-                        <el-form-item label="新密码" prop="password">
-                            <el-input v-model="addForm.password" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
+                <el-dialog :title="$t('home.pwd')" v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
+                    <el-form :model="addForm" label-width="120px" :rules="passRule" ref="addForm">
+                        <el-form-item :label="$t('home.newPwd')" prop="password">
+                            <el-input v-model="addForm.password" autocomplete="off" :placeholder="$t('msg.inputNewPwd')" show-password></el-input>
                         </el-form-item>
                     </el-form>
                     <div slot="footer" class="dialog-footer">
-                        <el-button @click.native="editPassWord = false">取消</el-button>
-                        <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
+                        <el-button @click.native="editPassWord = false">{{$t('el.messagebox.cancel')}}</el-button>
+                        <el-button type="primary" @click.native="resetPwd" :loading="editLoading">{{$t('el.messagebox.confirm')}}</el-button>
                     </div>
                 </el-dialog>
 
                 <!--修改信息-->
-                <el-dialog title="修改信息" v-if="editInformation" :visible.sync="editInformation" :close-on-click-modal="false" customClass="customWidth">
-                    <el-form :model="editInfoForm" label-width="80px" :rules="passRule" ref="editInfoForm">
-                        <el-form-item label="姓名" prop="username">
-                        <el-input v-model="editInfoForm.username" autocomplete="off" placeholder="请输入姓名"></el-input>
+                <el-dialog :title="$t('home.msg')" v-if="editInformation" :visible.sync="editInformation" :close-on-click-modal="false" customClass="customWidth">
+                    <el-form :model="editInfoForm" label-width="120px" :rules="passRule" ref="editInfoForm">
+                        <el-form-item :label="$t('base.name')" prop="username">
+                        <el-input v-model="editInfoForm.username" autocomplete="off" :placeholder="$t('msg.inputName')"></el-input>
                         </el-form-item>
                     </el-form>
                     <el-form :model="editInfoForm" label-width="80px" :rules="passRule" ref="editInfoForm">
-                        <el-form-item label="手机号" prop="mobile">
-                            <el-input v-model="editInfoForm.mobile" autocomplete="off" placeholder="请输入手机号" :disabled="true"></el-input>
+                        <el-form-item :label="$t('base.mobile')" prop="mobile">
+                            <el-input v-model="editInfoForm.mobile" autocomplete="off" :placeholder="$t('msg.inputMobile')" :disabled="true"></el-input>
                         </el-form-item>
                     </el-form>
                     <el-form :model="editInfoForm" label-width="80px" :rules="passRule" ref="editInfoForm">
-                        <el-form-item label="所属公司" prop="companyName">
-                            <el-input v-model="editInfoForm.companyName" autocomplete="off" placeholder="请输入所属公司" :disabled="true"></el-input>
+                        <el-form-item :label="$t('base.company')" prop="companyName">
+                            <el-input v-model="editInfoForm.companyName" autocomplete="off" :placeholder="$t('msg.inputCompany')" :disabled="true"></el-input>
                         </el-form-item>
                     </el-form>
                     <div slot="footer" class="dialog-footer">
-                        <el-button @click.native="editInformation = false">取消</el-button>
-                        <el-button type="primary" @click.native="editInfo" :loading="editLoading2">提交</el-button>
+                        <el-button @click.native="editInformation = false">{{$t('el.messagebox.cancel')}}</el-button>
+                        <el-button type="primary" @click.native="editInfo" :loading="editLoading2">{{$t('el.messagebox.confirm')}}</el-button>
                     </div>
                 </el-dialog>
 
@@ -193,6 +193,17 @@
 <script>
     export default {
         data() {
+            const msg = (rule, value, callback) => {
+                if (!value) {
+                    if(rule.field == "password") {
+                        return callback(new Error(this.$t('msg.inputNewPwd')));
+                    } else {
+                        return callback(new Error(this.$t('msg.loginPass')));
+                    }
+                } else {
+                    callback();
+                }
+            };
             return {
                 user: sessionStorage.getItem("user"),
                 collapsed: false,
@@ -213,10 +224,8 @@
                     companyName: ""
                 },
                 passRule: {
-                    password: [
-                    { required: true, message: "请输入新密码", trigger: "blur" }
-                    ],
-                    username: [{ required: true, message: "请输入姓名", trigger: "blur" }]
+                    password: [{ validator: msg , trigger: "blur" }],
+                    username: [{ validator: msg , trigger: "blur" }]
                 },
                 //消息数据
                 popoverData: ["", "", ""],
@@ -297,39 +306,36 @@
             editInfo() {
                 this.$refs.editInfoForm.validate(valid => {
                     if (valid) {
-                    this.editLoading2 = true;
-                    this.http.post(
-                        this.port.pwd.resetPwd,
-                        { id: this.editInfoForm.id, username: this.editInfoForm.username },
+                        this.editLoading2 = true;
+                        this.http.post( this.port.pwd.resetPwd, { id: this.editInfoForm.id, username: this.editInfoForm.username },
                         res => {
-                        this.editLoading2 = false;
-                        this.editInformation = false;
-                        if (res.code == "ok") {
-                            this.$message({
-                            message: "修改成功",
-                            type: "success"
-                            });
-                            //读取并覆盖session storage
-                            var userObject = JSON.parse(sessionStorage.getItem("user"));
-                            userObject.username = this.editInfoForm.username;
-                            sessionStorage.setItem("user", JSON.stringify(userObject));
-                            this.sysUserName = this.editInfoForm.username;
-                        } else {
-                            this.$message({
-                            message: res.msg,
-                            type: "error"
-                            });
-                        }
+                            this.editLoading2 = false;
+                            this.editInformation = false;
+                            if (res.code == "ok") {
+                                this.$message({
+                                    message: this.$t('prompt.success'),
+                                    type: "success"
+                                });
+                                //读取并覆盖session storage
+                                var userObject = JSON.parse(sessionStorage.getItem("user"));
+                                userObject.username = this.editInfoForm.username;
+                                sessionStorage.setItem("user", JSON.stringify(userObject));
+                                this.sysUserName = this.editInfoForm.username;
+                            } else {
+                                this.$message({
+                                    message: res.msg,
+                                    type: "error"
+                                });
+                            }
                         },
                         error => {
-                        this.editLoading2 = false;
-                        this.editInformation = false;
-                        this.$message({
-                            message: error,
-                            type: "error"
+                            this.editLoading2 = false;
+                            this.editInformation = false;
+                            this.$message({
+                                message: error,
+                                type: "error"
+                            });
                         });
-                        }
-                    );
                     }
                 });
             },
@@ -338,53 +344,48 @@
                 this.editPassWord = true;
                 this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
                 this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
-                },
+            },
 
-                resetPwd() {
+            resetPwd() {
                 this.$refs.addForm.validate(valid => {
                     if (valid) {
-                    this.editLoading = true;
-                    this.http.post(
-                        this.port.pwd.resetPwd,
-                        this.addForm,
+                        this.editLoading = true;
+                        this.http.post( this.port.pwd.resetPwd, this.addForm,
                         res => {
-                        this.editLoading = false;
-                        this.editPassWord = false;
-                        if (res.code == "ok") {
-                            this.$message({
-                            message: "修改成功,请重新登录",
-                            type: "success"
-                            });
-                            this.$router.push("/login");
-                        } else {
-                            this.$message({
-                            message: res.msg,
-                            type: "error"
-                            });
-                        }
+                            this.editLoading = false;
+                            this.editPassWord = false;
+                            if (res.code == "ok") {
+                                this.$message({
+                                    message: this.$t('prompt.success1'),
+                                    type: "success"
+                                });
+                                this.$router.push("/login");
+                            } else {
+                                this.$message({
+                                    message: res.msg,
+                                    type: "error"
+                                });
+                            }
                         },
                         error => {
-                        this.editLoading = false;
-                        this.editPassWord = false;
-                        this.$message({
-                            message: error,
-                            type: "error"
+                            this.editLoading = false;
+                            this.editPassWord = false;
+                            this.$message({
+                                message: error,
+                                type: "error"
+                            });
                         });
-                        }
-                    );
                     }
                 });
             },
 
             //读取消息提示
             loadNotice() {
-                this.http.post(
-                    this.port.notice.list,
-                    {
+                this.http.post( this.port.notice.list, {
                     pageNum: 1,
                     pageSize: 5
-                    },
-                    res => {
+                },
+                res => {
                     if (res.code == "ok") {
                         this.popoverData = [];
                         this.popoverData.push(res.data[0].approvelList.list);
@@ -403,14 +404,13 @@
                         type: "error"
                         });
                     }
-                    },
-                    error => {
+                },
+                error => {
                     this.$message({
                         message: error,
                         type: "error"
                     });
-                    }
-                );
+                });
             },
 
             //点击消息的跳转