WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2021-04-08 f969b32736ab60b141d076f7aeaafdbd9dc1c546
forms/chinaArea/CChinaArea.vue
@@ -35,7 +35,7 @@
import ChinaLocations from './ChinaLocations';
import './cChinaArea.scss';
const { locationTree, getRegionNames } = ChinaLocations;
const { onReady, getLocationTree, getRegionNames } = ChinaLocations;
export default {
    name: 'CChinaArea',
@@ -72,11 +72,14 @@
    },
    methods: {
        handleOpen(evt) {
            if (evt.target.className.indexOf('at-input__title') >= 0) {
                evt.stopPropagation();
                evt.preventDefault();
                return;
            if (process.env.TARO_ENV === 'h5') {
                if (evt && evt.target.className.indexOf('at-input__title') >= 0) {
                    evt.stopPropagation();
                    evt.preventDefault();
                    return;
                }
            }
            const locationTree = getLocationTree();
            const curVal = this.itemRes.formData[this.itemRes.name];
            const range = [
                locationTree,
@@ -89,7 +92,7 @@
                // 省
                if (curVal[0]) {
                    const proviceIndex = locationTree.findIndex(
                        provice => provice.code === curVal[0]
                        provice => provice.value === curVal[0]
                    );
                    if (proviceIndex >= 0) {
                        range[1] = locationTree[proviceIndex].children;
@@ -98,19 +101,19 @@
                        // 市
                        if (curVal[1]) {
                            const cityIndex = range[1].findIndex(
                                city => city.code === curVal[1]
                                city => city.value === curVal[1]
                            );
                            if (cityIndex >= 0) {
                                range[2] = range[1].children[cityIndex].children;
                                range[2] = range[1][cityIndex].children;
                                current[1] = cityIndex;
                            }
                            // 区
                            if (curVal[2]) {
                                const areaIndex = range[2].findIndex(
                                    area => area.code === curVal[2]
                                    area => area.value === curVal[2]
                                );
                                if (areaIndex >= 0) {
                                    current[2] === areaIndex;
                                    current[2] = areaIndex;
                                }
                            }
                        }
@@ -121,19 +124,26 @@
            this.current = current;
        },
        updateColumns(roll) {
            const locationTree = getLocationTree();
            // 第一列滚动
            if (roll.column === 0) {
                const cities = locationTree[roll.value].children;
                this.range.splice(1, 2, cities, cities[0].children);
                this.range = [this.range[0], cities, cities[0].children];
                this.current = [roll.value, 0, 0];
            } else if (roll.column === 1) {
            }
            // 第二列滚动
            else if (roll.column === 1) {
                const areas = locationTree[this.current[0]].children[roll.value].children;
                this.range.splice(2, 1, areas);
                this.range = [this.range[0], this.range[1], areas];
                this.current = [this.current[0], roll.value, 0];
            } else if (roll.column === 3) {
            }
            // 第三列滚动
            else if (roll.column === 3) {
                this.current.splice(2, 1, roll.value);
            }
        },
        handleChange(detail) {
            const locationTree = getLocationTree();
            const codes = [];
            const provice = locationTree[detail[0]];
            codes[0] = provice.value;
@@ -144,6 +154,12 @@
            this.itemRes.onChange(codes);
        },
    },
    mounted() {},
    mounted() {
        if (process.env.TARO_ENV === 'weapp') {
            onReady(() => {
                this.handleOpen();
            });
        }
    },
};
</script>