From b240bd25997bde8b7cc868f528af549e1c7f742d Mon Sep 17 00:00:00 2001 From: pioneer Date: Fri, 17 Mar 2023 16:07:36 +0800 Subject: [PATCH] open --- README.md | 6 + plugin.xml | 20 + .../tuomin/UserTMPluginLifecycleMonitor.java | 24 + .../controller/TableDataSyncAction.java | 257 +++ .../tuomin/controller/UserTMController.java | 132 ++ .../controller/UserTMControllerProvider.java | 14 + .../UserTMWebResourceProvider.java | 33 + .../com/fr/plugin/user/tuomin/userinfo.js | 1686 +++++++++++++++++ 8 files changed, 2172 insertions(+) create mode 100644 README.md create mode 100644 plugin.xml create mode 100644 src/main/java/com/fr/plugin/user/tuomin/UserTMPluginLifecycleMonitor.java create mode 100644 src/main/java/com/fr/plugin/user/tuomin/controller/TableDataSyncAction.java create mode 100644 src/main/java/com/fr/plugin/user/tuomin/controller/UserTMController.java create mode 100644 src/main/java/com/fr/plugin/user/tuomin/controller/UserTMControllerProvider.java create mode 100644 src/main/java/com/fr/plugin/user/tuomin/webresource/UserTMWebResourceProvider.java create mode 100644 src/main/resources/com/fr/plugin/user/tuomin/userinfo.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae570be --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# open-JSD-10625 + +JSD-10625 用户隐私信息如手机号邮箱脱敏处理\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..a5d7b95 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,20 @@ + + com.fr.plugin.user.tuomin + + yes + 1.0 + 10.0 + 2018-07-31 + fr.open + + + ]]> + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/user/tuomin/UserTMPluginLifecycleMonitor.java b/src/main/java/com/fr/plugin/user/tuomin/UserTMPluginLifecycleMonitor.java new file mode 100644 index 0000000..b7a81ef --- /dev/null +++ b/src/main/java/com/fr/plugin/user/tuomin/UserTMPluginLifecycleMonitor.java @@ -0,0 +1,24 @@ +package com.fr.plugin.user.tuomin; + +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.workspace.WorkContext; + +@EnableMetrics +@FunctionRecorder +public class UserTMPluginLifecycleMonitor extends AbstractPluginLifecycleMonitor { + + @Override + public void afterRun(PluginContext pluginContext) { + FineLoggerFactory.getLogger().info(pluginContext.getID() + "插件启动:"); + } + + @Override + public void beforeStop(PluginContext pluginContext) { + FineLoggerFactory.getLogger().info(pluginContext.getID()+"插件停止"); + } + +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/user/tuomin/controller/TableDataSyncAction.java b/src/main/java/com/fr/plugin/user/tuomin/controller/TableDataSyncAction.java new file mode 100644 index 0000000..19aa420 --- /dev/null +++ b/src/main/java/com/fr/plugin/user/tuomin/controller/TableDataSyncAction.java @@ -0,0 +1,257 @@ +package com.fr.plugin.user.tuomin.controller; + +import com.fr.decision.authority.base.constant.type.operation.SyncOperationType; +import com.fr.decision.authority.controller.personnel.PersonnelController; +import com.fr.decision.authority.controller.personnel.PersonnelWork; +import com.fr.decision.sync.CascadeData; +import com.fr.decision.sync.SourceConflictData; +import com.fr.decision.sync.SourceConflictStrategy; +import com.fr.decision.sync.SyncDetail; +import com.fr.decision.sync.data.RowData; +import com.fr.decision.sync.result.FailedData; +import com.fr.decision.sync.result.SyncResultData; +import com.fr.decision.sync.result.SyncWorkResult; +import com.fr.decision.sync.work.SyncWork; +import com.fr.decision.sync.work.impl.*; +import com.fr.decision.webservice.interceptor.handler.PreHandlerFactory; +import com.fr.general.data.DataModel; +import com.fr.log.FineLoggerFactory; +import com.fr.script.Calculator; + +import java.lang.reflect.Field; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TableDataSyncAction implements PersonnelWork { + private SyncDetail syncDetail; + private DataModel dm; + private Map syncWorks = new TreeMap(); + private UserSyncWork userSyncWork; + + public static com.fr.plugin.user.tuomin.controller.TableDataSyncAction create(SyncDetail var0) { + return new com.fr.plugin.user.tuomin.controller.TableDataSyncAction(var0); + } + + private TableDataSyncAction(SyncDetail var1) { + this.syncDetail = var1; + this.dm = var1.getSyncSource().buildTableData(var1.getDataSetName()).createDataModelWithTimeout(Calculator.createCalculator(), (int)var1.getRate()); + } + + public void before(PersonnelController var1) throws Exception { + this.registerSyncWorks(var1); + this.checkPlatformDirtyData(); + } + + + private static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$"; + + private boolean validatePwd(String pswd,String userName){ + boolean falg = false; + try { + if (null==pswd&&pswd.isEmpty()&&pswd.length()>9){ + return falg; + } + //不全是特殊符号 不全是数字 不全是字母 不全是大写 不全是小写 + if (pswd.matches(PW_PATTERN)){ + falg = true; + } + + } catch (Exception e) { + falg = false; + } + + if(falg == false){ + FineLoggerFactory.getLogger().info("密码强度验证:长度,大小写字母,符号不符合"); + return false; + } + + if(pswd.toLowerCase().indexOf(userName.toLowerCase()) != -1){ + FineLoggerFactory.getLogger().info("密码强度验证:密码不能包含用户名"); + return false; + } + return true; + } + + public SyncResultData execute(PersonnelController var1) throws Exception { + this.clearDiffSource(); + this.preparePlatformData(); + this.beforePrepareSyncData(); + this.prepareSyncData(); + this.afterPrepareSyncData(); + Field[] fileds = this.userSyncWork.getClass().getDeclaredFields(); + for(int i = 0 ; i < fileds.length;i++) { + Field field = fileds[i]; + String fieldName = field.getName(); + FineLoggerFactory.getLogger().info("fieldName:"+fieldName); + if(fieldName.equals("syncNamePasswordMap")){ + try { + field.setAccessible(true); + Object obj = field.get( this.userSyncWork); + Map syncNamePasswordMap = (Map)obj; + FineLoggerFactory.getLogger().info("一共有几个用户导入:"+syncNamePasswordMap.size()); + Set keys = syncNamePasswordMap.keySet(); + for(String key : keys){ + String pwd = syncNamePasswordMap.get(key).toString(); + //这里判断密码强度 + boolean isOk = validatePwd(pwd,key); + + if(isOk == false){ + SyncResultData resultData = new SyncResultData(); + resultData.setSuccessUserCount(-100); + return resultData; + } + } + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + this.sourceCover(); + this.addOrUpdate(); + this.delete(); + return this.over(); + } + + private void registerSyncWorks(PersonnelController var1) { + this.userSyncWork = new UserSyncWork(var1, this.syncDetail); + SyncWork[] var2 = new SyncWork[]{userSyncWork, new DepartmentSyncWork(var1, this.syncDetail), new PostSyncWork(var1, this.syncDetail), new CustomRoleSyncWork(var1, this.syncDetail), new DepRoleSyncWork(var1, this.syncDetail), new UserRoleMiddleSyncWork(var1, this.syncDetail)}; + SyncWork[] var3 = var2; + int var4 = var2.length; + + for(int var5 = 0; var5 < var4; ++var5) { + SyncWork var6 = var3[var5]; + this.syncWorks.put(var6.processOrder(), var6); + } + + } + + private void checkPlatformDirtyData() throws Exception { + Iterator var1 = this.syncWorks.values().iterator(); + + while(var1.hasNext()) { + SyncWork var2 = (SyncWork)var1.next(); + var2.checkPlatformDirtyData(); + } + + } + + private void preparePlatformData() throws Exception { + Iterator var1 = this.syncWorks.values().iterator(); + + while(var1.hasNext()) { + SyncWork var2 = (SyncWork)var1.next(); + var2.preparePlatformData(); + } + + } + + private void beforePrepareSyncData() throws Exception { + Iterator var1 = this.syncWorks.values().iterator(); + + while(var1.hasNext()) { + SyncWork var2 = (SyncWork)var1.next(); + var2.beforePrepareSyncData(this.dm); + } + + } + + private void prepareSyncData() throws Exception { + for(int var1 = 0; var1 < this.dm.getRowCount(); ++var1) { + RowData var2 = new RowData(var1); + Iterator var3 = this.syncWorks.values().iterator(); + + while(var3.hasNext()) { + SyncWork var4 = (SyncWork)var3.next(); + var4.prepareSyncData(this.dm, var2); + } + } + + this.dm.release(); + } + + private void afterPrepareSyncData() throws Exception { + CascadeData var1 = new CascadeData(); + + SyncWork var3; + for(Iterator var2 = this.syncWorks.values().iterator(); var2.hasNext(); var1 = var3.afterPrepareSyncData(var1)) { + var3 = (SyncWork)var2.next(); + } + + } + + private void sourceCover() throws Exception { + SourceConflictData var1 = new SourceConflictData(); + + SyncWork var3; + for(Iterator var2 = this.syncWorks.values().iterator(); var2.hasNext(); var1 = var3.resolveSourceConflict(var1)) { + var3 = (SyncWork)var2.next(); + } + + } + + private void addOrUpdate() throws Exception { + Iterator var1 = this.syncWorks.values().iterator(); + + while(var1.hasNext()) { + SyncWork var2 = (SyncWork)var1.next(); + var2.addOrUpdate(); + } + + } + + private void delete() throws Exception { + if (this.syncDetail.getOperationType() == SyncOperationType.KEY) { + CascadeData var1 = new CascadeData(); + Iterator var2 = this.syncWorks.values().iterator(); + + while(var2.hasNext()) { + SyncWork var3 = (SyncWork)var2.next(); + var3.delete(var1); + } + + } + } + + private void clearDiffSource() throws Exception { + if (this.syncDetail.getSourceConflictStrategy() == SourceConflictStrategy.CLEAR) { + SyncWork[] var1 = new SyncWork[]{(SyncWork)this.syncWorks.get(1), (SyncWork)this.syncWorks.get(5), (SyncWork)this.syncWorks.get(2), (SyncWork)this.syncWorks.get(3), (SyncWork)this.syncWorks.get(4)}; + SyncWork[] var2 = var1; + int var3 = var1.length; + + for(int var4 = 0; var4 < var3; ++var4) { + SyncWork var5 = var2[var4]; + var5.clearDiffSource(); + } + } + + } + + private SyncResultData over() throws Exception { + SyncResultData var1 = new SyncResultData(); + Iterator var2 = this.syncWorks.entrySet().iterator(); + + while(var2.hasNext()) { + Entry var3 = (Entry)var2.next(); + SyncWorkResult var4 = ((SyncWork)var3.getValue()).over(); + if (var4 != null) { + if ((Integer)var3.getKey() == 1) { + var1.setSuccessUserCount(var4.getAddOrUpdateCount()); + var1.setCurrentUserCount(var4.getCurrentCount()); + } + + var1.addFailedData(var4.getRoleType(), (FailedData[])var4.getFailedData().toArray(new FailedData[0])); + var1.addOtherSourceRole(var4.getRoleType(), (String[])var4.getDiffSourceData().toArray(new String[0])); + } + } + + return var1; + } +} + diff --git a/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMController.java b/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMController.java new file mode 100644 index 0000000..9a2cb2e --- /dev/null +++ b/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMController.java @@ -0,0 +1,132 @@ +package com.fr.plugin.user.tuomin.controller; + + +import com.fr.config.Configuration; +import com.fr.decision.authority.AuthorityContext; +import com.fr.decision.authority.base.constant.type.operation.ManualOperationType; +import com.fr.decision.config.Encryption; +import com.fr.decision.config.EncryptionConfig; +import com.fr.decision.config.SystemConfig; +import com.fr.decision.config.UserDataSetConfig; +import com.fr.decision.sync.SyncDetail; +import com.fr.decision.sync.SyncUserStatus; +import com.fr.decision.sync.result.SyncResultData; +import com.fr.decision.webservice.Response; +import com.fr.decision.webservice.annotation.DecisionControllerLog; +import com.fr.decision.webservice.annotation.LoginStatusChecker; +import com.fr.decision.webservice.annotation.VisitRefer; +import com.fr.decision.webservice.bean.user.UserDataSetBean; +import com.fr.decision.webservice.bean.user.UserImportOperation; +import com.fr.decision.webservice.exception.user.EncryptChangeUserNotCleanupException; +import com.fr.decision.webservice.v10.login.LoginService; +import com.fr.decision.webservice.v10.user.UserService; +import com.fr.general.ComparatorUtils; +import com.fr.intelligence.IntelligenceRuntimeException; +import com.fr.log.FineLoggerFactory; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.stable.query.QueryFactory; +import com.fr.stable.query.restriction.RestrictionFactory; +import com.fr.third.springframework.stereotype.Controller; +import com.fr.third.springframework.web.bind.annotation.*; +import com.fr.transaction.Configurations; +import com.fr.transaction.Worker; +import com.fr.transaction.WorkerAdaptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@EnableMetrics +@Controller +@LoginStatusChecker( + required = false +) +@RequestMapping({"/{version}"}) +public class UserTMController { + + @RequestMapping( + value = {"/dataset/newUsers"}, + method = {RequestMethod.POST} + ) + + @VisitRefer( + refer = {"decision-management-user-add"} + ) + @ResponseBody + public Response importUser(HttpServletRequest req, HttpServletResponse res, @PathVariable("version") String version, @RequestBody UserDataSetBean userDataSet, @RequestParam(value = "importOp",required = false,defaultValue = "0") int importOp) throws Exception { + String currentUser = LoginService.getInstance().getUserNameFromRequest(req); + FineLoggerFactory.getLogger().info("导入数据......"); + SyncUserStatus status = importUsers(currentUser, userDataSet, UserImportOperation.parse(importOp)); + if(status.getResultData().getSuccessUserCount() == -100){ + return Response.error("500","导入失败,用户密码不满足密码强度"); + } + else{ + return Response.ok(status); + } + + } + + public SyncUserStatus importUsers(String currentUserName, UserDataSetBean userDataSetBean, UserImportOperation userImportOperation) throws Exception { + Encryption oldEncryption = EncryptionConfig.getInstance().getEncryption(ManualOperationType.KEY); + int oldEmbedEncryption = oldEncryption.getEncryption(); + final int newEmbedEncryption = userDataSetBean.getEncryption(); + final String newEmbedCustomEncrypt = userDataSetBean.getCustomEncrypt(); + boolean encryptionChanged = !ComparatorUtils.equals(oldEmbedEncryption, newEmbedEncryption) || !ComparatorUtils.equals(oldEncryption.getCustomEncrypt(), userDataSetBean.getCustomEncrypt()); + userDataSetBean.setTurnOn(false); + if (userImportOperation != UserImportOperation.CLEAR && encryptionChanged) { + throw new EncryptChangeUserNotCleanupException(); + } else { + if (userImportOperation == UserImportOperation.CLEAR) { + UserService.getInstance().deleteAllCommonUsers((String)UserService.getInstance().getAdminUserNameList().get(0)); + AuthorityContext.getInstance().getCustomRoleController().remove(QueryFactory.create().addRestriction(RestrictionFactory.eq("creationType", ManualOperationType.KEY)).addRestriction(RestrictionFactory.neq("id", "super-user-custom-role"))); + AuthorityContext.getInstance().getDepartmentController().remove(QueryFactory.create().addRestriction(RestrictionFactory.eq("creationType", ManualOperationType.KEY))); + AuthorityContext.getInstance().getPostController().remove(QueryFactory.create().addRestriction(RestrictionFactory.eq("creationType", ManualOperationType.KEY))); + } + + Configurations.update(new Worker() { + public void run() { + Encryption embedEncrypt = new Encryption(); + embedEncrypt.setEncryption(newEmbedEncryption); + embedEncrypt.setCustomEncrypt(newEmbedCustomEncrypt); + EncryptionConfig.getInstance().removeEncryption(ManualOperationType.KEY); + EncryptionConfig.getInstance().setEncryption(ManualOperationType.KEY, embedEncrypt); + } + + public Class[] targets() { + return new Class[]{UserDataSetConfig.class, EncryptionConfig.class}; + } + }); + + SyncUserStatus var10; + try { + SyncDetail detail = SyncDetail.parse(userDataSetBean); + SyncResultData syncResultData = AuthorityContext.getInstance().doPersonnelWork(TableDataSyncAction.create(detail)); + SyncUserStatus var11 = (new SyncUserStatus()).resultData(syncResultData); + return var11; + } catch (IntelligenceRuntimeException var15) { + var10 = (new SyncUserStatus()).status(SyncUserStatus.Status.FAIL).error(var15); + } finally { + if (userImportOperation == UserImportOperation.CLEAR && encryptionChanged) { + class NamelessClass_1 extends WorkerAdaptor { + NamelessClass_1(Class x0, Class... x1) { + super(x0, x1); + } + + public void run() { + SystemConfig.getInstance().setServerInitStatus("fail"); + } + } + + Configurations.update(new NamelessClass_1(SystemConfig.class, new Class[0])); + } + + } + + return var10; + } + } + + + + + +} diff --git a/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMControllerProvider.java b/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMControllerProvider.java new file mode 100644 index 0000000..552e0a1 --- /dev/null +++ b/src/main/java/com/fr/plugin/user/tuomin/controller/UserTMControllerProvider.java @@ -0,0 +1,14 @@ +package com.fr.plugin.user.tuomin.controller; + +import com.fr.decision.fun.impl.AbstractControllerRegisterProvider; + +public class UserTMControllerProvider extends AbstractControllerRegisterProvider { + + @Override + public Class[] getControllers() { + return new Class[]{ + UserTMController.class + }; + } + +} diff --git a/src/main/java/com/fr/plugin/user/tuomin/webresource/UserTMWebResourceProvider.java b/src/main/java/com/fr/plugin/user/tuomin/webresource/UserTMWebResourceProvider.java new file mode 100644 index 0000000..bcb0933 --- /dev/null +++ b/src/main/java/com/fr/plugin/user/tuomin/webresource/UserTMWebResourceProvider.java @@ -0,0 +1,33 @@ +package com.fr.plugin.user.tuomin.webresource; + +import com.fr.decision.fun.impl.AbstractWebResourceProvider; +import com.fr.decision.web.MainComponent; +import com.fr.intelli.record.Focus; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ParserType; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + +public class UserTMWebResourceProvider extends AbstractWebResourceProvider{ + + @Override + public Atom attach() { + return MainComponent.KEY; + } + + public Atom[] clients() { + return new Atom[]{ + new Component() { + @Override + public ScriptPath script(RequestClient client) { + return ScriptPath.build( "com/fr/plugin/user/tuomin/userinfo.js", ParserType.DYNAMIC ); + } + + } + }; + } + +} diff --git a/src/main/resources/com/fr/plugin/user/tuomin/userinfo.js b/src/main/resources/com/fr/plugin/user/tuomin/userinfo.js new file mode 100644 index 0000000..cb608c8 --- /dev/null +++ b/src/main/resources/com/fr/plugin/user/tuomin/userinfo.js @@ -0,0 +1,1686 @@ +!(function () { + console.info("加载用户脱敏插件js......"); + + function userCompCreate() { + var e; + (e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-table", + $testId: "dec-user-table", + columnSize: [50, "fill", 100], + headerRowSize: 32, + rowSize: 36, + pager: {}, + perPage: 10, + header: [], + items: [] + }, + _store: function () { + return BI.Models.getModel("dec.model.user.all.table") + }, + watch: { + isAllChecked: function () { + this.header.setSelected(this.model.isAllChecked) + } + }, + render: function () { + var e = this + , t = this.options; + return { + type: "bi.vertical", + items: [{ + type: "dec.user.table.header", + ref: function (t) { + e.header = t + }, + columnSize: t.columnSize, + items: BI.Constants.getConstant("dec.constant.user.table.headers"), + height: t.headerRowSize, + onSortChange: function (t, i) { + e.store.onSortChange(t, i) + }, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (t, i) { + e.store.handleCheckAll(i) + } + }] + }, { + type: "bi.button_group", + ref: function (t) { + e.table = t + }, + chooseType: 1, + layouts: [{ + type: "bi.vertical" + }], + items: [] + }, { + el: { + type: "dec.pager", + ref: function (t) { + e.pager = t + }, + height: 30, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var i = this.getCurrentPage && this.getCurrentPage(); + t.itemsCreator({ + page: i + }, (function (t) { + e.populate(t) + } + )) + } + }] + }, + vgap: 10 + }] + } + }, + _formatItems: function (t) { + var i = this + , n = this.options; + return BI.map(t, (function (t, o) { + return { + type: "dec.user.table.row1", + id: o.id, + cls: BI.isOdd(t) ? "odd" : "even", + userInfo: o, + columnSize: n.columnSize, + height: n.rowSize, + onDelete: function (t) { + i.fireEvent(e.EVENT_DELETE, t) + }, + onEdit: n.onEdit + } + } + )) + }, + setCount: function (e) { + this.pager.setCount(e), + this.setAllPages(Math.ceil(e / this.options.perPage)) + }, + setAllPages: function (e) { + this.pager.setAllPages(e) + }, + setPage: function (e) { + this.pager.setPage(e) + }, + getValue: function () { + return this.table.getValue() + }, + empty: function () { + this.header.setSelected(!1) + }, + populate: function (e) { + if (e != undefined && e instanceof Array) { + try { + e.forEach(function (item) { + var email = item.email; + item["newEmail"] = ""; + if (email != undefined && email != "" && email.indexOf("@") != -1) { + var newEmail = email.replace(/(.{0,3}).*@(.*)/, "$1***@$2"); + item["newEmail"] = newEmail; + } + var phone = item.mobile; + item["newPhone"] = ""; + if (phone != undefined && phone != "") { + var phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{4}(\d{4})$/; + var newPhone = phone.replace(phoneReg, '$1****$2'); + item["newPhone"] = newPhone; + } + }) + } + catch (err) { + console.log("脱敏异常:" + err) + } + } + this.table.populate(this._formatItems(e)) + } + })).EVENT_DELETE = "EVENT_DELETE", + BI.shortcut("dec.user.table1", e) + + + + } + + function userTableRowCreate() { + var e; + (e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-table-row bi-border-bottom", + columnSize: [50, "fill", 100], + userInfo: {}, + value: BI.UUID() + }, + _store: function () { + return BI.Models.getModel("dec.model.user.all.row", this.options) + }, + watch: { + selected: function (e) { + this.setSelected(e) + } + }, + render: function () { + var e = this.options; + return { + type: "bi.htape", + $testId: "dec-user-table-row", + $value: e.userInfo.username, + items: this._formatItem(e.userInfo) + } + }, + _formatItem: function (e) { + var t = this + , i = this.options + , n = [] + , o = i.columnSize + , r = this.model.keywordMap; + return n.push({ + type: "bi.center_adapt", + width: o[0], + height: i.height, + items: [{ + type: "bi.checkbox", + $testId: "dec-user-row-checkbox", + $value: e.username, + ref: function (e) { + t.checkbox = e + }, + disabled: !e.enableCheck, + selected: e.selected, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + t.store.changeSelected(this.isSelected()) + } + }] + }] + }), + n.push({ + el: { + type: "bi.htape", + height: i.height, + scrollable: !1, + disabled: !e.enable, + items: [{ + el: { + type: "bi.label", + ref: function (e) { + t.username = e + }, + scrollable: !1, + textAlign: "left", + text: e.username, + $testId: "dec-user-row-username", + $value: e.username, + keyword: r.username, + title: function () { + return e.username + }, + rgap: 10, + height: i.height + }, + width: .2 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.realName = e + }, + scrollable: !1, + textAlign: "left", + text: e.realName, + $testId: "dec-user-row-real-name", + $value: e.realName, + keyword: r.realName, + title: function () { + return e.realName + }, + rgap: 10, + height: i.height + }, + width: .1 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.depPostNames = e + }, + textAlign: "left", + text: e.depPostNames, + $testId: "dec-user-row-depost-names", + $value: e.depPostNames, + title: function () { + return e.depPostNames + }, + rgap: 10, + height: i.height + }, + width: .15 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.roleNames = e + }, + textAlign: "left", + text: e.roleNames, + $testId: "dec-user-row-role-names", + $value: e.roleNames, + title: function () { + return e.roleNames + }, + rgap: 10, + height: i.height + }, + width: .15 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.email = e + }, + textAlign: "left", + text: e.newEmail, + $testId: "dec-user-row-email", + $value: e.newEmail, + keyword: r.newEmail, + title: function () { + return e.newEmail + }, + rgap: 10, + height: i.height + }, + width: .18 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.mobile = e + }, + textAlign: "left", + text: e.newPhone, + $testId: "dec-user-row-mobile", + $value: e.newPhone, + keyword: r.newPhone, + title: function () { + return e.newPhone + }, + rgap: 10, + height: i.height + }, + width: .15 + }, { + el: { + type: "bi.label", + ref: function (e) { + t.enable = e + }, + textAlign: "left", + text: e.enable ? BI.i18nText("Dec-User_Enabled") : BI.i18nText("Dec-User_Disabled"), + $testId: "dec-user-row-enable", + $value: e.enable, + rgap: 10, + height: i.height + }, + width: .07 + }] + }, + width: o[1] + }), + (n = BI.concat(n, this._createExtraItems(e))).push(BI.extend({}, e, { + type: "dec.user.row.tools", + width: o[2], + $scope: e.username, + infoGetter: function () { + return e + }, + onDelete: function () { + t.options.onDelete([e.id]) + }, + onEdit: i.onEdit, + onDisable: function (e) { + t.store.disableUser(e, t.getValue()) + } + })), + n + }, + _createExtraItems: function (e) { + var t = [] + , i = BI.Providers.getProvider("dec.provider.all_user").getExtraAttributes(); + return BI.each(i, (function (i, n) { + BI.isKey(n.column) ? t.push(BI.extend({ + type: n.column, + width: n.width + }, e)) : BI.isFunction(n.column) ? t.push(BI.extend({ + width: n.width + }, n.column(e))) : t.push({ + type: "bi.layout", + width: n.width + }) + } + )), + t + }, + isSelected: function () { + return this.checkbox.isSelected() + }, + getValue: function () { + return this.options.userInfo.id + }, + setSelected: function (e) { + this.options.userInfo.enableCheck && this.checkbox.setSelected(e) + } + })).EVENT_DELETE = "EVENT_DELETE", + BI.shortcut("dec.user.table.row1", e) + } + + function formEditorCompCreator() { + var e; + e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-label-editor-item", + textWidth: 115, + textAlign: "left", + textCls: "", + text: "", + value: "", + allowBlank: !0, + editorWidth: 300, + errorTop: 0, + el: {}, + realTime: !1, + stop: !0, + rules: {} + }, + render: function () { + var e = this + , t = this.options + , i = BI.isNotNull(t.rules.required) && t.realTime ? !t.rules.required : t.allowBlank; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.label", + cls: t.textCls, + text: t.text, + title: t.text, + textHeight: 24, + width: t.textWidth, + textAlign: t.textAlign + }, + rgap: t.textRGap + }, { + type: "dec.component.error_bubble_container", + width: t.editorWidth, + errorTop: t.errorTop, + el: BI.extend({ + type: "bi.editor", + $value: "dec-label-editor-" + (t.$value ? t.$value : t.text), + cls: "bi-border bi-border-radius", + watermark: t.watermark, + height: 22, + value: t.value, + inputType: t.inputType, + allowBlank: i, + validationChecker: t.realTime ? function (t) { + return e._validate(t) + } + : BI.emptyFn, + ref: function (t) { + e.editor = t + }, + listeners: [{ + eventName: BI.Editor.EVENT_FOCUS, + action: function () { + e.hideError(), + e.fireEvent(BI.Editor.EVENT_FOCUS, arguments) + } + }, { + eventName: BI.Editor.EVENT_CHANGE, + action: function () { + e.fireEvent(BI.Editor.EVENT_CHANGE, arguments), + e.hideError() + } + }, { + eventName: BI.Editor.EVENT_CONFIRM, + action: function () { + e.fireEvent(BI.Editor.EVENT_CONFIRM, arguments) + } + }, { + eventName: BI.Editor.EVENT_BLUR, + action: function () { + e.fireEvent(BI.Editor.EVENT_BLUR, arguments) + } + }, { + eventName: BI.Editor.EVENT_ERROR, + action: function (t) { + BI.isEmptyString(t) && e.editor.isEditing() && e.showError(BI.i18nText("Dec-Error_Null")) + } + }, { + eventName: BI.Editor.EVENT_VALID, + action: function () { + e.hideError() + } + }] + }, t.el), + ref: function (t) { + e.editorError = t + } + }] + } + }, + getValue: function () { + return this.editor.getValue() + }, + setValue: function (e) { + this.editor.setValue(e), + this.hideError() + }, + showError: function (e) { + this.editorError.showError(e) + }, + focus: function () { + this.editor.focus() + }, + hideError: function () { + this.editorError.hideError() + }, + validate: function () { + return this._validate(this.getValue()) + }, + getValidations: function () { + var e = this.options; + return BI.validator.validate(this.getValue(), e.rules, e.stop) + }, + _validate: function (e) { + var t = this.options + , i = BI.validator.validate(e, t.rules, t.stop); + return !(!BI.isNotNull(i) || !i.approved) || (this.showError(i.errors[0]), + !1) + } + }), + BI.shortcut("dec.form.editor1", e) + } + + function userEditEmailCompCreate() { + var e; + e = BI.inherit(BI.Widget, { + props: { + editControll: {}, + userInfo: {} + }, + render: function () { + var e = this + , t = this.options + , i = t.userInfo + , n = t.editControll; + return { + type: "dec.form.editor1", + $value: "email", + textWidth: 90, + editorWidth: 420, + invisible: !n.enableEditInfo, + text: BI.i18nText("Dec-User_Email"), + watermark: BI.i18nText("Dec-User_Email"), + value: i.email, + inputType: "password", + name: "email", + rules: { + email: !0 + }, + el: { + disabled: n.userInfoReadOnly + }, + ref: function (t) { + e.email = t + } + } + }, + getValidations: function () { + return this.email.getValidations() + }, + showError: function (e) { + this.email.showError(e) + }, + hideError: function () { + this.email.hideError() + }, + getValue: function () { + return { + email: this.email.getValue() + } + } + }), + BI.shortcut("dec.user.edit_user.item.email1", e) + + } + + function userPhoneEditorCreate() { + var e; + e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-components-phone-editor", + $testId: "dec-components-phone-editor", + value: "", + textWidth: 116, + comboWidth: 150, + editorWidth: 270, + textRGap: 0, + stop: !0, + rules: { + phone: !0 + }, + editable: !0 + }, + render: function () { + var e = this + , t = this.options; + this.service = BI.Services.getService("dec.service.components.phone.editor"); + var i = this.service.getNumberInfo(t.value); + return { + type: "bi.vertical_adapt", + items: [{ + el: { + type: "bi.label", + cls: t.textCls, + textAlign: "left", + text: t.text, + width: t.textWidth, + rgap: t.textRGap + } + }, { + el: { + type: "dec.left_right_text_value_combo", + $testId: "dec-text-value-combo", + height: 24, + width: t.comboWidth, + disabled: !t.editable, + textFormatter: function (t) { + var i = e.service.getNumberTypeItem(t); + return { + value: i.value, + text: i.text + } + }, + items: BI.map(BI.Constants.getConstant("dec.constant.common.phone.type"), (function (e, t) { + return { + type: "dec.components.phone.editor.item", + value: t.value, + label: t.text, + text: t.value + } + } + )), + value: i.value, + ref: function (t) { + e.codeCombo = t + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + e.numberEditor.setValue("") + } + }] + }, + rgpa: 10 + }, { + type: "dec.label.editor.item", + textWidth: 0, + disabled: !t.editable, + editorWidth: t.editorWidth, + watermark: t.watermark, + errorTop: t.errorTop, + inputType: "password", + value: i.number, + ref: function (t) { + e.numberEditor = t + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + console.log("mobile changed......") + e.fireEvent("EVENT_CHANGE") + } + }] + }] + } + }, + getValue: function () { + var e = this.codeCombo.getValue() + , t = this.numberEditor.getValue(); + return BI.isKey(t) ? (e === DecCst.Web.Components.PhoneEditor.Code.ZH_CN ? "" : e) + t : "" + }, + showError: function (e) { + this.numberEditor.showError(e) + }, + validate: function () { + return this._validate(this.numberEditor.getValue()) + }, + getValidations: function () { + return BI.validator.validate(this.numberEditor.getValue(), this._getRule(), this.options.stop) + }, + _getRule: function () { + return BI.extend({}, this.options.rules, { + phone: { + code: this.codeCombo.getValue() + } + }) + }, + _validate: function (e) { + var t = BI.validator.validate(e, this._getRule(), this.options.stop); + return !(!BI.isNotNull(t) || !t.approved) || (this.showError(t.errors[0]), + !1) + } + }), + BI.shortcut("dec.components.phone.editor1", e) + } + + function userPhoneCompCreate() { + var e; + e = BI.inherit(BI.Widget, { + props: { + editControll: {}, + userInfo: {} + }, + render: function () { + var e = this + , t = this.options + , i = t.userInfo + , n = t.editControll; + return { + type: "dec.components.phone.editor1", + $value: "mobile", + textWidth: 90, + invisible: !n.enableEditInfo, + text: BI.i18nText("Dec-User_Mobile"), + watermark: BI.i18nText("Dec-Basic_Optional_Filling"), + editorWidth: 270, + editable: !n.userInfoReadOnly, + name: "mobile", + value: i.mobile, + ref: function (t) { + e.mobile = t + } + } + }, + getValidations: function () { + return this.mobile.getValidations() + }, + showError: function (e) { + this.mobile.showError(e) + }, + getValue: function () { + return { + mobile: this.mobile.getValue() + } + } + }), + BI.shortcut("dec.user.edit_user.item.mobile1", e) + } + + userTableRowCreate(); + userCompCreate(); + formEditorCompCreator(); + userEditEmailCompCreate(); + userPhoneEditorCreate(); + userPhoneCompCreate(); + + /** + * 脱敏公用 + * @param str 脱敏字符串 + * @param begin 起始保留长度,从0开始 + * @param end 结束保留长度,到str.length结束 + * @returns {string} + */ + function desensitizedCommon(str, begin, end) { + if (!str && (begin + end) >= str.length) { + return ""; + } + + let leftStr = str.substring(0, begin); + let rightStr = str.substring(str.length - end, str.length); + + let strCon = '' + for (let i = 0; i < str.length - end - begin; i++) { + strCon += '*'; + } + return leftStr + strCon + rightStr; + } + + + var addUserPop = function() { + var e, t, i; + e = 90, + t = 420, + (i = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-add-user-popup", + passwordEditable: !0, + cleanDataSet: !1 + }, + _store: function() { + return BI.Models.getModel("dec.model.user.add.popup", this.options) + }, + watch: {}, + render: function() { + var e = this; + return { + type: "bi.vtape", + items: [{ + el: this.rebuildCenter() + }, { + type: "bi.right_vertical_adapt", + height: 44, + lgap: 10, + items: [{ + type: "bi.button", + text: BI.i18nText("Dec-Basic_Cancel"), + level: "ignore", + handler: function() { + e.close() + } + }, { + type: "bi.button", + text: BI.i18nText("Dec-Basic_Sure"), + handler: function() { + e.end() + } + }] + }] + } + }, + rebuildCenter: function() { + var i = this + , n = this.options + , o = { + type: "dec.form.editor", + $value: "username", + textWidth: e, + text: BI.i18nText("Dec-User_Name"), + watermark: BI.i18nText("Dec-Please_Input"), + editorWidth: t, + rules: { + required: { + message: BI.i18nText("Dec-User_Name_Can_Not_Null") + }, + validName: { + message: BI.i18nText("Dec-Error_Name_Limit_Tip", BI.i18nText("Dec-User_Name")) + }, + max: DecCst.STRING_SHORT_TEXT_LENGTH + }, + ref: function(e) { + i.userName = e + } + } + , r = { + type: "dec.form.editor", + $value: "real-name", + textWidth: e, + text: BI.i18nText("Dec-Real_Name"), + watermark: BI.i18nText("Dec-Please_Input"), + editorWidth: t, + rules: { + required: { + message: BI.i18nText("Dec-Real_Name_Can_Not_Null") + }, + max: DecCst.STRING_SHORT_TEXT_LENGTH + }, + ref: function(e) { + i.realName = e + } + } + , s = { + rules: { + required: { + message: BI.i18nText("Dec-Password_Can_Not_Null") + } + }, + el: { + type: "dec.common.cipher.editor", + $value: "password", + invisible: !n.passwordEditable, + textWidth: e, + editorWidth: t, + text: BI.i18nText("Dec-Password"), + watermark: BI.i18nText("Dec-Please_Input"), + value: this.model.passwordValue, + ref: function(e) { + i.password = e + } + } + } + , a = { + type: "dec.form.editor", + $value: "email", + text: BI.i18nText("Dec-User_Email"), + watermark: BI.i18nText("Dec-Basic_Optional_Filling"), + editorWidth: t, + textWidth: e, + rules: { + email: !0 + }, + ref: function(e) { + i.email = e + } + } + , c = { + type: "dec.components.phone.editor", + $value: "mobile", + textWidth: e, + text: BI.i18nText("Dec-User_Mobile"), + watermark: BI.i18nText("Dec-Basic_Optional_Filling"), + editorWidth: 270, + ref: function(e) { + i.mobile = e + } + } + , l = { + type: "dec.role.multi_select_combo", + $value: "add-user", + text: BI.i18nText("Dec-Basic_Optional_Filling"), + creationType: DecCst.User.CreationType.MANUAL, + width: t, + ref: function(e) { + i.role = e + } + } + , u = { + type: "dec.depost.multi_select_combo", + $value: "add-user", + width: t, + height: 24, + text: BI.i18nText("Dec-Basic_Optional_Filling"), + creationType: DecCst.User.CreationType.MANUAL, + ref: function(e) { + i.postTree = e + } + }; + return { + type: "bi.form", + cls: "dec-add-user-popup", + layouts: [{ + type: "bi.vertical", + bgap: 15 + }], + ref: function(e) { + i.form = e + }, + items: [{ + type: "bi.htape", + cls: "bi-tips", + height: 36, + items: [{ + type: "bi.vertical", + items: [{ + type: "bi.label", + textAlign: "left", + text: BI.i18nText("Dec-Basic_Tip") + ":" + }], + width: 40 + }, { + type: "bi.vertical", + items: [{ + type: "bi.label", + whiteSpace: "normal", + textAlign: "left", + text: BI.i18nText("Dec-Add_User_Tips") + }] + }] + }, o, r, s, { + type: "bi.vertical_adapt", + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Department_And_Post") + }, u] + }, { + type: "bi.vertical_adapt", + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Role") + }, l] + }, c, a] + } + }, + getValue: function() { + return BI.extend({ + username: this.userName.getValue(), + realName: this.realName.getValue(), + email: this.email.getValue(), + mobile: this.mobile.getValue(), + roleIds: this.role.getValue(), + departmentPostIds: this.postTree.getValue(), + password: this.password.getCipher() + }) + }, + close: function() { + this.fireEvent(i.EVENT_CLOSE) + }, + validatePwd:function(){ + console.log("validatePwd.....") + var pwdComp = this.password; + var pwd = pwdComp.getValue(); + var username = this.userName.getValue(); + console.log("pwd:"+pwd) + var errormsg = ""; + if(pwd.length < 8){ + pwdComp.showError("密码最小长度8位"); + return false; + } + var isOk = /\d+/.test(pwd); + if(isOk == false){ + pwdComp.showError("密码需要包含数字"); + return false; + } + isOk = /[a-z]+/.test(pwd); + if(isOk == false){ + pwdComp.showError("密码需要包含小写字母"); + return false; + } + isOk = /[A-Z]+/.test(pwd); + if(isOk == false){ + pwdComp.showError("密码需要包含大写字母"); + return false; + } + isOk = /[^a-zA-Z0-9]+/.test(pwd); + if(isOk == false){ + pwdComp.showError("密码需要包含符号"); + return false; + } + if(BI.toLowerCase(pwd).indexOf(BI.toLowerCase(username)) != -1){ + pwdComp.showError("密码不能包含用户名"); + return false; + } + return true; + + }, + end: function() { + var e = this; + this.form.submit((function() { + if(e.validatePwd()){ + e.store.addUser(e.getValue(), (function(t) { + t.errorCode && t.errorCode === DecCst.ErrorCode.DUPLICATE_NAMES ? e.userName.showError(BI.i18nText("Dec-Error_Duplicate_User_Names")) : t.errorCode && t.errorCode === DecCst.ErrorCode.SPECIAL_CHAR_PROHIBIT ? e.userName.showError(BI.i18nText("Dec-Error_User_Username_Special_Keyword")) : e.fireEvent(i.EVENT_CLICK_CONFIRM) + } + )) + } + + } + )) + } + })).EVENT_CLICK_CONFIRM = "EVENT_CONFIRM", + i.EVENT_CLOSE = "EVENT_CLOSE", + BI.shortcut("dec.user.add.popup1", i) + } + + addUserPop(); + + Dec.Utils = Dec.Utils || {}, + BI.extend(Dec.Utils, { + newImportUsers: function(e, t, i) { + Dec.reqPost("/v10/dataset/newUsers?importOp=" + t, e, i) + }, + }); + + + function importUserModel() { + var e, t, i; + e = 0, + t = 1, + i = BI.inherit(Fix.Model, { + _init: function() {}, + state: function() { + return { + dataSets: [], + tableColumns: [], + encryption: { + encryption: 0, + customEncrypt: "" + }, + strategy: DecCst.User.SyncUserStrategy.FULL_COVER, + importStatus: "" + } + }, + context: ["syncConfigs"], + computed: { + tables: function() { + return BI.map(this.model.dataSets, (function(e, t) { + return { + text: t.dataSetName, + value: t.dataSetValue + } + } + )) + }, + columns: function() { + return BI.map(this.model.tableColumns, (function(e, t) { + return { + text: t.columnName, + value: t.columnValue + } + } + )) + } + }, + actions: { + initData: function(e) { + var t = this + , i = BI.after(2, e); + Dec.Utils.getServerDataSets((function(e) { + t.model.dataSets = e.data, + i() + } + )), + Dec.Utils.getLastImportEncryptionConfig((function(e) { + t.model.encryption.encryption = e.data.encryption, + t.model.encryption.customEncrypt = e.data.customEncrypt, + i() + } + )) + }, + getCustomPasswordClasses: function(e) { + Dec.Utils.getCustomPasswordClasses((function(t) { + var i = BI.map(t.data, (function(e, t) { + return BI.extend({ + value: t.path + }, t) + } + )); + e(i) + } + )) + }, + setUserUpdateControl: function(e) { + this.model.strategy = e ? DecCst.User.SyncUserStrategy.INCREMENTAL_UPDATE : DecCst.User.SyncUserStrategy.FULL_COVER + }, + selectTable: function(e) { + var t = this; + e = BI.isArray(e) ? e[0] : e, + BI.isNotNull(this.columnsReq) && this.columnsReq.abort(), + this.columnsReq = Dec.Utils.getDataSetColumns(e, (function(e) { + t.model.tableColumns = e.data + } + ), (function() { + t.columnsReq = null + } + )) + }, + prepareImport: function(t) { + this.model.importStatus = "importing", + BI.extend(t, { + strategy: this.model.strategy + }), + this.importVals = t, + this.encryptionMethodChanged = this._encryptionMethodChanged(t), + this.doImport(t, e) + }, + doImport: function(e, t) { + var i = BI.Providers.getProvider("dec.provider.user").getInternalSyncSource() + , n = BI.extend(e, { + syncSource: { + "@class": i["@class"], + type: i.type + } + }); + Dec.Utils.newImportUsers(n, t, this.importCallbackHandler) + }, + importCallbackHandler: function(e) { + var i = this; + e.errorCode && e.errorCode === DecCst.ErrorCode.IMPORTED_ENCRYPTION_METHOD_CHANGE ? BI.Msg.confirm(BI.i18nText("Dec-Basic_Confirm"), BI.i18nText("Dec-User_Import_Encryption_Method_Change"), (function(e) { + e ? i.doImport(i.importVals, t) : i.model.importStatus = "abort" + } + )) : e.errorCode && "500" === e.errorCode ? this.model.importStatus = e.errorMsg : (this.encryptionMethodChanged && (window.location.href = Dec.fineServletURL + "/login/initialization"), + this.model.importStatus = "finish", + this.handlerSuccessLog(e)) + }, + handlerSuccessLog: function(e) { + var t = BI.Services.getService("dec.service.users.sync"); + if (BI.isNotNull(BI.get(e, ["data", "error"]))) + t.createSyncFailLayer(BI.get(e, ["data", "error"]), { + resultType: "import" + }); + else if (e.errorCode) + t.createSyncFailLayer(e, { + resultType: "import" + }); + else { + var i = e.data.resultData || {}; + t.createSyncSuccessLayer(i, "import") + } + } + }, + _encryptionMethodChanged: function(e) { + return e.encryption !== this.model.encryption.encryption || e.customEncrypt !== this.model.encryption.customEncrypt + } + }), + BI.model("dec.model.user.import1", i) + } + + importUserModel(); + + function importUser() { + var e, t, i, n; + e = 110, + t = 35, + i = 385, + (n = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-import-user-popup", + $testId: "dec-import-user-popup", + btns: [BI.i18nText("BI-Basic_Sure"), BI.i18nText("BI-Basic_Cancel")], + onClickConfirm: BI.emptyFn, + passwordEditable: !0 + }, + _store: function() { + return BI.Models.getModel("dec.model.user.import1", this.options) + }, + watch: { + columns: function(e) { + this.empty(), + this.populate(e) + }, + importStatus: function(e) { + switch (e) { + case "importing": + this._startImport(); + break; + case "abort": + this._stopImport(); + break; + case "finish": + this._finishImport(), + this.options.onClickConfirm(), + this.close(); + break; + default: + this._importFailed(e) + } + } + }, + beforeInit: function(e) { + this.store.initData(e) + }, + mounted: function() { + var e = this; + this.store.getCustomPasswordClasses((function(t) { + e.customPassword.populate(t), + e.customPassword.setValue(e.model.encryption.customEncrypt) + } + )) + }, + render: function() { + return { + type: "bi.vtape", + items: [{ + el: this.rebuildCenter() + }, { + el: this.rebuildSouth(), + height: 40 + }] + } + }, + rebuildSouth: function() { + var e = this + , t = this.options + , i = { + type: "bi.button", + $testId: "dec-import-user-popup-btn", + ref: function(t) { + e.sure = t + }, + text: t.btns[0], + handler: function() { + e.end() + } + }; + return { + type: "bi.right_vertical_adapt", + rgap: 10, + items: [{ + type: "bi.button", + $testId: "dec-import-user-popup-btn", + ref: function(t) { + e.cancel = t + }, + text: t.btns[1], + level: "ignore", + handler: function() { + e.close() + } + }, i] + } + }, + rebuildCenter: function() { + var n = this + , o = this.options + , r = { + type: "bi.text_value_check_combo", + $value: "server", + ref: function(e) { + n.serverTables = e + }, + el: {}, + width: i, + items: this.model.tables, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + n.store.selectTable(this.getValue()) + } + }] + } + , s = { + type: "bi.text_value_check_combo", + $value: "username", + ref: function(e) { + n.userName = e + }, + items: this.model.columns, + width: i + } + , a = { + type: "bi.text_value_check_combo", + $value: "real-name", + ref: function(e) { + n.realName = e + }, + items: this.model.columns, + width: i + } + , c = { + type: "bi.text_value_check_combo", + $value: "password", + ref: function(e) { + n.password = e + }, + items: this.model.columns, + width: i + } + , l = { + type: "bi.text_value_check_combo", + $value: "encryption-method", + ref: function(e) { + n.encryptionMethod = e + }, + width: i, + items: BI.Constants.getConstant("dec.constant.user.import.encryption"), + value: this.model.encryption.encryption, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function(e, t) { + n.customPasswordRow.setVisible(o.passwordEditable && 1 === t) + } + }] + } + , u = { + type: "bi.multilayer_single_tree_combo", + $testId: "dec-task-customize-class", + cls: "ms-page-hack", + ref: function(e) { + n.customPassword = e + }, + value: this.model.encryption.customEncrypt, + height: 24, + width: i + } + , d = { + type: "dec.text.value.check.combo", + $value: "department", + ref: function(e) { + n.department = e + }, + items: this.model.columns, + width: i + } + , h = { + type: "dec.text.value.check.combo", + $value: "post", + ref: function(e) { + n.post = e + }, + items: this.model.columns, + width: i + } + , p = { + type: "dec.text.value.check.combo", + $value: "role", + ref: function(e) { + n.role = e + }, + items: this.model.columns, + width: i + } + , m = { + type: "dec.text.value.check.combo", + $value: "email", + ref: function(e) { + n.email = e + }, + items: this.model.columns, + width: i + } + , f = { + type: "dec.text.value.check.combo", + $value: "mobile", + ref: function(e) { + n.mobile = e + }, + items: this.model.columns, + width: i + } + , g = { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-User_Import_Keep_Data"), + title: BI.i18nText("Dec-User_Import_Keep_Data") + }, { + el: { + type: "bi.multi_select_item", + iconWrapperWidth: 16, + hgap: 5, + logic: { + dynamic: !0 + }, + text: BI.i18nText("Dec-User_Import_Incremental_Update_Control"), + handler: function() { + n.store.setUserUpdateControl(this.isSelected()) + } + } + }, { + type: "bi.icon_button", + cls: "remark-font bi-high-light", + title: BI.i18nText("Dec-User_Import_Incremental_Update_Control_Tip") + }] + }; + return { + type: "bi.vertical", + cls: "dec-import-user-popup", + hgap: 20, + items: [{ + el: { + type: "bi.label", + cls: "bi-tips", + textAlign: "left", + whiteSpace: "normal", + text: BI.i18nText("Dec-Users_Import_User_Tip") + } + }, { + el: { + type: "bi.right_vertical_adapt", + height: 24, + items: [{ + type: "dec.link.button", + text: BI.i18nText("Dec-Users_Import_User_Rule_Help_Link"), + link: Dec.system[DecCst.Hyperlink.DECISION_HYPERLINK_CONFIG][DecCst.Hyperlink.USER_IMPORT] + }] + }, + bgap: 10 + }, { + el: g + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + width: e, + textAlign: "left", + text: BI.i18nText("Dec-Server_Table_Data") + }, r, { + type: "bi.icon_button", + title: BI.i18nText("Dec-User_Import_Dataset_Tip"), + cls: "remark-font bi-high-light", + width: 24, + height: 24 + }] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + width: e, + textAlign: "left", + text: BI.i18nText("Dec-User_Name") + }, s] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Real_Name") + }, a] + }, { + type: "bi.vertical_adapt", + height: t, + invisible: !o.passwordEditable, + warningTitle: BI.i18nText("Dec-Ldap_No_Need_Password"), + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Password") + }, c] + }, { + type: "bi.vertical_adapt", + height: t, + invisible: !o.passwordEditable, + warningTitle: BI.i18nText("Dec-Ldap_No_Need_Password"), + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Encryption_Method") + }, l] + }, { + type: "bi.vertical_adapt", + height: t, + invisible: !o.passwordEditable || this.model.encryption.encryption === DecCst.Encryption_Method.BUILT_IN_SHA, + items: [{ + el: u, + lgap: e + }], + ref: function(e) { + n.customPasswordRow = e + } + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Department") + }, d] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Post") + }, h] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-Role") + }, p] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-User_Mobile") + }, f] + }, { + type: "bi.vertical_adapt", + height: t, + items: [{ + type: "bi.label", + textAlign: "left", + width: e, + text: BI.i18nText("Dec-User_Email") + }, m] + }] + } + }, + _quitChecker: function() { + return BI.isEmpty(this.serverTables.getValue()) ? (BI.Msg.toast(BI.i18nText("Dec-Server_Table_Can_Not_Null"), { + level: "error" + }), + !1) : BI.isEmpty(this.userName.getValue()) ? (BI.Msg.toast(BI.i18nText("Dec-User_Name_Can_Not_Null"), { + level: "error" + }), + !1) : BI.isEmpty(this.realName.getValue()) ? (BI.Msg.toast(BI.i18nText("Dec-Real_Name_Can_Not_Null"), { + level: "error" + }), + !1) : BI.isEmpty(this.password.getValue()) && BI.isEmpty(this.options.info) && this.options.passwordEditable ? (BI.Msg.toast(BI.i18nText("Dec-Password_Can_Not_Null"), { + level: "error" + }), + !1) : BI.isEmpty(this.customPassword.getValue()) && this.encryptionMethod.getValue()[0] === DecCst.Encryption_Method.CUSTOM_PASSWORD && this.options.passwordEditable ? (BI.Msg.toast(BI.i18nText("Dec-Custom_Password_Can_Not_Null"), { + level: "error" + }), + !1) : !(BI.isKey(this.post.getValue()[0]) && !BI.isKey(this.department.getValue()[0]) && (BI.Msg.toast(BI.i18nText("Dec-Users_Post_Must_With_Department"), { + level: "error" + }), + 1)) + }, + _startImport: function() { + var e = this + , t = this.getName() + "status" + , i = { + type: "dec.test.status", + waitingText: BI.i18nText("Dec-User_Importing"), + successText: BI.i18nText("Dec-User_Import_Success"), + failText: BI.i18nText("Dec-User_Import_Fail"), + listeners: [{ + eventName: "EVENT_CLOSE", + action: function() { + BI.Maskers.hide(t), + BI.Maskers.remove(t) + } + }], + ref: function(t) { + e.uploadMasker = t + } + }; + BI.Maskers.create(t, null, { + render: i + }), + BI.Maskers.show(t) + }, + _importFailed: function(e) { + this.uploadMasker && this.uploadMasker.setStatus({ + status: DecCst.TestStatus.FAIL, + message: e + }) + }, + _stopImport: function() { + var e = this.getName() + "status"; + BI.Maskers.hide(e), + BI.Maskers.remove(e) + }, + _finishImport: function() { + this.uploadMasker && this.uploadMasker.setStatus({ + status: DecCst.TestStatus.SUCCESS + }) + }, + getValue: function() { + return { + dataSetName: this.serverTables.getValue()[0], + usernameColumn: this.userName.getValue()[0], + realNameColumn: this.realName.getValue()[0], + passwordColumn: this.password.getValue()[0], + encryption: this.encryptionMethod.getValue()[0], + customEncrypt: this.customPassword.getValue()[0], + departmentColumn: this.department.getValue()[0], + postColumn: this.post.getValue()[0], + emailColumn: this.email.getValue()[0], + mobileColumn: this.mobile.getValue()[0], + roleColumn: this.role.getValue()[0] + } + }, + setValue: function(e) { + this.userName.setValue(e.userName), + this.realName.setValue(e.realName), + this.email.setValue(e.email), + this.mobile.setValue(e.mobile), + this.role.setValue({}) + }, + empty: function() { + this.userName.setValue([]), + this.realName.setValue([]), + this.password.setValue([]), + this.department.setValue([]), + this.post.setValue([]), + this.role.setValue([]), + this.email.setValue([]), + this.mobile.setValue([]) + }, + populate: function(e) { + BI.each([this.userName, this.realName, this.password, this.department, this.post, this.role, this.email, this.mobile], (function(t, i) { + i.populate(e) + } + )) + }, + close: function() { + this.fireEvent("EVENT_CLOSE") + }, + end: function() { + this._quitChecker() && this.store.prepareImport(this.getValue()) + } + })).EVENT_CLICK_CONFIRM = "EVENT_CONFIRM", + BI.shortcut("dec.user.import.popup1", n) + } + + importUser(); + + BI.config("dec.user.table", function (options) { + options.type = "dec.user.table1"; // 将组件的type替换为自定义的组件 + return options; + }); + + BI.config("dec.user.edit_user.item.email", function (options) { + options.type = "dec.user.edit_user.item.email1"; // 将组件的type替换为自定义的组件 + return options; + }); + + BI.config("dec.user.edit_user.item.mobile", function (options) { + options.type = "dec.user.edit_user.item.mobile1"; // 将组件的type替换为自定义的组件 + return options; + }); + + BI.config("dec.user.add.popup", function (options) { + options.type = "dec.user.add.popup1"; // 将组件的type替换为自定义的组件 + return options; + }); + + + BI.config("dec.user.import.popup", function (options) { + options.type = "dec.user.import.popup1"; + return options; + }); + + + + + +})(); \ No newline at end of file