sanmu
authored
2 years ago
1
<template>
sanmu
authored
2 years ago
2
<div class="order-page">
sanmu
authored
2 years ago
3
4
5
6
7
<BasicTable @register="registerTable" bordered>
<template #headerCell="{ column }">
<!-- <template v-if="column.key === 'address1'">
<span class="flex items-center justify-center"> 自定义字段列11 </span>
</template> -->
sanmu
authored
2 years ago
8
<template v-if="SELECT_FIELD_COLUMNS.includes(column.key) && role === ROLE.ADMIN">
sanmu
authored
2 years ago
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
<span class="flex items-center justify-center">
{{ column.customTitle }}
<FormOutlined class="ml-2 cursor-pointer" @click="handleFieldVisible(column)" />
</span>
</template>
<template v-else>
<HeaderCell :column="column" />
</template>
</template>
<template #headerTop>
<a-alert type="info" show-icon>
<template #message>
<template v-if="checkedKeys.length > 0">
<span>已选中{{ checkedKeys.length }}条记录(可跨页)</span>
<a-button type="link" @click="checkedKeys = []" size="small">清空</a-button>
</template>
<template v-else>
<span>未选中任何订单</span>
</template>
</template>
</a-alert>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
sanmu
authored
2 years ago
36
37
38
39
40
41
// 数据分析没有编辑权限
...(role !== ROLE.DATA_REPORT_USER && {
label: '编辑',
// icon: 'ic:outline-delete-outline',
onClick: handleEdit.bind(null, record),
}),
sanmu
authored
2 years ago
42
43
},
{
sanmu
authored
2 years ago
44
45
46
47
48
...(role !== ROLE.DATA_REPORT_USER && {
label: '申请权限',
// icon: 'ic:outline-delete-outline',
onClick: handleCheck.bind(null, record),
}),
sanmu
authored
2 years ago
49
50
},
]"
sanmu
authored
2 years ago
51
52
53
54
55
56
57
:dropDownActions="
role !== ROLE.DATA_REPORT_USER
? [
{
label: '历史记录',
onClick: handleHistory.bind(null, record),
},
58
59
60
61
62
63
64
65
66
67
{
...(role === ROLE.ADMIN && {
label: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record?.id),
},
}),
},
sanmu
authored
2 years ago
68
69
70
]
: []
"
sanmu
authored
2 years ago
71
72
73
74
75
76
/>
</template>
<template v-if="column.key === 'picUrl'">
<img
:width="100"
:height="100"
sanmu
authored
2 years ago
77
78
:src="record.smallPicUrl"
:key="record.smallPicUrl"
sanmu
authored
2 years ago
79
80
81
82
83
84
@click="handlePreview(record.picUrl)"
/>
</template>
</template>
<template #toolbar>
sanmu
authored
2 years ago
85
86
<a-button type="primary" @click="handleRateModal">比重计算</a-button>
<a-button type="primary" @click="handleExportModal">导出</a-button>
sanmu
authored
2 years ago
87
88
89
<a-button type="primary" @click="handleProfitModal" :disabled="!checkedKeys.length"
>分析利润</a-button
>
sanmu
authored
2 years ago
90
91
92
93
94
95
<a-button
type="primary"
@click="handleAdd"
v-if="role !== ROLE.INSPECT && role !== ROLE.DATA_REPORT_USER"
>创建订单</a-button
>
sanmu
authored
2 years ago
96
97
98
99
100
101
102
103
</template>
</BasicTable>
<FormDetail
@register="formDetailRegister"
:onGoCheckDetail="handleGoCheckDetail"
@success="handleFormSuccess"
/>
<ProfitAnalysis @register="profitModalRegister" />
sanmu
authored
2 years ago
104
105
<RateModal @register="rateModalRegister" />
<ExportModal @register="exportModalRegister" :role="role" />
sanmu
authored
2 years ago
106
107
108
109
110
111
<CheckDetail @register="checkModalRegister" :onGoFormDetail="handleGoFormDetail" />
<HistoryDetail @register="historyDetailRegister" />
<FieldDetail @register="fieldDetailRegister" />
</div>
</template>
<script lang="ts">
sanmu
authored
2 years ago
112
import { defineComponent, onMounted, ref, toRaw, computed } from 'vue';
sanmu
authored
2 years ago
113
114
115
116
117
118
119
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { FormOutlined } from '@ant-design/icons-vue';
import HeaderCell from '/@/components/Table/src/components/HeaderCell.vue';
import { Alert } from 'ant-design-vue';
import { useDrawer } from '/@/components/Drawer';
import ProfitAnalysis from './ProfitAnalysis.vue';
sanmu
authored
2 years ago
120
121
import RateModal from './RateModal.vue';
import ExportModal from './ExportModal.vue';
sanmu
authored
2 years ago
122
123
import { useModal } from '/@/components/Modal';
sanmu
authored
2 years ago
124
125
import { getFormConfig, getOrderColumns, SELECT_FIELD_COLUMNS } from './tableData';
import FormDetail from './FormDetail/index.vue';
sanmu
authored
2 years ago
126
127
128
129
import CheckDetail from './CheckDetail.vue';
import HistoryDetail from './HistoryDetail.vue';
import FieldDetail from './FieldDetail.vue';
import { createImgPreview } from '/@/components/Preview/index';
sanmu
authored
2 years ago
130
import { getOrderList } from '/@/api/project/order';
sanmu
authored
2 years ago
131
import { useOrderStoreWithOut } from '/@/store/modules/order';
sanmu
authored
2 years ago
132
import { useUserStoreWithOut } from '/@/store/modules/user';
sanmu
authored
2 years ago
133
import { ROLE } from './type.d';
sanmu
authored
2 years ago
134
135
const orderStore = useOrderStoreWithOut();
sanmu
authored
2 years ago
136
const userStore = useUserStoreWithOut();
sanmu
authored
2 years ago
137
138
139
140
141
142
143
144
145
146
147
148
149
export default defineComponent({
components: {
HeaderCell,
BasicTable,
AAlert: Alert,
TableAction,
FormDetail,
ProfitAnalysis,
FormOutlined,
CheckDetail,
HistoryDetail,
FieldDetail,
sanmu
authored
2 years ago
150
151
RateModal,
ExportModal,
sanmu
authored
2 years ago
152
153
154
155
},
setup() {
const checkedKeys = ref<Array<string | number>>([]);
const [profitModalRegister, { openModal: openProfitModal }] = useModal();
sanmu
authored
2 years ago
156
157
158
const [rateModalRegister, { openModal: openRateModal }] = useModal();
const [exportModalRegister, { openModal: openExportModal }] = useModal();
sanmu
authored
2 years ago
159
160
161
162
163
const tooltipVisible = ref(false);
const [formDetailRegister, { openDrawer: openFormDetailDrawer }] = useDrawer();
const [historyDetailRegister, { openDrawer: openHistoryDetailDrawer }] = useDrawer();
const [fieldDetailRegister, { openDrawer: openFieldDetailDrawer }] = useDrawer();
sanmu
authored
2 years ago
164
const user = userStore.getUserInfo;
sanmu
authored
2 years ago
165
166
167
const role = computed(() => {
return user?.roleSmallVO?.code;
});
sanmu
authored
2 years ago
168
sanmu
authored
2 years ago
169
170
171
172
173
const [checkModalRegister, { openDrawer: openCheckDetailDrawer }] = useDrawer();
onMounted(async () => {
await orderStore.getDict();
});
sanmu
authored
2 years ago
174
const [registerTable, { getForm, reload, getColumns }] = useTable({
sanmu
authored
2 years ago
175
176
177
178
179
api: getOrderList,
title: '订单列表',
pagination: {
total: 60,
},
sanmu
authored
2 years ago
180
columns: getOrderColumns(user?.roleSmallVO?.code),
sanmu
authored
2 years ago
181
182
183
184
185
186
187
188
189
useSearchForm: true,
formConfig: getFormConfig(),
showTableSetting: true,
// tableSetting: { fullScreen: true },
showIndexColumn: false,
rowKey: 'id',
rowSelection: {
type: 'checkbox',
selectedRowKeys: checkedKeys,
sanmu
authored
2 years ago
190
191
onSelect,
onSelectAll,
sanmu
authored
2 years ago
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
},
actionColumn: {
width: 160,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
function getFormValues() {
console.log(getForm().getFieldsValue());
}
function onSelect(record, selected) {
if (selected) {
checkedKeys.value = [...checkedKeys.value, record.id];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
}
}
function onSelectAll(selected, selectedRows, changeRows) {
const changeIds = changeRows.map((item) => item.id);
if (selected) {
checkedKeys.value = [...checkedKeys.value, ...changeIds];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => {
return !changeIds.includes(id);
});
}
}
function handleEdit(record, e) {
openFormDetailDrawer(true, { ...toRaw(record) });
e?.stopPropagation();
return false;
}
function handleAdd() {
sanmu
authored
2 years ago
230
openFormDetailDrawer(true, {});
sanmu
authored
2 years ago
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
}
function handleCheck(record, e) {
openCheckDetailDrawer(true, record);
e?.stopPropagation();
return false;
}
function handleHistory(record, e) {
openHistoryDetailDrawer(true, record);
e?.stopPropagation();
return false;
}
function handleProfitModal() {
openProfitModal(true, {
data: checkedKeys.value,
});
}
sanmu
authored
2 years ago
251
252
253
254
255
256
257
258
259
function handleRateModal() {
const form = getForm();
const values = form.getFieldsValue();
openRateModal(true, {
data: values,
});
}
sanmu
authored
2 years ago
260
261
262
263
264
265
266
267
268
269
270
271
272
273
function handleFieldVisible(record) {
openFieldDetailDrawer(true, record);
}
function handleGoCheckDetail() {
openCheckDetailDrawer(true);
openFormDetailDrawer(false);
}
function handleGoFormDetail() {
openCheckDetailDrawer(false);
openFormDetailDrawer(true);
}
sanmu
authored
2 years ago
274
function handlePreview(url) {
sanmu
authored
2 years ago
275
276
277
278
279
280
createImgPreview({ imageList: [url], defaultWidth: 500 });
// e?.stopPropagation();
// e?.preventDefault();
return false;
}
sanmu
authored
2 years ago
281
282
async function handleExportModal() {
openExportModal(true);
sanmu
authored
2 years ago
283
284
285
286
287
288
}
const handleFormSuccess = () => {
reload();
};
289
function handleDelete(id: string) {}
sanmu
authored
2 years ago
290
sanmu
authored
2 years ago
291
return {
sanmu
authored
2 years ago
292
user,
sanmu
authored
2 years ago
293
SELECT_FIELD_COLUMNS,
sanmu
authored
2 years ago
294
295
fieldDetailRegister,
profitModalRegister,
sanmu
authored
2 years ago
296
297
rateModalRegister,
exportModalRegister,
sanmu
authored
2 years ago
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
historyDetailRegister,
formDetailRegister,
handleProfitModal,
registerTable,
getFormValues,
checkedKeys,
onSelect,
handleEdit,
handleCheck,
onSelectAll,
tooltipVisible,
handleFieldVisible,
checkModalRegister,
handleGoCheckDetail,
handleGoFormDetail,
handleHistory,
handleAdd,
createImgPreview,
sanmu
authored
2 years ago
316
handleExportModal,
sanmu
authored
2 years ago
317
318
handlePreview,
handleFormSuccess,
sanmu
authored
2 years ago
319
320
handleRateModal,
openExportModal,
321
handleDelete,
sanmu
authored
2 years ago
322
323
role,
ROLE,
sanmu
authored
2 years ago
324
325
326
327
328
329
330
331
332
333
334
335
336
};
},
});
</script>
<style>
.ant-table-thead th,
.ant-table-tbody td {
padding: 0;
white-space: pre-wrap;
}
.ant-table-cell img {
sanmu
authored
2 years ago
337
338
width: 40px;
height: 40px;
sanmu
authored
2 years ago
339
}
sanmu
authored
2 years ago
340
341
342
343
.order-page .vben-basic-table .ant-form-item .ant-picker {
width: 100%;
}
sanmu
authored
2 years ago
344
345
346
347
348
.order-page .ant-table.ant-table-middle .ant-table-tbody > tr > td {
padding-top: 0;
padding-bottom: 0;
}
sanmu
authored
2 years ago
349
</style>
sanmu
authored
2 years ago
350
./constant