shuishen
2023-02-23 f5d288347e559a36fa4dc33ff528ddc05a4f3902
商业排序
1 files modified
139 ■■■■ changed files
src/views/house/index.vue 139 ●●●● patch | view | raw | blame | history
src/views/house/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:17
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-02-23 08:57:03
 * @LastEditTime: 2023-02-23 10:57:03
 * @FilePath: \srs-police-affairs\src\views\house\index.vue
 * @Description: 小区-栋-层-房屋
 * 
@@ -140,9 +140,9 @@
                                <div class="two">
                                    <div>
                                        <div>98</div>
                                                <div>户籍人口</div>
                                            </div>
                                            <div>
                                                                                                                                                            <div>户籍人口</div>
                                                                                                                                                        </div>
                                                                                                                                                        <div>
                                        <div style="color:#0E88FF">20</div>
                                        <div>流动人口</div>
                                    </div>
@@ -164,17 +164,17 @@
                                <div>
                                    <div>120</div>
                                    <div>出租</div>
                                        </div>
                                        <div>
                                            <div>160</div>
                                            <div>自住</div>
                                        </div>
                                        <div>
                                            <div>8</div>
                                            <div>空置</div>
                                        </div>
                                    </div>
                                </div>-->
                                                                                                                                                    </div>
                                                                                                                                                    <div>
                                                                                                                                                        <div>160</div>
                                                                                                                                                        <div>自住</div>
                                                                                                                                                    </div>
                                                                                                                                                    <div>
                                                                                                                                                        <div>8</div>
                                                                                                                                                        <div>空置</div>
                                                                                                                                                    </div>
                                                                                                                                                </div>
                                                                                                                                            </div>-->
                        <div class="house-element-info" v-if="isShowHouseBox">
                        <!-- 选择单元 -->
                        <div class="condo" v-show="isShowUnitChoose">
@@ -219,17 +219,17 @@
                                    <div>
                                        <span class="zizhu"></span>
                                        自住
                                            </div>
                                            <div>
                                                <span class="kongzhi"></span>
                                                空置
                                            </div>
                                            <div>
                                                <span class="shangye"></span>
                                                商业
                                            </div>
                                        </div>
                                    </div>-->
                                                                                                                                                        </div>
                                                                                                                                                        <div>
                                                                                                                                                            <span class="kongzhi"></span>
                                                                                                                                                            空置
                                                                                                                                                        </div>
                                                                                                                                                        <div>
                                                                                                                                                            <span class="shangye"></span>
                                                                                                                                                            商业
                                                                                                                                                        </div>
                                                                                                                                                    </div>
                                                                                                                                                </div>-->
                            <el-main v-loading="pictLoading" element-loading-background="rgba(17, 38, 163, .1)"
                                element-loading-text="数据正在加载中" element-loading-spinner="el-icon-loading"
                                v-show="isShowHouseBox">
@@ -266,8 +266,8 @@
                                                <!-- :class="[{ 'chuzu': value.houseType == '出租' }, { 'zizhu': value.houseType == '自住' }, { 'kongzhi': value.houseType == '空置' }, { 'shangye': value.houseType == '商业' }]" -->
                                                {{ value.properties.fojcu }}
                                                <!-- <div class="flow"></div>
                                                    <div class="focus"></div>
                                                        <div class="warning"></div>-->
                                                                                                                                                                <div class="focus"></div>
                                                                                                                                                                    <div class="warning"></div>-->
                                            </div>
                                        </div>
                                    </div>
@@ -304,8 +304,9 @@
                        <el-table :data="businessData" style="width: 100%"
                            :header-cell-style="{ 'text-align': 'center', 'background-color': '#203c60', 'borderColor': '#324e75' }"
                            :cell-style="{ 'text-align': 'center', 'borderColor': '#324e75' }"
                            :row-class-name="tableRowClassName" @row-click="deepDataRowClick($event, 'business')">
                            <el-table-column prop="name" label="名称" width="180"
                            :row-class-name="tableRowClassName" @row-click="deepDataRowClick($event, 'business')"
                            @sort-change="sortDevName">
                            <el-table-column sortable="custom" prop="name" label="名称" width="180"
                                :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column prop="x" label="经度" width="100"></el-table-column>
                            <el-table-column prop="y" label="纬度" width="100"></el-table-column>
@@ -936,7 +937,6 @@
        },
        buildingClick (item, aoiArr) {
            console.log(item, 456)
            this.unitHouseChoosed = []
            this.pictLoading = true
            if (!aoiArr) {
@@ -1385,6 +1385,83 @@
                })
        },
        /**
         * @description: 小区商业排序
         * @return {*}
         */
        sortDevName ({ prop, order }) {
            this.businessData.sort(this.compare(prop, order))
        },
        compare (property, order) {
            if (order == 'ascending') {
                return (a, b) => {
                    var value1 = a[property]
                    var value2 = b[property]
                    const char1Type = this.getChartType(value1)
                    const char2Type = this.getChartType(value2)
                    // 类型相同的逐个比较字符
                    if (char1Type[0] === char2Type[0]) {
                        if (value1 === value2) {
                            return char1Type[1] - char2Type[1]
                        } else {
                            if (char1Type[0] === 'zh') {
                                return value1.localeCompare(value2)
                            } else if (char1Type[0] === 'en') {
                                return value1.charCodeAt(0) - value2.charCodeAt(0)
                            } else {
                                return value1 - value2
                            }
                        }
                    } else {
                        return char1Type[1] - char2Type[1]
                    }
                }
            } else {
                return (a, b) => {
                    var value1 = a[property]
                    var value2 = b[property]
                    const char1Type = this.getChartType(value1)
                    const char2Type = this.getChartType(value2)
                    // 类型相同的逐个比较字符
                    if (char1Type[0] === char2Type[0]) {
                        if (value1 === value2) {
                            return char2Type[1] - char1Type[1]
                        } else {
                            if (char1Type[0] === 'zh') {
                                return value2.localeCompare(value1)
                            } else if (char1Type[0] === 'en') {
                                return value2.charCodeAt(0) - value1.charCodeAt(0)
                            } else {
                                return value2 - value1
                            }
                        }
                    } else {
                        return char2Type[1] - char1Type[1]
                    }
                }
            }
        },
        getChartType (char) {
            // 数字可按照排序的要求进行自定义,我这边产品的要求是
            // 数字(0->9)->大写字母(A->Z)->小写字母(a->z)->中文拼音(a->z)
            if (/^[\u4e00-\u9fa5]$/.test(char.trim().charAt(0))) {
                return ['zh', 300]
            }
            if (/^[a-zA-Z]$/.test(char.trim().charAt(0))) {
                return ['en', 200]
            }
            if (/^[0-9]$/.test(char.trim().charAt(0))) {
                return ['number', 100]
            }
            return ['others', 999]
        }
    },
    destroyed () {