sanmu
authored
|
1
2
3
4
5
|
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
|
sanmu
authored
|
6
|
title="导出"
|
sanmu
authored
|
7
8
9
10
11
12
13
14
|
width="500px"
:height="100"
wrapClassName="h-[260px]"
@visible-change="handleShow"
:footer="null"
>
<CheckboxGroup v-model:value="checkedList" :options="options" />
<div className="mt-6">
|
sanmu
authored
|
15
16
17
|
<a-button type="primary" @click="handleExport" className="ml-4" :loading="exportLoading"
>导出</a-button
>
|
sanmu
authored
|
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
|
</div>
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { orderExport } from '/@/api/project/order';
import { ROLE } from './type.d';
import { CheckboxGroup } from 'ant-design-vue';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { useOrderInfo } from '/@/hooks/component/order';
import { merge } from 'lodash-es';
import {
ORDER_LIST_BASE_FIELDS,
ORDER_LIST_REPORT_FIELDS,
ORDER_LIST_PROFIT_FIELDS,
ORDER_LIST_INSPECT_FIELDS,
ORDER_LIST_TRACK_FIELDS,
} from './tableData';
export default defineComponent({
components: { BasicModal, CheckboxGroup },
props: {
role: {
type: String,
},
|
|
44
45
46
|
ids: {
type: Array<string | number>,
},
|
sanmu
authored
|
47
48
49
50
51
|
},
setup(props) {
const orderStore = useOrderStoreWithOut();
const { manualPreform, exchangeRate } = useOrderInfo(orderStore);
const checkedList = ref([
|
sanmu
authored
|
52
53
54
55
56
|
// 'baseFields',
// 'reportFields',
// 'profitAnalysisFields',
// 'trackStageFields',
// 'inspectionStageFields',
|
sanmu
authored
|
57
58
|
]);
const loading = ref(true);
|
sanmu
authored
|
59
|
const exportLoading = ref(false);
|
sanmu
authored
|
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
|
const activeUser = ref();
const info = ref();
const searchData = ref({});
const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
searchData.value = data.data || {};
activeUser.value = undefined;
info.value = '';
});
const options = computed(() => {
if (props.role === ROLE.TRACKER) {
return [
{ label: '基本信息', value: 'baseFields' },
{ label: '利润分析', value: 'profitAnalysisFields' },
{ label: '跟单信息', value: 'trackStageFields' },
{ label: '质检信息', value: 'inspectionStageFields' },
];
}
if (props.role === ROLE.INSPECT) {
return [
{ label: '基本信息', value: 'baseFields' },
{ label: '跟单信息', value: 'trackStageFields' },
{ label: '质检信息', value: 'inspectionStageFields' },
];
}
return [
{ label: '基本信息', value: 'baseFields' },
{ label: '项目报告', value: 'reportFields' },
{ label: '利润分析', value: 'profitAnalysisFields' },
{ label: '跟单信息', value: 'trackStageFields' },
{ label: '质检信息', value: 'inspectionStageFields' },
];
});
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
setModalProps({ loading: false, confirmLoading: false });
}
}
|
sanmu
authored
|
101
|
async function handleExport() {
|
sanmu
authored
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
const fieldVO: any = {};
checkedList.value.forEach((item) => {
if (item === 'baseFields') {
fieldVO.baseFields = ORDER_LIST_BASE_FIELDS.map((item) => ({
[item.dataIndex]: 'selected',
}));
fieldVO.baseFields = merge({}, ...fieldVO.baseFields);
} else if (item === 'reportFields') {
fieldVO.reportFields = ORDER_LIST_REPORT_FIELDS[0].children.map((item) => ({
[item.dataIndex]: 'selected',
}));
fieldVO.reportFields = merge({}, ...fieldVO.reportFields);
} else if (item === 'profitAnalysisFields') {
if (props.role === ROLE.TRACKER) {
fieldVO.profitAnalysisFields = ORDER_LIST_PROFIT_FIELDS[0].children
|
sanmu
authored
|
117
118
119
120
121
122
123
|
.filter((k) =>
[
'customerPrice',
'customerRmbPrice',
'customerTotalPrice',
'customerRmbTotalPrice',
].includes(k.dataIndex),
|
sanmu
authored
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
)
.map((item) => ({
[item.dataIndex]: 'selected',
}));
} else {
fieldVO.profitAnalysisFields = ORDER_LIST_PROFIT_FIELDS[0].children.map((item) => ({
[item.dataIndex]: 'selected',
}));
}
fieldVO.profitAnalysisFields = merge({}, ...fieldVO.profitAnalysisFields);
} else if (item === 'trackStageFields') {
fieldVO.trackStageFields = ORDER_LIST_TRACK_FIELDS[0].children.map((item) => ({
[item.dataIndex]: 'selected',
}));
fieldVO.trackStageFields = merge({}, ...fieldVO.trackStageFields);
} else if (item === 'inspectionStageFields') {
fieldVO.inspectionStageFields = ORDER_LIST_INSPECT_FIELDS[0].children.map((item) => ({
[item.dataIndex]: 'selected',
}));
fieldVO.inspectionStageFields = merge({}, ...fieldVO.inspectionStageFields);
}
});
|
|
147
148
|
//导出选中的订单
fieldVO.orderIds = props.ids;
|
sanmu
authored
|
149
|
exportLoading.value = true;
|
sanmu
authored
|
150
|
await orderExport({ ...searchData.value, fieldVO });
|
sanmu
authored
|
151
|
exportLoading.value = false;
|
sanmu
authored
|
152
153
154
155
156
157
158
159
160
161
|
closeModal();
}
return {
register,
options,
loading,
handleShow,
info,
manualPreform,
|
sanmu
authored
|
162
|
handleExport,
|
sanmu
authored
|
163
164
165
|
activeUser,
exchangeRate,
checkedList,
|
sanmu
authored
|
166
|
exportLoading,
|
sanmu
authored
|
167
168
169
170
|
};
},
});
</script>
|