|
|
@ -1,14 +1,15 @@ |
|
|
|
<script setup> |
|
|
|
<script setup> |
|
|
|
import { onMounted, ref, computed } from 'vue' |
|
|
|
import { onMounted, ref, computed, onUnmounted, onBeforeUnmount } from 'vue' |
|
|
|
import { |
|
|
|
import { |
|
|
|
userChangeService, |
|
|
|
userChangeService, |
|
|
|
userChangePasswordService, |
|
|
|
userChangePasswordService, |
|
|
|
|
|
|
|
userCodeRegisterService, |
|
|
|
} from '@/api/user/user.js' |
|
|
|
} from '@/api/user/user.js' |
|
|
|
// import { defineEmits } from 'vue' |
|
|
|
// import { defineEmits } from 'vue' |
|
|
|
import useUserStore from '@/store/modules/user' |
|
|
|
import useUserStore from '@/store/modules/user' |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
import { ElMessage, dayjs } from 'element-plus' |
|
|
|
import { ElMessage, dayjs } from 'element-plus' |
|
|
|
|
|
|
|
import { Edit } from '@element-plus/icons-vue' |
|
|
|
const props = defineProps({ |
|
|
|
const props = defineProps({ |
|
|
|
name: { |
|
|
|
name: { |
|
|
|
type: String, |
|
|
|
type: String, |
|
|
@ -36,12 +37,12 @@ const passFormVisible = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
//dialog |
|
|
|
//dialog |
|
|
|
const form = ref({}) |
|
|
|
const form = ref({}) |
|
|
|
|
|
|
|
|
|
|
|
const formLabelWidth = '80px' |
|
|
|
const formLabelWidth = '80px' |
|
|
|
//打开dialog |
|
|
|
//打开dialog |
|
|
|
|
|
|
|
form.value = { ...props.userData, code: '' } |
|
|
|
const openInfo = () => { |
|
|
|
const openInfo = () => { |
|
|
|
dialogFormVisible.value = true |
|
|
|
dialogFormVisible.value = true |
|
|
|
form.value = { ...props.userData } |
|
|
|
codeVisible.value = false |
|
|
|
// console.log(form.value, 'form') |
|
|
|
// console.log(form.value, 'form') |
|
|
|
} |
|
|
|
} |
|
|
|
const openPass = () => { |
|
|
|
const openPass = () => { |
|
|
@ -64,20 +65,21 @@ const checkNewSame = (rule, value, cb) => { |
|
|
|
} |
|
|
|
} |
|
|
|
//信息校验 |
|
|
|
//信息校验 |
|
|
|
const infoRules = { |
|
|
|
const infoRules = { |
|
|
|
|
|
|
|
nickName: [ |
|
|
|
|
|
|
|
{ required: true, message: '请输入昵称', trigger: 'blur' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
max: 10, |
|
|
|
|
|
|
|
min: 1, |
|
|
|
|
|
|
|
message: '昵称长度最小一位最大十位', |
|
|
|
|
|
|
|
trigger: ['change', 'blur'], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
phone: [ |
|
|
|
phone: [ |
|
|
|
{ required: true, message: '请输入手机号', trigger: 'blur' }, |
|
|
|
{ required: true, message: '请输入手机号', trigger: 'blur' }, |
|
|
|
{ |
|
|
|
{ |
|
|
|
pattern: /^1[3-9]\d{9}$/, |
|
|
|
pattern: /^1[3-9]\d{9}$/, |
|
|
|
message: '手机号格式不正确', |
|
|
|
message: '手机号格式不正确', |
|
|
|
trigger: 'blur', |
|
|
|
trigger: ['change', 'blur'], |
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
nickName: [ |
|
|
|
|
|
|
|
{ required: true, message: '请输入昵称', trigger: 'blur' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pattern: /^[\u4e00-\u9fa5a-zA-Z0-9_]{1,10}$/, |
|
|
|
|
|
|
|
message: '昵称格式不正确', |
|
|
|
|
|
|
|
trigger: 'blur', |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
} |
|
|
|
} |
|
|
@ -117,15 +119,49 @@ const rules = { |
|
|
|
const infoRef = ref() |
|
|
|
const infoRef = ref() |
|
|
|
//修改用户信息 |
|
|
|
//修改用户信息 |
|
|
|
const emit = defineEmits(['get-message']) |
|
|
|
const emit = defineEmits(['get-message']) |
|
|
|
|
|
|
|
//验证码倒计时 |
|
|
|
|
|
|
|
const countdown = ref(0) |
|
|
|
|
|
|
|
//修改手机号 |
|
|
|
|
|
|
|
const codeVisible = ref(false) |
|
|
|
|
|
|
|
//切换可见性 |
|
|
|
|
|
|
|
const toggleVisibility = () => { |
|
|
|
|
|
|
|
codeVisible.value = !codeVisible.value |
|
|
|
|
|
|
|
if (codeVisible.value == true) { |
|
|
|
|
|
|
|
// 清空输入框 |
|
|
|
|
|
|
|
form.value.phone = '' |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果输入框为空,可以设置为某个默认值,比如'sample text' |
|
|
|
|
|
|
|
form.value.phone = props.userData.phone // 这里可以根据需要自定义默认值 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 切换输入框的值,如果输入框当前有值则设置为空,如果没有值则设置为一个默认值 |
|
|
|
|
|
|
|
const toggleInputValue = () => {} |
|
|
|
|
|
|
|
//验证码 |
|
|
|
|
|
|
|
const codecode = ref() |
|
|
|
|
|
|
|
const codeSubmit = async () => { |
|
|
|
|
|
|
|
await infoRef.value.validate() |
|
|
|
|
|
|
|
// console.log('开始发起注册验证码') |
|
|
|
|
|
|
|
const phoness = form.value.phone |
|
|
|
|
|
|
|
userCodeRegisterService(phoness) |
|
|
|
|
|
|
|
.then((response) => { |
|
|
|
|
|
|
|
codecode.value = response.data |
|
|
|
|
|
|
|
console.log(codecode.value, 'codecode') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
|
|
console.log(error.message, 'error') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const changePhone = () => { |
|
|
|
|
|
|
|
codeVisible.value = true |
|
|
|
|
|
|
|
} |
|
|
|
const changeInfo = async () => { |
|
|
|
const changeInfo = async () => { |
|
|
|
await infoRef.value.validate() |
|
|
|
await infoRef.value.validate() |
|
|
|
const userInfo = { |
|
|
|
await userChangeService({ |
|
|
|
phone: form.value.phone, |
|
|
|
phone: form.value.phone, |
|
|
|
id: form.value.id, |
|
|
|
id: form.value.id, |
|
|
|
nickName: form.value.nickName, |
|
|
|
nickName: form.value.nickName, |
|
|
|
} |
|
|
|
}).then(() => { |
|
|
|
const jsonData = JSON.stringify(userInfo) |
|
|
|
|
|
|
|
await userChangeService(jsonData).then(() => { |
|
|
|
|
|
|
|
ElMessage.success('修改成功') |
|
|
|
ElMessage.success('修改成功') |
|
|
|
emit('get-message', form.value.nickName) |
|
|
|
emit('get-message', form.value.nickName) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -138,12 +174,11 @@ const cancleInfo = () => { |
|
|
|
const userStore = useUserStore() |
|
|
|
const userStore = useUserStore() |
|
|
|
const onSubmit = async () => { |
|
|
|
const onSubmit = async () => { |
|
|
|
await formRef.value.validate() |
|
|
|
await formRef.value.validate() |
|
|
|
const passData = ref({ |
|
|
|
await userChangePasswordService({ |
|
|
|
oldPassword: pwdForm.value.old_pwd, |
|
|
|
oldPassword: pwdForm.value.old_pwd, |
|
|
|
newPassword: pwdForm.value.new_pwd, |
|
|
|
newPassword: pwdForm.value.new_pwd, |
|
|
|
username: props.userData.username, |
|
|
|
username: props.userData.username, |
|
|
|
}) |
|
|
|
}) |
|
|
|
await userChangePasswordService(passData.value) |
|
|
|
|
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
ElMessage.success('密码修改成功') |
|
|
|
ElMessage.success('密码修改成功') |
|
|
|
passFormVisible.value = false |
|
|
|
passFormVisible.value = false |
|
|
@ -173,8 +208,22 @@ const flagVisible = ref(true) |
|
|
|
|
|
|
|
|
|
|
|
//展示当前日期 |
|
|
|
//展示当前日期 |
|
|
|
const currentDate = new Date() |
|
|
|
const currentDate = new Date() |
|
|
|
const formattedDate = dayjs(currentDate).format('YYYY-MM-DD') |
|
|
|
const formattedDate = ref() |
|
|
|
|
|
|
|
// const formattedDate = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
|
|
|
|
// const timer = ref() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取验证码 |
|
|
|
|
|
|
|
let timer |
|
|
|
|
|
|
|
const updateCountdown = () => { |
|
|
|
|
|
|
|
if (countdown.value > 0) { |
|
|
|
|
|
|
|
countdown.value-- |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
clearInterval(timer) // 清除计时器 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
onBeforeUnmount(() => { |
|
|
|
|
|
|
|
clearInterval(timer) // 组件销毁前清除计时器,避免内存泄漏 |
|
|
|
|
|
|
|
}) |
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
username.value = props.data.name |
|
|
|
username.value = props.data.name |
|
|
|
const hireDate = new Date(props.data.joinWorkTime) |
|
|
|
const hireDate = new Date(props.data.joinWorkTime) |
|
|
@ -182,6 +231,12 @@ onMounted(() => { |
|
|
|
// const currentDate = new Date() |
|
|
|
// const currentDate = new Date() |
|
|
|
const millisecondsPerDay = 1000 * 60 * 60 * 24 |
|
|
|
const millisecondsPerDay = 1000 * 60 * 60 * 24 |
|
|
|
daysOnJob.value = Math.floor((currentDate - hireDate) / millisecondsPerDay) |
|
|
|
daysOnJob.value = Math.floor((currentDate - hireDate) / millisecondsPerDay) |
|
|
|
|
|
|
|
let timer = setInterval(() => { |
|
|
|
|
|
|
|
formattedDate.value = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
|
|
|
|
}, 100) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
onUnmounted(() => { |
|
|
|
|
|
|
|
clearInterval(timer) |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -212,7 +267,7 @@ onMounted(() => { |
|
|
|
title="登录信息" |
|
|
|
title="登录信息" |
|
|
|
style="width: 800px; text-align: center" |
|
|
|
style="width: 800px; text-align: center" |
|
|
|
> |
|
|
|
> |
|
|
|
<el-form :rules="infoRules" ref="infoRef" :data="form"> |
|
|
|
<el-form :model="form" :rules="infoRules" ref="infoRef" size="large"> |
|
|
|
<el-form-item label="用户名" :label-width="formLabelWidth"> |
|
|
|
<el-form-item label="用户名" :label-width="formLabelWidth"> |
|
|
|
<el-input :disabled="true" v-model="form.username" autocomplete="off" /> |
|
|
|
<el-input :disabled="true" v-model="form.username" autocomplete="off" /> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
@ -220,13 +275,53 @@ onMounted(() => { |
|
|
|
<el-input v-model="form.nickName" autocomplete="off" /> |
|
|
|
<el-input v-model="form.nickName" autocomplete="off" /> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="手机" :label-width="formLabelWidth" prop="phone"> |
|
|
|
<el-form-item label="手机" :label-width="formLabelWidth" prop="phone"> |
|
|
|
<el-input v-model="form.phone" autocomplete="off" /> |
|
|
|
<el-input v-model="form.phone" autocomplete="off" style="width: 92%" /> |
|
|
|
|
|
|
|
<el-button |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
plain |
|
|
|
|
|
|
|
circle |
|
|
|
|
|
|
|
@click="toggleVisibility" |
|
|
|
|
|
|
|
style="margin-left: 2%" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<el-icon> |
|
|
|
|
|
|
|
<Edit /> |
|
|
|
|
|
|
|
</el-icon> |
|
|
|
|
|
|
|
</el-button> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item |
|
|
|
|
|
|
|
label="验证码" |
|
|
|
|
|
|
|
:label-width="formLabelWidth" |
|
|
|
|
|
|
|
prop="code" |
|
|
|
|
|
|
|
v-if="codeVisible" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<el-input |
|
|
|
|
|
|
|
type="text" |
|
|
|
|
|
|
|
v-model="form.code" |
|
|
|
|
|
|
|
placeholder="请输入验证码" |
|
|
|
|
|
|
|
size="large" |
|
|
|
|
|
|
|
style="width: 84%" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<div class="p" v-if="countdown > 0"> |
|
|
|
|
|
|
|
<p>{{ countdown }} 秒</p> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<el-button |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
plain |
|
|
|
|
|
|
|
v-if="countdown <= 0" |
|
|
|
|
|
|
|
@click="codeSubmit" |
|
|
|
|
|
|
|
:disabled="countdown > 0" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
发送验证码 |
|
|
|
|
|
|
|
</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
<template #footer> |
|
|
|
<template #footer> |
|
|
|
<div class="dialog-footer"> |
|
|
|
<div class="dialog-footer"> |
|
|
|
<el-button @click="cancleInfo">取消</el-button> |
|
|
|
<el-button @click="cancleInfo">取消</el-button> |
|
|
|
<el-button type="primary" @click="changeInfo">确认</el-button> |
|
|
|
<el-button type="primary" @click="changeInfo, toggleInputValue"> |
|
|
|
|
|
|
|
确认 |
|
|
|
|
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> |
|
|
@ -235,7 +330,7 @@ onMounted(() => { |
|
|
|
title="修改密码" |
|
|
|
title="修改密码" |
|
|
|
style="width: 800px; text-align: center" |
|
|
|
style="width: 800px; text-align: center" |
|
|
|
> |
|
|
|
> |
|
|
|
<el-form :rules="rules" ref="formRef" :data="pwdForm"> |
|
|
|
<el-form :rules="rules" ref="formRef" :model="pwdForm"> |
|
|
|
<el-form-item label="原密码" prop="old_pwd" :label-width="formLabelWidth"> |
|
|
|
<el-form-item label="原密码" prop="old_pwd" :label-width="formLabelWidth"> |
|
|
|
<el-input |
|
|
|
<el-input |
|
|
|
type="password" |
|
|
|
type="password" |
|
|
@ -287,7 +382,7 @@ onMounted(() => { |
|
|
|
margin-right: 68px; |
|
|
|
margin-right: 68px; |
|
|
|
} |
|
|
|
} |
|
|
|
.intro { |
|
|
|
.intro { |
|
|
|
width: 60%; |
|
|
|
width: 50%; |
|
|
|
height: 22px; |
|
|
|
height: 22px; |
|
|
|
font-family: Inter, Inter; |
|
|
|
font-family: Inter, Inter; |
|
|
|
font-weight: bold; |
|
|
|
font-weight: bold; |
|
|
|