|
@@ -3,74 +3,119 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
<div class="w_1200 one">
|
|
|
- <el-col :span="24" class="one_1"> 基本信息</el-col>
|
|
|
- <el-col :span="24" class="one_2">
|
|
|
- <el-form
|
|
|
- label-position="top"
|
|
|
- ref="ruleFormRef"
|
|
|
- :model="form"
|
|
|
- :rules="rules"
|
|
|
- label-width="80px"
|
|
|
- class="form"
|
|
|
- >
|
|
|
- <el-form-item label="账号" prop="account">
|
|
|
- <el-input disabled v-model="form.account" placeholder="请输入账号">
|
|
|
- <template #prefix>
|
|
|
- <el-icon>
|
|
|
- <User />
|
|
|
- </el-icon>
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="昵称" prop="nick_name">
|
|
|
- <el-input v-model="form.nick_name" placeholder="请输入昵称">
|
|
|
- <template #prefix>
|
|
|
- <el-icon>
|
|
|
- <Avatar />
|
|
|
- </el-icon>
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="性别" prop="gender">
|
|
|
- <el-select v-model="form.gender" width="100%" placeholder="请选择性别">
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in genderList"
|
|
|
- :key="index"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="手机号" prop="phone">
|
|
|
- <el-input v-model="form.phone" placeholder="请输入手机号">
|
|
|
- <template #prefix>
|
|
|
- <el-icon>
|
|
|
- <Iphone />
|
|
|
- </el-icon>
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="角色" prop="role">
|
|
|
- <el-col :span="24" class="role"> {{ getRole(form.role) }}</el-col>
|
|
|
- </el-form-item>
|
|
|
- <el-col :span="24" class="button">
|
|
|
- <el-button type="primary" @click="submitForm(ruleFormRef)">保存</el-button>
|
|
|
+ <el-tabs v-model="activeName" type="card" class="tabs">
|
|
|
+ <el-tab-pane label="个人中心" name="first">
|
|
|
+ <el-col :span="24" class="one_1"> 基本信息</el-col>
|
|
|
+ <el-col :span="24" class="one_2">
|
|
|
+ <el-form
|
|
|
+ label-position="top"
|
|
|
+ ref="ruleFormRef"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="80px"
|
|
|
+ class="form"
|
|
|
+ >
|
|
|
+ <el-form-item label="账号" prop="account">
|
|
|
+ <el-input disabled v-model="form.account" placeholder="请输入账号">
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon>
|
|
|
+ <User />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="昵称" prop="nick_name">
|
|
|
+ <el-input v-model="form.nick_name" placeholder="请输入昵称">
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon>
|
|
|
+ <Avatar />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="性别" prop="gender">
|
|
|
+ <el-select v-model="form.gender" width="100%" placeholder="请选择性别">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in genderList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="手机号" prop="phone">
|
|
|
+ <el-input v-model="form.phone" placeholder="请输入手机号">
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon>
|
|
|
+ <Iphone />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-col :span="24" class="button">
|
|
|
+ <el-button type="primary" @click="submitForm(ruleFormRef)">保存</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
</el-col>
|
|
|
- </el-form>
|
|
|
- </el-col>
|
|
|
- <el-row v-if="form.type">
|
|
|
- <el-col :span="24" class="one_1"> 基本资料</el-col>
|
|
|
- <el-col :span="24" class="one_2">
|
|
|
- <expert v-if="form.type == '1'"></expert>
|
|
|
- <company v-if="form.type == '2'"></company>
|
|
|
- <incubator v-if="form.type == '3'"></incubator>
|
|
|
- <competition v-if="form.type == '4'"></competition>
|
|
|
- <investment v-if="form.type == '5'"></investment>
|
|
|
- <association v-if="form.type == '6'"></association>
|
|
|
- <state v-if="form.type == '7'"></state>
|
|
|
- <unit v-if="form.type == '8'"></unit>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ <el-row v-if="form.type">
|
|
|
+ <el-col :span="24" class="one_1"> 基本资料</el-col>
|
|
|
+ <el-col :span="24" class="one_2">
|
|
|
+ <expert v-if="form.type == '1'"></expert>
|
|
|
+ <company v-if="form.type == '2'"></company>
|
|
|
+ <incubator v-if="form.type == '3'"></incubator>
|
|
|
+ <competition v-if="form.type == '4'"></competition>
|
|
|
+ <investment v-if="form.type == '5'"></investment>
|
|
|
+ <association v-if="form.type == '6'"></association>
|
|
|
+ <state v-if="form.type == '7'"></state>
|
|
|
+ <unit v-if="form.type == '8'"></unit>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="修改密码" name="second">
|
|
|
+ <el-col :span="24" class="one_2">
|
|
|
+ <el-form
|
|
|
+ label-position="top"
|
|
|
+ ref="secondRule"
|
|
|
+ :model="secondForm"
|
|
|
+ :rules="secondRules"
|
|
|
+ label-width="80px"
|
|
|
+ class="form"
|
|
|
+ >
|
|
|
+ <el-form-item label="新密码" prop="password">
|
|
|
+ <el-input
|
|
|
+ v-model="secondForm.password"
|
|
|
+ type="password"
|
|
|
+ show-password
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon>
|
|
|
+ <Unlock />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="确认密码" prop="refpassword">
|
|
|
+ <el-input
|
|
|
+ v-model="secondForm.refpassword"
|
|
|
+ type="password"
|
|
|
+ show-password
|
|
|
+ placeholder="请再次确认输入密码"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon>
|
|
|
+ <Unlock />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-col :span="24" class="button">
|
|
|
+ <el-button type="primary" @click="submit(secondRule)">修改密码</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -80,7 +125,7 @@
|
|
|
<script setup>
|
|
|
// API 引用
|
|
|
import { getCity } from '@/utils/city'
|
|
|
-import { cloneDeep, get } from 'lodash-es'
|
|
|
+import { cloneDeep } from 'lodash-es'
|
|
|
// 组件
|
|
|
import association from './parts/association.vue'
|
|
|
import company from './parts/company.vue'
|
|
@@ -94,15 +139,17 @@ import investment from './parts/investment.vue'
|
|
|
import { UserStore } from '@/store/user'
|
|
|
const userStore = UserStore()
|
|
|
const user = computed(() => userStore.user)
|
|
|
+const router = useRouter()
|
|
|
import { UsersStore } from '@/store/api/user/user'
|
|
|
const store = UsersStore()
|
|
|
import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+import { LoginStore } from '@/store/api/login'
|
|
|
+const loginStore = LoginStore()
|
|
|
const dictDataStore = DictDataStore()
|
|
|
-import { RoleStore } from '@/store/api/system/role'
|
|
|
-const roleStore = RoleStore()
|
|
|
const $checkRes = inject('$checkRes')
|
|
|
// 加载中
|
|
|
const loading = ref(false)
|
|
|
+const activeName = ref('first')
|
|
|
const form = ref({})
|
|
|
// 表单验证
|
|
|
const ruleFormRef = ref()
|
|
@@ -116,12 +163,28 @@ const validatePhoneNumber = (rule, value, callback) => {
|
|
|
}
|
|
|
callback()
|
|
|
}
|
|
|
+const validatePassword = (rule, value, callback) => {
|
|
|
+ if (!value) {
|
|
|
+ return callback(new Error('请输入确认密码'))
|
|
|
+ }
|
|
|
+ if (secondForm.value.password !== value) {
|
|
|
+ callback(new Error('两次输入的密码不一致'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
const rules = reactive({
|
|
|
nick_name: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
|
|
|
gender: [{ required: true, message: '请选择性别', trigger: 'blur' }],
|
|
|
phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
|
|
|
account: [{ required: true, message: '请输入账号', trigger: 'blur' }]
|
|
|
})
|
|
|
+const secondRule = ref()
|
|
|
+const secondForm = ref({})
|
|
|
+const secondRules = reactive({
|
|
|
+ password: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
|
|
|
+ refpassword: [{ required: true, validator: validatePassword, trigger: 'blur' }]
|
|
|
+})
|
|
|
// 字典
|
|
|
const typeList = ref([])
|
|
|
const genderList = ref([])
|
|
@@ -134,7 +197,6 @@ const scaleList = ref([])
|
|
|
const IndustryList = ref([])
|
|
|
const cardTypeList = ref([])
|
|
|
const contributionList = ref([])
|
|
|
-const roleList = ref([])
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
@@ -182,19 +244,38 @@ const searchOther = async () => {
|
|
|
if ($checkRes(result)) isUseList.value = result.data
|
|
|
// 城市
|
|
|
getCity().then((response) => (cityList.value = response.address))
|
|
|
- // 角色
|
|
|
- result = await roleStore.query({ is_use: '0' })
|
|
|
- if ($checkRes(result)) roleList.value = result.data
|
|
|
}
|
|
|
-const getRole = (data) => {
|
|
|
- if (data) {
|
|
|
- const list = []
|
|
|
- for (const val of data) {
|
|
|
- const res = roleList.value.find((f) => f.code === val)
|
|
|
- list.push(get(res, 'name'))
|
|
|
+// 保存
|
|
|
+const submitForm = async (formEl) => {
|
|
|
+ if (!formEl) return
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ console.log(data)
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields)
|
|
|
}
|
|
|
- return list.join(',')
|
|
|
- }
|
|
|
+ })
|
|
|
+}
|
|
|
+// 修改密码
|
|
|
+const submit = async (formEl) => {
|
|
|
+ if (!formEl) return
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ const data = cloneDeep(secondForm.value)
|
|
|
+ const res = await loginStore.rp({
|
|
|
+ type: 'User',
|
|
|
+ _id: user.value._id,
|
|
|
+ password: data.password
|
|
|
+ })
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ userStore.logOut()
|
|
|
+ router.push('/login')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
// provide
|
|
|
provide('cloneDeep', cloneDeep)
|
|
@@ -215,12 +296,6 @@ provide('contributionList', contributionList)
|
|
|
.main {
|
|
|
background-color: #f1f2f5;
|
|
|
padding: 20px;
|
|
|
- .role {
|
|
|
- border: 1px solid #dcdfe6;
|
|
|
- border-radius: 4px;
|
|
|
- padding: 1px 11px;
|
|
|
- color: #606266;
|
|
|
- }
|
|
|
.one {
|
|
|
background-color: #fff;
|
|
|
padding: 20px;
|