|
|
@ -30,13 +30,14 @@ typedef struct { |
|
|
|
} UIUsrTableIterm; |
|
|
|
|
|
|
|
typedef struct { |
|
|
|
bool enable; |
|
|
|
bool enable; |
|
|
|
|
|
|
|
int usrId; |
|
|
|
int index; |
|
|
|
char name[32]; |
|
|
|
const UserRole* role; |
|
|
|
bool resetPasswd; |
|
|
|
|
|
|
|
bool editDirty; |
|
|
|
bool editDirty; |
|
|
|
} EditContext_t; |
|
|
|
|
|
|
|
static UIUsrTableIterm m_uiUsrTable[MAX_USR_NUM] = { |
|
|
@ -54,11 +55,11 @@ static void resetUiUsrTable() { |
|
|
|
for (int i = 0; i < MAX_USR_NUM; i++) { |
|
|
|
m_uiUsrTable[i].enable = false; |
|
|
|
m_uiUsrTable[i].role = nullptr; |
|
|
|
m_uiUsrTable[i].usrId = 0; |
|
|
|
m_uiUsrTable[i].usrId = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static EditContext_t m_editContext = {false, -1, "", &UserRole::user, false, false}; |
|
|
|
static EditContext_t m_editContext = {0}; |
|
|
|
|
|
|
|
class MuUsrMgr : public IPageProcesser { |
|
|
|
private: |
|
|
@ -179,25 +180,25 @@ class MuUsrMgr : public IPageProcesser { |
|
|
|
UIControler::ins()->popWarningWin("用户数量已达上限"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
UserDao::addUser(); |
|
|
|
fillUsrStateUICache(); |
|
|
|
syncUIUsrTableState(); |
|
|
|
UIControler::ins()->popInfoWin("添加成功"); |
|
|
|
} |
|
|
|
|
|
|
|
void delUsr() { |
|
|
|
ZLOGI(TAG, "delUsr"); |
|
|
|
// 删除用户
|
|
|
|
do { |
|
|
|
user_t* user = UserDao::getUserById(m_uiUsrTable[m_editContext.index].usrId); |
|
|
|
user_t* user = UserDao::getUserById(m_editContext.usrId); |
|
|
|
if (user == nullptr) { |
|
|
|
ZLOGE(TAG, "user not exist ,find by id %d", m_uiUsrTable[m_editContext.index].usrId); |
|
|
|
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId); |
|
|
|
UIControler::ins()->popWarningWin("用户不存在"); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (user->builtIn) { |
|
|
|
ZLOGE(TAG, "user is builtIn ,find by id %d", m_uiUsrTable[m_editContext.index].usrId); |
|
|
|
ZLOGE(TAG, "user is builtIn ,find by id %d", m_editContext.usrId); |
|
|
|
UIControler::ins()->popWarningWin("内置管理员用户不能删除"); |
|
|
|
break; |
|
|
|
} |
|
|
@ -209,15 +210,16 @@ class MuUsrMgr : public IPageProcesser { |
|
|
|
|
|
|
|
fillEditContext(-1); |
|
|
|
syncEditContext(); |
|
|
|
UIControler::ins()->popInfoWin("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
void saveUsr() { |
|
|
|
ZLOGI(TAG, "saveUsr"); |
|
|
|
// 保存
|
|
|
|
if (m_editContext.editDirty) { |
|
|
|
user_t* user = UserDao::getUserById(m_uiUsrTable[m_editContext.index].usrId); |
|
|
|
user_t* user = UserDao::getUserById(m_editContext.usrId); |
|
|
|
if (user == nullptr) { |
|
|
|
ZLOGE(TAG, "user not exist ,find by id %d", m_uiUsrTable[m_editContext.index].usrId); |
|
|
|
ZLOGE(TAG, "user not exist ,find by id %d", m_editContext.usrId); |
|
|
|
UIControler::ins()->popWarningWin("用户不存在"); |
|
|
|
return; |
|
|
|
} |
|
|
@ -240,11 +242,10 @@ class MuUsrMgr : public IPageProcesser { |
|
|
|
|
|
|
|
fillUsrStateUICache(); |
|
|
|
syncUIUsrTableState(); |
|
|
|
fillEditContext(m_editContext.index); |
|
|
|
syncEditContext(); |
|
|
|
} |
|
|
|
|
|
|
|
UIControler::ins()->popWarningWin("保存成功"); |
|
|
|
UIControler::ins()->popInfoWin("保存成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/***********************************************************************************************************************
|
|
|
@ -301,21 +302,22 @@ class MuUsrMgr : public IPageProcesser { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void fillEditContext(int index) { |
|
|
|
if (index >= MAX_USR_NUM) { |
|
|
|
void fillEditContext(int useroff) { |
|
|
|
if (useroff >= MAX_USR_NUM) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (index < 0) { |
|
|
|
if (useroff < 0) { |
|
|
|
m_editContext.enable = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
m_editContext.index = index; |
|
|
|
strcpy(m_editContext.name, m_uiUsrTable[index].userName); |
|
|
|
m_editContext.role = m_uiUsrTable[index].role; |
|
|
|
m_editContext.usrId = m_uiUsrTable[useroff].usrId; |
|
|
|
strcpy(m_editContext.name, m_uiUsrTable[useroff].userName); |
|
|
|
m_editContext.role = m_uiUsrTable[useroff].role; |
|
|
|
m_editContext.resetPasswd = false; |
|
|
|
m_editContext.editDirty = false; |
|
|
|
m_editContext.enable = true; |
|
|
|
m_editContext.index = m_uiUsrTable[useroff].index; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|