|
@@ -20,7 +20,7 @@
|
|
|
<div class="clearfix">
|
|
|
<span>个人信息</span>
|
|
|
<el-button style="float: right; padding: 3px 0" text @click="quitLogin">退出账号</el-button>
|
|
|
- <el-button style="float: right; padding: 3px 0; margin-right: 10px" text @click="dialogVisible = true">
|
|
|
+ <el-button style="float: right; padding: 3px 0; margin-right: 10px" text @click="changePassword">
|
|
|
修改密码
|
|
|
</el-button>
|
|
|
</div>
|
|
@@ -79,20 +79,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <el-dialog title="修改密码" v-model="dialogVisible" width="360px">
|
|
|
- <el-input v-model="changePwdParam.oldPassword" type="password" show-password
|
|
|
- placeholder="请输入旧密码"></el-input>
|
|
|
- <div style="margin-top: 20px"></div>
|
|
|
- <el-input v-model="changePwdParam.newPassword" type="password" show-password
|
|
|
- placeholder="请输入新密码"></el-input>
|
|
|
- <div style="margin-top: 20px"></div>
|
|
|
- <el-input v-model="changePwdParam.newPasswordCopy" type="password" show-password
|
|
|
- placeholder="请重复新密码"></el-input>
|
|
|
- <template #footer>
|
|
|
- <el-button type="info" icon="RefreshLeft" @click="closeDialog">取消</el-button>
|
|
|
- <el-button type="primary" icon="Check" @click="confirmDialog">确定</el-button>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
<el-dialog title="建议详情" v-model="showCurrentAdvice" width="380px">
|
|
|
<div class="advice-detail">
|
|
|
<div><span>当前状态:</span>{{ filterStatusText(currentAdvice.statusFlag) }}</div>
|
|
@@ -116,10 +102,9 @@
|
|
|
</el-container>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
-import {computed, onActivated, onDeactivated, reactive, ref} from 'vue'
|
|
|
+<script setup>
|
|
|
+import {computed, onActivated, onDeactivated, ref} from 'vue'
|
|
|
import {
|
|
|
- changePassword,
|
|
|
checkAdvice,
|
|
|
dismissUserBadge,
|
|
|
getMyAdvices,
|
|
@@ -133,197 +118,124 @@ import router from '@/router'
|
|
|
import Cookies from 'js-cookie'
|
|
|
import store from '@/store'
|
|
|
import {setCallback} from '@/utils/websocket'
|
|
|
+import changePassword from "@/components/system/password-layer";
|
|
|
|
|
|
-export default {
|
|
|
- setup() {
|
|
|
- const windowSize = store.state.app.windowSize
|
|
|
- const adviceBoxStyle = {
|
|
|
- height: windowSize.h / 2 + 'px',
|
|
|
- padding: '0 5px',
|
|
|
- overflowY: 'auto',
|
|
|
- }
|
|
|
- const userInfo = ref({})
|
|
|
- const isAdmin = computed(() => {
|
|
|
- return userInfo.value.roles.indexOf(1) > -1
|
|
|
- })
|
|
|
- const errorHandler = () => {
|
|
|
- return true
|
|
|
- }
|
|
|
- const makeTextPortrait = () => {
|
|
|
- return genTextPortrait(userInfo.value.name)
|
|
|
- }
|
|
|
- const dialogVisible = ref(false)
|
|
|
- const changePwdParam = reactive({
|
|
|
- oldPassword: '',
|
|
|
- newPassword: '',
|
|
|
- newPasswordCopy: '',
|
|
|
- })
|
|
|
- const closeDialog = () => {
|
|
|
- dialogVisible.value = false
|
|
|
- changePwdParam.oldPassword = changePwdParam.newPassword = changePwdParam.newPasswordCopy = ''
|
|
|
- }
|
|
|
- const confirmDialog = () => {
|
|
|
- if (!changePwdParam.oldPassword) {
|
|
|
- ElMessage({
|
|
|
- message: '请输入旧密码!',
|
|
|
- type: 'warning',
|
|
|
- duration: 2500,
|
|
|
- showClose: true,
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (!changePwdParam.newPassword) {
|
|
|
- ElMessage({
|
|
|
- message: '请输入新密码!',
|
|
|
- type: 'warning',
|
|
|
- duration: 2500,
|
|
|
- showClose: true,
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (changePwdParam.newPassword !== changePwdParam.newPasswordCopy) {
|
|
|
- ElMessage({
|
|
|
- message: '两次输入的新密码不一致,请检查!',
|
|
|
- type: 'warning',
|
|
|
- duration: 2500,
|
|
|
- showClose: true,
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- changePassword(changePwdParam).then(() => {
|
|
|
- ElMessageBox.alert('修改成功,请重新登录。', '提示', {
|
|
|
- type: 'success',
|
|
|
- }).then(() => {
|
|
|
- quitLogin()
|
|
|
- }).catch(() => {
|
|
|
- quitLogin()
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- const quitLogin = () => {
|
|
|
- Cookies.remove('token')
|
|
|
- router.push('/login')
|
|
|
- }
|
|
|
- const currentStatus = ref('')
|
|
|
- const myAdvices = ref([])
|
|
|
- const cptAdvices = computed(() => {
|
|
|
- return myAdvices.value.filter((item) => {
|
|
|
- return item.statusFlag.toString().indexOf(currentStatus.value) !== -1
|
|
|
- })
|
|
|
- })
|
|
|
- const currentAdvice = ref({})
|
|
|
- const showCurrentAdvice = ref(false)
|
|
|
- const newAdvice = () => {
|
|
|
- ElMessageBox.prompt('请填写建议内容(不超过300个字)', '新建议', {
|
|
|
- confirmButtonText: '提交',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'info',
|
|
|
- }).then(({value}) => {
|
|
|
- submitNewAdvice({submitContent: value}).then(() => {
|
|
|
- getMyAdvices().then((res) => {
|
|
|
- myAdvices.value = res
|
|
|
- ElMessage({
|
|
|
- message: '提交成功',
|
|
|
- type: 'success',
|
|
|
- duration: 2000,
|
|
|
- showClose: true,
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- const filterStatusType = (val) => {
|
|
|
- switch (val) {
|
|
|
- case 0:
|
|
|
- return 'info'
|
|
|
- case 1:
|
|
|
- return 'primary'
|
|
|
- case 2:
|
|
|
- return 'success'
|
|
|
- default:
|
|
|
- return 'error'
|
|
|
- }
|
|
|
- }
|
|
|
- const filterStatusText = (val) => {
|
|
|
- switch (val) {
|
|
|
- case 0:
|
|
|
- return '未查看'
|
|
|
- case 1:
|
|
|
- return '已查看'
|
|
|
- case 2:
|
|
|
- return '已回复'
|
|
|
- default:
|
|
|
- return '未知状态'
|
|
|
- }
|
|
|
- }
|
|
|
- const seeAdviceDetail = (item) => {
|
|
|
- currentAdvice.value = item
|
|
|
- showCurrentAdvice.value = true
|
|
|
- if (item.statusFlag === 0 && isAdmin.value) {
|
|
|
- checkAdvice(item.id).then(() => {
|
|
|
- item.statusFlag = 1
|
|
|
- })
|
|
|
- }
|
|
|
- if (item.statusFlag === 2 && !isAdmin.value) {
|
|
|
- dismissUserBadge(item.id).then(() => {
|
|
|
- item.userBadge = 0
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- const replyAdvice = () => {
|
|
|
- updateReply(currentAdvice.value).then(() => {
|
|
|
- currentAdvice.value.statusFlag = 2
|
|
|
- showCurrentAdvice.value = false
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
- const callback = () => {
|
|
|
+const windowSize = store.state.app.windowSize
|
|
|
+const adviceBoxStyle = {
|
|
|
+ height: windowSize.h / 2 + 'px',
|
|
|
+ padding: '0 5px',
|
|
|
+ overflowY: 'auto',
|
|
|
+}
|
|
|
+const userInfo = ref({})
|
|
|
+const isAdmin = computed(() => {
|
|
|
+ return userInfo.value.roles.indexOf(1) > -1
|
|
|
+})
|
|
|
+const errorHandler = () => {
|
|
|
+ return true
|
|
|
+}
|
|
|
+const makeTextPortrait = () => {
|
|
|
+ return genTextPortrait(userInfo.value.name)
|
|
|
+}
|
|
|
+const quitLogin = () => {
|
|
|
+ Cookies.remove('token')
|
|
|
+ router.push('/login')
|
|
|
+}
|
|
|
+const currentStatus = ref('')
|
|
|
+const myAdvices = ref([])
|
|
|
+const cptAdvices = computed(() => {
|
|
|
+ return myAdvices.value.filter((item) => {
|
|
|
+ return item.statusFlag.toString().indexOf(currentStatus.value) !== -1
|
|
|
+ })
|
|
|
+})
|
|
|
+const currentAdvice = ref({})
|
|
|
+const showCurrentAdvice = ref(false)
|
|
|
+const newAdvice = () => {
|
|
|
+ ElMessageBox.prompt('请填写建议内容(不超过300个字)', '新建议', {
|
|
|
+ confirmButtonText: '提交',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'info',
|
|
|
+ }).then(({value}) => {
|
|
|
+ submitNewAdvice({submitContent: value}).then(() => {
|
|
|
getMyAdvices().then((res) => {
|
|
|
myAdvices.value = res
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- onActivated(() => {
|
|
|
- getUserInfo().then((res) => {
|
|
|
- userInfo.value = res
|
|
|
- getMyAdvices().then((res2) => {
|
|
|
- myAdvices.value = res2
|
|
|
- setCallback(callback)
|
|
|
- if (isAdmin.value) {
|
|
|
- currentStatus.value = '0'
|
|
|
- }
|
|
|
+ ElMessage({
|
|
|
+ message: '提交成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ showClose: true,
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- onDeactivated(() => {
|
|
|
- setCallback(null)
|
|
|
+ })
|
|
|
+}
|
|
|
+const filterStatusType = (val) => {
|
|
|
+ switch (val) {
|
|
|
+ case 0:
|
|
|
+ return 'info'
|
|
|
+ case 1:
|
|
|
+ return 'primary'
|
|
|
+ case 2:
|
|
|
+ return 'success'
|
|
|
+ default:
|
|
|
+ return 'error'
|
|
|
+ }
|
|
|
+}
|
|
|
+const filterStatusText = (val) => {
|
|
|
+ switch (val) {
|
|
|
+ case 0:
|
|
|
+ return '未查看'
|
|
|
+ case 1:
|
|
|
+ return '已查看'
|
|
|
+ case 2:
|
|
|
+ return '已回复'
|
|
|
+ default:
|
|
|
+ return '未知状态'
|
|
|
+ }
|
|
|
+}
|
|
|
+const seeAdviceDetail = (item) => {
|
|
|
+ currentAdvice.value = item
|
|
|
+ showCurrentAdvice.value = true
|
|
|
+ if (item.statusFlag === 0 && isAdmin.value) {
|
|
|
+ checkAdvice(item.id).then(() => {
|
|
|
+ item.statusFlag = 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (item.statusFlag === 2 && !isAdmin.value) {
|
|
|
+ dismissUserBadge(item.id).then(() => {
|
|
|
+ item.userBadge = 0
|
|
|
})
|
|
|
+ }
|
|
|
+}
|
|
|
+const replyAdvice = () => {
|
|
|
+ updateReply(currentAdvice.value).then(() => {
|
|
|
+ currentAdvice.value.statusFlag = 2
|
|
|
+ showCurrentAdvice.value = false
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
- return {
|
|
|
- userInfo,
|
|
|
- isAdmin,
|
|
|
- adviceBoxStyle,
|
|
|
- errorHandler,
|
|
|
- makeTextPortrait,
|
|
|
- dialogVisible,
|
|
|
- changePwdParam,
|
|
|
- closeDialog,
|
|
|
- confirmDialog,
|
|
|
- quitLogin,
|
|
|
- myAdvices,
|
|
|
- newAdvice,
|
|
|
- filterStatusType,
|
|
|
- filterStatusText,
|
|
|
- currentAdvice,
|
|
|
- seeAdviceDetail,
|
|
|
- showCurrentAdvice,
|
|
|
- replyAdvice,
|
|
|
- currentStatus,
|
|
|
- cptAdvices,
|
|
|
- }
|
|
|
- },
|
|
|
+const callback = () => {
|
|
|
+ getMyAdvices().then((res) => {
|
|
|
+ myAdvices.value = res
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+onActivated(() => {
|
|
|
+ getUserInfo().then((res) => {
|
|
|
+ userInfo.value = res
|
|
|
+ getMyAdvices().then((res2) => {
|
|
|
+ myAdvices.value = res2
|
|
|
+ setCallback(callback)
|
|
|
+ if (isAdmin.value) {
|
|
|
+ currentStatus.value = '0'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+onDeactivated(() => {
|
|
|
+ setCallback(null)
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|