ProfitAnalysis.vue
2.65 KB
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
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="利润分析表"
@visible-change="handleShow"
:footer="null"
>
<!-- :helpMessage="['提示1', '提示2']" -->
<!-- <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"
:data="info"
:schema="schema"
/>
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, toRaw, watch } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Description, DescItem, useDescription } from '/@/components/Description/index';
import { orderAnalysis } from '/@/api/project/order';
export default defineComponent({
components: { BasicModal, Description },
setup() {
const loading = ref(true);
const lines = ref(10);
const info = ref({});
const [register, { setModalProps, redoModalHeight }] = useModalInner(async (data) => {
const orderIds = toRaw(data.data);
const res = await orderAnalysis({ orderIds });
info.value = {
...(res || {}),
};
});
const schema: DescItem[] = [
{
field: 'customerTotalPrice',
label: '客户总金额',
},
{
field: 'packetTotalPrice',
label: '供应商总价',
},
{
field: 'productionDepartmentTotalPrice',
label: '包装费用',
},
{
field: 'profitRate',
label: '总利润率',
},
];
watch(
() => lines.value,
() => {
redoModalHeight();
},
);
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
// setModalProps({ loading: true, confirmLoading: true });
setTimeout(() => {
lines.value = Math.round(Math.random() * 30 + 5);
loading.value = false;
setModalProps({ loading: false, confirmLoading: false });
}, 3000);
}
}
function setLines() {
lines.value = Math.round(Math.random() * 20 + 10);
}
return { register, loading, handleShow, lines, setLines, info, schema };
},
});
</script>
<style scoped>
.empty-tips {
height: 100px;
line-height: 100px;
text-align: center;
}
</style>