zhaolei
2020-11-20 921de2254ff5712a44ed8575ee8efe34252f6603
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@typeparam TItem
@inherits TableBase<TItem>
 
<div class="bootstrap-table">
    @if (ShowToolBar)
    {
        <div class="fixed-table-toolbar">
            <div class="float-left bs-bars">
                <TableToolbar>
                    @if (ShowDefaultButtons)
                    {
                        <TableToolbarButton class="btn btn-success" Icon="fa fa-plus" Title="新增" OnClick="Add" />
                        <TableToolbarButton class="btn btn-danger" Icon="fa fa-remove" Title="删除" OnClick="Delete" />
                        <TableToolbarButton class="btn btn-primary" Icon="fa fa-pencil" Title="编辑" OnClick="Edit" />
                    }
                    @TableToolbarTemplate
                </TableToolbar>
            </div>
            <div class="float-right columns columns-right">
                @if (ShowRefresh)
                {
                    <button class="btn btn-secondary" type="button" title="刷新" @onclick="Query">
                        <i class="fa fa-refresh"></i><span>刷新</span>
                    </button>
                }
            </div>
            @if (ShowSearch)
            {
                <div class="float-right search btn-group">
                    <div class="input-group">
                        <input class="form-control search-input" type="text" placeholder="搜索" @bind="SearchText" />
                        <div class="input-group-append">
                            <button class="btn btn-secondary" type="button" title="搜索" @onclick="SearchClick">
                                <i class="fa fa-search"></i><span>搜索</span>
                            </button>
                            <button class="btn btn-secondary" type="button" title="清空过滤" @onclick="ClearSearchClick">
                                <i class="fa fa-trash"></i> <span>清空过滤</span>
                            </button>
                            @if (ShowAdvancedSearch)
                            {
                                <button class="btn btn-secondary" type="button" title="高级搜索" @onclick="AdvancedSearchClick">
                                    <i class="fa fa-search-plus"></i><span>高级搜索</span>
                                </button>
                            }
                        </div>
                    </div>
                </div>
            }
        </div>
    }
    <div class="@(FixedHeader ? "table-wrapper table-fixed-header table-fixed" : "table-wrapper")">
        @if (FixedHeader)
        {
            <div class="fixed-table-header">
                <table class="table table-bordered table-hover table-selected">
                    <thead>
                        <tr>
                            @if (ShowCheckbox)
                            {
                                <th class="table-col-checkbox"><Checkbox TItem="TItem" SetCheckCallback="CheckState" OnClick="ToggleCheck"></Checkbox></th>
                            }
                            @if (ShowLineNo)
                            {
                                <th class="table-col-lineno">行号</th>
                            }
                            <TableHeader OnSort="OnSort">
                                @TableHeader?.Invoke(EditModel)
                            </TableHeader>
                            @if (ShowExtendButtons)
                            {
                                <th>@ButtonTemplateHeaderText</th>
                            }
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table-body invisible">
                <table class="table table-bordered table-hover table-selected" id="@RetrieveId()">
                    <thead>
                        <tr>
                            @if (ShowCheckbox)
                            {
                                <th class="table-col-checkbox"><Checkbox TItem="TItem" SetCheckCallback="CheckState" OnClick="ToggleCheck"></Checkbox></th>
                            }
                            @if (ShowLineNo)
                            {
                                <th class="table-col-lineno">行号</th>
                            }
                            <TableHeader OnSort="OnSort">
                                @TableHeader?.Invoke(EditModel)
                            </TableHeader>
                            @if (ShowExtendButtons)
                            {
                                <th>@ButtonTemplateHeaderText</th>
                            }
                        </tr>
                    </thead>
                    <tbody>
                        @for (int index = 0; index < Items.Count(); index++)
                        {
                            <tr>
                                @if (ShowCheckbox)
                                {
                                    <td class="table-col-checkbox"><Checkbox TItem="TItem" Item="Items.ElementAt(index)" SetCheckCallback="item => SelectedItems.Contains(item) ? CheckBoxState.Checked : CheckBoxState.UnChecked" OnClick="ToggleCheck"></Checkbox></td>
                                }
                                @if (ShowLineNo)
                                {
                                    <td class="table-col-lineno">@(index + 1 + (PageIndex - 1) * PageItems)</td>
                                }
                                @RowTemplate?.Invoke(Items.ElementAt(index))
                                @if (ShowExtendButtons)
                                {
                                    <td>@ButtonTemplate?.Invoke(Items.ElementAt(index))</td>
                                }
                            </tr>
                        }
                    </tbody>
                    <tfoot>
                        <tr>@TableFooter</tr>
                    </tfoot>
                </table>
            </div>
        }
        else
        {
            <table class="table table-striped table-bordered table-hover table-selected" id="@($"{Id}_table")">
                <thead>
                    <tr>
                        @if (ShowCheckbox)
                        {
                            <th class="table-col-checkbox"><Checkbox TItem="TItem" SetCheckCallback="CheckState" OnClick="ToggleCheck"></Checkbox></th>
                        }
                        @if (ShowLineNo)
                        {
                            <th class="table-col-lineno">行号</th>
                        }
                        <TableHeader OnSort="OnSort">
                            @TableHeader?.Invoke(EditModel)
                        </TableHeader>
                        @if (ShowExtendButtons)
                        {
                            <th>@ButtonTemplateHeaderText</th>
                        }
                    </tr>
                </thead>
                <tbody>
                    @for (int index = 0; index < Items.Count(); index++)
                    {
                        <tr>
                            @if (ShowCheckbox)
                            {
                                <td class="table-col-checkbox"><Checkbox TItem="TItem" Item="Items.ElementAt(index)" SetCheckCallback="item => SelectedItems.Contains(item) ? CheckBoxState.Checked : CheckBoxState.UnChecked" OnClick="ToggleCheck"></Checkbox></td>
                            }
                            @if (ShowLineNo)
                            {
                                <td class="table-col-lineno">@(index + 1 + (PageIndex - 1) * PageItems)</td>
                            }
                            @RowTemplate?.Invoke(Items.ElementAt(index))
                            @if (ShowExtendButtons)
                            {
                                <td>@ButtonTemplate?.Invoke(Items.ElementAt(index))</td>
                            }
                        </tr>
                    }
                </tbody>
                @if (ShowFooter)
                {
                    <tfoot>
                        <tr>@TableFooter</tr>
                    </tfoot>
                }
            </table>
        }
    </div>
    @if (ShowPagination)
    {
        <Pagination PageItems="PageItems" TotalCount="TotalCount" PageIndex="PageIndex" OnPageClick="PageClick" OnPageItemsChange="PageItemsChange"></Pagination>
    }
</div>
 
@if (OnDelete != null)
{
    <Modal @ref="ConfirmModal" Id="@($"{Id}_confirm")" Title="数据删除">
        <ModalBody>
            <div class="modal-confirm-body">您确定要删除选中的所有数据吗?</div>
        </ModalBody>
        <ModalFooter>
            <button type="button" class="btn btn-danger" @onclick="Confirm">
                <i class="fa fa-trash-o"></i>
                <span>我要删除</span>
            </button>
            <button type="button" class="btn btn-secondary" data-dismiss="modal">
                <i class="fa fa-times"></i>
                <span>取消</span>
            </button>
        </ModalFooter>
    </Modal>
}
 
@if (OnSave != null || OnAdd != null)
{
    <SubmitModal @ref="EditModal" Id="@($"{Id}_edit")" TItem="TItem" Title="@SubmitModalTitle" Size="ModalSize.ExtraLarge" @bind-Model="EditModel" OnValidSubmit="Save">
        <ModalBody>
            @EditTemplate?.Invoke(EditModel)
        </ModalBody>
    </SubmitModal>
}
 
@if (ShowSearch && ShowAdvancedSearch)
{
    <Modal @ref="SearchModal" Id="@($"{Id}_search")" Title="查询条件">
        <ModalBody>
            <LgbEditForm class="form-inline" Id="@Id" Model="QueryModel">
                <div class="row">
                    @SearchTemplate?.Invoke(QueryModel)
                </div>
            </LgbEditForm>
        </ModalBody>
        <ModalFooter>
            <button type="button" class="btn btn-info" data-dismiss="modal" @onclick="ResetSearchClick">
                <i class="fa fa-trash-o"></i>
                <span>重置</span>
            </button>
            <button type="button" class="btn btn-primary" data-dismiss="modal" @onclick="SearchClick">
                <i class="fa fa-search"></i>
                <span>查询</span>
            </button>
        </ModalFooter>
    </Modal>
}