RateModal.vue
2.78 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
100
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="比重计算"
width="600px"
@visible-change="handleShow"
:footer="null"
>
<Space>
<span>
设计师:
<Select
:options="options"
placeholder="请选择"
v-model:value="activeUser"
showSearch
style="width: 100px"
/>
</span>
<a-button type="primary" @click="handleCalc" className="ml-4">计算</a-button>
<a-button type="primary" @click="handleExport" className="ml-4" :loading="exportLoading"
>导出所有设计师比重</a-button
>
</Space>
<div className="mt-2">比重结果:{{ info }}</div>
</BasicModal>
</template>
<script lang="ts">
import { computed, defineComponent, ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { orderGravity, orderRateExport } from '/@/api/project/order';
import { Select, Space } from 'ant-design-vue';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { useOrderInfo } from '/@/hooks/component/order';
import { uniqBy } from 'lodash-es';
export default defineComponent({
components: { BasicModal, Select, Space },
setup() {
const orderStore = useOrderStoreWithOut();
const { manualPreform, exchangeRate, ideaSource } = useOrderInfo(orderStore);
let options = computed(() => {
return uniqBy([...(manualPreform.value || []), ...(ideaSource.value || [])], 'label');
});
const exportLoading = ref(false);
const activeUser = ref();
const info = ref();
const searchData = ref({});
const [register, { setModalProps }] = useModalInner(async (data) => {
searchData.value = data.data || {};
activeUser.value = undefined;
info.value = '';
});
function handleShow(visible: boolean) {
if (visible) {
// setModalProps({ loading: true, confirmLoading: true });
setModalProps({ loading: false, confirmLoading: false });
}
}
async function handleCalc() {
const res = await orderGravity({
...searchData.value,
designer: activeUser.value,
});
info.value = res?.rate || 0;
}
async function handleExport() {
exportLoading.value = true;
await orderRateExport({ ...searchData.value });
exportLoading.value = false;
}
return {
register,
handleShow,
info,
manualPreform,
handleCalc,
activeUser,
exchangeRate,
options,
exportLoading,
handleExport,
};
},
});
</script>
<style scoped>
.empty-tips {
height: 100px;
line-height: 100px;
text-align: center;
}
</style>