个人中心更改
continuous-integration/drone/push Build is passing Details

uat_us
wangxiaoshuang 2024-05-09 11:27:30 +08:00
parent 5cc38ada71
commit bd1ee8a520
7 changed files with 867 additions and 688 deletions

View File

@ -262,7 +262,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'baiscInfo', path: 'baiscInfo',
name: 'BaiscInfo', name: 'BaiscInfo',
component: () => import('@/views/user/myInfo') component: () => import('@/views/user/editInfo')
} }
] ]
} }

View File

@ -0,0 +1,247 @@
<template>
<div class="trial-myinfo-right">
<div class="trial-myinfo-right-box">
<div class="trial-myinfo-head">
<!-- 账号信息 -->
{{ $t("trials:trials-myinfo:title:accountInfo") }}
</div>
<el-form label-position="right" label-width="100px">
<!-- 用户名 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:userName')"
style="margin-bottom: 5px"
prop="UserName"
>
<span>{{ user.UserName }}</span>
</el-form-item>
<el-form-item label="" style="position: relative" prop="UserName">
<el-input
v-model="userForm.UserName"
:placeholder="$t('trials:trials-myinfo:form:userName')"
/>
<!-- 修改 -->
<el-button
:disabled="!userForm.UserName"
class="saveBtn"
type="primary"
size="small"
@click="setNewUserName"
>
{{ $t("trials:trials-myinfo:button:update") }}
</el-button>
</el-form-item>
<!-- 电话 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:phone')"
style="margin-bottom: 5px"
prop="UserName"
>
<span>{{ user.Phone }}</span>
</el-form-item>
<el-form-item label="" style="position: relative" prop="UserName">
<el-input
v-model="userForm.Phone"
:placeholder="$t('trials:trials-myinfo:form:phone')"
/>
<!-- 修改 -->
<el-button
:disabled="!userForm.Phone"
class="saveBtn"
type="primary"
size="small"
@click="setNewPhone"
>
{{ $t("trials:trials-myinfo:button:update") }}
</el-button>
</el-form-item>
<!-- 邮箱 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:email')"
style="margin-bottom: 5px"
prop="UserName"
>
<span>{{ user.EMail }}</span>
</el-form-item>
<el-form-item
label=""
style="margin-bottom: 10px; position: relative"
prop="EMail"
v-if="IsCanConnectInternet"
>
<el-input
v-model="userForm.EMail"
@input="handleEmailChange"
:placeholder="$t('trials:trials-myinfo:form:email')"
/>
<el-button
class="sendCode"
:disabled="sendDisabled"
type="primary"
size="mini"
@click="sendVerificationCode"
>{{ sendTitle }}</el-button
>
</el-form-item>
<el-form-item
label=""
style="position: relative"
prop="VerificationCode"
v-if="IsCanConnectInternet"
>
<el-input
v-model="userForm.VerificationCode"
:placeholder="$t('trials:researchForm:form:verifyCode')"
/>
<!-- 修改 -->
<el-button
:disabled="
!userForm.EMail || !userForm.VerificationCode || sendDisabled
"
class="saveBtn"
type="primary"
size="small"
@click="setNewEmail"
>
{{ $t("trials:trials-myinfo:button:update") }}
</el-button>
</el-form-item>
</el-form>
</div>
<password />
</div>
</template>
<script>
import {
sendVerificationCode,
setNewEmail,
setNewPhone,
setNewUserName,
} from "@/api/system/user.js";
import { removeToken } from "@/utils/auth";
import password from "./password.vue";
var timer = "";
var countdown = 60;
export default {
name: "account",
components: { password },
props: {
user: {
required: true,
default: () => {
return {};
},
},
IsCanConnectInternet: {
required: true,
default: true,
},
},
data() {
return {
userForm: {},
sendDisabled: true,
sendTitle: this.$t("trials:trials-myinfo:button:getVCode"),
};
},
methods: {
setNewEmail() {
setNewEmail(this.userForm.EMail, this.userForm.VerificationCode).then(
() => {
this.userForm.EMail = "";
this.userForm.VerificationCode = "";
this.$message.success(
this.$t("trials:trials-myinfo:message:updateSuccessfully")
);
this.$emit("getUserInfo");
}
);
},
async setNewUserName() {
try {
let confirm = await this.$confirm(
this.$t("trials:trials-myInfo:confirmMessage:updateUserName"),
{
type: "warning",
distinguishCancelAndClose: true,
confirmButtonText: this.$t("common:button:confirm"),
cancelButtonText: this.$t("common:button:cancel"),
}
);
if (confirm !== "confirm") return;
let res = await setNewUserName(this.userForm.UserName);
if (res.IsSuccess) {
this.userForm.UserName = "";
this.$message.success(
this.$t("trials:trials-myinfo:message:updateSuccessfully")
);
this.$emit("getUserInfo");
removeToken();
this.logout();
}
} catch (err) {
console.log(err);
}
},
setNewPhone() {
setNewPhone(this.userForm.Phone).then(() => {
this.userForm.Phone = "";
this.$message.success(
this.$t("trials:trials-myinfo:message:updateSuccessfully")
);
this.$emit("getUserInfo");
});
},
handleEmailChange() {
var reg =
/^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/;
if (this.userForm.EMail && reg.test(this.userForm.EMail)) {
this.sendDisabled = false;
} else {
this.sendDisabled = true;
}
},
sendVerificationCode() {
sendVerificationCode(this.userForm.EMail).then(() => {
this.settime(this);
//
this.$message.success(
this.$t("trials:trials-myinfo:message:sendSuccessfully")
);
});
},
settime(obj) {
if (countdown === 0) {
obj.sendDisabled = false;
obj.sendTitle = this.$t("trials:trials-myinfo:button:getVCode"); // ''
countdown = 60;
clearTimeout(timer);
return;
} else {
obj.sendDisabled = true;
obj.sendTitle = `${this.$t(
"trials:trials-myinfo:button:wait"
)}(${countdown}s)`;
countdown--;
// eslint-disable-next-line no-self-assign
countdown = countdown;
timer = setTimeout(function () {
obj.settime(obj);
}, 1000);
}
},
async logout() {
/* eslint-disable */
var loginType = zzSessionStorage.getItem("loginType");
await this.$store.dispatch("user/logout");
if (loginType) {
this.$router.push(`/login?loginType=${loginType}`);
} else {
this.$router.push(`/login`);
}
this.$i18n.locale = "zh";
this.setLanguage("zh");
this.$updateDictionary();
},
},
};
</script>

View File

@ -1,390 +1,187 @@
<template> <template>
<div class="trial-myinfo"> <div class="trial-myinfo">
<div class="trial-myinfo-left"> <el-menu
<div class="trial-myinfo-left-top"> :default-active="activeIndex"
<div class="trial-myinfo-head"> @select="handleSelect"
<!-- 个人头像 --> class="el-menu-demo"
{{ $t('trials:trials-myinfo:title:avater') }} style="width: 200px"
</div> >
<div class="trial-myinfo-body"> <el-menu-item index="1">{{
<div> $t("trials:trials-myinfo:menuTitle:mine")
{{ user.LastName }} }}</el-menu-item>
</div> <el-menu-item index="2">{{
</div> $t("trials:trials-myinfo:menuTitle:account")
</div> }}</el-menu-item>
<div class="trial-myinfo-left-bottom"> <el-menu-item index="3">{{
<div class="trial-myinfo-head"> $t("trials:trials-myinfo:menuTitle:loginLog")
<!-- 用户基本信息 --> }}</el-menu-item>
{{ $t('trials:trials-myinfo:title:basicInfo') }} </el-menu>
</div> <div class="contentBox">
<el-form ref="userForm" label-position="right" :model="user" :rules="userFormRules" label-width="120px"> <mine
<el-form-item v-if="user.Code" label="ID: " prop="Code"> :user="user"
<el-input v-model="user.Code" disabled /> :userTypeOptions="userTypeOptions"
</el-form-item> v-if="activeIndex === '1'"
<!-- --> @getUserInfo="getUserInfo"
<el-form-item :disabled="user.UserTypeEnum === 8" :label="$t('trials:trials-myinfo:form:surname')" prop="LastName"> />
<el-input v-model="user.LastName" :placeholder="$t('trials:trials-myinfo:form:surname')"/> <account
</el-form-item> :user="user"
<!-- --> @getUserInfo="getUserInfo"
<el-form-item :disabled="user.UserTypeEnum === 8" :label="$t('trials:trials-myinfo:form:givenname')" prop="FirstName"> :IsCanConnectInternet="IsCanConnectInternet"
<el-input v-model="user.FirstName" :placeholder="$t('trials:trials-myinfo:form:givenname')"/> v-if="activeIndex === '2'"
</el-form-item> />
<!-- 性别 --> <login-log v-if="activeIndex === '3'" :name="userName" :isMine="true" />
<el-form-item :label="$t('trials:trials-myinfo:form:gender')" prop="Sex" style="margin-right:40px;">
<el-radio-group v-model="user.Sex">
<el-radio :label="1">Male</el-radio>
<el-radio :label="0">Female</el-radio>
</el-radio-group>
</el-form-item>
<!-- 单位 -->
<el-form-item :label="$t('trials:trials-myinfo:form:organization')" prop="OrganizationName">
<el-input v-model="user.OrganizationName" :placeholder="$t('trials:trials-myinfo:form:organization')"/>
</el-form-item>
<!-- 部门 -->
<el-form-item :label="$t('trials:trials-myinfo:form:department')" prop="DepartmentName">
<el-input v-model="user.DepartmentName" :placeholder="$t('trials:trials-myinfo:form:organization')"/>
</el-form-item>
<!-- 职位 -->
<el-form-item :label="$t('trials:trials-myinfo:form:position')" prop="PositionName">
<el-input v-model="user.PositionName" :placeholder="$t('trials:trials-myinfo:form:position')"/>
</el-form-item>
</el-form>
<!-- 保存 -->
<el-button
class="trial-info-btn"
type="primary"
size="small"
@click="handleSave"
>
{{ $t('trials:trials-myinfo:button:save') }}
</el-button>
</div>
</div>
<div class="trial-myinfo-right">
<div class="trial-myinfo-right-box">
<div class="trial-myinfo-head">
<!-- 账号信息 -->
{{ $t('trials:trials-myinfo:title:accountInfo') }}
</div>
<el-form label-position="right" label-width="180px">
<!-- 用户名 -->
<el-form-item :label="$t('trials:trials-myinfo:form:userName')" style="margin-bottom: 5px;" prop="UserName">
<span>{{ user.UserName }}</span>
</el-form-item>
<el-form-item label="" style="position: relative" prop="UserName">
<el-input v-model="userForm.UserName" :placeholder="$t('trials:trials-myinfo:form:userName')"/>
<!-- 修改 -->
<el-button :disabled="!userForm.UserName" class="saveBtn" type="primary" size="small" @click="setNewUserName">
{{ $t('trials:trials-myinfo:button:update') }}
</el-button>
</el-form-item>
<!-- 电话 -->
<el-form-item :label="$t('trials:trials-myinfo:form:phone')" style="margin-bottom: 5px;" prop="UserName">
<span>{{ user.Phone }}</span>
</el-form-item>
<el-form-item label="" style="position: relative" prop="UserName">
<el-input v-model="userForm.Phone" :placeholder="$t('trials:trials-myinfo:form:phone')"/>
<!-- 修改 -->
<el-button :disabled="!userForm.Phone" class="saveBtn" type="primary" size="small" @click="setNewPhone">
{{ $t('trials:trials-myinfo:button:update') }}
</el-button>
</el-form-item>
<!-- 邮箱 -->
<el-form-item :label="$t('trials:trials-myinfo:form:email')" style="margin-bottom: 5px;" prop="UserName">
<span>{{ user.EMail }}</span>
</el-form-item>
<el-form-item label="" style="margin-bottom: 10px;position: relative" prop="EMail">
<el-input v-model="userForm.EMail" @input="handleEmailChange" :placeholder="$t('trials:trials-myinfo:form:email')"/>
<el-button class="sendCode" :disabled="sendDisabled" type="primary" size="mini" @click="sendVerificationCode">{{ sendTitle }}</el-button>
</el-form-item>
<el-form-item label="" style="position: relative" prop="VerificationCode">
<el-input v-model="userForm.VerificationCode" :placeholder="$t('trials:researchForm:form:verifyCode')"/>
<!-- 修改 -->
<el-button :disabled="!userForm.EMail || !userForm.VerificationCode" class="saveBtn" type="primary" size="small" @click="setNewEmail">
{{ $t('trials:trials-myinfo:button:update') }}
</el-button>
</el-form-item>
</el-form>
</div>
<div class="trial-myinfo-right-box">
<div class="trial-myinfo-head">
<!-- 修改密码 -->
{{ $t('trials:trials-myinfo:title:updatePaasord') }}
</div>
<el-form ref="passwordForm" label-position="right" :model="password" :rules="passwordFormRules" label-width="180px">
<!-- 旧密码 -->
<el-form-item :label="$t('recompose:form:oldPassword')" prop="OldPassWord">
<el-input v-model="password.OldPassWord" type="password" show-password auto-complete="new-password" :placeholder="$t('recompose:form:oldPassword')"/>
</el-form-item>
<!-- 新密码 -->
<el-form-item class="my_new_pwd" :label="$t('recompose:form:newPassword')" prop="NewPassWord">
<el-input v-model="password.NewPassWord" type="password" show-password auto-complete="new-password" :placeholder="$t('recompose:form:newPassword')"/>
</el-form-item>
<!-- 确认密码 -->
<el-form-item :label="$t('recompose:form:confirmPassword')" prop="ConfirmPassWord">
<el-input v-model="password.ConfirmPassWord" type="password" show-password auto-complete="new-password" :placeholder="$t('recompose:form:confirmPassword')"/>
</el-form-item>
</el-form>
<el-button
type="primary"
size="small"
class="trial-info-btn"
@click="save"
>
{{ $t('trials:trials-myinfo:button:save') }}
</el-button>
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getUserTypeList, getUser, updateUser, modifyPassword } from '@/api/admin.js' import mine from "./mine.vue";
import { sendVerificationCode, setNewEmail, setNewPhone, setNewUserName } from '@/api/system/user.js' import account from "./account.vue";
import md5 from 'js-md5' import loginLog from "@/views/trials/trials-panel/trial-summary/login-log";
var timer = '' import { getUserTypeList, getUser } from "@/api/admin.js";
var countdown = 60 import store from "@/store";
import store from '@/store' import { mapGetters } from "vuex";
import {mapGetters, mapMutations} from 'vuex'
export default { export default {
name: "TrialsMyinfo",
name: 'TrialsMyinfo', components: { mine, account, "login-log": loginLog },
data() { data() {
return { return {
activeIndex: "1",
userTypeOptions: [], userTypeOptions: [],
user: {}, user: {},
password: {}, IsCanConnectInternet: true, //
userForm: {}, };
sendDisabled: true,
sendTitle: this.$t('trials:trials-myinfo:button:getVCode'),
userFormRules: {
UserName: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }],
UserTypeId: [{ required: true, message: this.$t('common:ruleMessage:select'), trigger: ['blur', 'change'] }],
IsZhiZhun: [{ required: true, message: this.$t('common:ruleMessage:select'), trigger: ['blur', 'change'] }],
OrganizationName: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }],
LastName: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }, { max: 50, message: `${this.$t('common:ruleMessage:maxLength')} 50` }],
FirstName: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }, { max: 50, message: `${this.$t('common:ruleMessage:maxLength')} 50` }],
Sex: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }],
Status: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }]
},
passwordFormRules: {
OldPassWord: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }],
NewPassWord: [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' },
{
required: true,
trigger: 'blur',
validator: this.$validatePassword
},
],
ConfirmPassWord: [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' },
{
required: true,
trigger: 'blur',
validator: this.$validatePassword
},
]
}
}
}, },
computed: { computed: {
...mapGetters(['userId', 'name']) ...mapGetters(["userId", "userName"]),
}, },
mounted() { mounted() {
this.getUserInfo() this.getUserInfo();
this.getUserTypeList() this.getUserTypeList();
}, },
methods: { methods: {
...mapMutations({ setLanguage: 'lang/setLanguage' }), handleSelect(index) {
handleSave() { this.activeIndex = index;
this.$refs.userForm.validate(valid => {
console.log(valid)
if (valid) {
this.isDisabled = true
const selectedUserType = this.userTypeOptions.filter((item) => {
return item.Id === this.user.UserTypeId
})
if (selectedUserType.length > 0) {
this.user.userTypeEnum = selectedUserType[0].UserTypeEnum
}
// if (this.user.IsZhiZhun === true) {
// this.user.OrganizationName = 'ZhiZhun'
// }
if (this.user.Id) {
updateUser(this.user).then(res => {
this.isDisabled = false
this.$message.success(this.$t('trials:trials-myinfo:message:updateSuccessfully'))
this.getUserInfo()
}).catch(() => { this.isDisabled = false })
}
}
})
},
handleEmailChange() {
var reg = /^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/
if (this.userForm.EMail && reg.test(this.userForm.EMail)) {
this.sendDisabled = false
} else {
this.sendDisabled = true
}
},
sendVerificationCode() {
sendVerificationCode(this.userForm.EMail).then(() => {
this.settime(this)
//
this.$message.success(this.$t('trials:trials-myinfo:message:sendSuccessfully'))
})
},
save() {
this.$refs.passwordForm.validate(valid => {
if (valid) {
if (this.password.NewPassWord !== this.password.ConfirmPassWord) {
this.$alert(this.$t('passwordReset:formRule:passwordsDiffer'))
return
}
const param = {
UserId: this.userId,
NewPassWord: md5(this.password.NewPassWord),
OldPassWord: md5(this.password.OldPassWord)
}
modifyPassword(param).then(res => {
if (res.IsSuccess) {
// ,
this.$message.success(this.$t('trials:trials-myinfo:message:modifyPWSuccessfully'))
setTimeout(() => {
this.logout()
}, 1000)
}
})
}
})
},
setNewEmail() {
setNewEmail(this.userForm.EMail, this.userForm.VerificationCode).then(() => {
this.userForm.EMail = ''
this.userForm.VerificationCode = ''
this.$message.success(this.$t('trials:trials-myinfo:message:updateSuccessfully'))
this.getUserInfo()
})
},
setNewUserName() {
setNewUserName(this.userForm.UserName).then(() => {
this.$store.dispatch('user/changeUserName', this.userForm.UserName).then((res) => {
this.user.UserName = this.userForm.UserName
this.userForm.UserName = ''
this.$message.success(this.$t('trials:trials-myinfo:message:modifyPWSuccessfully'))
this.logout()
})
})
},
setNewPhone() {
setNewPhone(this.userForm.Phone).then(() => {
this.userForm.Phone = ''
this.$message.success(this.$t('trials:trials-myinfo:message:updateSuccessfully'))
this.getUserInfo()
})
}, },
getUserInfo() { getUserInfo() {
const loading = this.$loading({ const loading = this.$loading({
fullscreen: false, fullscreen: false,
lock: true, lock: true,
text: 'Loading', text: "Loading",
spinner: 'el-icon-loading', spinner: "el-icon-loading",
background: 'rgba(0, 0, 0, 0.07)' background: "rgba(0, 0, 0, 0.07)",
}) });
getUser(this.userId).then(async res => { getUser(this.userId)
this.user = res.Result .then(async (res) => {
/* eslint-disable */ this.user = res.Result;
zzSessionStorage.setItem('realName', this.user.RealName) /* eslint-disable */
await store.dispatch('user/updateInfo') zzSessionStorage.setItem("realName", this.user.RealName);
loading.close() await store.dispatch("user/updateInfo");
}).catch(() => { loading.close() }) loading.close();
}, })
settime(obj) { .catch(() => {
if (countdown === 0) { loading.close();
obj.sendDisabled = false });
obj.sendTitle = this.$t('trials:trials-myinfo:button:getVCode')// ''
countdown = 60
clearTimeout(timer)
return
} else {
obj.sendDisabled = true
obj.sendTitle = `${this.$t('trials:trials-myinfo:button:wait')}(${countdown}s)`
countdown--
// eslint-disable-next-line no-self-assign
countdown = countdown
timer = setTimeout(function() {
obj.settime(obj)
}, 1000)
}
}, },
getUserTypeList() { getUserTypeList() {
getUserTypeList().then(res => { getUserTypeList().then((res) => {
if (res.IsSuccess) { if (res.IsSuccess) {
this.userTypeOptions = res.Result this.userTypeOptions = res.Result;
} }
}) });
}, },
async logout() { },
/* eslint-disable */ };
var loginType = zzSessionStorage.getItem('loginType')
await this.$store.dispatch('user/logout')
if (loginType) {
this.$router.push(`/login?loginType=${loginType}`)
} else {
this.$router.push(`/login`)
}
this.$i18n.locale = 'zh'
this.setLanguage('zh')
this.$updateDictionary()
}
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
.trial-myinfo{ .trial-myinfo {
flex: 1;overflow: auto;display: flex;flex-direction: row;justify-content: space-around; flex: 1;
.trial-myinfo-head{ overflow: auto;
position: absolute;top: 40px;left: -10%;font-size: 14px; display: flex;
} flex-direction: row;
.trial-myinfo-left{ justify-content: space-around;
overflow: auto; .contentBox {
background: #fff;width: calc(50% - 9px);margin: 6px 0; width: calc(100% - 220px);
padding-bottom: 50px; background-color: #fff;
.trial-myinfo-left-top{ padding: 0 20px;
width: 70%;padding-top: 100px;position: relative;margin: 0 auto;margin-bottom: 10px; height: 100%;
} overflow: auto;
} // padding-bottom: 50px;
.trial-myinfo-body{ }
width:160px;height:160px;border-radius: 50%;background: #428bca;display: flex;justify-content: center;align-items: center; .trial-myinfo-head {
div{ position: absolute;
color:#fff;font-size: 30px; top: 40px;
} left: 20px;
} font-size: 14px;
.saveBtn{ }
position: absolute;right: -10px;top:2px;transform: translateX(100%) .trial-myinfo-left {
} overflow: auto;
.trial-info-btn{ background: #fff;
position: absolute;bottom: -60px;left: calc(100% + 10px);min-width: 97px; // width: calc(50% - 9px);
} // margin: 6px 0;
.trial-myinfo-left-bottom{ height: 100%;
width: 70%;padding-top: 100px;position: relative;margin: 0 auto; // padding-bottom: 50px;
} .trial-myinfo-left-top {
.trial-myinfo-right{ width: 70%;
overflow: auto; padding-top: 100px;
background: #fff;width: calc(50% - 9px);margin: 6px 0; position: relative;
padding-bottom: 50px; // margin: 0 auto;
.sendCode { margin-bottom: 10px;
position: absolute;right: -10px;top: 50%;transform: translate(100%, -50%); .trial-myinfo-body {
} width: 160px;
.trial-myinfo-right-box{ height: 160px;
width: 70%;padding-top: 100px;position: relative;margin: 0 auto; border-radius: 50%;
background: #428bca;
display: flex;
justify-content: center;
align-items: center;
margin-left: 30px;
div {
color: #fff;
font-size: 30px;
}
} }
} }
} }
</style> .saveBtn {
<style scoped> position: absolute;
right: -10px;
top: 2px;
transform: translateX(100%);
}
.trial-info-btn {
position: absolute;
bottom: -60px;
left: 10px;
min-width: 97px;
}
.trial-myinfo-left-bottom {
width: 40%;
padding-top: 100px;
position: relative;
// margin: 0 auto;
}
.trial-myinfo-right {
overflow: auto;
background: #fff;
// width: calc(50% - 9px);
// margin: 6px 0;
height: 100%;
.sendCode {
position: absolute;
right: -10px;
top: 50%;
transform: translate(100%, -50%);
}
.trial-myinfo-right-box {
width: 40%;
padding-top: 100px;
position: relative;
// margin: 0 auto;
}
}
}
</style> </style>

View File

@ -0,0 +1,198 @@
<template>
<div class="trial-myinfo-left">
<div class="trial-myinfo-left-bottom">
<div class="trial-myinfo-head">
<!-- 用户基本信息 -->
{{ $t("trials:trials-myinfo:title:basicInfo") }}
</div>
<el-form
ref="userForm"
label-position="right"
:model="user"
:rules="userFormRules"
label-width="120px"
>
<el-form-item v-if="user.Code" label="ID: " prop="Code">
<el-input v-model="user.Code" disabled />
</el-form-item>
<!-- -->
<el-form-item
:disabled="user.UserTypeEnum === 8"
:label="$t('trials:trials-myinfo:form:surname')"
prop="LastName"
>
<el-input
v-model="user.LastName"
:placeholder="$t('trials:trials-myinfo:form:surname')"
/>
</el-form-item>
<!-- -->
<el-form-item
:disabled="user.UserTypeEnum === 8"
:label="$t('trials:trials-myinfo:form:givenname')"
prop="FirstName"
>
<el-input
v-model="user.FirstName"
:placeholder="$t('trials:trials-myinfo:form:givenname')"
/>
</el-form-item>
<!-- 单位 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:organization')"
prop="OrganizationName"
>
<el-input
v-model="user.OrganizationName"
:placeholder="$t('trials:trials-myinfo:form:organization')"
/>
</el-form-item>
<!-- 部门 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:department')"
prop="DepartmentName"
>
<el-input
v-model="user.DepartmentName"
:placeholder="$t('trials:trials-myinfo:form:organization')"
/>
</el-form-item>
<!-- 职位 -->
<el-form-item
:label="$t('trials:trials-myinfo:form:position')"
prop="PositionName"
>
<el-input
v-model="user.PositionName"
:placeholder="$t('trials:trials-myinfo:form:position')"
/>
</el-form-item>
</el-form>
<!-- 保存 -->
<el-button
class="trial-info-btn"
type="primary"
size="small"
@click="handleSave"
>
{{ $t("trials:trials-myinfo:button:save") }}
</el-button>
</div>
</div>
</template>
<script>
import { updateUser } from "@/api/admin.js";
export default {
name: "mine",
props: {
user: {
required: true,
default: () => {
return {};
},
},
userTypeOptions: {
required: true,
default: () => {
return [];
},
},
},
data() {
return {
userFormRules: {
UserName: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
],
UserTypeId: [
{
required: true,
message: this.$t("common:ruleMessage:select"),
trigger: ["blur", "change"],
},
],
IsZhiZhun: [
{
required: true,
message: this.$t("common:ruleMessage:select"),
trigger: ["blur", "change"],
},
],
OrganizationName: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
],
LastName: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
{ max: 50, message: `${this.$t("common:ruleMessage:maxLength")} 50` },
],
FirstName: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
{ max: 50, message: `${this.$t("common:ruleMessage:maxLength")} 50` },
],
Sex: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
],
Status: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
],
},
};
},
methods: {
handleSave() {
this.$refs.userForm.validate((valid) => {
console.log(valid);
if (valid) {
this.isDisabled = true;
const selectedUserType = this.userTypeOptions.filter((item) => {
return item.Id === this.user.UserTypeId;
});
if (selectedUserType.length > 0) {
this.user.userTypeEnum = selectedUserType[0].UserTypeEnum;
}
// if (this.user.IsZhiZhun === true) {
// this.user.OrganizationName = 'ZhiZhun'
// }
if (this.user.Id) {
updateUser(this.user)
.then((res) => {
this.isDisabled = false;
this.$message.success(
this.$t("trials:trials-myinfo:message:updateSuccessfully")
);
this.$emit("getUserInfo");
})
.catch(() => {
this.isDisabled = false;
});
}
}
});
},
},
};
</script>

View File

@ -0,0 +1,160 @@
<template>
<div class="trial-myinfo-right-box">
<div class="trial-myinfo-head">
<!-- 修改密码 -->
{{ $t("trials:trials-myinfo:title:updatePaasord") }}
</div>
<el-form
ref="passwordForm"
label-position="right"
:model="password"
:rules="passwordFormRules"
label-width="100px"
>
<!-- 旧密码 -->
<el-form-item
:label="$t('recompose:form:oldPassword')"
prop="OldPassWord"
>
<el-input
v-model="password.OldPassWord"
type="password"
show-password
auto-complete="new-password"
:placeholder="$t('recompose:form:oldPassword')"
/>
</el-form-item>
<!-- 新密码 -->
<el-form-item
:label="$t('recompose:form:newPassword')"
prop="NewPassWord"
>
<el-input
v-model="password.NewPassWord"
type="password"
show-password
auto-complete="new-password"
:placeholder="$t('recompose:form:newPassword')"
/>
</el-form-item>
<!-- 确认密码 -->
<el-form-item
:label="$t('recompose:form:confirmPassword')"
prop="ConfirmPassWord"
>
<el-input
v-model="password.ConfirmPassWord"
type="password"
show-password
auto-complete="new-password"
:placeholder="$t('recompose:form:confirmPassword')"
/>
</el-form-item>
</el-form>
<el-button type="primary" size="small" class="trial-info-btn" @click="save">
{{ $t("trials:trials-myinfo:button:save") }}
</el-button>
</div>
</template>
<script>
import md5 from "js-md5";
import { mapGetters, mapMutations } from "vuex";
import { modifyPassword } from "@/api/admin.js";
import { removeToken } from "@/utils/auth";
export default {
name: "password",
data() {
return {
password: {},
passwordFormRules: {
OldPassWord: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
],
NewPassWord: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
{
required: true,
trigger: "blur",
validator: this.$validatePassword,
},
],
ConfirmPassWord: [
{
required: true,
message: this.$t("common:ruleMessage:specify"),
trigger: "blur",
},
{
required: true,
trigger: "blur",
validator: this.$validatePassword,
},
],
},
};
},
computed: {
...mapGetters(["userId"]),
},
methods: {
...mapMutations({ setLanguage: "lang/setLanguage" }),
async save() {
try {
let validate = await this.$refs.passwordForm.validate();
if (!validate) return;
if (this.password.NewPassWord !== this.password.ConfirmPassWord) {
this.$alert(this.$t("passwordReset:formRule:passwordsDiffer"));
return;
}
let confirm = await this.$confirm(
this.$t("trials:trials-myInfo:confirmMessage:updatePassWord"),
{
type: "warning",
distinguishCancelAndClose: true,
confirmButtonText: this.$t("common:button:confirm"),
cancelButtonText: this.$t("common:button:cancel"),
}
);
if (confirm !== "confirm") return;
const param = {
UserId: this.userId,
NewPassWord: md5(this.password.NewPassWord),
OldPassWord: md5(this.password.OldPassWord),
};
let res = await modifyPassword(param);
if (res.IsSuccess) {
// ,
this.$message.success(
this.$t("trials:trials-myinfo:message:modifyPWSuccessfully")
);
removeToken();
this.logout();
}
} catch (err) {
console.log(err);
}
},
async logout() {
/* eslint-disable */
var loginType = zzSessionStorage.getItem("loginType");
await this.$store.dispatch("user/logout");
if (loginType) {
this.$router.push(`/login?loginType=${loginType}`);
} else {
this.$router.push(`/login`);
}
this.$i18n.locale = "zh";
this.setLanguage("zh");
this.$updateDictionary();
},
},
};
</script>

View File

@ -1,12 +1,16 @@
<template> <template>
<BaseContainer> <BaseContainer>
<template slot="search-container"> <template slot="search-container">
<el-form :inline="true"> <el-form :inline="true">
<el-form-item <el-form-item
:label="$t('trials:loginLog:table:optType')" :label="$t('trials:loginLog:table:optType')"
prop="OptType" prop="OptType"
> >
<el-select v-model="searchData.OptType" clearable style="width:120px;"> <el-select
v-model="searchData.OptType"
clearable
style="width: 120px"
>
<el-option <el-option
v-for="item of $d.UserOptType" v-for="item of $d.UserOptType"
v-show="item.value !== 3 && item.value !== 10" v-show="item.value !== 3 && item.value !== 10"
@ -16,44 +20,48 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item label="IP" prop="IP">
label="IP"
prop="IP"
>
<el-input <el-input
v-model="searchData.IP" v-model="searchData.IP"
size="small" size="small"
clearable clearable
style="width:120px;" style="width: 120px"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('trials:loginLog:table:incorrectUserName')" :label="$t('trials:loginLog:table:incorrectUserName')"
prop="LoginFaildName" prop="LoginFaildName"
v-if="!isMine"
> >
<el-input <el-input
v-model="searchData.LoginFaildName" v-model="searchData.LoginFaildName"
size="small" size="small"
clearable clearable
style="width:120px;" style="width: 120px"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('trials:loginLog:table:userName')" :label="$t('trials:loginLog:table:userName')"
prop="LoginUserName" prop="LoginUserName"
v-if="!isMine"
> >
<el-input <el-input
v-model="searchData.LoginUserName" v-model="searchData.LoginUserName"
size="small" size="small"
clearable clearable
style="width:120px;" style="width: 120px"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('trials:loginLog:table:userType')" :label="$t('trials:loginLog:table:userType')"
prop="OptType" prop="OptType"
v-if="!isMine"
> >
<el-select v-model="searchData.LoginUserTypeEnum" clearable style="width:120px;"> <el-select
v-model="searchData.LoginUserTypeEnum"
clearable
style="width: 120px"
>
<el-option <el-option
v-for="item of $d.UserType" v-for="item of $d.UserType"
v-show="item.value !== 7 && item.value !== 8" v-show="item.value !== 7 && item.value !== 8"
@ -63,9 +71,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item :label="$t('trials:loginLog:table:createTime')">
:label="$t('trials:loginLog:table:createTime')"
>
<el-date-picker <el-date-picker
v-model="datetimerange" v-model="datetimerange"
type="datetimerange" type="datetimerange"
@ -78,11 +84,15 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleSearch"> <el-button type="primary" icon="el-icon-search" @click="handleSearch">
{{ $t('common:button:search') }} {{ $t("common:button:search") }}
</el-button> </el-button>
<!-- 重置 --> <!-- 重置 -->
<el-button type="primary" icon="el-icon-refresh-left" @click="handleReset"> <el-button
{{ $t('common:button:reset') }} type="primary"
icon="el-icon-refresh-left"
@click="handleReset"
>
{{ $t("common:button:reset") }}
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -90,17 +100,14 @@
<template slot="main-container"> <template slot="main-container">
<el-table <el-table
v-loading="loading" v-loading="loading"
v-adaptive="{bottomOffset:60}" v-adaptive="{ bottomOffset: isMine ? 80 : 60 }"
height="100" height="100"
:data="list" :data="list"
class="table" class="table"
@sort-change="handleSortByColumn" @sort-change="handleSortByColumn"
:default-sort ="{prop: 'CreateTime', order: 'descending'}" :default-sort="{ prop: 'CreateTime', order: 'descending' }"
> >
<el-table-column <el-table-column type="index" width="50" />
type="index"
width="50"
/>
<el-table-column <el-table-column
:label="$t('trials:loginLog:table:optType')" :label="$t('trials:loginLog:table:optType')"
prop="OptType" prop="OptType"
@ -109,7 +116,7 @@
sortable="custom" sortable="custom"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd('UserOptType',scope.row.OptType) }} {{ $fd("UserOptType", scope.row.OptType) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -120,6 +127,7 @@
sortable="custom" sortable="custom"
/> />
<el-table-column <el-table-column
v-if="!isMine"
:label="$t('trials:loginLog:table:incorrectUserName')" :label="$t('trials:loginLog:table:incorrectUserName')"
prop="LoginFaildName" prop="LoginFaildName"
min-width="90" min-width="90"
@ -141,10 +149,11 @@
sortable="custom" sortable="custom"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd('UserType',scope.row.LoginUserTypeEnum) }} {{ $fd("UserType", scope.row.LoginUserTypeEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="!isMine"
:label="$t('trials:loginLog:table:optUserName')" :label="$t('trials:loginLog:table:optUserName')"
prop="OptUserName" prop="OptUserName"
min-width="90" min-width="90"
@ -152,6 +161,7 @@
sortable="custom" sortable="custom"
/> />
<el-table-column <el-table-column
v-if="!isMine"
:label="$t('trials:loginLog:table:optUserType')" :label="$t('trials:loginLog:table:optUserType')"
prop="OptUserTypeEnum" prop="OptUserTypeEnum"
min-width="90" min-width="90"
@ -159,7 +169,7 @@
sortable="custom" sortable="custom"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd('UserType',scope.row.OptUserTypeEnum) }} {{ $fd("UserType", scope.row.OptUserTypeEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -170,34 +180,50 @@
sortable="custom" sortable="custom"
/> />
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination class="page" :total="total" :page.sync="searchData.PageIndex" :limit.sync="searchData.PageSize" @pagination="getList" /> <pagination
class="page"
:total="total"
:page.sync="searchData.PageIndex"
:limit.sync="searchData.PageSize"
@pagination="getList"
/>
</template> </template>
</BaseContainer> </BaseContainer>
</template> </template>
<script> <script>
import { getUserLogList } from '@/api/user' import { getUserLogList } from "@/api/user";
import BaseContainer from '@/components/BaseContainer' import BaseContainer from "@/components/BaseContainer";
import Pagination from '@/components/Pagination' import Pagination from "@/components/Pagination";
import moment from 'moment' import moment from "moment";
const searchDataDefault = () => { const searchDataDefault = () => {
return { return {
TrialId:'', TrialId: "",
OptType: null, OptType: null,
Ip: '', Ip: "",
LoginFaildName: '', LoginFaildName: "",
LoginUserName: '', LoginUserName: "",
LoginUserTypeEnum: null, LoginUserTypeEnum: null,
BeginDate: '', BeginDate: "",
EndDate: '', EndDate: "",
Asc: false, Asc: false,
SortField: 'CreateTime', SortField: "CreateTime",
PageIndex: 1, PageIndex: 1,
PageSize: 20 PageSize: 20,
} };
} };
export default { export default {
components: { BaseContainer,Pagination }, components: { BaseContainer, Pagination },
props: {
isMine: {
type: Boolean,
default: false,
},
name: {
type: String,
default: "",
},
},
data() { data() {
return { return {
moment, moment,
@ -205,55 +231,60 @@ export default {
list: [], list: [],
total: 0, total: 0,
loading: false, loading: false,
datetimerange: [] datetimerange: [],
} };
}, },
mounted() { mounted() {
console.log(this.$d.UserOptType) console.log(this.$d.UserOptType);
this.getList() this.getList();
}, },
methods: { methods: {
getList() { getList() {
this.loading = true this.loading = true;
this.searchData.TrialId = this.$route.query.trialId this.searchData.TrialId = this.$route.query.trialId;
getUserLogList(this.searchData).then((res) => { if (this.isMine) {
this.loading = false this.searchData.LoginUserName = this.name;
this.list = res.Result.CurrentPageData }
this.total = res.Result.TotalCount getUserLogList(this.searchData)
}).catch(() => { .then((res) => {
this.loading = false this.loading = false;
}) this.list = res.Result.CurrentPageData;
this.total = res.Result.TotalCount;
})
.catch(() => {
this.loading = false;
});
}, },
handleDatetimeChange(val) { handleDatetimeChange(val) {
if (val) { if (val) {
this.searchData.BeginDate = val[0] this.searchData.BeginDate = val[0];
this.searchData.EndDate = val[1] this.searchData.EndDate = val[1];
} else { } else {
this.searchData.BeginDate = '' this.searchData.BeginDate = "";
this.searchData.EndDate = '' this.searchData.EndDate = "";
} }
}, },
handleSearch() { handleSearch() {
this.searchData.PageIndex = 1 this.searchData.PageIndex = 1;
this.getList() this.getList();
}, },
// //
handleReset() { handleReset() {
this.datetimerange = null this.datetimerange = null;
this.searchData = searchDataDefault() this.searchData = searchDataDefault();
this.getList() this.getList();
}, },
// //
handleSortByColumn(column) { handleSortByColumn(column) {
if (column.order === 'ascending') { if (column.order === "ascending") {
this.searchData.Asc = true this.searchData.Asc = true;
} else { } else {
this.searchData.Asc = false this.searchData.Asc = false;
} }
this.searchData.SortField = column.prop this.searchData.SortField = column.prop;
this.searchData.PageIndex = 1 this.searchData.PageIndex = 1;
this.getList() this.getList();
} },
} },
} };
</script> </script>

View File

@ -1,265 +1,11 @@
<template> <template>
<div class="app-container"> <trials-info />
<el-card class="Security" style="width:800px;">
<div slot="header" class="clearfix">
<span>Security</span>
</div>
<el-form
ref="userForm"
size="small"
:model="user"
:rules="userFormRules"
label-width="210px"
style="width:600px;"
>
<el-form-item v-if="user.Code" label="ID: " prop="Code">
<el-input v-model="user.Code" disabled />
</el-form-item>
<el-form-item label="User Name: " prop="UserName">
<el-input v-model="user.UserName" disabled />
</el-form-item>
<el-form-item v-if="user.UserTypeEnum !== 8" label="Surname: " prop="LastName">
<el-input v-model="user.LastName" />
</el-form-item>
<el-form-item v-if="user.UserTypeEnum !== 8" label="Given Name: " prop="FirstName">
<el-input v-model="user.FirstName" />
</el-form-item>
<el-form-item label="Gender: " prop="Sex" style="margin-right:40px;">
<el-radio-group v-model="user.Sex">
<el-radio :label="1">Male</el-radio>
<el-radio :label="0">Female</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="Email: " prop="EMail">
<el-input v-model="user.EMail" />
</el-form-item>
<el-form-item label="Phone: ">
<el-input v-model="user.Phone" />
</el-form-item>
<el-form-item v-if="user.UserTypeEnum !== 8" label="Disable">
<el-switch v-model="user.Status" :active-value="0" :inactive-value="1" disabled />
</el-form-item>
<!-- <el-form-item label="User Type: " prop="UserTypeId">
<el-select v-model="user.UserTypeId" size="small" placeholder="Please select" disabled>
<el-option
v-for="(value,key) of dictionaryList.UserType"
:key="key"
:label="value"
:value="key"
/>
</el-select>
</el-form-item> -->
<!-- <el-form-item label="User Type: " prop="UserTypeId">
<el-select ref="userType" v-model="user.UserTypeId" size="small" placeholder="Please select" style="width:100%;">
<el-option
v-for="(userType,key) of userTypeOptions"
:key="key"
:label="userType.UserType"
:value="userType.Id"
/>
</el-select>
</el-form-item> -->
<el-form-item label="User Type: " prop="UserType">
<el-input v-model="user.UserType" disabled />
</el-form-item>
<!-- <div slot="header" class="clearfix">-->
<!-- <span>Affiliation</span>-->
<!-- </div>-->
<el-form-item prop="IsZhiZhun">
<el-radio-group v-model="user.IsZhiZhun">
<el-radio :label="true">Internal</el-radio>
<el-radio :label="false">External</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-show="user.IsZhiZhun === false" label="Organization Name: " prop="OrganizationName">
<el-input v-model="user.OrganizationName" />
</el-form-item>
<!-- <el-form-item label="Orgnization Type: " prop="OrganizationTypeId">
<el-select
v-model="user.OrganizationTypeId"
placeholder="Please select"
@change="handelOrgnizationTypeChange"
>
<el-option
v-for="(value,key) of dictionaryList.InstitutionalType"
:key="key"
:label="value"
:value="key"
/>
</el-select>
</el-form-item>
<el-form-item v-show="user.OrganizationTypeId" label="Orgnization: " prop="OrganizationId">
<el-select v-model="user.OrganizationId" placeholder="Please select">
<el-option
v-for="(item) of OrganizationOptions"
:key="item.Id"
:label="item.InstitutionName"
:value="item.Id"
/>
</el-select>
</el-form-item> -->
<el-form-item label="Department: " prop="DepartmentName">
<el-input v-model="user.DepartmentName" />
</el-form-item>
<el-form-item label="Position: " prop="PositionName">
<el-input v-model="user.PositionName" />
</el-form-item>
<el-form-item>
<el-button
type="primary"
size="small"
:disabled="isDisabled"
style="margin:10px 15px"
@click="handleSave"
>Save</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="Security" style="width:800px;">
<div slot="header" class="clearfix">
<span>Security</span>
</div>
<el-form
ref="userAccount"
:model="user"
:rules="userFormRules"
label-width="210px"
style="width:600px;"
>
<el-form-item label="Current Password" prop="OldPassWord">
<el-input v-model="user.OldPassWord" type="password" />
</el-form-item>
<el-form-item label="New Password" prop="NewPassWord">
<el-input v-model="user.NewPassWord" type="password" />
</el-form-item>
<el-form-item label="Confirm New Password" prop="ConfirmPassWord">
<el-input v-model="user.ConfirmPassWord" type="password" />
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="save">save</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</template> </template>
<script> <script>
import { getUserTypeList, getInstitutionList, getUser, addUser, updateUser } from '@/api/admin.js' import TrialsMyinfo from "@/views/trials/trials-myinfo";
import store from '@/store'
import { mapGetters } from 'vuex'
export default { export default {
data() { components: {
return { "trials-info": TrialsMyinfo,
user: {},
userFormRules: {
UserName: [{ required: true, message: 'Please specify', trigger: 'blur' }],
UserTypeId: [{ required: true, message: 'Please Select', trigger: ['blur', 'change'] }],
// OrganizationId: [{ required: true, message: 'Please specify', trigger: 'blur' }],
// OrganizationTypeId: [{ required: true, message: 'Please specify', trigger: 'blur' }],
// RealName: [{ required: true, message: 'Please specify', trigger: 'blur' }],
IsZhiZhun: [{ required: true, message: 'Please Select', trigger: ['blur', 'change'] }],
OrganizationName: [{ required: true, message: 'Please specify', trigger: 'blur' }],
LastName: [{ required: true, message: 'Please specify', trigger: 'blur' }, { max: 50, message: 'The maximum length is 50' }],
FirstName: [{ required: true, message: 'Please specify', trigger: 'blur' }, { max: 50, message: 'The maximum length is 50' }],
// Phone: [
// { max: 20, min: 7, message: 'The length is 7 to 20' }
// ],
EMail: [
{
required: true,
message: 'Please input the email address',
trigger: 'blur'
},
{
type: 'email',
message: 'Please input the correct email address',
trigger: ['blur', 'change']
},
{ max: 50, message: 'The maximum length is 50' }
],
Sex: [{ required: true, message: 'Please specify', trigger: 'blur' }],
Status: [{ required: true, message: 'Please specify', trigger: 'blur' }]
},
// OrganizationOptions: [],
userTypeOptions: [],
isDisabled: false
}
}, },
computed: { };
...mapGetters(['userId']) </script>
},
mounted() {
// this.getUserTypeList()
this.initPage()
},
methods: {
handleSave() {
this.$refs.userForm.validate(valid => {
if (valid) {
this.isDisabled = true
const selectedUserType = this.userTypeOptions.filter((item) => {
return item.Id === this.user.UserTypeId
})
if (selectedUserType.length > 0) {
this.user.userTypeEnum = selectedUserType[0].UserTypeEnum
}
if (this.user.IsZhiZhun === true) {
this.user.OrganizationName = 'ZhiZhun'
}
if (this.user.Id) {
updateUser(this.user).then(res => {
this.isDisabled = false
this.$message.success('Updated successfully')
}).catch(() => { this.isDisabled = false })
} else {
addUser(this.user).then(res => {
this.isDisabled = false
this.$emit('getUserId', res.Result.Id)
this.$message.success('Added successfully')
}).catch(() => { this.isDisabled = false })
}
}
})
},
getUserInfo() {
getUser(this.userId).then(res => {
this.user = res.Result
// res.Result.OrganizationTypeId !== '00000000-0000-0000-0000-000000000000' ? this.getOrgnizationList(res.Result.OrganizationTypeId) : this.user.OrganizationTypeId = ''
})
},
getUserTypeList() {
getUserTypeList().then(res => {
if (res.IsSuccess) {
this.userTypeOptions = res.Result
}
})
},
handelOrgnizationTypeChange(val) {
if (val) {
this.user.OrganizationId = ''
this.getOrgnizationList(val)
}
},
getOrgnizationList(OrganizationTypeId) {
getInstitutionList(OrganizationTypeId).then(res => {
if (res.IsSuccess) {
this.OrganizationOptions = res.Result
}
})
},
async initPage() {
this.userId === '' ? await store.dispatch('user/getInfo') : ''
if (this.userId === '') {
await store.dispatch('user/getInfo')
}
this.getUserInfo()
}
}
}
</script>