|
@@ -2,19 +2,61 @@
|
|
<div id="index">
|
|
<div id="index">
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
- <el-col :span="24" class="one"> 修改密码 </el-col>
|
|
|
|
|
|
+ <el-col :span="24" class="one">
|
|
|
|
+ <custom-form v-model="form" :fields="fields" :rules="rules" @save="toSave"></custom-form>
|
|
|
|
+ </el-col>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
|
+import { UserStore } from '@/store/user'
|
|
|
|
+import { useTagsViewStore } from '@/store'
|
|
|
|
+import { LoginStore } from '@/store/api/login'
|
|
|
|
+const store = LoginStore()
|
|
|
|
+const userStore = UserStore()
|
|
|
|
+const tagsViewStore = useTagsViewStore()
|
|
|
|
+const user = computed(() => userStore.user)
|
|
|
|
+const router = useRouter()
|
|
|
|
+const $checkRes = inject('$checkRes')
|
|
// 加载中
|
|
// 加载中
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
|
+// 表单
|
|
|
|
+const form = ref({})
|
|
|
|
+const fields = ref([
|
|
|
|
+ { label: '新密码', model: 'password', type: 'password' },
|
|
|
|
+ { label: '确认新密码', model: 'ispassword', type: 'password' }
|
|
|
|
+])
|
|
|
|
+const rules = ref({
|
|
|
|
+ password: [{ required: true, message: '请输入新密码' }],
|
|
|
|
+ ispassword: [
|
|
|
|
+ { required: true, message: '请输入确认新密码' },
|
|
|
|
+ {
|
|
|
|
+ trigger: 'blur',
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (form.value.password !== value) {
|
|
|
|
+ callback(new Error('两次输入的密码不一致'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+})
|
|
// 请求
|
|
// 请求
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
loading.value = true
|
|
loading.value = true
|
|
loading.value = false
|
|
loading.value = false
|
|
})
|
|
})
|
|
|
|
+// 提交保存
|
|
|
|
+const toSave = async (data) => {
|
|
|
|
+ let res = await store.rp({ id: user.id, password: data.password, type: user.role })
|
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
|
+ userStore.logOut()
|
|
|
|
+ tagsViewStore.delAllViews()
|
|
|
|
+ router.push('/login')
|
|
|
|
+ }
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
<style scoped lang="scss"></style>
|
|
<style scoped lang="scss"></style>
|