/**/ export default { template: `
`, props: ['componentData'], data(){ return { win:{}, user:{}, editForm:{}, userChildren:{ data: [], pagination: { current: 0, pageSize: 1, total:0 }, params: { keyword:"", pageSize:10 }, userValidList:[], submitType:0, userDrive:{ list:[], user:{}, editData:{ valid:1 }, edit:false, ioDriveList:[], userDriveValidList:[], userDriveValidMap:{} } }, userValidMap:{}, defaultPwd:"123456" } }, methods: { selectUserAvatar:async function (){ const that = this; var desktop = webos.el.findParentComponent(that,"desktop-component"); await desktop.selectFileAction("jpg,jpeg,png,bmp,gif",false, async function (files){ if(files.length > 0){ var url = await webos.fileSystem.zl(files[0].path); that.editForm.imgPath = url; return true; } }); }, changeSecondView:async function (val,text){ var that = this; that.componentData.selectedSecond = val; that.componentData.selectedSecondText=text; that.componentData.selectedThird = ""; that.editForm = {}; if(that.componentData.selectedSecond == "info"){ that.user = await webos.user.info(); that.editForm = that.user; }else if(that.componentData.selectedSecond == "children"){ that.userSearch(); } }, saveUserInfo:async function (){ var that = this; webos.context.set("showOkErrMsg",true); var flag = await webos.user.updateInfo(that.editForm); if(flag){ that.componentData.selectedSecond = ""; that.componentData.selectedThird = ""; var settings = webos.el.findParentComponent(that,"settings-component"); if(settings){ settings.init(); } var desktop = webos.el.findParentComponent(that,"desktop-component"); if(desktop){ desktop.$refs["taskbar"].init(); } } }, saveUserPassword:async function (){ var that = this; if(that.editForm.password != that.editForm.confirmPassword){ webos.message.error("两次密码输入不一致"); return; } webos.context.set("showOkErrMsg",true); var flag = await webos.user.updatePassword(that.editForm.oldPassword,that.editForm.password); if(flag){ that.componentData.selectedSecond = ""; webos.user.logOut(); var app = webos.el.findParentComponent(that,"app-component"); app.checkLogin(); } }, userSearch:async function (page,size){ var that = this; if(!page){ page = 1; } if(!size){ size = 10; } that.userChildren.params.current = page; that.userChildren.params.pageSize = size; var data = await webos.user.list(that.userChildren.params); if (data) { that.userChildren.data = data.data; that.userChildren.pagination.total = data.count; that.userChildren.pagination.current = that.userChildren.params.current; that.userChildren.pagination.pageSize = that.userChildren.params.pageSize; } }, userSearchSize:function (size){ this.userSearch(1,size); }, userSearchPage:function (page){ this.userSearch(page,this.userChildren.params.pageSize); }, userDel:function (record){ const that = this; utils.$.confirm("确认删除'"+record.username+"'?此操作不可逆",async function (flag){ if(!flag){ return; } webos.context.set("showOkErrMsg",true); var res = await webos.user.del(record.id); if(res){ await that.userSearch(); } }); }, userEdit:async function (type,record){ //0新增主 1新增子 2编辑 var that = this; that.componentData.selectedThird = "edit"; if(that.userChildren.userValidList.length < 1){ that.userChildren.userValidList = await webos.dict.select("USER_VALID"); } if(type == 2){ //编辑 that.editForm = await webos.user.infoById(record.id); that.componentData.selectedThirdText = "编辑用户"; }else if(type == 1){ //新增子 that.editForm = {valid:1,parentUserNo:record.parentUserNo}; that.componentData.selectedThirdText = "新增子用户"; }else{ //新增主 that.editForm = {valid:1}; that.componentData.selectedThirdText = "新增主用户"; } that.userChildren.submitType = type; }, userEditSubmit:async function (){ var that = this; var flag; webos.context.set("showOkErrMsg",true); if(that.userChildren.submitType == 2){ //编辑 flag = await webos.user.update(that.editForm); }else if(that.userChildren.submitType == 1){ //新增子 flag = await webos.user.createChild(that.editForm); }else{ //新增主 flag = await webos.user.createMain(that.editForm); } if(flag){ that.componentData.selectedThird = ""; that.userSearch(); } }, resetPassword:async function (record){ var that = this; utils.$.confirm("确认重置'"+record.username+"'的用户密码为"+that.defaultPwd+"吗?",async function (flag){ if(!flag){ return; } webos.context.set("showOkErrMsg",true); flag = await webos.user.resetPassword(record.id); if(flag){ that.userSearch(); } }); }, userDriveManage:async function (record){ var that = this; that.userChildren.userDrive.user=record; that.componentData.selectedThird='user_drive'; that.componentData.selectedThirdText= record.username+"的磁盘"; var res = await webos.userDrive.list({"current":1,"pageSize":9999,"userId":record.id}); that.userChildren.userDrive.list = res.data; that.userChildren.userDrive.userDriveValidMap = await webos.dict.selectMap("USER_VALID"); }, saveUserDrive:async function (){ var that = this; var flag; webos.context.set("showOkErrMsg",true); if(that.userChildren.userDrive.editData.id){ //编辑 flag = await webos.userDrive.update(that.userChildren.userDrive.editData); }else{ //新增 flag = await webos.userDrive.save(that.userChildren.userDrive.editData); } if(flag){ that.userDriveManage(that.userChildren.userDrive.user); that.userChildren.userDrive.edit = false; } }, userDriveEdit:async function (type,record){ var that = this; if(that.userChildren.userDrive.ioDriveList.length < 1){ that.userChildren.userDrive.ioDriveList = await webos.drive.select(); } if(that.userChildren.userDrive.userDriveValidList.length < 1){ that.userChildren.userDrive.userDriveValidList = await webos.dict.select("USER_VALID"); } if(type == 1){ //编辑 that.userChildren.userDrive.editData = await webos.userDrive.info(record.id); }else{ //新增 that.userChildren.userDrive.editData = {valid:1,userId:that.userChildren.userDrive.user.id} } that.userChildren.userDrive.edit = true; }, delUserDrive:async function (record){ var that = this; utils.$.confirm("确认删除'"+record.name+"'?(此操作仅删除关联关系)",async function (flag){ if(!flag){ return; }; webos.context.set("showOkErrMsg",true); flag = await webos.userDrive.dels([record.id]); if(flag){ that.userDriveManage(that.userChildren.userDrive.user); } }); }, toManageFile:function (record){ var that = this; var path = "{uio:"+record.no+"}"; var name = record.name; var icon = "modules/win11/imgs/folder-sm.png"; var desktop = webos.el.findParentComponent(that,"desktop-component"); desktop.openFile(path,2,name,icon); } }, created: async function () { var that = this; that.user = await webos.user.info(); let winRef = webos.el.findParentComponent(that,"window-component"); that.win = winRef.win; that.userValidMap = await webos.dict.selectMap("USER_VALID"); that.defaultPwd = await webos.user.defaultPwd(); } }