@beisen/area-selector
Advanced tools
Comparing version 0.2.10 to 0.2.11
22
index.js
@@ -38,8 +38,25 @@ /* eslint-disable */ | ||
{ | ||
id: 140101, | ||
id: 1118, | ||
name: "山西省太原市小店区" | ||
} | ||
,{ | ||
, | ||
{ | ||
id: 204, | ||
name: "白俄罗斯" | ||
}, | ||
{ | ||
id: 21005, | ||
name: "白俄罗斯" | ||
}, | ||
{ | ||
id:140606, | ||
name: "" | ||
}, | ||
{ | ||
id:1, | ||
name:"" | ||
}, | ||
{ | ||
id:2, | ||
name:"" | ||
} | ||
@@ -69,1 +86,2 @@ ], | ||
render(<Demo />, document.getElementById('content')) | ||
@@ -64,5 +64,10 @@ 'use strict'; | ||
_this.handleDefaultResults = function (data) { | ||
if (_this.props.isSingleSelect) { | ||
return data; | ||
} | ||
var isChina = function isChina(id) { | ||
if (id === 1 || id.toString().length % 2 === 0) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
/* | ||
@@ -82,4 +87,11 @@ 由于外部传入的已选数据仅包含id和name,在多级交互时会出现问题 | ||
var assignData = (0, _commonFunc.deepClone)(_this.chinaData).concat((0, _commonFunc.deepClone)(_this.foreignData)); | ||
var subIndex = 2; | ||
var assignData = void 0; | ||
var subIndex = void 0; | ||
if (isChina(i.id)) { | ||
assignData = (0, _commonFunc.deepClone)(_this.chinaData); | ||
subIndex = 2; | ||
} else { | ||
assignData = (0, _commonFunc.deepClone)(_this.foreignData); | ||
subIndex = 3; | ||
} | ||
var allLevelName = ''; | ||
@@ -92,2 +104,3 @@ for (var m = 0; m < assignData.length; m++) { | ||
arr.push(item); | ||
break; | ||
} else if (item.id.toString().length > 1 && item.id.toString().indexOf(subId) == 0 && item.childList) { | ||
@@ -458,5 +471,4 @@ if (_this.props.allLevelDisplay) allLevelName += item.name + '/'; //全路径显示名称 | ||
allLevelDisplay: this.props.allLevelDisplay | ||
}; | ||
// 已选地区提示 数据 | ||
var _resultTipData = { | ||
// 已选地区提示 数据 | ||
};var _resultTipData = { | ||
totalCount: this.props.totalCount, | ||
@@ -466,5 +478,4 @@ hasCount: this.state.resultsData.length, | ||
translation: this.translation | ||
}; | ||
// 已选地区列表 数据 | ||
var _resultItemData = { | ||
// 已选地区列表 数据 | ||
};var _resultItemData = { | ||
resultsData: this.state.resultsData, | ||
@@ -471,0 +482,0 @@ clearResultsData: this.clearResultsData, |
{ | ||
"name": "@beisen\/area-selector", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "area-selector", | ||
@@ -52,8 +52,8 @@ "main": "lib\/index.js", | ||
"@beisen\/beisen-scroll-bar": "^1.0.22", | ||
"@beisen\/common-func": "", | ||
"@beisen\/common-func": "0.0.20", | ||
"@beisen\/hookformatter": "0.0.2", | ||
"@beisen\/tab-component": "", | ||
"@beisen\/common-mount": "", | ||
"@beisen\/tab-component": "0.1.92", | ||
"@beisen\/common-mount": "0.1.15", | ||
"@beisen\/es6-promise-debounce": "^0.0.2", | ||
"@beisen\/tool-tip": "", | ||
"@beisen\/tool-tip": "0.1.95", | ||
"babel": "^6.5.2", | ||
@@ -60,0 +60,0 @@ "babel-cli": "^6.6.5", |
@@ -66,5 +66,12 @@ import React, {Component} from 'react' | ||
handleDefaultResults = (data) => { | ||
if(this.props.isSingleSelect) { | ||
return data; | ||
handleDefaultResults = data => { | ||
// 判断id是否是国内id | ||
let isChina = id => { | ||
const type = { "CHINA": 1 }; | ||
// id等于1代表全国, 国内id组成全部为偶数位, 判断id长度来判断是否是国内id | ||
if(id === type.CHINA || id.toString().length%2 === 0) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -78,13 +85,21 @@ /* | ||
for(let i of data) { | ||
let assignData = deepClone(this.chinaData).concat(deepClone(this.foreignData)) | ||
let subIndex = 2; | ||
let allLevelName = '' | ||
let assignData,//国内/国外城市信息 | ||
subIndex; | ||
//国内国外都走一套逻辑, 但是参数有所不同. 不同的国家由三位数字判断, 但是国内不同城市由两位数字判断, 所以对应的 subIndex 不同 | ||
if(isChina(i.id)) { | ||
assignData = deepClone(this.chinaData); | ||
subIndex = 2; | ||
}else { | ||
assignData = deepClone(this.foreignData); | ||
subIndex = 3; | ||
} | ||
let allLevelName = ''; | ||
for(let m = 0; m < assignData.length; m++) { | ||
let item = assignData[m] | ||
let subId = i.id.toString().substring(0,subIndex) | ||
let item = assignData[m]; | ||
let subId = i.id.toString().substring(0,subIndex); | ||
if(item.id == i.id) { | ||
if(allLevelName.length>0) item.name = allLevelName + item.name; | ||
arr.push(item) | ||
arr.push(item); | ||
} else if(item.id.toString().length > 1 && item.id.toString().indexOf(subId) == 0 && item.childList) { | ||
if(this.props.allLevelDisplay) allLevelName += item.name + '/' //全路径显示名称 | ||
if(this.props.allLevelDisplay) allLevelName += item.name + '/'; //全路径显示名称 | ||
assignData = item.childList; //循环遍历子集 | ||
@@ -96,3 +111,3 @@ m = -1; //当进入子集时会执行m++,如果是0的话会变成1 | ||
} | ||
return arr | ||
return arr; | ||
}catch(e) { | ||
@@ -319,3 +334,3 @@ console.error("地区已选数据处理有误",e) | ||
if(this.foreignData.length>0){ | ||
if(this.foreignData.length>0) { | ||
_tabComponentData.tabItems.push({ | ||
@@ -339,4 +354,3 @@ idx: 'tab1', | ||
(this.state.currentAreaTab ? item.isForeign : !item.isForeign) && item.pIndex == pIndex).length>0 | ||
|| (lastBreadData.isChecked && lastBreadData.index == pIndex)) | ||
{ | ||
|| (lastBreadData.isChecked && lastBreadData.index == pIndex)) { | ||
this.currentData.map(item => { | ||
@@ -343,0 +357,0 @@ item.isChecked = true |
@@ -1,1 +0,1 @@ | ||
{"errors" :44 } | ||
{"errors" :108 } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4703493
43
99531