import type { TopLayoutType } from 'lib/type/TopLayout' import { ElMessage } from 'element-plus' import { indexStore } from 'lib/stores' import login from 'src/api/login' import clipboard from 'clipboard' import 'src/layout/TopLayout.scss' import TableLayout from 'lib/layout/TableLayout.vue' import message from 'lib/utils/message' import type { Form, FormData } from 'lib/type/TableData' import { formatConfig } from 'src/tools' // const TableLayout: any = utils.deepClone(tl) const store = indexStore() const data: TopLayoutType = { userButtons: [ // { // name: '修改配置', // type: 'success', // icon: 'EditPen', // onClick(self) { // self.methods?.getConfig(self) // ;(self.bean as any).configForm.show = 'form' // } // // getHide() { // // return store.$state.kwargs.role != 1 // // } // }, // { // name: '用户信息', // type: 'success', // icon: 'User', // onClick(self) { // ;(self.bean as any).userInfoDialogShow = true // } // }, // { // name: '修改密码', // type: 'warning', // icon: 'Key', // onClick(self) { // ;(self.bean as any).resetPasswordDialogShow = true // } // } ], bean: { userInfoDialogShow: false, resetPasswordDialogShow: false, resetPasswordInput: '', resetPasswordInputOld: '', resetPasswordInputTwo: '', configForm: { hideButton: true, show: false, data: [], async subFun(self, data) { // console.log(data) for (const key in data){ if (typeof data[key] === "object" && Array.isArray(data[key])){ data[key] = data[key].join(",") } } return login.editorConfig(data) } } as Form }, methods: { handleEditorConfigSubmit(self: TopLayoutType) { login.editorConfig((self.bean as any).editorConfigInfo).then((res: any) => { if (res.code == 0) { ElMessage.success('配置修改成功') } else { ElMessage.success('配置修改失败') } self.methods?.updateConfig(self) }) }, handleResetPasswordSubmit(self: TopLayoutType) { if ((self.bean as any).resetPasswordInputOld === '') { ElMessage.error('旧密码不能为空') return } if ((self.bean as any).resetPasswordInput === '') { ElMessage.error('密码不能为空') return } if ((self.bean as any).resetPasswordInput !== (self.bean as any).resetPasswordInputTwo) { ElMessage.error('两次输入的密码不一致') return } login .resetPassWord({ old_password: (self.bean as any).resetPasswordInputOld, password: (self.bean as any).resetPasswordInput }) .then((res: any) => { if (res.code === 0) { ElMessage.success('密码修改成功') setTimeout(() => { store.logout() }, 1000) } else { ElMessage.error(res.message) } }) }, copy(text: string) { clipboard.copy(text) message.success('复制成功') }, async getConfig(self: TopLayoutType) { const res = await login.getConfig() let formData: FormData[] = res.data formData = formatConfig(formData) ;(self.bean as any).configForm.data = formData } }, launchTask: [ // async (self) => { // const res = await login.getHomeData({}) // ;(self.bean as any).homeData = res.data // } ], addNods: [ (self) => { return (
{store.$state.kwargs.realname}
{store.$state.kwargs.role_name}
{store.$state.kwargs.level_name}
{store.$state.kwargs.parent_info.realname}
{/*
{store.$state.kwargs.parent_info.role_name}
{store.$state.kwargs.parent_info.level_name}
*/} {/**/} {/* */} {/**/} {/**/} {/*
*/} {/* {self.bean?.homeData.url}*/} {/* {*/} {/* self.methods?.copy(self.bean?.homeData.url)*/} {/* }}*/} {/* >*/} {/* 复制*/} {/* */} {/*
*/} {/*
*/}
) }, (self) => { return ( { ;(self.bean as any).resetPasswordDialogShow = false }} > 取消 { ;(self.methods as any).handleResetPasswordSubmit(self) }} > 确定 ) }, (self) => { let element: any = <> if (self.bean && TableLayout.methods) { element = TableLayout.methods.createForm.call( { ...TableLayout.methods, ...self.this_, fetchData: () => {} }, self.bean.configForm, { id: 'form' } ) } return element } ] } export default data