123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import ajax from 'jquery/src/ajax/xhr.js'
- import $ from 'jquery/src/ajax';
- module.exports = {
-
- provinceSelect(addressList) {
- let option = [];
- addressList.map(function (item, i) {
- option.push({
- value: item.id,
- label: item.name
- });
- });
- return option;
- },
- citySelect(addressList) {
- let option = [];
- addressList.map(function (item, i) {
- if(item.cityList==null){
- item.cityList=[];
- }
- if (item.cityList.length) {
- let cityArr = [];
- item.cityList.map(function (city, n) {
- cityArr.push({
- value: city.id,
- label: city.name
- });
- });
- option.push({
- value: item.id,
- label: item.name,
- children: cityArr
- });
- } else {
- option.push({
- value: item.id,
- label: item.name
- });
- };
- });
- return option;
- },
- areaSelect(addressList) {
- let option = [];
- addressList.map(function (item, i) {
- if(item.cityList==null){
- item.cityList=[];
- }
- if (item.cityList.length) {
- let cityArr = [];
- item.cityList.map(function (city, n) {
- if(city.areaList==null){
- city.areaList=[];
- }
- if (city.areaList.length) {
- let areaArr = [];
- city.areaList.map(function (area, j) {
- areaArr.push({
- value: area.id,
- label: area.name
- });
- });
- cityArr.push({
- value: city.id,
- label: city.name,
- children: areaArr
- });
- } else {
- cityArr.push({
- value: city.id,
- label: city.name
- });
- };
- });
- option.push({
- value: item.id,
- label: item.name,
- children: cityArr
- });
- } else {
- option.push({
- value: item.id,
- label: item.name
- });
- };
- });
- return option;
- },
- getProvince(province, city, area) {
- let PList = [];
- for (let i = 0; i < addressList.length; i++) {
- PList.push({
- id: addressList[i].id,
- name: addressList[i].name
- });
- if (addressList[i].cityList) {
- for (let j = 0; j < addressList[i].cityList.length; j++) {
- PList.push({
- id: addressList[i].cityList[j].id,
- name: addressList[i].cityList[j].name
- });
- if (addressList[i].cityList[j].areaList) {
- for (let n = 0; n < addressList[i].cityList[j].areaList.length; n++) {
- PList.push({
- id: addressList[i].cityList[j].areaList[n].id,
- name: addressList[i].cityList[j].areaList[n].name
- });
- }
- };
- };
- }
- };
- PList.sort(function (a, b) {
- return a.id - b.id
- });
- let provinceKey = "";
- PList.map(function (item) {
- if (province) {
- if (province == item.id) {
- provinceKey = item.name;
- };
- if (city == item.id) {
- provinceKey = provinceKey + "/" + item.name;
- };
- if (area == item.id) {
- provinceKey = provinceKey + "/" + item.name;
- };
- };
- });
- return provinceKey;
- }
- }
|