zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
(function (vc) {
    //员工权限
    vc.extends({
        data: {
            memberInfo: {
                members: [],
                _currentOwnerId: '',
                listColumns: [],
                currentPage: 1,
                total: 0,
                records: 0,
                conditions: {
                    ownerId: '',
                    nameLike: '',
                    link: '',
                    idCard: '',
                    ownerTypeCd: ''
                }
            }
        },
        _initMethod: function () {
            $that._getColumns(function () {
            });
        },
        _initEvent: function () {
            vc.on('listOwnerMember', 'loadOwner', function (_param) {
                $that.memberInfo.conditions.ownerId = _param.ownerId;
                $that._loadOwners($that.memberInfo.currentPage, 10);
            });
            vc.on('listOwnerMember', 'listOwnerData', function (_param) {
                $that.memberInfo.conditions.ownerId = _param.ownerId;
                $that._loadOwners($that.memberInfo.currentPage, 10);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that.memberInfo.currentPage = _currentPage;
                $that._listOwnerData(_currentPage, 10);
            });
        },
        methods: {
            _loadOwners: function (_page, _row) {
                $that.memberInfo.conditions.page = _page;
                $that.memberInfo.conditions.row = _row;
                $that.memberInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                let param = {
                    params: $that.memberInfo.conditions
                };
                param.params.nameLike = param.params.nameLike.trim();
                param.params.link = param.params.link.trim();
                param.params.idCard = param.params.idCard.trim();
                //发送get请求
                vc.http.apiGet('/owner.queryOwnerMembers',
                    param,
                    function (json) {
                        var _memberInfo = JSON.parse(json);
                        $that.memberInfo.members = _memberInfo.owners;
                        $that.dealOwnerAttr(_memberInfo.owners);
                        $that.memberInfo.total = _memberInfo.total;
                        $that.memberInfo.records = _memberInfo.records;
                        vc.emit('pagination', 'init', {
                            total: $that.memberInfo.records,
                            dataCount: $that.memberInfo.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    });
            },
            //查询
            _queryOwnerMember: function () {
                $that._loadOwners(1, 10);
            },
            //重置
            _resetOwnerMember: function () {
                vc.component.memberInfo.conditions.nameLike = "";
                vc.component.memberInfo.conditions.link = "";
                vc.component.memberInfo.conditions.idCard = "";
                vc.component.memberInfo.conditions.ownerTypeCd = "";
                // vc.component.memberInfo.conditions.ownerId = "";
                $that._loadOwners(1, 10);
            },
            _openDeleteOwnerModel: function (_member) {
                _member.ownerId = $that.memberInfo.conditions.ownerId;
                vc.emit('deleteOwner', 'openOwnerModel', _member);
            },
            _openEditOwnerMemberModel: function (_member) {
                _member.ownerId = $that.memberInfo.conditions.ownerId;
                vc.emit('editOwner', 'openEditOwnerModal', _member);
            },
            dealOwnerAttr: function (owners) {
                owners.forEach(item => {
                    $that._getColumnsValue(item);
                });
            },
            _getColumnsValue: function (_owner) {
                _owner.listValues = [];
                if (!_owner.hasOwnProperty('ownerAttrDtos') || _owner.ownerAttrDtos.length < 1) {
                    $that.memberInfo.listColumns.forEach(_value => {
                        _owner.listValues.push('');
                    })
                    return;
                }
                let _ownerAttrDtos = _owner.ownerAttrDtos;
                $that.memberInfo.listColumns.forEach(_value => {
                    let _tmpValue = '';
                    _ownerAttrDtos.forEach(_attrItem => {
                        if (_value == _attrItem.specName) {
                            _tmpValue = _attrItem.valueName;
                        }
                    })
                    _owner.listValues.push(_tmpValue);
                })
            },
            _getColumns: function (_call) {
                $that.memberInfo.listColumns = [];
                vc.getAttrSpec('building_owner_attr', function (data) {
                    $that.memberInfo.listColumns = [];
                    data.forEach(item => {
                        if (item.listShow == 'Y') {
                            $that.memberInfo.listColumns.push(item.specName);
                        }
                    });
                    _call();
                });
                // 循环所有房屋信息
                // for (let _ownerIndex = 0; _ownerIndex < _owners.length; _ownerIndex++) {
                //     let _owner = _owners[_ownerIndex];
                //     if (!_owner.hasOwnProperty('ownerAttrDtos')) {
                //         break;
                //     }
                //     let _ownerAttrDtos = _owner.ownerAttrDto;
                //     if (_ownerAttrDtos.length < 1) {
                //         break;
                //     }
                //     //获取房屋信息中 任意属性作为 列
                //     for (let _ownerAttrIndex = 0; _ownerAttrIndex < _ownerAttrDtos.length; _ownerAttrIndex++) {
                //         let attrItem = _ownerAttrDtos[_ownerAttrIndex];
                //         if (attrItem.listShow == 'Y') {
                //             $that.ownerInfo.listColumns.push(attrItem.specName);
                //         }
                //     }
                //     if ($that.ownerInfo.listColumns.length > 0) {
                //         break;
                //     }
                // }
            },
            _viewOwnerFace: function (_url) {
                vc.emit('viewImage', 'showImage', {
                    url: _url
                });
            },
        }
    });
})(window.vc);