深圳网站建设迈,南京宣传片制作公司,广州番禺清河市场火灾,网址域名查询1.共享登录#xff08;单点登录#xff09;主要是前端部分主要是根据是否有cookie来判断是否已经登录主系统#xff0c;然后再根据是否有当前系统的登录信息来#xff08;这块主要是sessionStorage做的#xff09;判断是否要再登录当前系统。设置、读取和设置cookie的方法…1.共享登录单点登录主要是前端部分主要是根据是否有cookie来判断是否已经登录主系统然后再根据是否有当前系统的登录信息来这块主要是sessionStorage做的判断是否要再登录当前系统。设置、读取和设置cookie的方法function setCookie(name,value)
{ var Days 30; var exp new Date(); exp.setTime(exp.getTime() Days*24*60*60*1000); document.cookie name escape (value) ;expires exp.toGMTString();
}
function getCookie(name)
{ var arr,regnew RegExp((^| )name([^;]*)(;|$)); return (arrdocument.cookie.match(reg))?unescape(arr[2]):null;
}
function delCookie(name)
{ var exp new Date(); exp.setTime(exp.getTime() - 1); var cvalgetCookie(name); if(cval!null) document.cookie name cval;expiresexp.toGMTString();
}
2.部门树的数据处理 后台返回的数据结构如下需要处理成一维数组。deptTree:[{children:[{deptId:001,deptName:xxx,businessUnit:000001,treeNodeNum:111111,need:Y,children:[{deptId:0000011,deptName:xxxxxx,businessUnit:00011,treeNodeNum:5555,need:Y},...]
主要是运用递归的方式处理loopDept: function (data) {var _this this;var deptTreeNode [];if (data.need Y) {deptTreeNode.push(data.deptId);}if (data.children) {data.children.forEach(function (node) {var nodes _this.loopDept(node);deptTreeNode deptTreeNode.concat(nodes);})}return deptTreeNode;},
递归组件templateul classtreeListliv-for(item,index) in list:keyindexclasstreeboxspanimgsrc/assets/deptIcon.pngaltem clickgoteamerList(item){{item.deptName | fixName }}/emvan-iconnamearrow-upv-show!item.showMore item.childrenclickchangeStatus(item)size0.4rem/van-iconnamearrow-downv-showitem.showMore item.childrenclickchangeStatus(item)size0.4rem//spanmyTreesv-ifitem.children !item.showMore:listitem.children/myTrees/li/ul/template-script
export default {name: myTrees,props: {list: Array},data() {return {scopesDefault: [],scopes: []};},filters:{fixName(value){if(value value.length 20){let startStr value.substring(0,10);let endStr value.substr(-9,9);return value startStr...endStr;}else{return value;}}},methods: {changeStatus(item) {item.showMore !item.showMore;},scope() {this.list.forEach((item, index) {if (children in item) {this.$set(item, showMore, true);} else {this.$set(item, showMore, false);}});},goteamerList(item) {let {businessUnit,deptId,isJKNode,isJRNode} item;sessionStorage.setItem(deptInfo, JSON.stringify(item));this.$router.push({name: teamerList,query:{businessUnit,deptId,isJKNode,isJRNode}});}},created() {this.scope();}
};
/script
3.一些处理数据的方式list.forEach(function (ele) {//数组设置法if (ele.isInner Y) {if (tempInner[ele.belongCategoryId]) {tempInner[ele.belongCategoryId].push(ele)} else {tempInner[ele.belongCategoryId] [ele]}} else {if (tempOut[ele.belongCategoryId]) {tempOut[ele.belongCategoryId].push(ele)} else {tempOut[ele.belongCategoryId] [ele]}}//对象设置法if (ele.isInner Y) {if (tempInner.hasOwnProperty(ele.belongCategoryId)) {tempInner[ele.belongCategoryId] ,ele.name } else {tempInner[ele.belongCategoryId] ele.name}} else {if (tempOut.hasOwnProperty(ele.belongCategoryId)) {tempOut[ele.belongCategoryId] ,ele.name } else {tempOut[ele.belongCategoryId] ele.name}}})
前端渣渣摸鱼时间所录先就这些想到再写如有问题请指出。