sanmu
authored
2 years ago
1
2
3
4
5
6
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="利润分析表"
sanmu
authored
2 years ago
7
width="600px"
sanmu
authored
2 years ago
8
9
10
@visible-change="handleShow"
:footer="null"
>
sanmu
authored
2 years ago
11
<div className="mb-2">
sanmu
authored
2 years ago
12
公式:
sanmu
authored
2 years ago
13
<Select
sanmu
authored
2 years ago
14
className="w-[240px]"
sanmu
authored
2 years ago
15
:options="[
sanmu
authored
2 years ago
16
17
{ label: '公式1:1 -(LOCAL总金额 / 汇率 + 包装总金额)/ 客户总金额', value: '0' },
{ label: '公式2:1 -(LOCAL总金额 / 汇率 / (客户总金额-包装费用总金额)', value: '1' },
sanmu
authored
2 years ago
18
19
20
]"
v-model:value="profitType"
placeholder="请选择"
sanmu
authored
2 years ago
21
defaultValue="0"
sanmu
authored
2 years ago
22
23
24
25
26
27
28
29
30
31
/>
</div>
<Space>
<span>
汇率:
{{ activeRate }}
</span>
<a-button type="primary" @click="handleCalc" className="ml-4">计算</a-button>
</Space>
<!-- <Button @click="handleCalc">计算</Button> -->
sanmu
authored
2 years ago
32
<!-- :helpMessage="['提示1', '提示2']" -->
sanmu
authored
2 years ago
33
34
35
36
37
38
39
40
41
42
43
<!-- <template #insertFooter>
<a-button type="primary" danger @click="setLines" :disabled="loading">点我更新内容</a-button>
</template> -->
<!-- <template v-if="loading">
<div class="empty-tips">加载中,稍等3秒……</div>
</template> -->
<Description
class="mt-4"
layout="vertical"
:collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
:column="2"
sanmu
authored
2 years ago
44
:data="info"
sanmu
authored
2 years ago
45
46
47
48
49
:schema="schema"
/>
</BasicModal>
</template>
<script lang="ts">
sanmu
authored
2 years ago
50
import { computed, defineComponent, onMounted, ref, toRaw, watch } from 'vue';
sanmu
authored
2 years ago
51
import { BasicModal, useModalInner } from '/@/components/Modal';
sanmu
authored
2 years ago
52
import { Description, DescItem } from '/@/components/Description/index';
sanmu
authored
2 years ago
53
import { orderAnalysis } from '/@/api/project/order';
sanmu
authored
2 years ago
54
55
56
57
import { Select, Space } from 'ant-design-vue';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { getList } from '/@/api/sys/config';
import { useOrderInfo } from '/@/hooks/component/order';
58
import { useUserStoreWithOut } from '/@/store/modules/user';
sanmu
authored
2 years ago
59
60
export default defineComponent({
sanmu
authored
2 years ago
61
components: { BasicModal, Description, Select, Space },
sanmu
authored
2 years ago
62
setup() {
sanmu
authored
2 years ago
63
64
65
const orderStore = useOrderStoreWithOut();
const { exchangeRate } = useOrderInfo(orderStore);
const orderIds = ref([]);
sanmu
authored
2 years ago
66
67
const loading = ref(true);
const lines = ref(10);
sanmu
authored
2 years ago
68
const activeRate = ref();
sanmu
authored
2 years ago
69
const profitType = ref('0');
sanmu
authored
2 years ago
70
const info = ref({});
sanmu
authored
2 years ago
71
const searchData = ref();
sanmu
authored
2 years ago
72
const [register, { setModalProps, redoModalHeight }] = useModalInner(async (data) => {
sanmu
authored
2 years ago
73
orderIds.value = toRaw(data.data);
sanmu
authored
2 years ago
74
searchData.value = data.searchData;
sanmu
authored
2 years ago
75
76
info.value = {};
});
sanmu
authored
2 years ago
77
sanmu
authored
2 years ago
78
79
onMounted(async () => {
const res = await getList({ settingCode: 'exchangeRate', page: 1, pageSize: 10 });
sanmu
authored
2 years ago
80
activeRate.value = res?.items?.[0]?.settingValue;
sanmu
authored
2 years ago
81
82
83
84
});
const schema: DescItem[] = [
{
sanmu
authored
2 years ago
85
field: 'customerTotalPrice',
sanmu
authored
2 years ago
86
label: '客户总金额',
sanmu
authored
2 years ago
87
render: (val) => '$ ' + (val || 0).toFixed(2),
sanmu
authored
2 years ago
88
89
},
{
sanmu
authored
2 years ago
90
field: 'productionDepartmentTotalPrice',
sanmu
authored
2 years ago
91
label: '供应商总价',
sanmu
authored
2 years ago
92
render: (val) => '¥ ' + (val || 0).toFixed(2),
sanmu
authored
2 years ago
93
94
},
{
sanmu
authored
2 years ago
95
field: 'packetTotalPrice',
sanmu
authored
2 years ago
96
label: '包装费用',
sanmu
authored
2 years ago
97
render: (val) => '$' + (val || 0).toFixed(2),
sanmu
authored
2 years ago
98
99
},
{
sanmu
authored
2 years ago
100
field: 'profitRate',
sanmu
authored
2 years ago
101
label: '总利润率',
sanmu
authored
2 years ago
102
render: (val) => (Number(val || 0) * 100).toFixed(2) + '%',
sanmu
authored
2 years ago
103
},
sanmu
authored
2 years ago
104
105
{
field: 'orderTotalNum',
sanmu
authored
2 years ago
106
label: '订单商品数量',
sanmu
authored
2 years ago
107
108
109
110
render: (val) => val || 0,
},
{
field: 'recordNum',
sanmu
authored
2 years ago
111
label: '含有利润分析的订单数',
sanmu
authored
2 years ago
112
113
render: (val) => val || 0,
},
sanmu
authored
2 years ago
114
115
116
117
118
119
120
121
];
watch(
() => lines.value,
() => {
redoModalHeight();
},
);
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const userStore = useUserStoreWithOut();
const user = userStore.getUserInfo;
const role = computed(() => {
return user?.roleSmallVO?.code;
});
/**
* 检查当前角色是否是跟单员
*/
function isTracker() {
if (role.value === 'tracker_user') {
return false;
}
return true;
}
sanmu
authored
2 years ago
137
138
139
140
141
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
// setModalProps({ loading: true, confirmLoading: true });
sanmu
authored
2 years ago
142
setModalProps({ loading: false, confirmLoading: false });
sanmu
authored
2 years ago
143
144
145
146
147
148
}
}
function setLines() {
lines.value = Math.round(Math.random() * 20 + 10);
}
sanmu
authored
2 years ago
149
150
151
152
153
154
async function handleCalc() {
const res = await orderAnalysis({
orderIds: orderIds.value,
profitType: profitType.value,
exchangeRate: activeRate.value,
sanmu
authored
2 years ago
155
queryVO: searchData.value,
sanmu
authored
2 years ago
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
});
info.value = {
...(res || {}),
};
}
return {
register,
loading,
handleShow,
lines,
setLines,
info,
schema,
exchangeRate,
handleCalc,
activeRate,
profitType,
};
sanmu
authored
2 years ago
174
175
176
177
178
179
180
181
182
183
},
});
</script>
<style scoped>
.empty-tips {
height: 100px;
line-height: 100px;
text-align: center;
}
</style>