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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
| <template>
| <div>
| <div class="jeecg-basic-table-form-container" v-if="showSearchFlag">
| <a-form ref="formRef" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="searchQuery">
| <a-row :gutter="24">
| <template v-for="(item, index) in queryInfo">
| <template v-if="item.hidden === '1'">
| <a-col :md="6" :sm="24" :key="'query' + index" v-show="toggleSearchStatus">
| <SearchFormItem :formElRef="formRef" :queryParam="queryParam" :item="item" :dictOptions="dictOptions"></SearchFormItem>
| </a-col>
| </template>
| <template v-else>
| <a-col :md="6" :sm="24" :key="'query' + index">
| <SearchFormItem :formElRef="formRef" :queryParam="queryParam" :item="item" :dictOptions="dictOptions"></SearchFormItem>
| </a-col>
| </template>
| </template>
|
| <a-col :md="6" :sm="8">
| <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
| <a-col :lg="6">
| <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
| <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
| <a @click="handleToggleSearch" style="margin-left: 8px">
| {{ toggleSearchStatus ? '收起' : '展开' }}
| <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
| </a>
| </a-col>
| </span>
| </a-col>
| </a-row>
| </a-form>
| </div>
| <BasicTable
| ref="tableRef"
| :canResize="true"
| :bordered="true"
| :loading="loading"
| :rowKey="combineRowKey"
| :columns="columns"
| :showIndexColumn="false"
| :dataSource="dataSource"
| :pagination="pagination"
| :rowSelection="rowSelection"
| @row-click="clickThenCheck"
| @change="handleChangeInTable"
| >
| <template #tableTitle>
| <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
| </template>
| </BasicTable>
|
| <!-- 跳转Href的动态组件方式 -->
| <a-modal v-bind="hrefComponent.model" v-on="hrefComponent.on">
| <component :is="hrefComponent.is" v-bind="hrefComponent.params" />
| </a-modal>
| </div>
| </template>
|
| <script lang="ts">
| import { defineComponent, unref, ref, watch, watchEffect, reactive, computed } from 'vue';
| import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
| import { useAttrs } from '/@/hooks/core/useAttrs';
| import { usePopBiz } from '/@/components/jeecg/OnLine/hooks/usePopBiz';
| import { useMessage } from '/@/hooks/web/useMessage';
| import { useRoute } from 'vue-router';
|
| export default defineComponent({
| name: 'JPopupOnlReport',
| components: {
| SearchFormItem: createAsyncComponent(() => import('/@/components/jeecg/OnLine/SearchFormItem.vue'), { loading: true }),
| BasicTable: createAsyncComponent(() => import('/@/components/Table/src/BasicTable.vue'), {
| loading: true,
| }),
| },
| props: ['multi', 'code', 'id', 'sorter', 'groupId', 'param', 'clickToRowSelect'],
| emits: ['ok', 'register'],
| setup(props, { emit, refs }) {
| const { createMessage } = useMessage();
| const labelCol = reactive({
| xs: { span: 24 },
| sm: { span: 6 },
| });
| const wrapperCol = reactive({
| xs: { span: 24 },
| sm: { span: 18 },
| });
| const formRef = ref();
| const tableRef = ref();
| const toggleSearchStatus = ref(false);
| const attrs = useAttrs();
| const tableScroll = ref({ x: true });
| const route = useRoute();
| console.log('route.query = ',route.query)
| const getBindValue = Object.assign({}, {routeQuery: route.query}, unref(props), unref(attrs));
|
| const [
| {
| visibleChange,
| loadColumnsInfo,
| dynamicParamHandler,
| loadData,
| loadColumnsAndData,
| handleChangeInTable,
| combineRowKey,
| clickThenCheck,
| filterUnuseSelect,
| handleExport,
| },
| {
| hrefComponent,
| visible,
| rowSelection,
| checkedKeys,
| selectRows,
| pagination,
| dataSource,
| columns,
| loading,
| title,
| iSorter,
| queryInfo,
| queryParam,
| dictOptions,
| },
| ] = usePopBiz(getBindValue, tableRef);
|
| const showSearchFlag = computed(() => unref(queryInfo) && unref(queryInfo).length > 0);
| /**
| *监听code
| */
| watch(
| () => props.code,
| () => {
| loadColumnsAndData();
| },
| { immediate: true }
| );
| /**
| *监听popup动态参数 支持系统变量语法
| */
| watch(
| () => props.param,
| () => {
| if (visible) {
| dynamicParamHandler();
| //loadData();
| }
| }
| );
| /**
| *监听sorter排序字段
| */
| watchEffect(() => {
| if (props.sorter) {
| let arr = props.sorter.split('=');
| if (arr.length === 2 && ['asc', 'desc'].includes(arr[1].toLowerCase())) {
| iSorter.value = { column: arr[0], order: arr[1].toLowerCase() };
| // 排序字段受控
| unref(columns).forEach((col) => {
| if (col.dataIndex === unref(iSorter).column) {
| col['sortOrder'] = unref(iSorter).order === 'asc' ? 'ascend' : 'descend';
| } else {
| col['sortOrder'] = false;
| }
| });
| } else {
| console.warn('【JPopup】sorter参数不合法');
| }
| }
| });
|
| function handleToggleSearch() {
| toggleSearchStatus.value = !unref(toggleSearchStatus);
| }
|
| /**
| * 导出excel
| */
| function onExportXls() {
| handleExport!();
| }
|
| /**
| * 查询
| */
| function searchQuery() {
| loadData(1);
| }
|
| /**
| * 重置
| */
| function searchReset() {
| queryParam.value = {};
| loadData(1);
| }
|
| return {
| attrs,
|
| tableScroll,
| dataSource,
| pagination,
| columns,
| rowSelection,
| checkedKeys,
| loading,
| title,
| hrefComponent,
|
| clickThenCheck,
| loadData,
| combineRowKey,
| handleChangeInTable,
| visibleChange,
| queryInfo,
| queryParam,
| tableRef,
| formRef,
| labelCol,
| wrapperCol,
| dictOptions,
| showSearchFlag,
| toggleSearchStatus,
| handleToggleSearch,
| searchQuery,
| searchReset,
| onExportXls,
| };
| },
| });
| </script>
|
| <style lang="less" scoped>
| .jeecg-basic-table-form-container {
| padding: 0px;
|
| .table-page-search-submitButtons {
| display: block;
| margin-bottom: 0;
| white-space: nowrap;
| }
| }
|
| :deep .jeecg-basic-table .ant-table-wrapper .ant-table-title {
| min-height: 0;
| }
| </style>
|
|